Skip to content

Commit

Permalink
Add a gyp flag to allow removing dependency on ppapi.
Browse files Browse the repository at this point in the history
 - Introduces a new macro ENABLE_PLUGINS
 - Create a new PluginDelegateHelper interface which is used by RenderViewImpl 


This flag will be used to remove all plugins related code from the Android build.

BUG=162667


Review URL: https://chromiumcodereview.appspot.com/11414180

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@171162 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
nileshagrawal@chromium.org committed Dec 5, 2012
1 parent f65b1c6 commit 6d17f63
Show file tree
Hide file tree
Showing 26 changed files with 465 additions and 196 deletions.
15 changes: 15 additions & 0 deletions build/common.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,11 @@
# Enable plug-in installation by default.
'enable_plugin_installation%': 1,

# Enable PPAPI and NPAPI by default.
# TODO(nileshagrawal): Make this flag enable/disable NPAPI as well
# as PPAPI; see crbug.com/162667.
'enable_plugins%': 1,

# Enable protector service by default.
'enable_protector_service%': 1,

Expand Down Expand Up @@ -517,6 +522,12 @@
'enable_plugin_installation%': 1,
}],

['OS=="android" or OS=="ios"', {
'enable_plugins%': 0,
}, {
'enable_plugins%': 1,
}],

['OS=="android" or OS=="ios"', {
'enable_protector_service%': 0,
}, {
Expand Down Expand Up @@ -667,6 +678,7 @@
'enable_web_intents%': '<(enable_web_intents)',
'enable_web_intents_tag%': '<(enable_web_intents_tag)',
'enable_plugin_installation%': '<(enable_plugin_installation)',
'enable_plugins%': '<(enable_plugins)',
'enable_protector_service%': '<(enable_protector_service)',
'enable_session_service%': '<(enable_session_service)',
'enable_themes%': '<(enable_themes)',
Expand Down Expand Up @@ -1858,6 +1870,9 @@
['enable_plugin_installation==1', {
'defines': ['ENABLE_PLUGIN_INSTALLATION=1'],
}],
['enable_plugins==1', {
'defines': ['ENABLE_PLUGINS=1'],
}],
['enable_protector_service==1', {
'defines': ['ENABLE_PROTECTOR_SERVICE=1'],
}],
Expand Down
4 changes: 4 additions & 0 deletions chrome/browser/browsing_data/browsing_data_remover.cc
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,7 @@ void BrowsingDataRemover::RemoveImpl(int remove_mask,
}
}

#if defined(ENABLE_PLUGINS)
if (remove_mask & REMOVE_CONTENT_LICENSES) {
content::RecordAction(
UserMetricsAction("ClearBrowsingData_ContentLicenses"));
Expand All @@ -500,6 +501,7 @@ void BrowsingDataRemover::RemoveImpl(int remove_mask,
deauthorize_content_licenses_request_id_ =
pepper_flash_settings_manager_->DeauthorizeContentLicenses();
}
#endif

// Always wipe accumulated network related data (TransportSecurityState and
// HttpServerPropertiesManager data).
Expand Down Expand Up @@ -944,6 +946,7 @@ void BrowsingDataRemover::OnWaitableEventSignaled(
NotifyAndDeleteIfDone();
}

#if defined(ENABLE_PLUGINS)
void BrowsingDataRemover::OnDeauthorizeContentLicensesCompleted(
uint32 request_id,
bool /* success */) {
Expand All @@ -953,6 +956,7 @@ void BrowsingDataRemover::OnDeauthorizeContentLicensesCompleted(
waiting_for_clear_content_licenses_ = false;
NotifyAndDeleteIfDone();
}
#endif

void BrowsingDataRemover::OnClearedCookies(int num_deleted) {
if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) {
Expand Down
12 changes: 9 additions & 3 deletions chrome/browser/browsing_data/browsing_data_remover.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,10 @@ struct SessionStorageUsageInfo;
// visits in url database, downloads, cookies ...

class BrowsingDataRemover : public content::NotificationObserver,
public base::WaitableEventWatcher::Delegate,
public PepperFlashSettingsManager::Client {
#if defined(ENABLE_PLUGINS)
public PepperFlashSettingsManager::Client,
#endif
public base::WaitableEventWatcher::Delegate {
public:
// Time period ranges available when doing browsing data removals.
enum TimePeriod {
Expand Down Expand Up @@ -213,9 +215,11 @@ class BrowsingDataRemover : public content::NotificationObserver,
virtual void OnWaitableEventSignaled(
base::WaitableEvent* waitable_event) OVERRIDE;

#if defined(ENABLE_PLUGINS)
// PepperFlashSettingsManager::Client implementation.
virtual void OnDeauthorizeContentLicensesCompleted(uint32 request_id,
bool success) OVERRIDE;
#endif

// Removes the specified items related to browsing for a specific host. If the
// provided |origin| is empty, data is removed for all origins. The
Expand Down Expand Up @@ -366,10 +370,12 @@ class BrowsingDataRemover : public content::NotificationObserver,
scoped_ptr<content::PluginDataRemover> plugin_data_remover_;
base::WaitableEventWatcher watcher_;

#if defined(ENABLE_PLUGINS)
// Used to deauthorize content licenses for Pepper Flash.
scoped_ptr<PepperFlashSettingsManager> pepper_flash_settings_manager_;
uint32 deauthorize_content_licenses_request_id_;
#endif

uint32 deauthorize_content_licenses_request_id_;
// True if we're waiting for various data to be deleted.
// These may only be accessed from UI thread in order to avoid races!
bool waiting_for_clear_cache_;
Expand Down
2 changes: 2 additions & 0 deletions chrome/browser/chrome_content_browser_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1751,9 +1751,11 @@ std::string ChromeContentBrowserClient::GetDefaultDownloadName() {

void ChromeContentBrowserClient::DidCreatePpapiPlugin(
content::BrowserPpapiHost* browser_host) {
#if defined(ENABLE_PLUGINS)
browser_host->GetPpapiHost()->AddHostFactoryFilter(
scoped_ptr<ppapi::host::HostFactory>(
new ChromeBrowserPepperHostFactory(browser_host)));
#endif
}

content::BrowserPpapiHost*
Expand Down
11 changes: 10 additions & 1 deletion chrome/chrome_browser.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -2235,7 +2235,6 @@
'../cc/cc.gyp:cc',
'../content/content.gyp:navigation_interception',
'../net/net.gyp:net_with_v8',
'../ppapi/ppapi_internal.gyp:ppapi_ipc', # For PpapiMsg_LoadPlugin
'../printing/printing.gyp:printing',
'../third_party/adobe/flash/flash_player.gyp:flapper_version_h',
'../third_party/expat/expat.gyp:expat',
Expand Down Expand Up @@ -2385,6 +2384,16 @@
['include', 'browser/policy/policy_service_stub.h'],
],
}],
['enable_plugins==1', {
'dependencies': [
'../ppapi/ppapi_internal.gyp:ppapi_ipc',
],
}, { # enable_plugins==0
'sources/': [
['exclude', '^browser/pepper_'],
['exclude', '^browser/renderer_host/pepper/'],
],
}],
['safe_browsing==1', {
'defines': [
'FULL_SAFE_BROWSING',
Expand Down
6 changes: 5 additions & 1 deletion chrome/chrome_browser_ui.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -2137,7 +2137,6 @@
'installer_util',
'../device/device.gyp:device_bluetooth',
'../net/net.gyp:net_with_v8',
'../ppapi/ppapi_internal.gyp:ppapi_ipc', # For PpapiMsg_LoadPlugin
'../printing/printing.gyp:printing',
'../third_party/adobe/flash/flash_player.gyp:flapper_version_h',
'../third_party/expat/expat.gyp:expat',
Expand Down Expand Up @@ -2227,6 +2226,11 @@
['exclude', 'browser/ui/webui/policy_ui.h'],
],
}],
['enable_plugins==1', {
'dependencies': [
'../ppapi/ppapi_internal.gyp:ppapi_ipc',
],
}],
['safe_browsing==1', {
'defines': [
'FULL_SAFE_BROWSING',
Expand Down
16 changes: 12 additions & 4 deletions chrome/chrome_renderer.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@
'chrome_resources.gyp:chrome_strings',
'../content/content.gyp:content_renderer',
'../net/net.gyp:net',
'../ppapi/ppapi_internal.gyp:ppapi_host',
'../ppapi/ppapi_internal.gyp:ppapi_proxy',
'../ppapi/ppapi_internal.gyp:ppapi_ipc',
'../ppapi/ppapi_internal.gyp:ppapi_shared',
'../printing/printing.gyp:printing',
'../skia/skia.gyp:skia',
'../third_party/hunspell/hunspell.gyp:hunspell',
Expand Down Expand Up @@ -290,6 +286,18 @@
'nacl',
],
}],
['enable_plugins==1', {
'dependencies': [
'../ppapi/ppapi_internal.gyp:ppapi_host',
'../ppapi/ppapi_internal.gyp:ppapi_proxy',
'../ppapi/ppapi_internal.gyp:ppapi_ipc',
'../ppapi/ppapi_internal.gyp:ppapi_shared',
],
}, { # enable_plugins==0
'sources/': [
['exclude', '^renderer/pepper/'],
],
}],
['safe_browsing==1', {
'defines': [
'FULL_SAFE_BROWSING',
Expand Down
5 changes: 5 additions & 0 deletions chrome/renderer/chrome_content_renderer_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,10 @@ void ChromeContentRendererClient::RenderViewCreated(
render_view, content_settings, chrome_observer_.get(),
extension_dispatcher_.get(), translate);

#if defined(ENABLE_PLUGINS)
new PepperHelper(render_view);
#endif

// FaviconHelper will delete itself when render_view is destroyed.
new FaviconHelper(render_view);
// Used only for testing/automation.
Expand Down Expand Up @@ -1026,7 +1029,9 @@ bool ChromeContentRendererClient::IsOtherExtensionWithWebRequestInstalled() {

void ChromeContentRendererClient::RegisterPPAPIInterfaceFactories(
webkit::ppapi::PpapiInterfaceFactoryManager* factory_manager) {
#if defined(ENABLE_PLUGINS)
factory_manager->RegisterFactory(ChromePPAPIInterfaceFactory);
#endif
}

} // namespace chrome
2 changes: 2 additions & 0 deletions content/app/content_main_runner.cc
Original file line number Diff line number Diff line change
Expand Up @@ -421,10 +421,12 @@ int RunNamedProcessTypeMain(
static const MainFunction kMainFunctions[] = {
{ "", BrowserMain },
{ switches::kRendererProcess, RendererMain },
#if defined(ENABLE_PLUGINS)
{ switches::kPluginProcess, PluginMain },
{ switches::kWorkerProcess, WorkerMain },
{ switches::kPpapiPluginProcess, PpapiPluginMain },
{ switches::kPpapiBrokerProcess, PpapiBrokerMain },
#endif
{ switches::kUtilityProcess, UtilityMain },
{ switches::kGpuProcess, GpuMain },
};
Expand Down
47 changes: 32 additions & 15 deletions content/browser/plugin_data_remover_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,13 @@
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/common/pepper_plugin_info.h"
#include "ppapi/proxy/ppapi_messages.h"
#include "webkit/plugins/npapi/plugin_utils.h"
#include "webkit/plugins/plugin_constants.h"

#if defined(ENABLE_PLUGINS)
#include "ppapi/proxy/ppapi_messages.h"
#endif

namespace content {

namespace {
Expand Down Expand Up @@ -178,8 +181,10 @@ class PluginDataRemoverImpl::Context
IPC_BEGIN_MESSAGE_MAP(Context, message)
IPC_MESSAGE_HANDLER(PluginHostMsg_ClearSiteDataResult,
OnClearSiteDataResult)
#if defined(ENABLE_PLUGINS)
IPC_MESSAGE_HANDLER(PpapiHostMsg_ClearSiteDataResult,
OnPpapiClearSiteDataResult)
#endif
IPC_MESSAGE_UNHANDLED_ERROR()
IPC_END_MESSAGE_MAP()

Expand All @@ -200,6 +205,31 @@ class PluginDataRemoverImpl::Context
friend class base::DeleteHelper<Context>;
virtual ~Context() {}

#if defined(ENABLE_PLUGINS)
IPC::Message* CreatePpapiClearSiteDataMsg(uint64 max_age) {
FilePath profile_path =
PepperFlashFileHost::GetDataDirName(browser_context_path_);
// TODO(vtl): This "duplicates" logic in webkit/plugins/ppapi/file_path.cc
// (which prepends the plugin name to the relative part of the path
// instead, with the absolute, profile-dependent part being enforced by
// the browser).
#if defined(OS_WIN)
FilePath plugin_data_path =
profile_path.Append(FilePath(UTF8ToUTF16(plugin_name_)));
#else
FilePath plugin_data_path = profile_path.Append(FilePath(plugin_name_));
#endif // defined(OS_WIN)
return new PpapiMsg_ClearSiteData(0u, plugin_data_path, std::string(),
kClearAllData, max_age);
}
#else
IPC::Message* CreatePpapiClearSiteDataMsg(uint64 max_age) {
NOTREACHED() << "CreatePpapiClearSiteDataMsg called with "
<< "ENABLE_PLUGINS undefined.";
return NULL;
}
#endif // defined(ENABLE_PLUGINS)

// Connects the client side of a newly opened plug-in channel.
void ConnectToChannel(const IPC::ChannelHandle& handle, bool is_ppapi) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
Expand All @@ -222,20 +252,7 @@ class PluginDataRemoverImpl::Context

IPC::Message* msg;
if (is_ppapi) {
FilePath profile_path =
PepperFlashFileHost::GetDataDirName(browser_context_path_);
// TODO(vtl): This "duplicates" logic in webkit/plugins/ppapi/file_path.cc
// (which prepends the plugin name to the relative part of the path
// instead, with the absolute, profile-dependent part being enforced by
// the browser).
#if defined(OS_WIN)
FilePath plugin_data_path =
profile_path.Append(FilePath(UTF8ToUTF16(plugin_name_)));
#else
FilePath plugin_data_path = profile_path.Append(FilePath(plugin_name_));
#endif
msg = new PpapiMsg_ClearSiteData(0u, plugin_data_path, std::string(),
kClearAllData, max_age);
msg = CreatePpapiClearSiteDataMsg(max_age);
} else {
msg = new PluginMsg_ClearSiteData(std::string(), kClearAllData, max_age);
}
Expand Down
6 changes: 6 additions & 0 deletions content/browser/plugin_service_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ PpapiPluginProcessHost* PluginServiceImpl::FindOrStartPpapiPluginProcess(
const FilePath& plugin_path,
const FilePath& profile_data_directory,
PpapiPluginProcessHost::PluginClient* client) {
#if defined(ENABLE_PLUGINS)
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));

PpapiPluginProcessHost* plugin_host =
Expand All @@ -284,6 +285,9 @@ PpapiPluginProcessHost* PluginServiceImpl::FindOrStartPpapiPluginProcess(
return PpapiPluginProcessHost::CreatePluginHost(
*info, profile_data_directory,
client->GetResourceContext()->GetHostResolver());
#else
return NULL;
#endif
}

PpapiPluginProcessHost* PluginServiceImpl::FindOrStartPpapiBrokerProcess(
Expand Down Expand Up @@ -346,13 +350,15 @@ void PluginServiceImpl::OpenChannelToPpapiPlugin(
void PluginServiceImpl::OpenChannelToPpapiBroker(
const FilePath& path,
PpapiPluginProcessHost::BrokerClient* client) {
#if defined(ENABLE_PLUGINS)
PpapiPluginProcessHost* plugin_host = FindOrStartPpapiBrokerProcess(path);
if (plugin_host) {
plugin_host->OpenChannelToPlugin(client);
} else {
// Send error.
client->OnPpapiChannelOpened(IPC::ChannelHandle(), 0);
}
#endif
}

void PluginServiceImpl::CancelOpenChannelToNpapiPlugin(
Expand Down
2 changes: 2 additions & 0 deletions content/browser/renderer_host/render_message_filter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,7 @@ bool RenderMessageFilter::OnMessageReceived(const IPC::Message& message,
IPC_MESSAGE_HANDLER(ViewHostMsg_DownloadUrl, OnDownloadUrl)
IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_OpenChannelToPlugin,
OnOpenChannelToPlugin)
#if defined(ENABLE_PLUGINS)
IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_OpenChannelToPepperPlugin,
OnOpenChannelToPepperPlugin)
IPC_MESSAGE_HANDLER(ViewHostMsg_DidCreateOutOfProcessPepperInstance,
Expand All @@ -393,6 +394,7 @@ bool RenderMessageFilter::OnMessageReceived(const IPC::Message& message,
OnDidDeleteOutOfProcessPepperInstance)
IPC_MESSAGE_HANDLER(ViewHostMsg_OpenChannelToPpapiBroker,
OnOpenChannelToPpapiBroker)
#endif
IPC_MESSAGE_HANDLER_GENERIC(ViewHostMsg_UpdateRect,
render_widget_helper_->DidReceiveBackingStoreMsg(message))
IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateIsDelayed, OnUpdateIsDelayed)
Expand Down
2 changes: 2 additions & 0 deletions content/browser/renderer_host/render_process_host_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -536,8 +536,10 @@ void RenderProcessHostImpl::CreateMessageFilters() {
#if defined(ENABLE_WEBRTC)
channel_->AddFilter(new MediaStreamDispatcherHost(GetID()));
#endif
#if defined(ENABLE_PLUGINS)
channel_->AddFilter(new PepperMessageFilter(PepperMessageFilter::RENDERER,
GetID(), browser_context));
#endif
#if defined(ENABLE_INPUT_SPEECH)
channel_->AddFilter(new InputTagSpeechDispatcherHost(
IsGuest(), GetID(), storage_partition_impl_->GetURLRequestContext(),
Expand Down
2 changes: 2 additions & 0 deletions content/common/all_messages.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@
// ipc/ipc_message_start.h to ensure the corresponding message file is
// included here.
#include "content/common/content_message_generator.h"
#if defined(ENABLE_PLUGINS)
#include "ppapi/proxy/ppapi_messages.h"
#endif
Loading

0 comments on commit 6d17f63

Please sign in to comment.