diff options
author | nileshagrawal@chromium.org <nileshagrawal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-05 05:24:54 +0000 |
---|---|---|
committer | nileshagrawal@chromium.org <nileshagrawal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-05 05:24:54 +0000 |
commit | 6d17f6396d15aefa7c26790019bf8ece2cfd9112 (patch) | |
tree | 2c6d462c7f30c1b25e361679b65a51d91ca3992a | |
parent | f65b1c6fdc7f153016ed6a669c80cdcef9c96a36 (diff) | |
download | chromium_src-6d17f6396d15aefa7c26790019bf8ece2cfd9112.zip chromium_src-6d17f6396d15aefa7c26790019bf8ece2cfd9112.tar.gz chromium_src-6d17f6396d15aefa7c26790019bf8ece2cfd9112.tar.bz2 |
Add a gyp flag to allow removing dependency on ppapi.
- 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
26 files changed, 465 insertions, 196 deletions
diff --git a/build/common.gypi b/build/common.gypi index 6a9dc5f..31bf1c4 100644 --- a/build/common.gypi +++ b/build/common.gypi @@ -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, @@ -518,6 +523,12 @@ }], ['OS=="android" or OS=="ios"', { + 'enable_plugins%': 0, + }, { + 'enable_plugins%': 1, + }], + + ['OS=="android" or OS=="ios"', { 'enable_protector_service%': 0, }, { 'enable_protector_service%': 1, @@ -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)', @@ -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'], }], diff --git a/chrome/browser/browsing_data/browsing_data_remover.cc b/chrome/browser/browsing_data/browsing_data_remover.cc index cee0b6b..7d3c5da 100644 --- a/chrome/browser/browsing_data/browsing_data_remover.cc +++ b/chrome/browser/browsing_data/browsing_data_remover.cc @@ -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")); @@ -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). @@ -944,6 +946,7 @@ void BrowsingDataRemover::OnWaitableEventSignaled( NotifyAndDeleteIfDone(); } +#if defined(ENABLE_PLUGINS) void BrowsingDataRemover::OnDeauthorizeContentLicensesCompleted( uint32 request_id, bool /* success */) { @@ -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)) { diff --git a/chrome/browser/browsing_data/browsing_data_remover.h b/chrome/browser/browsing_data/browsing_data_remover.h index 25b95d5..b0a39bc 100644 --- a/chrome/browser/browsing_data/browsing_data_remover.h +++ b/chrome/browser/browsing_data/browsing_data_remover.h @@ -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 { @@ -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 @@ -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_; diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc index ed16096..eadba8b 100644 --- a/chrome/browser/chrome_content_browser_client.cc +++ b/chrome/browser/chrome_content_browser_client.cc @@ -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* diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index e705cc5..ea6e71b 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -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', @@ -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', diff --git a/chrome/chrome_browser_ui.gypi b/chrome/chrome_browser_ui.gypi index 78a4e55..d0fa49a 100644 --- a/chrome/chrome_browser_ui.gypi +++ b/chrome/chrome_browser_ui.gypi @@ -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', @@ -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', diff --git a/chrome/chrome_renderer.gypi b/chrome/chrome_renderer.gypi index 89d35ad..102d02b 100644 --- a/chrome/chrome_renderer.gypi +++ b/chrome/chrome_renderer.gypi @@ -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', @@ -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', diff --git a/chrome/renderer/chrome_content_renderer_client.cc b/chrome/renderer/chrome_content_renderer_client.cc index 7f249b8..c7b30ab2 100644 --- a/chrome/renderer/chrome_content_renderer_client.cc +++ b/chrome/renderer/chrome_content_renderer_client.cc @@ -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. @@ -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 diff --git a/content/app/content_main_runner.cc b/content/app/content_main_runner.cc index 22115ce..a74e7b6 100644 --- a/content/app/content_main_runner.cc +++ b/content/app/content_main_runner.cc @@ -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 }, }; diff --git a/content/browser/plugin_data_remover_impl.cc b/content/browser/plugin_data_remover_impl.cc index f4a26be..9c11458 100644 --- a/content/browser/plugin_data_remover_impl.cc +++ b/content/browser/plugin_data_remover_impl.cc @@ -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 { @@ -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() @@ -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)); @@ -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); } diff --git a/content/browser/plugin_service_impl.cc b/content/browser/plugin_service_impl.cc index dabd26d..fa21c7d 100644 --- a/content/browser/plugin_service_impl.cc +++ b/content/browser/plugin_service_impl.cc @@ -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 = @@ -284,6 +285,9 @@ PpapiPluginProcessHost* PluginServiceImpl::FindOrStartPpapiPluginProcess( return PpapiPluginProcessHost::CreatePluginHost( *info, profile_data_directory, client->GetResourceContext()->GetHostResolver()); +#else + return NULL; +#endif } PpapiPluginProcessHost* PluginServiceImpl::FindOrStartPpapiBrokerProcess( @@ -346,6 +350,7 @@ 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); @@ -353,6 +358,7 @@ void PluginServiceImpl::OpenChannelToPpapiBroker( // Send error. client->OnPpapiChannelOpened(IPC::ChannelHandle(), 0); } +#endif } void PluginServiceImpl::CancelOpenChannelToNpapiPlugin( diff --git a/content/browser/renderer_host/render_message_filter.cc b/content/browser/renderer_host/render_message_filter.cc index 9d6b5b9..30c821c 100644 --- a/content/browser/renderer_host/render_message_filter.cc +++ b/content/browser/renderer_host/render_message_filter.cc @@ -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, @@ -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) diff --git a/content/browser/renderer_host/render_process_host_impl.cc b/content/browser/renderer_host/render_process_host_impl.cc index 9520546..10c78e5 100644 --- a/content/browser/renderer_host/render_process_host_impl.cc +++ b/content/browser/renderer_host/render_process_host_impl.cc @@ -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(), diff --git a/content/common/all_messages.h b/content/common/all_messages.h index 5cd7743..106af5a 100644 --- a/content/common/all_messages.h +++ b/content/common/all_messages.h @@ -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 diff --git a/content/content_browser.gypi b/content/content_browser.gypi index f886762..2f6b626 100644 --- a/content/content_browser.gypi +++ b/content/content_browser.gypi @@ -932,7 +932,6 @@ 'browser/debugger/devtools_resources.gyp:devtools_resources', '../cc/cc.gyp:cc', '../net/net.gyp:http_server', - '../ppapi/ppapi_internal.gyp:ppapi_ipc', '../printing/printing.gyp:printing', '<(webkit_src_dir)/Source/WebKit/chromium/WebKit.gyp:webkit', '../ui/surface/surface.gyp:surface', @@ -1125,6 +1124,18 @@ ['exclude', '^browser/renderer_host/tap_suppression_controller_aura.cc'], ], }], + ['enable_plugins==1', { + 'dependencies': [ + '../ppapi/ppapi_internal.gyp:ppapi_ipc', + ], + }, { # enable_plugins==0 + 'sources!': [ + 'browser/ppapi_plugin_process_host.cc', + ], + 'sources/': [ + ['exclude', '^browser/renderer_host/pepper/'], + ], + }], ['java_bridge==1', { 'defines': [ 'ENABLE_JAVA_BRIDGE', diff --git a/content/content_common.gypi b/content/content_common.gypi index a1a6a1d..8c5c4ca 100644 --- a/content/content_common.gypi +++ b/content/content_common.gypi @@ -416,7 +416,6 @@ '../gpu/gpu.gyp:gpu_ipc', '../ipc/ipc.gyp:ipc', '../media/media.gyp:shared_memory_support', - '../ppapi/ppapi_internal.gyp:ppapi_shared', '../third_party/npapi/npapi.gyp:npapi', '<(webkit_src_dir)/Source/WebKit/chromium/WebKit.gyp:webkit', '../ui/gl/gl.gyp:gl', @@ -466,6 +465,11 @@ 'common/gpu/x_util.h', ], }], + ['enable_plugins==1', { + 'dependencies': [ + '../ppapi/ppapi_internal.gyp:ppapi_shared', + ], + }], ['enable_gpu==1', { 'dependencies': [ '../gpu/gpu.gyp:command_buffer_service', diff --git a/content/content_ppapi_plugin.gypi b/content/content_ppapi_plugin.gypi index cd90d6f..4b8025d 100644 --- a/content/content_ppapi_plugin.gypi +++ b/content/content_ppapi_plugin.gypi @@ -3,24 +3,28 @@ # found in the LICENSE file. { - 'dependencies': [ - '../base/base.gyp:base', - '../ppapi/ppapi_internal.gyp:ppapi_ipc', - '../ui/ui.gyp:ui', - ], - 'sources': [ - 'ppapi_plugin/broker_process_dispatcher.cc', - 'ppapi_plugin/broker_process_dispatcher.h', - 'ppapi_plugin/plugin_process_dispatcher.cc', - 'ppapi_plugin/plugin_process_dispatcher.h', - 'ppapi_plugin/ppapi_broker_main.cc', - 'ppapi_plugin/ppapi_plugin_main.cc', - 'ppapi_plugin/ppapi_thread.cc', - 'ppapi_plugin/ppapi_thread.h', - 'ppapi_plugin/ppapi_webkitplatformsupport_impl.cc', - 'ppapi_plugin/ppapi_webkitplatformsupport_impl.h', - ], - 'include_dirs': [ - '..', + 'conditions': [ + ['enable_plugins==1', { + 'dependencies': [ + '../base/base.gyp:base', + '../ppapi/ppapi_internal.gyp:ppapi_ipc', + '../ui/ui.gyp:ui', + ], + 'sources': [ + 'ppapi_plugin/broker_process_dispatcher.cc', + 'ppapi_plugin/broker_process_dispatcher.h', + 'ppapi_plugin/plugin_process_dispatcher.cc', + 'ppapi_plugin/plugin_process_dispatcher.h', + 'ppapi_plugin/ppapi_broker_main.cc', + 'ppapi_plugin/ppapi_plugin_main.cc', + 'ppapi_plugin/ppapi_thread.cc', + 'ppapi_plugin/ppapi_thread.h', + 'ppapi_plugin/ppapi_webkitplatformsupport_impl.cc', + 'ppapi_plugin/ppapi_webkitplatformsupport_impl.h', + ], + 'include_dirs': [ + '..', + ], + }], ], } diff --git a/content/content_renderer.gypi b/content/content_renderer.gypi index 2ac0b59..3058717 100644 --- a/content/content_renderer.gypi +++ b/content/content_renderer.gypi @@ -6,9 +6,6 @@ 'dependencies': [ '../jingle/jingle.gyp:jingle_glue', '../net/net.gyp:net', - '../ppapi/ppapi_internal.gyp:ppapi_host', - '../ppapi/ppapi_internal.gyp:ppapi_proxy', - '../ppapi/ppapi_internal.gyp:ppapi_shared', '../skia/skia.gyp:skia', '../third_party/hyphen/hyphen.gyp:hyphen', '../third_party/icu/icu.gyp:icuuc', @@ -238,6 +235,8 @@ 'renderer/render_view_linux.cc', 'renderer/render_view_mouse_lock_dispatcher.cc', 'renderer/render_view_mouse_lock_dispatcher.h', + 'renderer/render_view_pepper_helper.cc', + 'renderer/render_view_pepper_helper.h', 'renderer/render_widget.cc', 'renderer/render_widget.h', 'renderer/render_widget_fullscreen.cc', @@ -373,6 +372,17 @@ 'renderer/p2p/socket_dispatcher.h', ], }], + ['enable_plugins==1', { + 'dependencies': [ + '../ppapi/ppapi_internal.gyp:ppapi_host', + '../ppapi/ppapi_internal.gyp:ppapi_proxy', + '../ppapi/ppapi_internal.gyp:ppapi_shared', + ], + }, { # enable_plugins==0 + 'sources/': [ + ['exclude', '^renderer/pepper/'], + ], + }], ['java_bridge==1', { 'defines': [ 'ENABLE_JAVA_BRIDGE', diff --git a/content/content_tests.gypi b/content/content_tests.gypi index 06d8e98..692bcdf 100644 --- a/content/content_tests.gypi +++ b/content/content_tests.gypi @@ -512,6 +512,12 @@ '../webkit/webkit.gyp:test_shell_test_support', ], }], + ['enable_plugins==0', { + 'sources/': [ + ['exclude', '^renderer/pepper/'], + ['exclude', '^browser/renderer_host/pepper/'], + ], + }], ['enable_webrtc==1', { 'sources': [ 'browser/renderer_host/p2p/socket_host_test_utils.h', diff --git a/content/renderer/media/media_stream_dispatcher.cc b/content/renderer/media/media_stream_dispatcher.cc index f1a6e3a..723acd8 100644 --- a/content/renderer/media/media_stream_dispatcher.cc +++ b/content/renderer/media/media_stream_dispatcher.cc @@ -5,6 +5,7 @@ #include "content/renderer/media/media_stream_dispatcher.h" #include "base/logging.h" +#include "base/message_loop_proxy.h" #include "content/common/media/media_stream_messages.h" #include "content/renderer/media/media_stream_dispatcher_eventhandler.h" #include "content/renderer/render_view_impl.h" diff --git a/content/renderer/pepper/pepper_plugin_delegate_impl.cc b/content/renderer/pepper/pepper_plugin_delegate_impl.cc index 744631c..eba8ee3 100644 --- a/content/renderer/pepper/pepper_plugin_delegate_impl.cc +++ b/content/renderer/pepper/pepper_plugin_delegate_impl.cc @@ -83,6 +83,7 @@ #include "webkit/plugins/npapi/webplugin.h" #include "webkit/plugins/ppapi/plugin_module.h" #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" +#include "webkit/plugins/ppapi/ppapi_webplugin_impl.h" #include "webkit/plugins/ppapi/ppb_file_io_impl.h" #include "webkit/plugins/ppapi/ppb_flash_impl.h" #include "webkit/plugins/ppapi/ppb_tcp_server_socket_private_impl.h" @@ -335,6 +336,23 @@ PepperPluginDelegateImpl::~PepperPluginDelegateImpl() { DCHECK(mouse_lock_instances_.empty()); } +WebKit::WebPlugin* PepperPluginDelegateImpl::CreatePepperWebPlugin( + const webkit::WebPluginInfo& webplugin_info, + const WebKit::WebPluginParams& params) { + bool pepper_plugin_was_registered = false; + scoped_refptr<webkit::ppapi::PluginModule> pepper_module( + CreatePepperPluginModule(webplugin_info, &pepper_plugin_was_registered)); + + if (pepper_plugin_was_registered) { + if (!pepper_module) + return NULL; + return new webkit::ppapi::WebPluginImpl( + pepper_module.get(), params, AsWeakPtr()); + } + + return NULL; +} + scoped_refptr<webkit::ppapi::PluginModule> PepperPluginDelegateImpl::CreatePepperPluginModule( const webkit::WebPluginInfo& webplugin_info, diff --git a/content/renderer/pepper/pepper_plugin_delegate_impl.h b/content/renderer/pepper/pepper_plugin_delegate_impl.h index 1e7a75e..700bbef 100644 --- a/content/renderer/pepper/pepper_plugin_delegate_impl.h +++ b/content/renderer/pepper/pepper_plugin_delegate_impl.h @@ -16,10 +16,10 @@ #include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" #include "base/observer_list.h" -#include "content/common/content_export.h" #include "content/public/renderer/render_view_observer.h" #include "content/renderer/mouse_lock_dispatcher.h" #include "content/renderer/pepper/pepper_parent_context_provider.h" +#include "content/renderer/render_view_pepper_helper.h" #include "ppapi/shared_impl/private/ppb_host_resolver_shared.h" #include "ppapi/shared_impl/private/ppb_tcp_server_socket_shared.h" #include "ppapi/shared_impl/private/tcp_socket_private_impl.h" @@ -28,12 +28,6 @@ #include "webkit/plugins/ppapi/plugin_delegate.h" class FilePath; -class TransportDIB; - -namespace gfx { -class Point; -class Rect; -} namespace IPC { struct ChannelHandle; @@ -45,10 +39,6 @@ class PPB_X509Certificate_Fields; class PpapiPermissions; } -namespace ui { -class Range; -} - namespace webkit { struct WebPluginInfo; namespace ppapi { @@ -59,20 +49,18 @@ class PluginModule; namespace WebKit { class WebGamepads; -class WebMouseEvent; struct WebCompositionUnderline; } namespace content { - class GamepadSharedMemoryReader; class PepperBrokerImpl; class PepperDeviceEnumerationEventHandler; -class PepperPluginDelegateImpl; class RenderViewImpl; class PepperPluginDelegateImpl : public webkit::ppapi::PluginDelegate, + public RenderViewPepperHelper, public base::SupportsWeakPtr<PepperPluginDelegateImpl>, public PepperParentContextProvider, public RenderViewObserver { @@ -82,20 +70,6 @@ class PepperPluginDelegateImpl RenderViewImpl* render_view() { return render_view_; } - // Attempts to create a PPAPI plugin for the given filepath. On success, it - // will return the newly-created module. - // - // There are two reasons for failure. The first is that the plugin isn't - // a PPAPI plugin. In this case, |*pepper_plugin_was_registered| will be set - // to false and the caller may want to fall back on creating an NPAPI plugin. - // the second is that the plugin failed to initialize. In this case, - // |*pepper_plugin_was_registered| will be set to true and the caller should - // not fall back on any other plugin types. - CONTENT_EXPORT scoped_refptr<webkit::ppapi::PluginModule> - CreatePepperPluginModule( - const webkit::WebPluginInfo& webplugin_info, - bool* pepper_plugin_was_registered); - // Sets up the renderer host and out-of-process proxy for an external plugin // module. Returns the renderer host, or NULL if it couldn't be created. RendererPpapiHost* CreateExternalPluginModule( @@ -105,63 +79,65 @@ class PepperPluginDelegateImpl const IPC::ChannelHandle& channel_handle, int plugin_child_id); - // Called by RenderView to tell us about painting events, these two functions - // just correspond to the WillInitiatePaint, DidInitiatePaint and - // DidFlushPaint hooks in RenderView. - void ViewWillInitiatePaint(); - void ViewInitiatedPaint(); - void ViewFlushedPaint(); - - // Called by RenderView to implement the corresponding function in its base - // class RenderWidget (see that for more). - webkit::ppapi::PluginInstance* GetBitmapForOptimizedPluginPaint( - const gfx::Rect& paint_bounds, - TransportDIB** dib, - gfx::Rect* location, - gfx::Rect* clip, - float* scale_factor); - - // Called by RenderView when ViewMsg_AsyncOpenFile_ACK. - void OnAsyncFileOpened(base::PlatformFileError error_code, - base::PlatformFile file, - int message_id); - - // Called by RenderView when ViewMsg_PpapiBrokerChannelCreated. - void OnPpapiBrokerChannelCreated(int request_id, - const IPC::ChannelHandle& handle); - // Removes broker from pending_connect_broker_ if present. Returns true if so. bool StopWaitingForBrokerConnection(PepperBrokerImpl* broker); - // Called when we know whether permission to access the PPAPI broker was - // granted. - void OnPpapiBrokerPermissionResult(int request_id, bool result); - - // Notification that the render view has been focused or defocused. This - // notifies all of the plugins. - void OnSetFocus(bool has_focus); + CONTENT_EXPORT int GetRoutingID() const; - // Notification that the page visibility has changed. The default is visible. - void PageVisibilityChanged(bool is_visible); + typedef base::Callback<void (int /* request_id */, + bool /* succeeded */, + const std::string& /* label */)> + OpenDeviceCallback; - // IME status. - bool IsPluginFocused() const; - gfx::Rect GetCaretBounds() const; - ui::TextInputType GetTextInputType() const; - bool IsPluginAcceptingCompositionEvents() const; - bool CanComposeInline() const; - void GetSurroundingText(string16* text, ui::Range* range) const; + // Opens the specified device. The request ID passed into the callback will be + // the same as the return value. If successful, the label passed into the + // callback identifies a audio/video steam, which can be used to call + // CloseDevice() and GetSesssionID(). + int OpenDevice(PP_DeviceType_Dev type, + const std::string& device_id, + const OpenDeviceCallback& callback); + void CloseDevice(const std::string& label); + // Gets audio/video session ID given a label. + int GetSessionID(PP_DeviceType_Dev type, const std::string& label); - // IME events. - void OnImeSetComposition( + private: + // RenderViewPepperHelper implementation. + virtual WebKit::WebPlugin* CreatePepperWebPlugin( + const webkit::WebPluginInfo& webplugin_info, + const WebKit::WebPluginParams& params) OVERRIDE; + virtual void ViewWillInitiatePaint() OVERRIDE; + virtual void ViewInitiatedPaint() OVERRIDE; + virtual void ViewFlushedPaint() OVERRIDE; + virtual webkit::ppapi::PluginInstance* GetBitmapForOptimizedPluginPaint( + const gfx::Rect& paint_bounds, + TransportDIB** dib, + gfx::Rect* location, + gfx::Rect* clip, + float* scale_factor) OVERRIDE; + virtual void OnAsyncFileOpened(base::PlatformFileError error_code, + base::PlatformFile file, + int message_id) OVERRIDE; + virtual void OnPpapiBrokerChannelCreated( + int request_id, + const IPC::ChannelHandle& handle) OVERRIDE; + virtual void OnPpapiBrokerPermissionResult(int request_id, + bool result) OVERRIDE; + virtual void OnSetFocus(bool has_focus) OVERRIDE; + virtual void PageVisibilityChanged(bool is_visible) OVERRIDE; + virtual bool IsPluginFocused() const OVERRIDE; + virtual gfx::Rect GetCaretBounds() const OVERRIDE; + virtual ui::TextInputType GetTextInputType() const OVERRIDE; + virtual bool IsPluginAcceptingCompositionEvents() const OVERRIDE; + virtual bool CanComposeInline() const OVERRIDE; + virtual void GetSurroundingText(string16* text, + ui::Range* range) const OVERRIDE; + virtual void OnImeSetComposition( const string16& text, const std::vector<WebKit::WebCompositionUnderline>& underlines, int selection_start, - int selection_end); - void OnImeConfirmComposition(const string16& text); - - // Notification that a mouse event has arrived at the render view. - void WillHandleMouseEvent(); + int selection_end) OVERRIDE; + virtual void OnImeConfirmComposition(const string16& text) OVERRIDE; + virtual void WillHandleMouseEvent() OVERRIDE; // PluginDelegate implementation. virtual void PluginFocusChanged(webkit::ppapi::PluginInstance* instance, @@ -269,7 +245,6 @@ class PepperPluginDelegateImpl FilePath* platform_path) OVERRIDE; virtual scoped_refptr<base::MessageLoopProxy> GetFileThreadMessageLoopProxy() OVERRIDE; - virtual uint32 TCPSocketCreate() OVERRIDE; virtual void TCPSocketConnect( webkit::ppapi::PPB_TCPSocket_Private_Impl* socket, @@ -293,7 +268,6 @@ class PepperPluginDelegateImpl virtual void RegisterTCPSocket( webkit::ppapi::PPB_TCPSocket_Private_Impl* socket, uint32 socket_id) OVERRIDE; - virtual uint32 UDPSocketCreate() OVERRIDE; virtual void UDPSocketSetBoolSocketFeature( webkit::ppapi::PPB_UDPSocket_Private_Impl* socket, @@ -318,7 +292,6 @@ class PepperPluginDelegateImpl virtual void TCPServerSocketStopListening( PP_Resource socket_resource, uint32 socket_id) OVERRIDE; - virtual void RegisterHostResolver( ppapi::PPB_HostResolver_Shared* host_resolver, uint32 host_resolver_id) OVERRIDE; @@ -327,12 +300,10 @@ class PepperPluginDelegateImpl const ::ppapi::HostPortPair& host_port, const PP_HostResolver_Private_Hint* hint) OVERRIDE; virtual void UnregisterHostResolver(uint32 host_resolver_id) OVERRIDE; - virtual bool AddNetworkListObserver( webkit_glue::NetworkListObserver* observer) OVERRIDE; virtual void RemoveNetworkListObserver( webkit_glue::NetworkListObserver* observer) OVERRIDE; - virtual bool X509CertificateParseDER( const std::vector<char>& der, ppapi::PPB_X509Certificate_Fields* fields) OVERRIDE; @@ -420,25 +391,20 @@ class PepperPluginDelegateImpl const std::string& canonical_name, const std::vector<PP_NetAddress_Private>& net_address_list); - CONTENT_EXPORT int GetRoutingID() const; - - typedef base::Callback<void (int /* request_id */, - bool /* succeeded */, - const std::string& /* label */)> - OpenDeviceCallback; - - // Opens the specified device. The request ID passed into the callback will be - // the same as the return value. If successful, the label passed into the - // callback identifies a audio/video steam, which can be used to call - // CloseDevice() and GetSesssionID(). - int OpenDevice(PP_DeviceType_Dev type, - const std::string& device_id, - const OpenDeviceCallback& callback); - void CloseDevice(const std::string& label); - // Gets audio/video session ID given a label. - int GetSessionID(PP_DeviceType_Dev type, const std::string& label); + // Attempts to create a PPAPI plugin for the given filepath. On success, it + // will return the newly-created module. + // + // There are two reasons for failure. The first is that the plugin isn't + // a PPAPI plugin. In this case, |*pepper_plugin_was_registered| will be set + // to false and the caller may want to fall back on creating an NPAPI plugin. + // the second is that the plugin failed to initialize. In this case, + // |*pepper_plugin_was_registered| will be set to true and the caller should + // not fall back on any other plugin types. + scoped_refptr<webkit::ppapi::PluginModule> + CreatePepperPluginModule( + const webkit::WebPluginInfo& webplugin_info, + bool* pepper_plugin_was_registered); - private: // Asynchronously attempts to create a PPAPI broker for the given plugin. scoped_refptr<PepperBrokerImpl> CreateBroker( webkit::ppapi::PluginModule* plugin_module); diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc index 3a6d353..a416e82 100644 --- a/content/renderer/render_view_impl.cc +++ b/content/renderer/render_view_impl.cc @@ -88,6 +88,7 @@ #include "content/renderer/media/rtc_peer_connection_handler.h" #include "content/renderer/mhtml_generator.h" #include "content/renderer/notification_provider.h" +#include "content/renderer/pepper/pepper_plugin_delegate_impl.h" #include "content/renderer/plugin_channel_host.h" #include "content/renderer/render_process.h" #include "content/renderer/render_thread_impl.h" @@ -199,7 +200,6 @@ #include "webkit/plugins/npapi/webplugin_delegate.h" #include "webkit/plugins/npapi/webplugin_delegate_impl.h" #include "webkit/plugins/npapi/webplugin_impl.h" -#include "webkit/plugins/ppapi/ppapi_webplugin_impl.h" #if defined(OS_ANDROID) #include "content/common/android/device_info.h" @@ -602,8 +602,12 @@ RenderViewImpl::RenderViewImpl(RenderViewImplParams* params) updating_frame_tree_(false), pending_frame_tree_update_(false), target_process_id_(0), - target_routing_id_(0), - ALLOW_THIS_IN_INITIALIZER_LIST(pepper_delegate_(this)) { + target_routing_id_(0) { +#if defined(ENABLE_PLUGINS) + pepper_helper_.reset(new PepperPluginDelegateImpl(this)); +#else + pepper_helper_.reset(new RenderViewPepperHelper()); +#endif set_throttle_input_events(params->renderer_prefs.throttle_input_events); routing_id_ = params->routing_id; surface_id_ = params->surface_id; @@ -4381,16 +4385,11 @@ WebKit::WebPlugin* RenderViewImpl::CreatePlugin( WebKit::WebFrame* frame, const webkit::WebPluginInfo& info, const WebKit::WebPluginParams& params) { - bool pepper_plugin_was_registered = false; - scoped_refptr<webkit::ppapi::PluginModule> pepper_module( - pepper_delegate_.CreatePepperPluginModule(info, - &pepper_plugin_was_registered)); - if (pepper_plugin_was_registered) { - if (!pepper_module) - return NULL; - return new webkit::ppapi::WebPluginImpl( - pepper_module.get(), params, pepper_delegate_.AsWeakPtr()); - } + WebKit::WebPlugin* pepper_webplugin = + pepper_helper_->CreatePepperWebPlugin(info, params); + + if (pepper_webplugin) + return pepper_webplugin; #if defined(USE_AURA) && !defined(OS_WIN) return NULL; @@ -4574,8 +4573,8 @@ void RenderViewImpl::SyncSelectionIfRequired() { size_t offset; ui::Range range; - if (pepper_delegate_.IsPluginFocused()) { - pepper_delegate_.GetSurroundingText(&text, &range); + if (pepper_helper_->IsPluginFocused()) { + pepper_helper_->GetSurroundingText(&text, &range); offset = 0; // Pepper API does not support offset reporting. // TODO(kinaba): cut as needed. } else { @@ -5544,12 +5543,12 @@ void RenderViewImpl::OnResize(const gfx::Size& new_size, void RenderViewImpl::WillInitiatePaint() { // Notify the pepper plugins that we're about to paint. - pepper_delegate_.ViewWillInitiatePaint(); + pepper_helper_->ViewWillInitiatePaint(); } void RenderViewImpl::DidInitiatePaint() { // Notify the pepper plugins that we've painted, and are waiting to flush. - pepper_delegate_.ViewInitiatedPaint(); + pepper_helper_->ViewInitiatedPaint(); } void RenderViewImpl::DidFlushPaint() { @@ -5557,7 +5556,7 @@ void RenderViewImpl::DidFlushPaint() { // and we it may ask to close itself as a result. This will, in turn, modify // our set, possibly invalidating the iterator. So we iterate on a copy that // won't change out from under us. - pepper_delegate_.ViewFlushedPaint(); + pepper_helper_->ViewFlushedPaint(); // If the RenderWidget is closing down then early-exit, otherwise we'll crash. // See crbug.com/112921. @@ -5603,7 +5602,7 @@ webkit::ppapi::PluginInstance* RenderViewImpl::GetBitmapForOptimizedPluginPaint( gfx::Rect* location, gfx::Rect* clip, float* scale_factor) { - return pepper_delegate_.GetBitmapForOptimizedPluginPaint( + return pepper_helper_->GetBitmapForOptimizedPluginPaint( paint_bounds, dib, location, clip, scale_factor); } @@ -5724,7 +5723,7 @@ bool RenderViewImpl::WillHandleMouseEvent(const WebKit::WebMouseEvent& event) { ui::DragDropTypes::DRAG_EVENT_SOURCE_MOUSE; possible_drag_event_info_.event_location = gfx::Point(event.globalX, event.globalY); - pepper_delegate_.WillHandleMouseEvent(); + pepper_helper_->WillHandleMouseEvent(); // If the mouse is locked, only the current owner of the mouse lock can // process mouse events. @@ -5773,7 +5772,7 @@ void RenderViewImpl::OnWasHidden() { } // Inform PPAPI plugins that their page is no longer visible. - pepper_delegate_.PageVisibilityChanged(false); + pepper_helper_->PageVisibilityChanged(false); #if defined(OS_MACOSX) // Inform NPAPI plugins that their container is no longer visible. @@ -5795,7 +5794,7 @@ void RenderViewImpl::OnWasShown(bool needs_repainting) { } // Inform PPAPI plugins that their page is visible. - pepper_delegate_.PageVisibilityChanged(true); + pepper_helper_->PageVisibilityChanged(true); #if defined(OS_MACOSX) // Inform NPAPI plugins that their container is now visible. @@ -5839,7 +5838,7 @@ void RenderViewImpl::OnSetFocus(bool enable) { } } // Notify all Pepper plugins. - pepper_delegate_.OnSetFocus(enable); + pepper_helper_->OnSetFocus(enable); // Notify all BrowserPlugins of the RenderView's focus state. if (browser_plugin_manager_) browser_plugin_manager()->SetEmbedderFocus(this, enable); @@ -5861,9 +5860,9 @@ void RenderViewImpl::PpapiPluginCaretPositionChanged() { } bool RenderViewImpl::GetPpapiPluginCaretBounds(gfx::Rect* rect) { - if (!pepper_delegate_.IsPluginFocused()) + if (!pepper_helper_->IsPluginFocused()) return false; - *rect = pepper_delegate_.GetCaretBounds(); + *rect = pepper_helper_->GetCaretBounds(); return true; } @@ -5902,12 +5901,12 @@ void RenderViewImpl::OnImeSetComposition( const std::vector<WebKit::WebCompositionUnderline>& underlines, int selection_start, int selection_end) { - if (pepper_delegate_.IsPluginFocused()) { + if (pepper_helper_->IsPluginFocused()) { // When a PPAPI plugin has focus, we bypass WebKit. - pepper_delegate_.OnImeSetComposition(text, - underlines, - selection_start, - selection_end); + pepper_helper_->OnImeSetComposition(text, + underlines, + selection_start, + selection_end); } else { #if defined(OS_WIN) // When a plug-in has focus, we create platform-specific IME data used by @@ -5944,9 +5943,9 @@ void RenderViewImpl::OnImeSetComposition( void RenderViewImpl::OnImeConfirmComposition( const string16& text, const ui::Range& replacement_range) { - if (pepper_delegate_.IsPluginFocused()) { + if (pepper_helper_->IsPluginFocused()) { // When a PPAPI plugin has focus, we bypass WebKit. - pepper_delegate_.OnImeConfirmComposition(text); + pepper_helper_->OnImeConfirmComposition(text); } else { #if defined(OS_WIN) // Same as OnImeSetComposition(), we send the text from IMEs directly to @@ -5983,17 +5982,17 @@ void RenderViewImpl::SetDeviceScaleFactor(float device_scale_factor) { } ui::TextInputType RenderViewImpl::GetTextInputType() { - return pepper_delegate_.IsPluginFocused() ? - pepper_delegate_.GetTextInputType() : RenderWidget::GetTextInputType(); + return pepper_helper_->IsPluginFocused() ? + pepper_helper_->GetTextInputType() : RenderWidget::GetTextInputType(); } void RenderViewImpl::GetSelectionBounds(gfx::Rect* start, gfx::Rect* end) { - if (pepper_delegate_.IsPluginFocused()) { + if (pepper_helper_->IsPluginFocused()) { // TODO(kinaba) http://crbug.com/101101 // Current Pepper IME API does not handle selection bounds. So we simply // use the caret position as an empty range for now. It will be updated // after Pepper API equips features related to surrounding text retrieval. - gfx::Rect caret = pepper_delegate_.GetCaretBounds(); + gfx::Rect caret = pepper_helper_->GetCaretBounds(); *start = caret; *end = caret; return; @@ -6032,8 +6031,8 @@ void RenderViewImpl::GetCompositionCharacterBounds( } bool RenderViewImpl::CanComposeInline() { - return pepper_delegate_.IsPluginFocused() ? - pepper_delegate_.CanComposeInline() : true; + return pepper_helper_->IsPluginFocused() ? + pepper_helper_->CanComposeInline() : true; } #if defined(OS_WIN) @@ -6288,13 +6287,13 @@ void RenderViewImpl::LaunchAndroidContentIntent(const GURL& intent, if (!intent.is_empty()) Send(new ViewHostMsg_StartContentIntent(routing_id_, intent)); } -#endif +#endif // defined(OS_ANDROID) void RenderViewImpl::OnAsyncFileOpened( base::PlatformFileError error_code, IPC::PlatformFileForTransit file_for_transit, int message_id) { - pepper_delegate_.OnAsyncFileOpened( + pepper_helper_->OnAsyncFileOpened( error_code, IPC::PlatformFileForTransitToPlatformFile(file_for_transit), message_id); @@ -6303,14 +6302,14 @@ void RenderViewImpl::OnAsyncFileOpened( void RenderViewImpl::OnPpapiBrokerChannelCreated( int request_id, const IPC::ChannelHandle& handle) { - pepper_delegate_.OnPpapiBrokerChannelCreated(request_id, - handle); + pepper_helper_->OnPpapiBrokerChannelCreated(request_id, + handle); } void RenderViewImpl::OnPpapiBrokerPermissionResult( int request_id, bool result) { - pepper_delegate_.OnPpapiBrokerPermissionResult(request_id, result); + pepper_helper_->OnPpapiBrokerPermissionResult(request_id, result); } #if defined(OS_MACOSX) diff --git a/content/renderer/render_view_impl.h b/content/renderer/render_view_impl.h index 5123688..ee266e4 100644 --- a/content/renderer/render_view_impl.h +++ b/content/renderer/render_view_impl.h @@ -28,7 +28,8 @@ #include "content/public/common/renderer_preferences.h" #include "content/public/common/stop_find_action.h" #include "content/public/renderer/render_view.h" -#include "content/renderer/pepper/pepper_plugin_delegate_impl.h" +#include "content/renderer/mouse_lock_dispatcher.h" +#include "content/renderer/render_view_pepper_helper.h" #include "content/renderer/render_widget.h" #include "content/renderer/renderer_webcookiejar_impl.h" #include "ipc/ipc_platform_file.h" @@ -80,7 +81,6 @@ namespace webkit { namespace ppapi { class PluginInstance; -class WebPluginImpl; } // namespace ppapi } // namespace webkit @@ -1536,15 +1536,15 @@ class CONTENT_EXPORT RenderViewImpl // view, if this is a swapped out render view. std::map<int, int> active_frame_id_map_; - // NOTE: pepper_delegate_ should be last member because its constructor calls - // AddObservers method of RenderViewImpl from c-tor. - PepperPluginDelegateImpl pepper_delegate_; - // This field stores drag/drop related info for the event that is currently // being handled. If the current event results in starting a drag/drop // session, this info is sent to the browser along with other drag/drop info. DragEventSourceInfo possible_drag_event_info_; + // NOTE: pepper_helper_ should be last member because its constructor calls + // AddObservers method of RenderViewImpl from c-tor. + scoped_ptr<RenderViewPepperHelper> pepper_helper_; + // --------------------------------------------------------------------------- // ADDING NEW DATA? Please see if it fits appropriately in one of the above // sections rather than throwing it randomly at the end. If you're adding a diff --git a/content/renderer/render_view_pepper_helper.cc b/content/renderer/render_view_pepper_helper.cc new file mode 100644 index 0000000..f69ca4f --- /dev/null +++ b/content/renderer/render_view_pepper_helper.cc @@ -0,0 +1,50 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "content/renderer/render_view_pepper_helper.h" + +#include "ui/gfx/rect.h" + +namespace content { + +RenderViewPepperHelper::~RenderViewPepperHelper() { +} + +WebKit::WebPlugin* RenderViewPepperHelper::CreatePepperWebPlugin( + const webkit::WebPluginInfo& webplugin_info, + const WebKit::WebPluginParams& params) { + return NULL; +} + +webkit::ppapi::PluginInstance* +RenderViewPepperHelper::GetBitmapForOptimizedPluginPaint( + const gfx::Rect& paint_bounds, + TransportDIB** dib, + gfx::Rect* location, + gfx::Rect* clip, + float* scale_factor) { + return NULL; +} + +bool RenderViewPepperHelper::IsPluginFocused() const { + return false; +} + +gfx::Rect RenderViewPepperHelper::GetCaretBounds() const { + return gfx::Rect(0, 0, 0, 0); +} + +ui::TextInputType RenderViewPepperHelper::GetTextInputType() const { + return ui::TEXT_INPUT_TYPE_NONE; +} + +bool RenderViewPepperHelper::IsPluginAcceptingCompositionEvents() const { + return false; +} + +bool RenderViewPepperHelper::CanComposeInline() const { + return false; +} + +} // namespace content diff --git a/content/renderer/render_view_pepper_helper.h b/content/renderer/render_view_pepper_helper.h new file mode 100644 index 0000000..ced5bf8 --- /dev/null +++ b/content/renderer/render_view_pepper_helper.h @@ -0,0 +1,116 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// This interface is used by RenderView to talk to the pepper plugin delegate. +#ifndef CONTENT_RENDERER_RENDER_VIEW_PEPPER_HELPER_H +#define CONTENT_RENDERER_RENDER_VIEW_PEPPER_HELPER_H + +#include <string> +#include <vector> + +#include "base/basictypes.h" +#include "base/memory/ref_counted.h" +#include "base/platform_file.h" +#include "ui/base/ime/text_input_type.h" + +class TransportDIB; + +namespace gfx { +class Rect; +} + +namespace IPC { +struct ChannelHandle; +} + +namespace ui { +class Range; +} + +namespace webkit { +struct WebPluginInfo; +namespace ppapi { +class PluginInstance; +} +} + +namespace WebKit { +struct WebCompositionUnderline; +struct WebPluginParams; +class WebPlugin; +} + +namespace content { + +class RenderViewPepperHelper { + public: + RenderViewPepperHelper() {} + virtual ~RenderViewPepperHelper(); + + virtual WebKit::WebPlugin* CreatePepperWebPlugin( + const webkit::WebPluginInfo& webplugin_info, + const WebKit::WebPluginParams& params); + + // Called by RenderView to implement the corresponding function in its base + // class RenderWidget (see that for more). + virtual webkit::ppapi::PluginInstance* GetBitmapForOptimizedPluginPaint( + const gfx::Rect& paint_bounds, + TransportDIB** dib, + gfx::Rect* location, + gfx::Rect* clip, + float* scale_factor); + + // Called by RenderView to tell us about painting events, these two functions + // just correspond to the WillInitiatePaint, DidInitiatePaint and + // DidFlushPaint hooks in RenderView. + virtual void ViewWillInitiatePaint() {} + virtual void ViewInitiatedPaint() {} + virtual void ViewFlushedPaint() {} + + // Called by RenderView when ViewMsg_AsyncOpenFile_ACK. + virtual void OnAsyncFileOpened(base::PlatformFileError error_code, + base::PlatformFile file, + int message_id) {} + + // Called by RenderView when ViewMsg_PpapiBrokerChannelCreated. + virtual void OnPpapiBrokerChannelCreated(int request_id, + const IPC::ChannelHandle& handle) {} + + // Called when we know whether permission to access the PPAPI broker was + // granted. + virtual void OnPpapiBrokerPermissionResult(int request_id, bool result) {} + + // Notification that the render view has been focused or defocused. This + // notifies all of the plugins. + virtual void OnSetFocus(bool has_focus) {} + + // Notification that the page visibility has changed. The default is visible. + virtual void PageVisibilityChanged(bool is_visible) {} + + // IME status. + virtual bool IsPluginFocused() const; + virtual gfx::Rect GetCaretBounds() const; + virtual ui::TextInputType GetTextInputType() const; + virtual bool IsPluginAcceptingCompositionEvents() const; + virtual bool CanComposeInline() const; + virtual void GetSurroundingText(string16* text, ui::Range* range) const {} + + // IME events. + virtual void OnImeSetComposition( + const string16& text, + const std::vector<WebKit::WebCompositionUnderline>& underlines, + int selection_start, + int selection_end) {} + virtual void OnImeConfirmComposition(const string16& text) {} + + // Notification that a mouse event has arrived at the render view. + virtual void WillHandleMouseEvent() {} + + private: + DISALLOW_COPY_AND_ASSIGN(RenderViewPepperHelper); +}; + +} // namespace content + +#endif // CONTENT_RENDERER_RENDER_VIEW_PEPPER_HELPER_H |