diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-13 00:18:06 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-13 00:18:06 +0000 |
commit | 88a1fb47ae5abed1c518cdb63836199431ac5af7 (patch) | |
tree | 6bd2be5124623c48546122c80b94a3b203352fe1 /chrome | |
parent | 226183d33f7e52d01d38cad1cfb2e70b938ae74e (diff) | |
download | chromium_src-88a1fb47ae5abed1c518cdb63836199431ac5af7.zip chromium_src-88a1fb47ae5abed1c518cdb63836199431ac5af7.tar.gz chromium_src-88a1fb47ae5abed1c518cdb63836199431ac5af7.tar.bz2 |
Get rid of the gears in renderer process code. This allows me to do some cleanup in how resource dispatching happens in a future cl.
Review URL: http://codereview.chromium.org/42158
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@11601 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/chrome_plugin_host.cc | 45 | ||||
-rw-r--r-- | chrome/browser/renderer_host/browser_render_process_host.cc | 8 | ||||
-rw-r--r-- | chrome/browser/sandbox_policy.cc | 31 | ||||
-rw-r--r-- | chrome/browser/sandbox_policy.h | 3 | ||||
-rw-r--r-- | chrome/chrome.gyp | 3 | ||||
-rw-r--r-- | chrome/common/chrome_switches.cc | 3 | ||||
-rw-r--r-- | chrome/common/chrome_switches.h | 2 | ||||
-rw-r--r-- | chrome/common/render_messages_internal.h | 6 | ||||
-rw-r--r-- | chrome/plugin/webplugin_proxy.h | 3 | ||||
-rw-r--r-- | chrome/renderer/chrome_plugin_host.cc | 651 | ||||
-rw-r--r-- | chrome/renderer/chrome_plugin_host.h | 13 | ||||
-rw-r--r-- | chrome/renderer/render_process.cc | 15 | ||||
-rw-r--r-- | chrome/renderer/render_process.h | 4 | ||||
-rw-r--r-- | chrome/renderer/render_thread.cc | 16 | ||||
-rw-r--r-- | chrome/renderer/render_thread.h | 3 | ||||
-rw-r--r-- | chrome/renderer/render_view.cc | 26 | ||||
-rw-r--r-- | chrome/renderer/renderer.scons | 4 | ||||
-rw-r--r-- | chrome/renderer/renderer.vcproj | 8 |
18 files changed, 16 insertions, 828 deletions
diff --git a/chrome/browser/chrome_plugin_host.cc b/chrome/browser/chrome_plugin_host.cc index ed801e6..7372796 100644 --- a/chrome/browser/chrome_plugin_host.cc +++ b/chrome/browser/chrome_plugin_host.cc @@ -682,44 +682,29 @@ CPProcessType STDCALL CPB_GetProcessType(CPID id) { } CPError STDCALL CPB_SendMessage(CPID id, const void *data, uint32 data_len) { - if (CommandLine::ForCurrentProcess()->HasSwitch( - switches::kGearsInRenderer)) { - ChromePluginLib* plugin = ChromePluginLib::FromCPID(id); - CHECK(plugin); - - const unsigned char* data_ptr = static_cast<const unsigned char*>(data); - std::vector<uint8> v(data_ptr, data_ptr + data_len); - for (RenderProcessHost::iterator it = RenderProcessHost::begin(); - it != RenderProcessHost::end(); ++it) { - it->second->Send(new ViewMsg_PluginMessage(plugin->filename(), v)); - } - - return CPERR_SUCCESS; - } else { - CHECK(ChromePluginLib::IsPluginThread()); - ChromePluginLib* plugin = ChromePluginLib::FromCPID(id); - CHECK(plugin); + CHECK(ChromePluginLib::IsPluginThread()); + ChromePluginLib* plugin = ChromePluginLib::FromCPID(id); + CHECK(plugin); - PluginService* service = PluginService::GetInstance(); - if (!service) + PluginService* service = PluginService::GetInstance(); + if (!service) return CPERR_FAILURE; - PluginProcessHost *host = - service->FindOrStartPluginProcess(plugin->filename(), std::string()); - if (!host) + PluginProcessHost *host = + service->FindOrStartPluginProcess(plugin->filename(), std::string()); + if (!host) return CPERR_FAILURE; - const unsigned char* data_ptr = static_cast<const unsigned char*>(data); - std::vector<uint8> v(data_ptr, data_ptr + data_len); + const unsigned char* data_ptr = static_cast<const unsigned char*>(data); + std::vector<uint8> v(data_ptr, data_ptr + data_len); #if defined(OS_WIN) - if (!host->Send(new PluginProcessMsg_PluginMessage(v))) - return CPERR_FAILURE; + if (!host->Send(new PluginProcessMsg_PluginMessage(v))) + return CPERR_FAILURE; #else - // TODO(port): Implement PluginProcessMsg. - NOTIMPLEMENTED(); + // TODO(port): Implement PluginProcessMsg. + NOTIMPLEMENTED(); #endif - return CPERR_SUCCESS; - } + return CPERR_SUCCESS; } CPError STDCALL CPB_SendSyncMessage(CPID id, const void *data, uint32 data_len, diff --git a/chrome/browser/renderer_host/browser_render_process_host.cc b/chrome/browser/renderer_host/browser_render_process_host.cc index 4a525a7..877e0a7 100644 --- a/chrome/browser/renderer_host/browser_render_process_host.cc +++ b/chrome/browser/renderer_host/browser_render_process_host.cc @@ -261,7 +261,6 @@ bool BrowserRenderProcessHost::Init() { switches::kSilentDumpOnDCHECK, switches::kDisablePopupBlocking, switches::kUseLowFragHeapCrt, - switches::kGearsInRenderer, switches::kEnableVideo, }; @@ -362,13 +361,6 @@ bool BrowserRenderProcessHost::Init() { return false; } - if (browser_command_line.HasSwitch(switches::kGearsInRenderer)) { - if (!AddPolicyForGearsInRenderer(policy)) { - NOTREACHED(); - return false; - } - } - if (!AddDllEvictionPolicy(policy)) { NOTREACHED(); return false; diff --git a/chrome/browser/sandbox_policy.cc b/chrome/browser/sandbox_policy.cc index 8d39650..d491aff 100644 --- a/chrome/browser/sandbox_policy.cc +++ b/chrome/browser/sandbox_policy.cc @@ -161,37 +161,6 @@ bool AddDllEvictionPolicy(sandbox::TargetPolicy* policy) { return true; } -bool AddPolicyForGearsInRenderer(sandbox::TargetPolicy* policy) { - sandbox::ResultCode result; - - // TODO(mpcomplete): need to restrict access to database files only. This - // is just temporary for debugging purposes. - std::wstring plugin_data; - if (!PathService::Get(chrome::DIR_USER_DATA, &plugin_data)) - return false; - if (!win_util::ConvertToLongPath(plugin_data, &plugin_data)) - return false; - - file_util::AppendToPath(&plugin_data, L"*"); - result = policy->AddRule(sandbox::TargetPolicy::SUBSYS_FILES, - sandbox::TargetPolicy::FILES_ALLOW_ANY, - plugin_data.c_str()); - if (result != sandbox::SBOX_ALL_OK) - return false; - - std::wstring temppath; - if (!file_util::GetTempDir(&temppath)) - return false; - file_util::AppendToPath(&temppath, L"*"); - result = policy->AddRule(sandbox::TargetPolicy::SUBSYS_FILES, - sandbox::TargetPolicy::FILES_ALLOW_ANY, - temppath.c_str()); - if (result != sandbox::SBOX_ALL_OK) - return false; - - return true; -} - bool AddGenericPolicy(sandbox::TargetPolicy* policy) { sandbox::ResultCode result; diff --git a/chrome/browser/sandbox_policy.h b/chrome/browser/sandbox_policy.h index f0e3346..393e4bf 100644 --- a/chrome/browser/sandbox_policy.h +++ b/chrome/browser/sandbox_policy.h @@ -17,9 +17,6 @@ bool AddGenericPolicy(sandbox::TargetPolicy* policy); // Adds policy rules for unloaded the known dlls that cause chrome to crash. bool AddDllEvictionPolicy(sandbox::TargetPolicy* policy); -// Adds policy rules for running Gears in the renderer process. -bool AddPolicyForGearsInRenderer(sandbox::TargetPolicy* policy); - // Adds the custom policy rules for a given plugin. If dll is activex-shim, // then clsid is the clsid of ActiveX control. Otherwise clsid is ignored. // |trusted_plugins| contains the comma separate list of plugins that should diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp index be44761..d864387 100644 --- a/chrome/chrome.gyp +++ b/chrome/chrome.gyp @@ -1335,8 +1335,6 @@ 'renderer/net/render_dns_queue.h', 'renderer/about_handler.cc', 'renderer/about_handler.h', - 'renderer/chrome_plugin_host.cc', - 'renderer/chrome_plugin_host.h', 'renderer/debug_message_handler.cc', 'renderer/debug_message_handler.h', 'renderer/dev_tools_agent.cc', @@ -1400,7 +1398,6 @@ },], ['OS!="win"', { 'sources!': [ - 'renderer/chrome_plugin_host.cc', 'renderer/plugin_channel_host.cc', 'renderer/webplugin_delegate_proxy.cc', 'renderer/webworker_proxy.cc', diff --git a/chrome/common/chrome_switches.cc b/chrome/common/chrome_switches.cc index cf1a56b..1a7e91b 100644 --- a/chrome/common/chrome_switches.cc +++ b/chrome/common/chrome_switches.cc @@ -337,9 +337,6 @@ const wchar_t kUseLowFragHeapCrt[] = L"use-lf-heap"; const wchar_t kGearsPluginPathOverride[] = L"gears-plugin-path"; #endif -// Switch to load Gears in the renderer process. -const wchar_t kGearsInRenderer[] = L"gears-in-renderer"; - // Enable the fastback page cache. const wchar_t kEnableFastback[] = L"enable-fastback"; diff --git a/chrome/common/chrome_switches.h b/chrome/common/chrome_switches.h index 7083d7a..07b171f 100644 --- a/chrome/common/chrome_switches.h +++ b/chrome/common/chrome_switches.h @@ -123,8 +123,6 @@ extern const wchar_t kUseLowFragHeapCrt[]; extern const wchar_t kGearsPluginPathOverride[]; #endif -extern const wchar_t kGearsInRenderer[]; - extern const wchar_t kEnableFastback[]; extern const wchar_t kJavaScriptDebuggerPath[]; diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h index bdbabaa..6416a4b 100644 --- a/chrome/common/render_messages_internal.h +++ b/chrome/common/render_messages_internal.h @@ -53,12 +53,6 @@ IPC_BEGIN_MESSAGES(View) size_t /* max_dead_capacity */, size_t /* capacity */) - // Allows a chrome plugin loaded in the browser process to send arbitrary - // data to an instance of the same plugin loaded in a renderer process. - IPC_MESSAGE_CONTROL2(ViewMsg_PluginMessage, - FilePath /* plugin_path of plugin */, - std::vector<uint8> /* opaque data */) - // Reply in response to ViewHostMsg_ShowView or ViewHostMsg_ShowWidget. // similar to the new command, but used when the renderer created a view // first, and we need to update it diff --git a/chrome/plugin/webplugin_proxy.h b/chrome/plugin/webplugin_proxy.h index fd55416..c51769d 100644 --- a/chrome/plugin/webplugin_proxy.h +++ b/chrome/plugin/webplugin_proxy.h @@ -41,9 +41,6 @@ class WebPluginProxy : public WebPlugin { void InvalidateRect(const gfx::Rect& rect); NPObject* GetWindowScriptNPObject(); NPObject* GetPluginElement(); - WebFrame* GetWebFrame() { - return NULL; // doesn't make sense in the plugin process. - } void SetCookie(const GURL& url, const GURL& policy_url, const std::string& cookie); diff --git a/chrome/renderer/chrome_plugin_host.cc b/chrome/renderer/chrome_plugin_host.cc deleted file mode 100644 index 81317c5..0000000 --- a/chrome/renderer/chrome_plugin_host.cc +++ /dev/null @@ -1,651 +0,0 @@ -// Copyright (c) 2006-2008 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 "chrome/plugin/chrome_plugin_host.h" - -#include "base/file_util.h" -#include "base/message_loop.h" -#include "chrome/common/chrome_constants.h" -#include "chrome/common/chrome_plugin_lib.h" -#include "chrome/common/chrome_plugin_util.h" -#include "chrome/common/render_messages.h" -#include "chrome/common/resource_dispatcher.h" -#include "chrome/renderer/render_thread.h" -#include "chrome/renderer/render_view.h" -#include "net/base/data_url.h" -#include "net/base/upload_data.h" -#include "webkit/glue/plugins/plugin_instance.h" -#include "webkit/glue/resource_loader_bridge.h" -#include "webkit/glue/resource_type.h" -#include "webkit/glue/webkit_glue.h" -#include "webkit/glue/webframe.h" - -namespace { - -using webkit_glue::ResourceLoaderBridge; - -// This class manages a network request made by the plugin, handling the -// data as it comes in from the ResourceLoaderBridge and is requested by the -// plugin. -// NOTE: All methods must be called on the Plugin thread. -class PluginRequestHandlerProxy - : public PluginHelper, public ResourceLoaderBridge::Peer { - public: - static PluginRequestHandlerProxy* FromCPRequest(CPRequest* request) { - return ScopableCPRequest::GetData<PluginRequestHandlerProxy*>(request); - } - - PluginRequestHandlerProxy(ChromePluginLib* plugin, - ScopableCPRequest* cprequest, - WebFrame* webframe) - : PluginHelper(plugin), cprequest_(cprequest), response_data_offset_(0), - completed_(false), sync_(false), read_buffer_(NULL), - webframe_(webframe) { - load_flags_ = PluginResponseUtils::CPLoadFlagsToNetFlags(0); - cprequest_->data = this; // see FromCPRequest(). - } - - ~PluginRequestHandlerProxy() { - if (bridge_.get() && !completed_) { - bridge_->Cancel(); - } - } - - // ResourceLoaderBridge::Peer - virtual void OnUploadProgress(uint64 position, uint64 size) { - CPRR_UploadProgressFunc upload_progress = - plugin_->functions().response_funcs->upload_progress; - if (upload_progress) - upload_progress(cprequest_.get(), position, size); - } - - virtual void OnReceivedRedirect(const GURL& new_url) { - plugin_->functions().response_funcs->received_redirect( - cprequest_.get(), new_url.spec().c_str()); - } - - virtual void OnReceivedResponse( - const ResourceLoaderBridge::ResponseInfo& info, - bool content_filtered) { - response_headers_ = info.headers; - plugin_->functions().response_funcs->start_completed( - cprequest_.get(), CPERR_SUCCESS); - } - - virtual void OnReceivedData(const char* data, int len) { - response_data_.append(data, len); - if (read_buffer_) { - // If we had an asynchronous operation pending, read into that buffer - // and inform the plugin. - int rv = Read(read_buffer_, read_buffer_size_); - DCHECK(rv != CPERR_IO_PENDING); - read_buffer_ = NULL; - plugin_->functions().response_funcs->read_completed( - cprequest_.get(), rv); - } - } - - virtual void OnCompletedRequest(const URLRequestStatus& status, - const std::string& security_info) { - completed_ = true; - - if (!status.is_success()) { - // TODO(mpcomplete): better error codes - // Inform the plugin, calling the right function depending on whether - // we got the start_completed event or not. - if (response_headers_) { - plugin_->functions().response_funcs->start_completed( - cprequest_.get(), CPERR_FAILURE); - } else { - plugin_->functions().response_funcs->read_completed( - cprequest_.get(), CPERR_FAILURE); - } - } else if (read_buffer_) { - // The plugin was waiting for more data. Inform him we're done. - read_buffer_ = NULL; - plugin_->functions().response_funcs->read_completed( - cprequest_.get(), CPERR_SUCCESS); - } - } - - virtual std::string GetURLForDebugging() { - return cprequest_->url; - } - - void set_extra_headers(const std::string& headers) { - extra_headers_ = headers; - } - void set_load_flags(uint32 flags) { - load_flags_ = flags; - } - void set_sync(bool sync) { - sync_ = sync; - } - void AppendDataToUpload(const char* bytes, int bytes_len) { - upload_content_.push_back(net::UploadData::Element()); - upload_content_.back().SetToBytes(bytes, bytes_len); - } - - void AppendFileToUpload(const std::wstring &filepath) { - AppendFileRangeToUpload(filepath, 0, kuint64max); - } - - void AppendFileRangeToUpload(const std::wstring &filepath, - uint64 offset, uint64 length) { - upload_content_.push_back(net::UploadData::Element()); - upload_content_.back().SetToFilePathRange(filepath, offset, length); - } - - CPError Start() { - bridge_.reset( - webkit_glue::ResourceLoaderBridge::Create( - webframe_, - cprequest_->method, - GURL(cprequest_->url), - GURL(cprequest_->url), // TODO(jackson): policy url? - GURL(), // TODO(mpcomplete): referrer? - extra_headers_, - load_flags_, - GetCurrentProcessId(), - ResourceType::OBJECT, - false)); // TODO (jcampan): mixed-content? - if (!bridge_.get()) - return CPERR_FAILURE; - - for (size_t i = 0; i < upload_content_.size(); ++i) { - switch (upload_content_[i].type()) { - case net::UploadData::TYPE_BYTES: { - const std::vector<char>& bytes = upload_content_[i].bytes(); - bridge_->AppendDataToUpload(&bytes[0], - static_cast<int>(bytes.size())); - break; - } - case net::UploadData::TYPE_FILE: { - bridge_->AppendFileRangeToUpload( - upload_content_[i].file_path(), - upload_content_[i].file_range_offset(), - upload_content_[i].file_range_length()); - break; - } - default: { - NOTREACHED() << "Unknown UploadData::Element type"; - } - } - } - - if (sync_) { - ResourceLoaderBridge::SyncLoadResponse response; - bridge_->SyncLoad(&response); - response_headers_ = response.headers; - response_data_ = response.data; - completed_ = true; - return response.status.is_success() ? CPERR_SUCCESS : CPERR_FAILURE; - } else { - if (!bridge_->Start(this)) { - bridge_.reset(); - return CPERR_FAILURE; - } - return CPERR_IO_PENDING; - } - } - - int GetResponseInfo(CPResponseInfoType type, void* buf, uint32 buf_size) { - return PluginResponseUtils::GetResponseInfo( - response_headers_, type, buf, buf_size); - } - - int Read(void* buf, uint32 buf_size) { - uint32 avail = - static_cast<uint32>(response_data_.size()) - response_data_offset_; - uint32 count = buf_size; - if (count > avail) - count = avail; - - int rv = CPERR_FAILURE; - if (count) { - // Data is ready now. - memcpy(buf, &response_data_[0] + response_data_offset_, count); - response_data_offset_ += count; - } else if (!completed_) { - read_buffer_ = buf; - read_buffer_size_ = buf_size; - DCHECK(!sync_); - return CPERR_IO_PENDING; - } - - if (response_data_.size() == response_data_offset_) { - // Simple optimization for large requests. Generally the consumer will - // read the data faster than it comes in, so we can clear our buffer - // any time it has all been read. - response_data_.clear(); - response_data_offset_ = 0; - } - - read_buffer_ = NULL; - return count; - } - - private: - scoped_ptr<ScopableCPRequest> cprequest_; - WebFrame* webframe_; - scoped_ptr<ResourceLoaderBridge> bridge_; - std::vector<net::UploadData::Element> upload_content_; - std::string extra_headers_; - uint32 load_flags_; - bool sync_; - - scoped_refptr<net::HttpResponseHeaders> response_headers_; - std::string response_data_; - int response_data_offset_; - bool completed_; - void* read_buffer_; - uint32 read_buffer_size_; -}; - -// -// Generic functions -// - -// TODO(mpcomplete): call up to browser to ask for a valid browsing context. -WebPlugin* WebPluginFromContext(CPBrowsingContext context) { - return reinterpret_cast<WebPlugin*>(static_cast<LONG_PTR>(context)); -} - -CPBrowsingContext ContextFromWebPlugin(WebPlugin* webplugin) { - return static_cast<CPBrowsingContext>(reinterpret_cast<LONG_PTR>(webplugin)); -} - -void STDCALL CPB_SetKeepProcessAlive(CPID id, CPBool keep_alive) { - // Doesn't apply in the renderer process. -} - -CPError STDCALL CPB_GetCookies(CPID id, CPBrowsingContext context, - const char* url, char** cookies) { - CHECK(ChromePluginLib::IsPluginThread()); - - std::string cookies_str; - RenderThread::current()->Send( - new ViewHostMsg_GetCookies(GURL(url), GURL(url), &cookies_str)); - - *cookies = CPB_StringDup(CPB_Alloc, cookies_str); - return CPERR_SUCCESS; -} - -CPError STDCALL CPB_ShowHtmlDialogModal( - CPID id, CPBrowsingContext context, const char* url, int width, int height, - const char* json_arguments, char** json_retval) { - CHECK(ChromePluginLib::IsPluginThread()); - - WebPlugin* webplugin = WebPluginFromContext(context); - if (!webplugin) - return CPERR_INVALID_PARAMETER; - - std::string retval_str; - webplugin->ShowModalHTMLDialog( - GURL(url), width, height, json_arguments, &retval_str); - *json_retval = CPB_StringDup(CPB_Alloc, retval_str); - return CPERR_SUCCESS; -} - -CPError STDCALL CPB_ShowHtmlDialog( - CPID id, CPBrowsingContext context, const char* url, int width, int height, - const char* json_arguments, void* plugin_context) { - // TODO(mpcomplete): support non-modal dialogs. - return CPERR_FAILURE; -} - -CPError STDCALL CPB_GetCommandLineArguments( - CPID id, CPBrowsingContext context, const char* url, char** arguments) { - CHECK(ChromePluginLib::IsPluginThread()); - std::string arguments_str; - CPError rv = CPB_GetCommandLineArgumentsCommon(url, &arguments_str); - if (rv == CPERR_SUCCESS) - *arguments = CPB_StringDup(CPB_Alloc, arguments_str); - return rv; -} - -CPBrowsingContext STDCALL CPB_GetBrowsingContextFromNPP(NPP npp) { - if (!npp) - return CPERR_INVALID_PARAMETER; - - NPAPI::PluginInstance* instance = - static_cast<NPAPI::PluginInstance *>(npp->ndata); - return ContextFromWebPlugin(instance->webplugin()); -} - -int STDCALL CPB_GetBrowsingContextInfo( - CPID id, CPBrowsingContext context, CPBrowsingContextInfoType type, - void* buf, uint32 buf_size) { - CHECK(ChromePluginLib::IsPluginThread()); - - switch (type) { - case CPBROWSINGCONTEXT_DATA_DIR_PTR: { - if (buf_size < sizeof(char*)) - return sizeof(char*); - - std::wstring wretval; - if (!RenderThread::current()->Send(new ViewHostMsg_GetDataDir(&wretval))) - return CPERR_FAILURE; - file_util::AppendToPath(&wretval, chrome::kChromePluginDataDirname); - *static_cast<char**>(buf) = CPB_StringDup(CPB_Alloc, WideToUTF8(wretval)); - return CPERR_SUCCESS; - } - case CPBROWSINGCONTEXT_UI_LOCALE_PTR: { - if (buf_size < sizeof(char*)) - return sizeof(char*); - - std::wstring wretval = webkit_glue::GetWebKitLocale(); - *static_cast<char**>(buf) = CPB_StringDup(CPB_Alloc, WideToUTF8(wretval)); - return CPERR_SUCCESS; - } - } - - return CPERR_FAILURE; -} - -CPError STDCALL CPB_AddUICommand(CPID id, int command) { - // Not implemented in the renderer process - return CPERR_FAILURE; -} - -CPError STDCALL CPB_HandleCommand( - CPID id, CPBrowsingContext context, int command, void *data) { - // Not implemented in the renderer process - return CPERR_FAILURE; -} - -// -// Functions related to network interception -// - -void STDCALL CPB_EnableRequestIntercept( - CPID id, const char** schemes, uint32 num_schemes) { - // We ignore requests by the plugin to intercept from this process. That's - // handled in the browser process. -} - -void STDCALL CPRR_ReceivedRedirect(CPRequest* request, const char* new_url) { - NOTREACHED() << "Network interception should not happen in renderer process."; -} - -void STDCALL CPRR_StartCompleted(CPRequest* request, CPError result) { - NOTREACHED() << "Network interception should not happen in renderer process."; -} - -void STDCALL CPRR_ReadCompleted(CPRequest* request, int bytes_read) { - NOTREACHED() << "Network interception should not happen in renderer process."; -} - -void STDCALL CPRR_UploadProgress(CPRequest* request, uint64 pos, uint64 size) { - NOTREACHED() << "Network interception should not happen in renderer process."; -} - -// -// Functions related to serving network requests to the plugin -// - -CPError STDCALL CPB_CreateRequest(CPID id, CPBrowsingContext context, - const char* method, const char* url, - CPRequest** request) { - CHECK(ChromePluginLib::IsPluginThread()); - ChromePluginLib* plugin = ChromePluginLib::FromCPID(id); - CHECK(plugin); - - WebPlugin* webplugin = WebPluginFromContext(context); - WebFrame* webframe = webplugin->GetWebFrame(); - ScopableCPRequest* cprequest = new ScopableCPRequest(url, method, context); - PluginRequestHandlerProxy* handler = - new PluginRequestHandlerProxy(plugin, cprequest, webframe); - - *request = cprequest; - return CPERR_SUCCESS; -} - -CPError STDCALL CPR_StartRequest(CPRequest* request) { - CHECK(ChromePluginLib::IsPluginThread()); - PluginRequestHandlerProxy* handler = - PluginRequestHandlerProxy::FromCPRequest(request); - CHECK(handler); - return handler->Start(); -} - -void STDCALL CPR_EndRequest(CPRequest* request, CPError reason) { - CHECK(ChromePluginLib::IsPluginThread()); - PluginRequestHandlerProxy* handler = - PluginRequestHandlerProxy::FromCPRequest(request); - delete handler; -} - -void STDCALL CPR_SetExtraRequestHeaders(CPRequest* request, - const char* headers) { - CHECK(ChromePluginLib::IsPluginThread()); - PluginRequestHandlerProxy* handler = - PluginRequestHandlerProxy::FromCPRequest(request); - CHECK(handler); - handler->set_extra_headers(headers); -} - -void STDCALL CPR_SetRequestLoadFlags(CPRequest* request, uint32 flags) { - CHECK(ChromePluginLib::IsPluginThread()); - PluginRequestHandlerProxy* handler = - PluginRequestHandlerProxy::FromCPRequest(request); - CHECK(handler); - - if (flags & CPREQUESTLOAD_SYNCHRONOUS) { - handler->set_sync(true); - } - - uint32 net_flags = PluginResponseUtils::CPLoadFlagsToNetFlags(flags); - handler->set_load_flags(net_flags); -} - -void STDCALL CPR_AppendDataToUpload(CPRequest* request, const char* bytes, - int bytes_len) { - CHECK(ChromePluginLib::IsPluginThread()); - PluginRequestHandlerProxy* handler = - PluginRequestHandlerProxy::FromCPRequest(request); - CHECK(handler); - handler->AppendDataToUpload(bytes, bytes_len); -} - -CPError STDCALL CPR_AppendFileToUpload(CPRequest* request, const char* filepath, - uint64 offset, uint64 length) { - CHECK(ChromePluginLib::IsPluginThread()); - PluginRequestHandlerProxy* handler = - PluginRequestHandlerProxy::FromCPRequest(request); - CHECK(handler); - - if (!length) length = kuint64max; - std::wstring wfilepath(UTF8ToWide(filepath)); - handler->AppendFileRangeToUpload(wfilepath, offset, length); - return CPERR_SUCCESS; -} - -int STDCALL CPR_GetResponseInfo(CPRequest* request, CPResponseInfoType type, - void* buf, uint32 buf_size) { - CHECK(ChromePluginLib::IsPluginThread()); - PluginRequestHandlerProxy* handler = - PluginRequestHandlerProxy::FromCPRequest(request); - CHECK(handler); - return handler->GetResponseInfo(type, buf, buf_size); -} - -int STDCALL CPR_Read(CPRequest* request, void* buf, uint32 buf_size) { - CHECK(ChromePluginLib::IsPluginThread()); - PluginRequestHandlerProxy* handler = - PluginRequestHandlerProxy::FromCPRequest(request); - CHECK(handler); - return handler->Read(buf, buf_size); -} - -CPBool STDCALL CPB_IsPluginProcessRunning(CPID id) { - CHECK(ChromePluginLib::IsPluginThread()); - return true; -} - -CPProcessType STDCALL CPB_GetProcessType(CPID id) { - CHECK(ChromePluginLib::IsPluginThread()); - return CP_PROCESS_RENDERER; -} - -CPError STDCALL CPB_SendMessage(CPID id, const void *data, uint32 data_len) { - CHECK(ChromePluginLib::IsPluginThread()); - ChromePluginLib* plugin = ChromePluginLib::FromCPID(id); - CHECK(plugin); - - const uint8* data_ptr = static_cast<const uint8*>(data); - std::vector<uint8> v(data_ptr, data_ptr + data_len); - if (!RenderThread::current()->Send( - new ViewHostMsg_PluginMessage(plugin->filename(), v))) { - return CPERR_FAILURE; - } - return CPERR_SUCCESS; -} - -CPError STDCALL CPB_SendSyncMessage(CPID id, const void *data, uint32 data_len, - void **retval, uint32 *retval_len) { - CHECK(ChromePluginLib::IsPluginThread()); - ChromePluginLib* plugin = ChromePluginLib::FromCPID(id); - CHECK(plugin); - - const uint8* data_ptr = static_cast<const uint8*>(data); - std::vector<uint8> v(data_ptr, data_ptr + data_len); - std::vector<uint8> r; - if (!RenderThread::current()->Send(new ViewHostMsg_PluginSyncMessage( - plugin->filename(), v, &r))) { - return CPERR_FAILURE; - } - - if (r.size()) { - *retval_len = static_cast<uint32>(r.size()); - *retval = CPB_Alloc(*retval_len); - memcpy(*retval, &(r.at(0)), r.size()); - } else { - *retval = NULL; - *retval_len = 0; - } - - return CPERR_SUCCESS; -} - -CPError STDCALL CPB_PluginThreadAsyncCall(CPID id, - void (*func)(void *), - void *user_data) { - MessageLoop *message_loop = ChromePluginLib::GetPluginThreadLoop(); - if (!message_loop) { - return CPERR_FAILURE; - } - message_loop->PostTask(FROM_HERE, NewRunnableFunction(func, user_data)); - - return CPERR_SUCCESS; -} - -class PluginOpenFileDialogListener : public WebFileChooserCallback { - public: - PluginOpenFileDialogListener(CPID cpid, void *user_data) - : cpid_(cpid), user_data_(user_data) { - } - virtual void OnFileChoose(const std::vector<std::wstring>& file_names) { - ChromePluginLib *chrome_plugin = ChromePluginLib::FromCPID(cpid_); - if (chrome_plugin) { - if (!file_names.empty()) { - std::vector<std::string> utf8_files; - std::vector<const char *> ret_files; - for (std::vector<std::wstring>::const_iterator ix = file_names.begin(); - ix != file_names.end(); ++ix) { - utf8_files.push_back(WideToUTF8(*ix)); - ret_files.push_back(utf8_files.back().c_str()); - } - - chrome_plugin->functions().on_file_dialog_result(user_data_, - &ret_files.at(0), - ret_files.size()); - } else { - chrome_plugin->functions().on_file_dialog_result(user_data_, 0, 0); - } - } - } - - private: - CPID cpid_; - void *user_data_; -}; - -CPError STDCALL CPB_OpenFileDialog(CPID id, - CPBrowsingContext context, - bool multiple_files, - const char *title, - const char *filter, - void *user_data) { - CHECK(ChromePluginLib::IsPluginThread()); - - WebPlugin* webplugin = WebPluginFromContext(context); - WebFrame* webframe = webplugin->GetWebFrame(); - WebView* webview = webframe->GetView(); - WebViewDelegate* webviewdelegate = webview->GetDelegate(); - - PluginOpenFileDialogListener *listener = - new PluginOpenFileDialogListener(id, user_data); - - webviewdelegate->RunFileChooser(multiple_files, UTF8ToWide(title), - std::wstring(), UTF8ToWide(filter), - listener); - - return CPERR_SUCCESS; -} - -} // namespace - -CPBrowserFuncs* GetCPBrowserFuncsForRenderer() { - static CPBrowserFuncs browser_funcs; - static CPRequestFuncs request_funcs; - static CPResponseFuncs response_funcs; - static bool initialized = false; - if (!initialized) { - initialized = true; - - browser_funcs.size = sizeof(browser_funcs); - browser_funcs.version = CP_VERSION; - browser_funcs.enable_request_intercept = CPB_EnableRequestIntercept; - browser_funcs.create_request = CPB_CreateRequest; - browser_funcs.get_cookies = CPB_GetCookies; - browser_funcs.alloc = CPB_Alloc; - browser_funcs.free = CPB_Free; - browser_funcs.set_keep_process_alive = CPB_SetKeepProcessAlive; - browser_funcs.show_html_dialog = CPB_ShowHtmlDialog; - browser_funcs.show_html_dialog_modal = CPB_ShowHtmlDialogModal; - browser_funcs.is_plugin_process_running = CPB_IsPluginProcessRunning; - browser_funcs.get_process_type = CPB_GetProcessType; - browser_funcs.send_message = CPB_SendMessage; - browser_funcs.get_browsing_context_from_npp = CPB_GetBrowsingContextFromNPP; - browser_funcs.get_browsing_context_info = CPB_GetBrowsingContextInfo; - browser_funcs.get_command_line_arguments = CPB_GetCommandLineArguments; - browser_funcs.add_ui_command = CPB_AddUICommand; - browser_funcs.handle_command = CPB_HandleCommand; - browser_funcs.send_sync_message = CPB_SendSyncMessage; - browser_funcs.plugin_thread_async_call = CPB_PluginThreadAsyncCall; - browser_funcs.open_file_dialog = CPB_OpenFileDialog; - - browser_funcs.request_funcs = &request_funcs; - browser_funcs.response_funcs = &response_funcs; - - request_funcs.size = sizeof(request_funcs); - request_funcs.start_request = CPR_StartRequest; - request_funcs.end_request = CPR_EndRequest; - request_funcs.set_extra_request_headers = CPR_SetExtraRequestHeaders; - request_funcs.set_request_load_flags = CPR_SetRequestLoadFlags; - request_funcs.append_data_to_upload = CPR_AppendDataToUpload; - request_funcs.get_response_info = CPR_GetResponseInfo; - request_funcs.read = CPR_Read; - request_funcs.append_file_to_upload = CPR_AppendFileToUpload; - - response_funcs.size = sizeof(response_funcs); - response_funcs.received_redirect = CPRR_ReceivedRedirect; - response_funcs.start_completed = CPRR_StartCompleted; - response_funcs.read_completed = CPRR_ReadCompleted; - response_funcs.upload_progress = CPRR_UploadProgress; - } - - return &browser_funcs; -} diff --git a/chrome/renderer/chrome_plugin_host.h b/chrome/renderer/chrome_plugin_host.h deleted file mode 100644 index 8b6d782..0000000 --- a/chrome/renderer/chrome_plugin_host.h +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright (c) 2006-2008 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. - -#ifndef CHROME_RENDERER_CHROME_PLUGIN_HOST_H__ -#define CHROME_RENDERER_CHROME_PLUGIN_HOST_H__ - -#include "chrome/common/chrome_plugin_api.h" - -// Returns the table of browser functions for use from the renderer process. -CPBrowserFuncs* GetCPBrowserFuncsForRenderer(); - -#endif // CHROME_RENDERER_CHROME_PLUGIN_HOST_H__ diff --git a/chrome/renderer/render_process.cc b/chrome/renderer/render_process.cc index b93adf59..e8af233 100644 --- a/chrome/renderer/render_process.cc +++ b/chrome/renderer/render_process.cc @@ -106,7 +106,6 @@ RenderProcess::~RenderProcess() { void RenderProcess::Init() { in_process_plugins_ = InProcessPlugins(); - in_process_gears_ = false; for (size_t i = 0; i < arraysize(shared_mem_cache_); ++i) shared_mem_cache_[i] = NULL; @@ -141,20 +140,6 @@ void RenderProcess::Init() { StatisticsRecorder::set_dump_on_exit(true); } - if (command_line.HasSwitch(switches::kGearsInRenderer)) { -#if defined(OS_WIN) - in_process_gears_ = true; - // Load gears.dll on startup so we can access it before the sandbox - // blocks us. - std::wstring path; - if (PathService::Get(chrome::FILE_GEARS_PLUGIN, &path)) - LoadLibrary(path.c_str()); -#else - // TODO(port) Need to handle loading gears on non-Windows platforms - NOTIMPLEMENTED(); -#endif - } - if (command_line.HasSwitch(switches::kEnableVideo) && LoadFFmpeg()) { webkit_glue::SetMediaPlayerAvailable(true); } diff --git a/chrome/renderer/render_process.h b/chrome/renderer/render_process.h index a4bc0ff5..e09d8fa 100644 --- a/chrome/renderer/render_process.h +++ b/chrome/renderer/render_process.h @@ -45,9 +45,6 @@ class RenderProcess : public ChildProcess { // Returns true if plugins should be loaded in-process. bool in_process_plugins() const { return in_process_plugins_; } - // Returns true if Gears should be loaded in-process. - bool in_process_gears() const { return in_process_gears_; } - // Returns a pointer to the RenderProcess singleton instance. static RenderProcess* current() { return static_cast<RenderProcess*>(ChildProcess::current()); @@ -95,7 +92,6 @@ class RenderProcess : public ChildProcess { uint32 sequence_number_; bool in_process_plugins_; - bool in_process_gears_; DISALLOW_COPY_AND_ASSIGN(RenderProcess); }; diff --git a/chrome/renderer/render_thread.cc b/chrome/renderer/render_thread.cc index 1c04cc1..846e866 100644 --- a/chrome/renderer/render_thread.cc +++ b/chrome/renderer/render_thread.cc @@ -10,7 +10,6 @@ #include "base/command_line.h" #include "base/shared_memory.h" #include "base/stats_table.h" -#include "chrome/common/chrome_plugin_lib.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/render_messages.h" #include "chrome/common/notification_service.h" @@ -158,26 +157,11 @@ void RenderThread::OnControlMessageReceived(const IPC::Message& msg) { OnGetRendererHistograms) IPC_MESSAGE_HANDLER(ViewMsg_GetCacheResourceStats, OnGetCacheResourceStats) - IPC_MESSAGE_HANDLER(ViewMsg_PluginMessage, OnPluginMessage) IPC_MESSAGE_HANDLER(ViewMsg_UserScripts_NewScripts, OnUpdateUserScripts) IPC_END_MESSAGE_MAP() } -void RenderThread::OnPluginMessage(const FilePath& plugin_path, - const std::vector<uint8>& data) { - if (!ChromePluginLib::IsInitialized()) { - return; - } - CHECK(ChromePluginLib::IsPluginThread()); - ChromePluginLib *chrome_plugin = ChromePluginLib::Find(plugin_path); - if (chrome_plugin) { - void *data_ptr = const_cast<void*>(reinterpret_cast<const void*>(&data[0])); - uint32 data_len = static_cast<uint32>(data.size()); - chrome_plugin->functions().on_message(data_ptr, data_len); - } -} - void RenderThread::OnSetNextPageID(int32 next_page_id) { // This should only be called at process initialization time, so we shouldn't // have to worry about thread-safety. diff --git a/chrome/renderer/render_thread.h b/chrome/renderer/render_thread.h index 2ae157f..1f215dd 100644 --- a/chrome/renderer/render_thread.h +++ b/chrome/renderer/render_thread.h @@ -107,9 +107,6 @@ class RenderThread : public RenderThreadBase, void OnUpdateVisitedLinks(base::SharedMemoryHandle table); void OnUpdateUserScripts(base::SharedMemoryHandle table); - - void OnPluginMessage(const FilePath& plugin_path, - const std::vector<uint8>& data); void OnSetNextPageID(int32 next_page_id); void OnCreateNewView(gfx::NativeViewId parent_hwnd, ModalDialogEvent modal_dialog_event, diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc index 2d614b4..8af74f5 100644 --- a/chrome/renderer/render_view.cc +++ b/chrome/renderer/render_view.cc @@ -66,7 +66,6 @@ #if defined(OS_WIN) // TODO(port): these files are currently Windows only because they concern: // * logging -// * plugins // * printing // * theming // * views @@ -75,8 +74,6 @@ #include "chrome/common/gfx/emf.h" #include "chrome/renderer/renderer_logging.h" #include "chrome/views/message_box_view.h" -#include "chrome/common/chrome_plugin_lib.h" -#include "chrome/renderer/chrome_plugin_host.h" #include "skia/ext/vector_canvas.h" #endif @@ -1869,24 +1866,6 @@ WebWidget* RenderView::CreatePopupWidget(WebView* webview, return widget->webwidget(); } -#if defined(OS_WIN) -// TODO(port): This is only used on Windows since the plugin code is #ifdefed -// out for other platforms currently - -static bool ShouldLoadPluginInProcess(const std::string& mime_type, - bool* is_gears) { - if (RenderProcess::current()->in_process_plugins()) - return true; - - if (mime_type == "application/x-googlegears") { - *is_gears = true; - return RenderProcess::current()->in_process_gears(); - } - - return false; -} -#endif - WebPluginDelegate* RenderView::CreatePluginDelegate( WebView* webview, const GURL& url, @@ -1894,8 +1873,7 @@ WebPluginDelegate* RenderView::CreatePluginDelegate( const std::string& clsid, std::string* actual_mime_type) { #if defined(OS_WIN) - bool is_gears = false; - if (ShouldLoadPluginInProcess(mime_type, &is_gears)) { + if (RenderProcess::current()->in_process_plugins()) { FilePath path; render_thread_->Send( new ViewHostMsg_GetPluginPath(url, mime_type, clsid, &path, @@ -1909,8 +1887,6 @@ WebPluginDelegate* RenderView::CreatePluginDelegate( else mime_type_to_use = mime_type; - if (is_gears) - ChromePluginLib::Create(path, GetCPBrowserFuncsForRenderer()); return WebPluginDelegate::Create(path, mime_type_to_use, gfx::NativeViewFromId(host_window_)); diff --git a/chrome/renderer/renderer.scons b/chrome/renderer/renderer.scons index 62b6d57..e7a22d2 100644 --- a/chrome/renderer/renderer.scons +++ b/chrome/renderer/renderer.scons @@ -63,8 +63,6 @@ input_files = ChromeFileList([ ]), 'about_handler.cc', 'about_handler.h', - 'chrome_plugin_host.cc', - 'chrome_plugin_host.h', 'debug_message_handler.cc', 'debug_message_handler.h', 'dev_tools_agent.cc', @@ -127,7 +125,6 @@ if env.Bit('linux'): # TODO(port): Port these to Linux input_files.Remove( - 'chrome_plugin_host.cc', 'plugin_channel_host.cc', 'webplugin_delegate_proxy.cc', ) @@ -135,7 +132,6 @@ if env.Bit('linux'): # TODO(port): Port these to Mac if env.Bit('mac'): input_files.Remove( - 'chrome_plugin_host.cc', 'debug_message_handler.cc', 'external_js_object.cc', 'net/render_dns_master.cc', diff --git a/chrome/renderer/renderer.vcproj b/chrome/renderer/renderer.vcproj index 4f15e7f..ce21c83 100644 --- a/chrome/renderer/renderer.vcproj +++ b/chrome/renderer/renderer.vcproj @@ -202,14 +202,6 @@ > </File> <File - RelativePath=".\chrome_plugin_host.cc" - > - </File> - <File - RelativePath=".\chrome_plugin_host.h" - > - </File> - <File RelativePath=".\debug_message_handler.cc" > </File> |