diff options
author | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-11 23:10:56 +0000 |
---|---|---|
committer | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-11 23:10:56 +0000 |
commit | 50285fffa5e44c61cbf6141908c6297fbd0b20d4 (patch) | |
tree | 5fb535a307298d93e4c885c40856303784cbf543 /chrome | |
parent | 1ad795b4c02d1fd42743252685bd411619a2d4e2 (diff) | |
download | chromium_src-50285fffa5e44c61cbf6141908c6297fbd0b20d4.zip chromium_src-50285fffa5e44c61cbf6141908c6297fbd0b20d4.tar.gz chromium_src-50285fffa5e44c61cbf6141908c6297fbd0b20d4.tar.bz2 |
Remove Gears from Chrome.
There are probably a few more bits and pieces that can be removed, but I think this is the majority of it.
BUG=51934
Review URL: http://codereview.chromium.org/6576020
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@77888 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
74 files changed, 27 insertions, 5108 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd index ef2d1ca..1760a29 100644 --- a/chrome/app/generated_resources.grd +++ b/chrome/app/generated_resources.grd @@ -2324,7 +2324,7 @@ Other platform defines such as use_titlecase are declared in build/common.gypi. Wait for downloads to finish </message> - <!-- Gears shortcut strings --> + <!-- "Create application shortcuts" menu item --> <if expr="not pp_ifdef('use_titlecase')"> <message name="IDS_CREATE_SHORTCUTS" desc="Default installation menu label"> Create application &shortcuts... @@ -2336,7 +2336,7 @@ Other platform defines such as use_titlecase are declared in build/common.gypi. </message> </if> - <!-- "Create application shortcuts" dialog (non-Gears) --> + <!-- "Create application shortcuts" dialog --> <if expr="not pp_ifdef('use_titlecase') or os != 'linux2'"> <message name="IDS_CREATE_SHORTCUTS_TITLE" desc="Title of the dialog to create application shortcuts for current page."> Create application shortcuts @@ -7063,13 +7063,6 @@ Keep your key file in a safe place. You will need it to create new versions of y </message> </if> - <message name="IDS_OPTIONS_GEARSSETTINGS_GROUP_NAME" desc="The label of the 'Gears Settings' group"> - Gears: - </message> - <message name="IDS_OPTIONS_GEARSSETTINGS_CONFIGUREGEARS_BUTTON" desc="The label of the 'configure gears' button"> - Change Gears settings - </message> - <message name="IDS_OPTIONS_TRANSLATE_ENABLE_TRANSLATE" desc="The label of the check-box that enables page translate"> Offer to translate pages that aren't in a language I read </message> diff --git a/chrome/browser/automation/url_request_automation_job.cc b/chrome/browser/automation/url_request_automation_job.cc index 2ae2736..beb7ad6 100644 --- a/chrome/browser/automation/url_request_automation_job.cc +++ b/chrome/browser/automation/url_request_automation_job.cc @@ -105,12 +105,6 @@ net::URLRequestJob* URLRequestAutomationJob::Factory( if (request_info) { int child_id = request_info->child_id(); int route_id = request_info->route_id(); - - if (request_info->process_type() == ChildProcessInfo::PLUGIN_PROCESS) { - child_id = request_info->host_renderer_id(); - route_id = request_info->host_render_view_id(); - } - AutomationResourceMessageFilter::AutomationDetails details; if (AutomationResourceMessageFilter::LookupRegisteredRenderView( child_id, route_id, &details)) { diff --git a/chrome/browser/browser_shutdown.cc b/chrome/browser/browser_shutdown.cc index 7476f49..d37a45a 100644 --- a/chrome/browser/browser_shutdown.cc +++ b/chrome/browser/browser_shutdown.cc @@ -30,7 +30,6 @@ #include "chrome/browser/ui/browser_list.h" #include "chrome/browser/ui/webui/chrome_url_data_manager.h" #include "chrome/common/chrome_paths.h" -#include "chrome/common/chrome_plugin_lib.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/pref_names.h" #include "chrome/common/switch_utils.h" @@ -121,11 +120,6 @@ void Shutdown() { // shutdown. base::ThreadRestrictions::SetIOAllowed(true); - // Unload plugins. This needs to happen on the IO thread. - BrowserThread::PostTask( - BrowserThread::IO, FROM_HERE, - NewRunnableFunction(&ChromePluginLib::UnloadAllPlugins)); - // Shutdown all IPC channels to service processes. ServiceProcessControlManager::GetInstance()->Shutdown(); diff --git a/chrome/browser/chrome_plugin_browsing_context.cc b/chrome/browser/chrome_plugin_browsing_context.cc deleted file mode 100644 index 380f074..0000000 --- a/chrome/browser/chrome_plugin_browsing_context.cc +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright (c) 2011 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/browser/chrome_plugin_browsing_context.h" - -#include "base/message_loop.h" -#include "base/singleton.h" -#include "content/browser/browser_thread.h" -#include "content/common/notification_service.h" - -CPBrowsingContextManager* CPBrowsingContextManager::GetInstance() { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - return Singleton<CPBrowsingContextManager>::get(); -} - -CPBrowsingContextManager::CPBrowsingContextManager() { - registrar_.Add(this, NotificationType::URL_REQUEST_CONTEXT_RELEASED, - NotificationService::AllSources()); -} - -CPBrowsingContextManager::~CPBrowsingContextManager() { -} - -CPBrowsingContext CPBrowsingContextManager::Allocate( - net::URLRequestContext* context) { - int32 map_id = map_.Add(context); - return static_cast<CPBrowsingContext>(map_id); -} - -net::URLRequestContext* CPBrowsingContextManager::ToURLRequestContext( - CPBrowsingContext id) { - return map_.Lookup(static_cast<int32>(id)); -} - -CPBrowsingContext CPBrowsingContextManager::Lookup( - net::URLRequestContext* context) { - ReverseMap::const_iterator it = reverse_map_.find(context); - if (it == reverse_map_.end()) { - CPBrowsingContext id = Allocate(context); - reverse_map_[context] = id; - return id; - } else { - return it->second; - } -} - -void CPBrowsingContextManager::Observe(NotificationType type, - const NotificationSource& source, - const NotificationDetails& details) { - DCHECK(type == NotificationType::URL_REQUEST_CONTEXT_RELEASED); - - net::URLRequestContext* context = - Source<net::URLRequestContext>(source).ptr(); - - // Multiple CPBrowsingContexts may refer to the same net::URLRequestContext. - for (Map::iterator it(&map_); !it.IsAtEnd(); it.Advance()) { - if (it.GetCurrentValue() == context) - map_.Remove(it.GetCurrentKey()); - } - - reverse_map_.erase(context); -} diff --git a/chrome/browser/chrome_plugin_browsing_context.h b/chrome/browser/chrome_plugin_browsing_context.h deleted file mode 100644 index 8ced746..0000000 --- a/chrome/browser/chrome_plugin_browsing_context.h +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright (c) 2011 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_BROWSER_CHROME_PLUGIN_BROWSING_CONTEXT_H_ -#define CHROME_BROWSER_CHROME_PLUGIN_BROWSING_CONTEXT_H_ -#pragma once - -#include <map> - -#include "base/id_map.h" -#include "chrome/common/chrome_plugin_api.h" -#include "content/common/notification_observer.h" -#include "content/common/notification_registrar.h" - -namespace net { -class URLRequestContext; -} // namespace net - -// This class manages the mapping between CPBrowsingContexts and -// net::URLRequestContexts. It observes when net::URLRequestContexts go away, -// and invalidates the corresponding CPBrowsingContexts. CPBrowsingContexts can -// be associated with other data as well, so there can be multiple ones -// referring to a given net::URLRequestContext. -// Note: This class should be used on the IO thread only. -class CPBrowsingContextManager : public NotificationObserver { - public: - static CPBrowsingContextManager* GetInstance(); - - // Note: don't call these directly - use Instance() above. They are public - // so Singleton can access them. - CPBrowsingContextManager(); - ~CPBrowsingContextManager(); - - // Generate a new unique CPBrowsingContext ID from the given - // net::URLRequestContext. Multiple CPBrowsingContexts can map to the same - // net::URLRequestContext. - CPBrowsingContext Allocate(net::URLRequestContext* context); - - // Return the net::URLRequestContext that this CPBrowsingContext refers to, or - // NULL if not found. - net::URLRequestContext* ToURLRequestContext(CPBrowsingContext id); - - // Return a CPBrowsingContext ID that corresponds to the given - // net::URLRequestContext. This function differs from Allocate in that calling - // this multiple times with the same argument gives the same ID. - CPBrowsingContext Lookup(net::URLRequestContext* context); - - private: - // NotificationObserver - virtual void Observe(NotificationType type, - const NotificationSource& source, - const NotificationDetails& details); - - typedef IDMap<net::URLRequestContext> Map; - typedef std::map<net::URLRequestContext*, CPBrowsingContext> ReverseMap; - - NotificationRegistrar registrar_; - - Map map_; // map of CPBrowsingContext -> net::URLRequestContext - ReverseMap reverse_map_; // map of net::URLRequestContext -> CPBrowsingContext -}; - -#endif // CHROME_BROWSER_CHROME_PLUGIN_BROWSING_CONTEXT_H_ diff --git a/chrome/browser/chrome_plugin_host.cc b/chrome/browser/chrome_plugin_host.cc deleted file mode 100644 index 4c069ab..0000000 --- a/chrome/browser/chrome_plugin_host.cc +++ /dev/null @@ -1,842 +0,0 @@ -// Copyright (c) 2011 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/browser/chrome_plugin_host.h" - -#include <set> -#include <string> -#include <vector> - -#include "base/basictypes.h" -#include "base/command_line.h" -#include "base/file_path.h" -#include "base/file_util.h" -#include "base/message_loop.h" -#include "base/metrics/histogram.h" -#include "base/path_service.h" -#include "base/perftimer.h" -#include "base/singleton.h" -#include "base/string_util.h" -#include "base/utf_string_conversions.h" -#include "chrome/browser/browser_list.h" -#include "chrome/browser/chrome_plugin_browsing_context.h" -#include "chrome/browser/gears_integration.h" -#include "chrome/browser/profiles/profile.h" -#include "chrome/browser/ui/webui/html_dialog_ui.h" -#include "chrome/common/chrome_constants.h" -#include "chrome/common/chrome_counters.h" -#include "chrome/common/chrome_paths.h" -#include "chrome/common/chrome_plugin_lib.h" -#include "chrome/common/chrome_plugin_util.h" -#include "chrome/common/gears_api.h" -#include "chrome/common/net/url_request_context_getter.h" -#include "chrome/common/net/url_request_intercept_job.h" -#include "chrome/common/plugin_messages.h" -#include "chrome/common/render_messages.h" -#include "content/browser/browser_thread.h" -#include "content/browser/plugin_process_host.h" -#include "content/browser/plugin_service.h" -#include "content/browser/renderer_host/render_process_host.h" -#include "content/common/notification_service.h" -#include "net/base/cookie_monster.h" -#include "net/base/io_buffer.h" -#include "net/base/net_errors.h" -#include "net/http/http_request_headers.h" -#include "net/url_request/url_request.h" -#include "net/url_request/url_request_context.h" -#include "net/url_request/url_request_error_job.h" -#include "third_party/skia/include/core/SkBitmap.h" - - -using base::TimeDelta; - -// This class manages the interception of network requests. It queries the -// plugin on every request, and creates an intercept job if the plugin can -// intercept the request. -// NOTE: All methods must be called on the IO thread. -class PluginRequestInterceptor - : public PluginHelper, public net::URLRequest::Interceptor { - public: - static net::URLRequestJob* UninterceptedProtocolHandler( - net::URLRequest* request, const std::string& scheme) { - // This will get called if a plugin failed to intercept a request for a - // protocol it has registered. In that case, we return NULL and the request - // will result in an error. - return new net::URLRequestErrorJob(request, net::ERR_FILE_NOT_FOUND); - } - - explicit PluginRequestInterceptor(ChromePluginLib* plugin) - : PluginHelper(plugin) { - net::URLRequest::RegisterRequestInterceptor(this); - } - - virtual ~PluginRequestInterceptor() { - net::URLRequest::UnregisterRequestInterceptor(this); - - // Unregister our protocols. - for (HandledProtocolList::iterator it = registered_protocols_.begin(); - it != registered_protocols_.end(); ++it) { - net::URLRequest::ProtocolFactory* factory = - net::URLRequest::RegisterProtocolFactory(*it, NULL); - DCHECK(factory == UninterceptedProtocolHandler); - } - } - - void RegisterProtocol(const std::string& scheme) { - DCHECK(CalledOnValidThread()); - - std::string lower_scheme = StringToLowerASCII(scheme); - handled_protocols_.insert(lower_scheme); - - // Only add a protocol factory if the net::URLRequest doesn't already handle - // it. If we fail to intercept, the request will be treated as an error. - if (!net::URLRequest::IsHandledProtocol(lower_scheme)) { - registered_protocols_.insert(lower_scheme); - net::URLRequest::RegisterProtocolFactory(lower_scheme, - &UninterceptedProtocolHandler); - } - } - - // net::URLRequest::Interceptor - virtual net::URLRequestJob* MaybeIntercept(net::URLRequest* request) { - // TODO(darin): This DCHECK fails in the unit tests because our interceptor - // is being persisted across unit tests. As a result, each time we get - // poked on a different thread, but never from more than one thread at a - // time. We need a way to have the URLRequestJobManager get reset between - // unit tests. - // DCHECK(CalledOnValidThread()); - - if (!IsHandledProtocol(request->url().scheme())) - return NULL; - - CPBrowsingContext context = - CPBrowsingContextManager::GetInstance()->Lookup(request->context()); - scoped_ptr<ScopableCPRequest> cprequest( - new ScopableCPRequest(request->url().spec().c_str(), - request->method().c_str(), - context)); - - PerfTimer timer; - if (!plugin_->functions().should_intercept_request(cprequest.get())) { - LogInterceptMissTime(timer.Elapsed()); - return NULL; - } - LogInterceptHitTime(timer.Elapsed()); - return new URLRequestInterceptJob(request, plugin_, cprequest.release()); - } - - private: - bool IsHandledProtocol(const std::string& scheme) { - return handled_protocols_.find(scheme) != handled_protocols_.end(); - } - - void LogInterceptHitTime(const TimeDelta& time) { - UMA_HISTOGRAM_TIMES("Gears.InterceptHit", time); - } - - void LogInterceptMissTime(const TimeDelta& time) { - UMA_HISTOGRAM_TIMES("Gears.InterceptMiss", time); - } - - typedef std::set<std::string> HandledProtocolList; - HandledProtocolList handled_protocols_; - HandledProtocolList registered_protocols_; -}; - -// This class manages a network request made by the plugin, also acting as -// the net::URLRequest delegate. -// NOTE: All methods must be called on the IO thread. -class PluginRequestHandler : public PluginHelper, - public net::URLRequest::Delegate { - public: - static PluginRequestHandler* FromCPRequest(CPRequest* request) { - return ScopableCPRequest::GetData<PluginRequestHandler*>(request); - } - - PluginRequestHandler(ChromePluginLib* plugin, ScopableCPRequest* cprequest) - : PluginHelper(plugin), cprequest_(cprequest), user_buffer_(NULL) { - cprequest_->data = this; // see FromCPRequest(). - - net::URLRequestContext* context = CPBrowsingContextManager::GetInstance()-> - ToURLRequestContext(cprequest_->context); - // TODO(mpcomplete): remove fallback case when Gears support is prevalent. - if (!context) - context = Profile::GetDefaultRequestContext()->GetURLRequestContext(); - - GURL gurl(cprequest_->url); - request_.reset(new net::URLRequest(gurl, this)); - request_->set_context(context); - request_->set_method(cprequest_->method); - request_->set_load_flags(PluginResponseUtils::CPLoadFlagsToNetFlags(0)); - } - - net::URLRequest* request() { return request_.get(); } - - // Wraper of net::URLRequest::Read() - bool Read(char* dest, int dest_size, int *bytes_read) { - CHECK(!my_buffer_.get()); - // We'll use our own buffer until the read actually completes. - user_buffer_ = dest; - my_buffer_ = new net::IOBuffer(dest_size); - - if (request_->Read(my_buffer_, dest_size, bytes_read)) { - memcpy(dest, my_buffer_->data(), *bytes_read); - my_buffer_ = NULL; - return true; - } - - if (!request_->status().is_io_pending()) - my_buffer_ = NULL; - - return false; - } - - // net::URLRequest::Delegate - virtual void OnReceivedRedirect(net::URLRequest* request, const GURL& new_url, - bool* defer_redirect) { - plugin_->functions().response_funcs->received_redirect( - cprequest_.get(), new_url.spec().c_str()); - } - - virtual void OnResponseStarted(net::URLRequest* request) { - // TODO(mpcomplete): better error codes - CPError result = - request_->status().is_success() ? CPERR_SUCCESS : CPERR_FAILURE; - plugin_->functions().response_funcs->start_completed( - cprequest_.get(), result); - } - - virtual void OnReadCompleted(net::URLRequest* request, int bytes_read) { - CHECK(my_buffer_.get()); - CHECK(user_buffer_); - if (bytes_read > 0) { - memcpy(user_buffer_, my_buffer_->data(), bytes_read); - } else if (bytes_read < 0) { - // TODO(mpcomplete): better error codes - bytes_read = CPERR_FAILURE; - } - my_buffer_ = NULL; - plugin_->functions().response_funcs->read_completed( - cprequest_.get(), bytes_read); - } - - private: - scoped_ptr<ScopableCPRequest> cprequest_; - scoped_ptr<net::URLRequest> request_; - scoped_refptr<net::IOBuffer> my_buffer_; - char* user_buffer_; -}; - -// This class manages plugins that want to handle UI commands. Right now, we -// only allow 1 plugin to do this, so there's only ever 1 instance of this -// class at once. -// NOTE: All methods must be called on the IO thread. -class PluginCommandHandler : public PluginHelper { - public: - static void HandleCommand(int command, - CPCommandInterface* data, - int32 context_as_int32) { - CPBrowsingContext context = - static_cast<CPBrowsingContext>(context_as_int32); - // Ensure plugins are loaded before we try to talk to it. This will be a - // noop if plugins are loaded already. - ChromePluginLib::LoadChromePlugins(GetCPBrowserFuncsForBrowser()); - - DCHECK(ChromePluginLib::IsPluginThread()); - CPError rv = CPERR_INVALID_VERSION; - if (instance_ && instance_->plugin_->functions().handle_command) { - rv = instance_->plugin_->functions().handle_command( - context, command, data ? data->GetData() : NULL); - } - if (data) - data->OnCommandInvoked(rv); - } - - static void RegisterPlugin(ChromePluginLib* plugin) { - DCHECK(ChromePluginLib::IsPluginThread()); - // TODO(mpcomplete): We only expect to have Gears register a command handler - // at the moment. We should either add support for other plugins to do - // this, or verify that the plugin is Gears. - DCHECK(!instance_) << - "We only support a single plugin handling UI commands."; - if (instance_) - return; - // Deleted in response to a notification in PluginHelper. - new PluginCommandHandler(plugin); - } - - private: - explicit PluginCommandHandler(ChromePluginLib* plugin) - : PluginHelper(plugin) { - DCHECK(instance_ == NULL); - instance_ = this; - } - - virtual ~PluginCommandHandler() { - instance_ = NULL; - } - - static PluginCommandHandler* instance_; -}; - -PluginCommandHandler* PluginCommandHandler::instance_ = NULL; - -// This class acts as a helper to display the HTML dialog. It is created -// on demand on the plugin thread, and proxies calls to and from the UI thread -// to display the UI. -class ModelessHtmlDialogDelegate : public HtmlDialogUIDelegate { - public: - ModelessHtmlDialogDelegate(const GURL& url, - int width, int height, - const std::string& json_arguments, - void* plugin_context, - ChromePluginLib* plugin, - MessageLoop* main_message_loop, - gfx::NativeWindow parent_wnd) - : main_message_loop_(main_message_loop), - io_message_loop_(MessageLoop::current()), - plugin_(plugin), - plugin_context_(plugin_context), - parent_wnd_(parent_wnd) { - DCHECK(ChromePluginLib::IsPluginThread()); - params_.url = url; - params_.height = height; - params_.width = width; - params_.json_input = json_arguments; - - main_message_loop_->PostTask(FROM_HERE, NewRunnableMethod( - this, &ModelessHtmlDialogDelegate::Show)); - } - virtual ~ModelessHtmlDialogDelegate() { - DCHECK(ChromePluginLib::IsPluginThread()); - } - - // The following public methods are called from the UI thread. - - // HtmlDialogUIDelegate implementation: - virtual bool IsDialogModal() const { return false; } - virtual std::wstring GetDialogTitle() const { return L"Gears"; } - virtual GURL GetDialogContentURL() const { return params_.url; } - virtual void GetWebUIMessageHandlers( - std::vector<WebUIMessageHandler*>* handlers) const {} - virtual void GetDialogSize(gfx::Size* size) const { - size->set_width(params_.width); - size->set_height(params_.height); - } - virtual std::string GetDialogArgs() const { return params_.json_input; } - virtual void OnDialogClosed(const std::string& json_retval) { - io_message_loop_->PostTask(FROM_HERE, NewRunnableMethod( - this, &ModelessHtmlDialogDelegate::ReportResults, json_retval)); - } - virtual void OnCloseContents(TabContents* source, bool* out_close_dialog) { } - virtual bool ShouldShowDialogTitle() const { return true; } - - private: - // Actually shows the dialog on the UI thread. - void Show() { - DCHECK(MessageLoop::current() == main_message_loop_); - Browser* browser = BrowserList::GetLastActive(); - browser->BrowserShowHtmlDialog(this, parent_wnd_); - } - - // Gives the JSON result string back to the plugin. - void ReportResults(const std::string& json_retval) { - DCHECK(MessageLoop::current() == io_message_loop_); - // The plugin may have unloaded before it was time to report the results. - if (plugin_->is_loaded()) - plugin_->functions().html_dialog_closed(plugin_context_, - json_retval.c_str()); - delete this; - } - - // The parameters needed to display a modal HTML dialog. - HtmlDialogUI::HtmlDialogParams params_; - - // Message loops for sending messages between UI and IO threads. - MessageLoop* main_message_loop_; - MessageLoop* io_message_loop_; - - // The plugin object that requested the dialog. This can only be accessed on - // the IO thread. - scoped_refptr<ChromePluginLib> plugin_; - - // The plugin's context argument to CPB_ShowHtmlDialog. - void* plugin_context_; - - // The window this dialog box should be parented to, or NULL for the last - // active browser window. - gfx::NativeWindow parent_wnd_; - - DISALLOW_COPY_AND_ASSIGN(ModelessHtmlDialogDelegate); -}; - -// Allows InvokeLater without adding refcounting. The object is only deleted -// when its last InvokeLater is run anyway. -DISABLE_RUNNABLE_METHOD_REFCOUNT(ModelessHtmlDialogDelegate); - -namespace { - -// -// Generic functions -// - -void STDCALL CPB_SetKeepProcessAlive(CPID id, CPBool keep_alive) { - // This is a no-op in the main browser process -} - -CPError STDCALL CPB_GetCookies(CPID id, CPBrowsingContext bcontext, - const char* url, char** cookies) { - CHECK(ChromePluginLib::IsPluginThread()); - net::URLRequestContext* context = CPBrowsingContextManager::GetInstance()-> - ToURLRequestContext(bcontext); - // TODO(mpcomplete): remove fallback case when Gears support is prevalent. - if (!context) { - context = Profile::GetDefaultRequestContext()->GetURLRequestContext(); - if (!context) - return CPERR_FAILURE; - } - std::string cookies_str = context->cookie_store()->GetCookies(GURL(url)); - *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) { - // Should not be called in browser process. - return CPERR_FAILURE; -} - -CPError STDCALL CPB_ShowHtmlDialog( - CPID id, CPBrowsingContext context, const char* url, int width, int height, - const char* json_arguments, void* plugin_context) { - CHECK(ChromePluginLib::IsPluginThread()); - ChromePluginLib* plugin = ChromePluginLib::FromCPID(id); - CHECK(plugin); - -#if defined(OS_WIN) - HWND parent_hwnd = reinterpret_cast<HWND>(static_cast<uintptr_t>(context)); - PluginService* service = PluginService::GetInstance(); - if (!service) - return CPERR_FAILURE; - MessageLoop* main_message_loop = service->main_message_loop(); - ModelessHtmlDialogDelegate* delegate = - new ModelessHtmlDialogDelegate(GURL(url), width, height, json_arguments, - plugin_context, plugin, main_message_loop, - parent_hwnd); -#else - // TODO(port): port ModelessHtmlDialogDelegate - NOTIMPLEMENTED(); -#endif - - return CPERR_SUCCESS; -} - -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(struct _NPP* npp) { - CHECK(ChromePluginLib::IsPluginThread()); - NOTREACHED() << "NPP does not exist in the browser process."; - return 0; -} - -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*); - - // TODO(mpcomplete): http://b/1143021 - When we support multiple profiles, - // fetch the data dir from the context. - PluginService* service = PluginService::GetInstance(); - if (!service) - return CPERR_FAILURE; - FilePath path = service->GetChromePluginDataDir(); - // This is wrong -- we can't in general stuff a path through a std::string. - // But this code is Gears-specific, so Windows-only anyway for now. - std::string retval; -#if defined(OS_WIN) - retval = WideToUTF8(path.Append(chrome::kChromePluginDataDirname).value()); -#else - NOTREACHED(); -#endif - *static_cast<char**>(buf) = CPB_StringDup(CPB_Alloc, retval); - return CPERR_SUCCESS; - } - case CPBROWSINGCONTEXT_UI_LOCALE_PTR: { - if (buf_size < sizeof(char*)) - return sizeof(char*); - - PluginService* service = PluginService::GetInstance(); - if (!service) - return CPERR_FAILURE; - const std::string& retval = service->GetUILocale(); - *static_cast<char**>(buf) = CPB_StringDup(CPB_Alloc, retval); - return CPERR_SUCCESS; - } - } - - return CPERR_FAILURE; -} - -CPError STDCALL CPB_AddUICommand(CPID id, int command) { - CHECK(ChromePluginLib::IsPluginThread()); - ChromePluginLib* plugin = ChromePluginLib::FromCPID(id); - CHECK(plugin); - - PluginCommandHandler::RegisterPlugin(plugin); - return CPERR_SUCCESS; -} - -static void NotifyGearsShortcutsChanged() { - DCHECK(MessageLoop::current() == - PluginService::GetInstance()->main_message_loop()); - - // TODO(michaeln): source should be the original profile, fix this - // when gears provides the correct browser context, and when we - // can relate that to an actual profile. - NotificationService::current()->Notify( - NotificationType::WEB_APP_INSTALL_CHANGED, - Source<Profile>(NULL), - NotificationService::NoDetails()); -} - -CPError STDCALL CPB_HandleCommand( - CPID id, CPBrowsingContext context, int command, void *data) { - CHECK(ChromePluginLib::IsPluginThread()); - ChromePluginLib* plugin = ChromePluginLib::FromCPID(id); - CHECK(plugin); - - if (command == GEARSBROWSERCOMMAND_CREATE_SHORTCUT_DONE) { - GearsCreateShortcutResult* result = - static_cast<GearsCreateShortcutResult*>(data); - CHECK(result); - - GearsCreateShortcutData* shortcut_data = - static_cast<GearsCreateShortcutData*>(result->shortcut); - shortcut_data->command_interface->OnCommandResponse(result->result); - } else if (command == GEARSBROWSERCOMMAND_NOTIFY_SHORTCUTS_CHANGED) { - PluginService* service = PluginService::GetInstance(); - if (!service) - return CPERR_FAILURE; - service->main_message_loop()->PostTask(FROM_HERE, - NewRunnableFunction(NotifyGearsShortcutsChanged)); - return CPERR_SUCCESS; - } - return CPERR_FAILURE; -} - -CPError STDCALL CPB_GetDragData( - CPID id, CPBrowsingContext context, struct NPObject* event, bool add_data, - int32* identity, int32* event_id, char** drag_type, char** drag_data) { - *identity = *event_id = 0; - NOTREACHED() << "Should not be called in the browser process."; - return CPERR_FAILURE; -} - -CPError STDCALL CPB_SetDropEffect( - CPID id, CPBrowsingContext context, struct NPObject* event, int effect) { - NOTREACHED() << "Should not be called in the browser process."; - return CPERR_FAILURE; -} - -CPError STDCALL CPB_AllowFileDrop( - CPID id, CPBrowsingContext context, const char* file_drag_data) { - NOTREACHED() << "Should not be called in the browser process."; - return CPERR_FAILURE; -} - -// -// Functions related to network interception -// - -void STDCALL CPB_EnableRequestIntercept(CPID id, const char** schemes, - uint32 num_schemes) { - CHECK(ChromePluginLib::IsPluginThread()); - ChromePluginLib* plugin = ChromePluginLib::FromCPID(id); - CHECK(plugin); - - if (schemes && num_schemes > 0) { - PluginRequestInterceptor* interceptor = - new PluginRequestInterceptor(plugin); - for (uint32 i = 0; i < num_schemes; ++i) - interceptor->RegisterProtocol(schemes[i]); - } else { - PluginRequestInterceptor::DestroyAllHelpersForPlugin(plugin); - } -} - -void STDCALL CPRR_ReceivedRedirect(CPRequest* request, const char* new_url) { -} - -void STDCALL CPRR_StartCompleted(CPRequest* request, CPError result) { - CHECK(ChromePluginLib::IsPluginThread()); - URLRequestInterceptJob* job = URLRequestInterceptJob::FromCPRequest(request); - CHECK(job); - job->OnStartCompleted(result); -} - -void STDCALL CPRR_ReadCompleted(CPRequest* request, int bytes_read) { - CHECK(ChromePluginLib::IsPluginThread()); - URLRequestInterceptJob* job = URLRequestInterceptJob::FromCPRequest(request); - CHECK(job); - job->OnReadCompleted(bytes_read); -} - -void STDCALL CPRR_UploadProgress(CPRequest* request, uint64 pos, uint64 size) { - // Does not apply, plugins do not yet intercept uploads -} - -// -// 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); - - ScopableCPRequest* cprequest = new ScopableCPRequest(url, method, context); - PluginRequestHandler* handler = new PluginRequestHandler(plugin, cprequest); - CHECK(handler); - - *request = cprequest; - return CPERR_SUCCESS; -} - -CPError STDCALL CPR_StartRequest(CPRequest* request) { - CHECK(ChromePluginLib::IsPluginThread()); - PluginRequestHandler* handler = PluginRequestHandler::FromCPRequest(request); - CHECK(handler); - handler->request()->Start(); - return CPERR_IO_PENDING; -} - -void STDCALL CPR_EndRequest(CPRequest* request, CPError reason) { - CHECK(ChromePluginLib::IsPluginThread()); - PluginRequestHandler* handler = PluginRequestHandler::FromCPRequest(request); - delete handler; -} - -void STDCALL CPR_SetExtraRequestHeaders(CPRequest* request, - const char* headers) { - CHECK(ChromePluginLib::IsPluginThread()); - PluginRequestHandler* handler = PluginRequestHandler::FromCPRequest(request); - CHECK(handler); - net::HttpRequestHeaders http_headers; - http_headers.AddHeadersFromString(headers); - handler->request()->SetExtraRequestHeaders(http_headers); -} - -void STDCALL CPR_SetRequestLoadFlags(CPRequest* request, uint32 flags) { - CHECK(ChromePluginLib::IsPluginThread()); - PluginRequestHandler* handler = PluginRequestHandler::FromCPRequest(request); - CHECK(handler); - uint32 net_flags = PluginResponseUtils::CPLoadFlagsToNetFlags(flags); - handler->request()->set_load_flags(net_flags); -} - -void STDCALL CPR_AppendDataToUpload(CPRequest* request, const char* bytes, - int bytes_len) { - CHECK(ChromePluginLib::IsPluginThread()); - PluginRequestHandler* handler = PluginRequestHandler::FromCPRequest(request); - CHECK(handler); - handler->request()->AppendBytesToUpload(bytes, bytes_len); -} - -CPError STDCALL CPR_AppendFileToUpload(CPRequest* request, const char* filepath, - uint64 offset, uint64 length) { - CHECK(ChromePluginLib::IsPluginThread()); - PluginRequestHandler* handler = PluginRequestHandler::FromCPRequest(request); - CHECK(handler); - - if (!length) length = kuint64max; - FilePath path(FilePath::FromWStringHack(UTF8ToWide(filepath))); - handler->request()->AppendFileRangeToUpload(path, offset, length, - base::Time()); - return CPERR_SUCCESS; -} - -int STDCALL CPR_GetResponseInfo(CPRequest* request, CPResponseInfoType type, - void* buf, uint32 buf_size) { - CHECK(ChromePluginLib::IsPluginThread()); - PluginRequestHandler* handler = PluginRequestHandler::FromCPRequest(request); - CHECK(handler); - return PluginResponseUtils::GetResponseInfo( - handler->request()->response_headers(), type, buf, buf_size); -} - -int STDCALL CPR_Read(CPRequest* request, void* buf, uint32 buf_size) { - CHECK(ChromePluginLib::IsPluginThread()); - PluginRequestHandler* handler = PluginRequestHandler::FromCPRequest(request); - CHECK(handler); - - int bytes_read; - if (handler->Read(static_cast<char*>(buf), buf_size, &bytes_read)) - return bytes_read; // 0 == CPERR_SUCESS - - if (handler->request()->status().is_io_pending()) - return CPERR_IO_PENDING; - - return CPERR_FAILURE; -} - -CPBool STDCALL CPB_IsPluginProcessRunning(CPID id) { - CHECK(ChromePluginLib::IsPluginThread()); - ChromePluginLib* plugin = ChromePluginLib::FromCPID(id); - CHECK(plugin); - PluginService* service = PluginService::GetInstance(); - if (!service) - return false; - PluginProcessHost *host = service->FindNpapiPluginProcess(plugin->filename()); - return host ? true : false; -} - -CPProcessType STDCALL CPB_GetProcessType(CPID id) { - CHECK(ChromePluginLib::IsPluginThread()); - return CP_PROCESS_BROWSER; -} - -CPError STDCALL CPB_SendMessage(CPID id, const void *data, uint32 data_len) { - CHECK(ChromePluginLib::IsPluginThread()); - ChromePluginLib* plugin = ChromePluginLib::FromCPID(id); - CHECK(plugin); - - PluginService* service = PluginService::GetInstance(); - if (!service) - return CPERR_FAILURE; - PluginProcessHost *host = - service->FindOrStartNpapiPluginProcess(plugin->filename()); - 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); -#if defined(OS_WIN) - if (!host->Send(new PluginProcessMsg_PluginMessage(v))) - return CPERR_FAILURE; -#else - // TODO(port): Implement PluginProcessMsg. - NOTIMPLEMENTED(); -#endif - - return CPERR_SUCCESS; -} - -CPError STDCALL CPB_SendSyncMessage(CPID id, const void *data, uint32 data_len, - void **retval, uint32 *retval_len) { - NOTREACHED() << "Sync messages should not be sent from the browser process."; - - return CPERR_FAILURE; -} - -CPError STDCALL CPB_PluginThreadAsyncCall(CPID id, - void (*func)(void *), - void *user_data) { - bool posted = BrowserThread::PostTask( - BrowserThread::IO, FROM_HERE, - NewRunnableFunction(func, user_data)); - return posted ? CPERR_SUCCESS : CPERR_FAILURE; -} - -CPError STDCALL CPB_OpenFileDialog(CPID id, - CPBrowsingContext context, - bool multiple_files, - const char *title, - const char *filter, - void *user_data) { - NOTREACHED() << - "Open file dialog should only be called from the renderer process."; - - return CPERR_FAILURE; -} - -} // namespace - -CPBrowserFuncs* GetCPBrowserFuncsForBrowser() { - 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_modal = CPB_ShowHtmlDialogModal; - browser_funcs.show_html_dialog = CPB_ShowHtmlDialog; - 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.request_funcs = &request_funcs; - browser_funcs.response_funcs = &response_funcs; - browser_funcs.send_sync_message = CPB_SendSyncMessage; - browser_funcs.plugin_thread_async_call = CPB_PluginThreadAsyncCall; - browser_funcs.open_file_dialog = CPB_OpenFileDialog; - browser_funcs.get_drag_data = CPB_GetDragData; - browser_funcs.set_drop_effect = CPB_SetDropEffect; - browser_funcs.allow_file_drop = CPB_AllowFileDrop; - - 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; -} - -void CPCommandInterface::OnCommandInvoked(CPError retval) { - delete this; -} - -void CPCommandInterface::OnCommandResponse(CPError retval) {} - -void CPHandleCommand(int command, CPCommandInterface* data, - CPBrowsingContext context) { - // Sadly if we try and pass context through, we seem to break cl's little - // brain trying to compile the Tuple3 ctor. This cast works. - int32 context_as_int32 = static_cast<int32>(context); - // Plugins can only be accessed on the IO thread. - BrowserThread::PostTask( - BrowserThread::IO, FROM_HERE, - NewRunnableFunction(PluginCommandHandler::HandleCommand, - command, data, context_as_int32)); -} diff --git a/chrome/browser/chrome_plugin_host.h b/chrome/browser/chrome_plugin_host.h deleted file mode 100644 index af8ee15..0000000 --- a/chrome/browser/chrome_plugin_host.h +++ /dev/null @@ -1,42 +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_BROWSER_CHROME_PLUGIN_HOST_H__ -#define CHROME_BROWSER_CHROME_PLUGIN_HOST_H__ -#pragma once - -#include "chrome/common/chrome_plugin_api.h" - -// Returns the table of browser functions for use from the browser process. -CPBrowserFuncs* GetCPBrowserFuncsForBrowser(); - -// Interface for generic data passed to plugin UI command handlers. -// Note: All functions are called on the plugin thread. -class CPCommandInterface { - public: - virtual ~CPCommandInterface() {} - - // Returns the actual pointer to pass to the plugin. - virtual void *GetData() = 0; - - // Called when the command has been invoked. The default action is deletion, - // but some callers may want to use output or check the return value before - // deleting. - virtual void OnCommandInvoked(CPError retval); - - // Some commands have an asynchronous response. This is called some time - // after OnCommandInvoked. - virtual void OnCommandResponse(CPError retval); -}; - -// Called when a builtin or plugin-registered UI command is invoked by a user -// gesture. 'data' is an optional parameter that allows command-specific data -// to be passed to the plugin. Ownership of 'data' is transferred to the -// callee. CPBrowsingContext is some additional data the caller wishes to pass -// through to the receiver. OnCommandInvoked is called after the command has -// been invoked. -void CPHandleCommand(int command, CPCommandInterface* data, - CPBrowsingContext context); - -#endif // CHROME_BROWSER_CHROME_PLUGIN_HOST_H__ diff --git a/chrome/browser/chrome_plugin_unittest.cc b/chrome/browser/chrome_plugin_unittest.cc deleted file mode 100644 index d82e868..0000000 --- a/chrome/browser/chrome_plugin_unittest.cc +++ /dev/null @@ -1,294 +0,0 @@ -// Copyright (c) 2011 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. -// Tests exercising the Chrome Plugin API. - -#include "base/file_util.h" -#include "base/message_loop_proxy.h" -#include "base/path_service.h" -#include "base/string_util.h" -#include "chrome/browser/chrome_plugin_host.h" -#include "chrome/browser/profiles/profile.h" -#include "chrome/common/chrome_plugin_lib.h" -#include "chrome/common/net/url_request_context_getter.h" -#include "chrome/test/chrome_plugin/test_chrome_plugin.h" -#include "chrome/test/test_url_request_context_getter.h" -#include "content/browser/browser_thread.h" -#include "net/base/io_buffer.h" -#include "net/http/http_response_headers.h" -#include "net/url_request/url_request_test_job.h" -#include "net/url_request/url_request_test_util.h" -#include "net/test/test_server.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace { - -const FilePath::CharType kDocRoot[] = FILE_PATH_LITERAL("chrome/test/data"); -const char kPluginFilename[] = "test_chrome_plugin.dll"; -const int kResponseBufferSize = 4096; - -class ChromePluginTest : public testing::Test, - public net::URLRequest::Delegate { - public: - ChromePluginTest() - : io_thread_(BrowserThread::IO, &message_loop_), - request_(NULL), - response_buffer_(new net::IOBuffer(kResponseBufferSize)), - plugin_(NULL), - expected_payload_(NULL), - request_context_getter_(new TestURLRequestContextGetter()) { - test_funcs_.test_make_request = NULL; - } - - // Loads/unloads the chrome test plugin. - void LoadPlugin(); - void UnloadPlugin(); - - // Runs the test and expects the given payload as a response. If expectation - // is NULL, the request is expected to fail. - void RunTest(const GURL& url, const TestResponsePayload* expected_payload); - - // net::URLRequest::Delegate implementations - virtual void OnResponseStarted(net::URLRequest* request); - virtual void OnReadCompleted(net::URLRequest* request, int bytes_read); - - // Helper called when the net::URLRequest is done. - void OnURLRequestComplete(); - - // testing::Test - virtual void SetUp() { - LoadPlugin(); - net::URLRequest::RegisterProtocolFactory("test", - &net::URLRequestTestJob::Factory); - - // We need to setup a default request context in order to issue HTTP - // requests. - DCHECK(!Profile::GetDefaultRequestContext()); - Profile::set_default_request_context(request_context_getter_.get()); - } - virtual void TearDown() { - UnloadPlugin(); - net::URLRequest::RegisterProtocolFactory("test", NULL); - - Profile::set_default_request_context(NULL); - - // Clear the request before flushing the message loop since killing the - // request can result in the generation of more tasks. - request_.reset(); - - // Flush the message loop to make Purify happy. - message_loop_.RunAllPending(); - } - protected: - MessageLoopForIO message_loop_; - BrowserThread io_thread_; - - // Note: we use net::URLRequest (instead of URLFetcher) because this allows - // the request to be intercepted. - scoped_ptr<net::URLRequest> request_; - scoped_refptr<net::IOBuffer> response_buffer_; - std::string response_data_; - - ChromePluginLib* plugin_; - TestFuncParams::PluginFuncs test_funcs_; - const TestResponsePayload* expected_payload_; - scoped_refptr<URLRequestContextGetter> request_context_getter_; -}; - -static void STDCALL CPT_Complete(CPRequest* request, bool success, - const std::string& raw_headers, - const std::string& body) { - GURL url(request->url); - if (url == GURL(kChromeTestPluginPayloads[0].url)) { - // This URL should fail, because the plugin should not have intercepted it. - EXPECT_FALSE(success); - MessageLoop::current()->Quit(); - return; - } - - scoped_refptr<net::HttpResponseHeaders> headers( - new net::HttpResponseHeaders(raw_headers)); - EXPECT_TRUE(success); - EXPECT_EQ(200, headers->response_code()); - - if (url == net::URLRequestTestJob::test_url_1()) { - EXPECT_EQ(net::URLRequestTestJob::test_data_1(), body); - } else if (url == net::URLRequestTestJob::test_url_2()) { - EXPECT_EQ(net::URLRequestTestJob::test_data_2(), body); - } else if (url.spec().find("echo") != std::string::npos) { - EXPECT_EQ(kChromeTestPluginPostData, body); - } - - MessageLoop::current()->Quit(); -} - -static void STDCALL CPT_InvokeLater(TestFuncParams::CallbackFunc callback, - void* callback_data, int delay_ms) { - MessageLoop::current()->PostDelayedTask(FROM_HERE, - NewRunnableFunction(callback, callback_data), delay_ms); -} - -void ChromePluginTest::LoadPlugin() { - FilePath path; - PathService::Get(base::DIR_EXE, &path); - path = path.AppendASCII(kPluginFilename); - plugin_ = ChromePluginLib::Create(path, GetCPBrowserFuncsForBrowser()); - ASSERT_TRUE(plugin_); - - // Exchange test APIs with the plugin. - TestFuncParams params; - params.bfuncs.test_complete = CPT_Complete; - params.bfuncs.invoke_later = CPT_InvokeLater; - EXPECT_EQ(CPERR_SUCCESS, plugin_->CP_Test(¶ms)); - test_funcs_ = params.pfuncs; -} - -void ChromePluginTest::UnloadPlugin() { - ChromePluginLib::UnloadAllPlugins(); - plugin_ = NULL; -} - -void ChromePluginTest::RunTest(const GURL& url, - const TestResponsePayload* expected_payload) { - expected_payload_ = expected_payload; - - response_data_.clear(); - request_.reset(new net::URLRequest(url, this)); - request_->set_context(new TestURLRequestContext()); - request_->Start(); - - MessageLoop::current()->Run(); -} - -void ChromePluginTest::OnResponseStarted(net::URLRequest* request) { - DCHECK(request == request_); - - int bytes_read = 0; - if (request_->status().is_success()) - request_->Read(response_buffer_, kResponseBufferSize, &bytes_read); - OnReadCompleted(request_.get(), bytes_read); -} - -void ChromePluginTest::OnReadCompleted(net::URLRequest* request, - int bytes_read) { - DCHECK(request == request_); - - do { - if (!request_->status().is_success() || bytes_read <= 0) - break; - response_data_.append(response_buffer_->data(), bytes_read); - } while (request_->Read(response_buffer_, kResponseBufferSize, &bytes_read)); - - if (!request_->status().is_io_pending()) { - OnURLRequestComplete(); - } -} - -void ChromePluginTest::OnURLRequestComplete() { - if (expected_payload_) { - EXPECT_TRUE(request_->status().is_success()); - - EXPECT_EQ(expected_payload_->status, request_->GetResponseCode()); - if (expected_payload_->mime_type) { - std::string mime_type; - EXPECT_TRUE(request_->response_headers()->GetMimeType(&mime_type)); - EXPECT_EQ(expected_payload_->mime_type, mime_type); - } - if (expected_payload_->body) { - EXPECT_EQ(expected_payload_->body, response_data_); - } - } else { - EXPECT_FALSE(request_->status().is_success()); - } - - MessageLoop::current()->Quit(); - // If MessageLoop::current() != main_loop_, it will be shut down when the - // main loop returns and this thread subsequently goes out of scope. -} - -// Tests that the plugin can intercept URLs. -TEST_F(ChromePluginTest, DoesIntercept) { - for (size_t i = 0; i < arraysize(kChromeTestPluginPayloads); ++i) { - RunTest(GURL(kChromeTestPluginPayloads[i].url), - &kChromeTestPluginPayloads[i]); - } -} - -// Tests that non-intercepted URLs are handled normally. -TEST_F(ChromePluginTest, DoesNotIntercept) { - TestResponsePayload about_blank = { - "about:blank", - false, - -1, - NULL, - "" - }; - RunTest(GURL(about_blank.url), &about_blank); -} - -// Tests that unloading the plugin correctly unregisters URL interception. -TEST_F(ChromePluginTest, UnregisterIntercept) { - UnloadPlugin(); - - RunTest(GURL(kChromeTestPluginPayloads[0].url), NULL); -} - -static void ProcessAllPendingMessages() { - while (net::URLRequestTestJob::ProcessOnePendingMessage()); -} - -// Tests that the plugin can issue a GET request and receives the data when -// it comes back synchronously. -TEST_F(ChromePluginTest, CanMakeGETRequestSync) { - // test_url_1 has a synchronous response - EXPECT_EQ(CPERR_SUCCESS, test_funcs_.test_make_request( - "GET", net::URLRequestTestJob::test_url_1())); - - // Note: we must add this task after we make the request, so that - // net::URLRequestTestJob's StartAsync task is added and run first. - MessageLoop::current()->PostTask(FROM_HERE, - NewRunnableFunction(&ProcessAllPendingMessages)); - MessageLoop::current()->Run(); -} - -// Tests that the plugin can issue a GET request and receives the data when -// it comes back asynchronously. -TEST_F(ChromePluginTest, CanMakeGETRequestAsync) { - // test_url_2 has an asynchronous response - EXPECT_EQ(CPERR_SUCCESS, test_funcs_.test_make_request( - "GET", net::URLRequestTestJob::test_url_2())); - - // Note: we must add this task after we make the request, so that - // net::URLRequestTestJob's StartAsync task is added and run first. - MessageLoop::current()->PostTask(FROM_HERE, - NewRunnableFunction(&ProcessAllPendingMessages)); - MessageLoop::current()->Run(); -} - -// Tests that the plugin can issue a POST request. -TEST_F(ChromePluginTest, CanMakePOSTRequest) { - net::TestServer test_server(net::TestServer::TYPE_HTTP, FilePath(kDocRoot)); - ASSERT_TRUE(test_server.Start()); - - GURL url = test_server.GetURL("echo"); - - EXPECT_EQ(CPERR_SUCCESS, test_funcs_.test_make_request("POST", url)); - - // Note: we must add this task after we make the request, so that - // net::URLRequestTestJob's StartAsync task is added and run first. - MessageLoop::current()->PostTask(FROM_HERE, - NewRunnableFunction(&ProcessAllPendingMessages)); - MessageLoop::current()->Run(); -} - -// Tests that the plugin does not intercept its own requests. -TEST_F(ChromePluginTest, DoesNotInterceptOwnRequest) { - const TestResponsePayload& payload = kChromeTestPluginPayloads[0]; - - EXPECT_EQ(CPERR_SUCCESS, test_funcs_.test_make_request( - "GET", GURL(payload.url))); - - MessageLoop::current()->Run(); -} - -} // namespace diff --git a/chrome/browser/content_settings/host_content_settings_map.cc b/chrome/browser/content_settings/host_content_settings_map.cc index fb899fc..5dc96e9 100644 --- a/chrome/browser/content_settings/host_content_settings_map.cc +++ b/chrome/browser/content_settings/host_content_settings_map.cc @@ -36,7 +36,6 @@ static bool ShouldAllowAllContent(const GURL& url) { url.SchemeIs(chrome::kChromeInternalScheme) || url.SchemeIs(chrome::kChromeUIScheme) || url.SchemeIs(chrome::kExtensionScheme) || - url.SchemeIs(chrome::kGearsScheme) || url.SchemeIs(chrome::kUserScriptScheme); } diff --git a/chrome/browser/extensions/user_script_listener_unittest.cc b/chrome/browser/extensions/user_script_listener_unittest.cc index bf5d952..e877bcc 100644 --- a/chrome/browser/extensions/user_script_listener_unittest.cc +++ b/chrome/browser/extensions/user_script_listener_unittest.cc @@ -89,7 +89,7 @@ class DummyResourceHandler : public ResourceHandler { ResourceDispatcherHostRequestInfo* CreateRequestInfo(int request_id) { return new ResourceDispatcherHostRequestInfo( new DummyResourceHandler(), ChildProcessInfo::RENDER_PROCESS, 0, 0, - request_id, ResourceType::MAIN_FRAME, 0, false, false, false, -1, -1); + request_id, ResourceType::MAIN_FRAME, 0, false, false, false); } // A simple test net::URLRequestJob. We don't care what it does, only that diff --git a/chrome/browser/gears_integration.cc b/chrome/browser/gears_integration.cc deleted file mode 100644 index 648d255..0000000 --- a/chrome/browser/gears_integration.cc +++ /dev/null @@ -1,309 +0,0 @@ -// Copyright (c) 2009 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/browser/gears_integration.h" - -#include <string> -#include <vector> - -#include "base/base64.h" -#include "base/logging.h" -#include "base/message_loop.h" -#include "base/scoped_ptr.h" -#include "base/utf_string_conversions.h" -#include "chrome/browser/chrome_plugin_host.h" -#include "chrome/common/chrome_plugin_util.h" -#include "chrome/common/gears_api.h" -#include "chrome/common/web_apps.h" -#include "googleurl/src/gurl.h" -#include "third_party/skia/include/core/SkBitmap.h" -#include "ui/gfx/codec/png_codec.h" - -// The following 2 helpers are borrowed from the Gears codebase. - -const size_t kUserPathComponentMaxChars = 64; - -// Returns true if and only if the char meets the following criteria: -// -// - visible ASCII -// - None of the following characters: / \ : * ? " < > | ; , -// -// This function is a heuristic that should identify most strings that are -// invalid pathnames on popular OSes. It's both overinclusive and -// underinclusive, though. -template<class CharT> -inline bool IsCharValidInPathComponent(CharT c) { - // Not visible ASCII? - // Note: the Gears version of this function excludes spaces (32) as well. We - // allow them for file names. - if (c < 32 || c >= 127) { - return false; - } - - // Illegal characters? - switch (c) { - case '/': - case '\\': - case ':': - case '*': - case '?': - case '"': - case '<': - case '>': - case '|': - case ';': - case ',': - return false; - - default: - return true; - } -} - -// Modifies a string, replacing characters that are not valid in a file path -// component with the '_' character. Also replaces leading and trailing dots -// with the '_' character. -// See IsCharValidInPathComponent -template<class StringT> -inline void EnsureStringValidPathComponent(StringT &s) { - if (s.empty()) { - return; - } - - typename StringT::iterator iter = s.begin(); - typename StringT::iterator end = s.end(); - - // Does it start with a dot? - if (*iter == '.') { - *iter = '_'; - ++iter; // skip it in the loop below - } - // Is every char valid? - while (iter != end) { - if (!IsCharValidInPathComponent(*iter)) { - *iter = '_'; - } - ++iter; - } - // Does it end with a dot? - --iter; - if (*iter == '.') { - *iter = '_'; - } - - // Is it too long? - if (s.size() > kUserPathComponentMaxChars) - s.resize(kUserPathComponentMaxChars); -} - -void GearsSettingsPressed(gfx::NativeWindow parent_wnd) { - CPBrowsingContext context = static_cast<CPBrowsingContext>( - reinterpret_cast<uintptr_t>(parent_wnd)); - CPHandleCommand(GEARSPLUGINCOMMAND_SHOW_SETTINGS, NULL, context); -} - -// Gears only supports certain icon sizes. -enum GearsIconSizes { - SIZE_16x16 = 0, - SIZE_32x32, - SIZE_48x48, - SIZE_128x128, - NUM_GEARS_ICONS, -}; - -// Helper function to convert a 16x16 favicon to a data: URL with the icon -// encoded as a PNG. -static GURL ConvertSkBitmapToDataURL(const SkBitmap& icon) { - DCHECK(!icon.isNull()); - DCHECK(icon.width() == 16 && icon.height() == 16); - - // Get the FavIcon data. - std::vector<unsigned char> icon_data; - gfx::PNGCodec::EncodeBGRASkBitmap(icon, false, &icon_data); - - // Base64-encode it (to make it a data URL). - std::string icon_data_str(reinterpret_cast<char*>(&icon_data[0]), - icon_data.size()); - std::string icon_base64_encoded; - base::Base64Encode(icon_data_str, &icon_base64_encoded); - GURL icon_url("data:image/png;base64," + icon_base64_encoded); - - return icon_url; -} - -// This class holds and manages the data passed to the -// GEARSPLUGINCOMMAND_CREATE_SHORTCUT plugin command. -class CreateShortcutCommand : public CPCommandInterface { - public: - CreateShortcutCommand( - const std::string& name, const std::string& orig_name, - const std::string& url, const std::string& description, - const std::vector<WebApplicationInfo::IconInfo> &icons, - const SkBitmap& fallback_icon, - GearsCreateShortcutCallback* callback) - : name_(name), url_(url), description_(description), - orig_name_(orig_name), callback_(callback), - calling_loop_(MessageLoop::current()) { - // shortcut_data_ has the same lifetime as our strings, so we just - // point it at their internal data. - memset(&shortcut_data_, 0, sizeof(shortcut_data_)); - shortcut_data_.name = name_.c_str(); - shortcut_data_.url = url_.c_str(); - shortcut_data_.description = description_.c_str(); - shortcut_data_.orig_name = orig_name_.c_str(); - - // Search the icons array for Gears-supported sizes and copy the strings. - bool has_icon = false; - - for (size_t i = 0; i < icons.size(); ++i) { - const WebApplicationInfo::IconInfo& icon = icons[i]; - if (icon.width == 16 && icon.height == 16) { - has_icon = true; - InitIcon(SIZE_16x16, icon.url, 16, 16); - } else if (icon.width == 32 && icon.height == 32) { - has_icon = true; - InitIcon(SIZE_32x32, icon.url, 32, 32); - } else if (icon.width == 48 && icon.height == 48) { - has_icon = true; - InitIcon(SIZE_48x48, icon.url, 48, 48); - } else if (icon.width == 128 && icon.height == 128) { - has_icon = true; - InitIcon(SIZE_128x128, icon.url, 128, 128); - } - } - - if (!has_icon) { - // Fall back to the favicon only if the site provides no icons at all. We - // assume if a site provides any icons, it wants to override default - // behavior. - InitIcon(SIZE_16x16, ConvertSkBitmapToDataURL(fallback_icon), 16, 16); - } - - shortcut_data_.command_interface = this; - } - virtual ~CreateShortcutCommand() { } - - // CPCommandInterface - virtual void* GetData() { return &shortcut_data_; } - virtual void OnCommandInvoked(CPError retval) { - if (retval != CPERR_IO_PENDING) { - // Older versions of Gears don't send a response, so don't wait for one. - OnCommandResponse(CPERR_FAILURE); - } - } - virtual void OnCommandResponse(CPError retval) { - calling_loop_->PostTask(FROM_HERE, NewRunnableMethod( - this, &CreateShortcutCommand::ReportResults, retval)); - } - - private: - void ReportResults(CPError retval) { - // Other code only knows about the original GearsShortcutData. Pass our - // GearsShortcutData2 off as one of those - but use the unmodified name. - // TODO(mpcomplete): this means that Gears will have stored its sanitized - // filename, but not expose it to us. We will use the unsanitized version, - // so our name will potentially differ. This is relevant because we store - // some prefs keyed off the webapp name. - shortcut_data_.name = shortcut_data_.orig_name; - callback_->Run(shortcut_data_, retval == CPERR_SUCCESS); - delete this; - } - - void InitIcon(GearsIconSizes size, const GURL& url, int width, int height) { - icon_urls_[size] = url.spec(); // keeps the string memory in scope - shortcut_data_.icons[size].url = icon_urls_[size].c_str(); - shortcut_data_.icons[size].width = width; - shortcut_data_.icons[size].height = height; - } - - GearsCreateShortcutData shortcut_data_; - std::string name_; - std::string url_; - std::string description_; - std::string icon_urls_[NUM_GEARS_ICONS]; - std::string orig_name_; - scoped_ptr<GearsCreateShortcutCallback> callback_; - MessageLoop* calling_loop_; -}; - -// Allows InvokeLater without adding refcounting. The object is only deleted -// when its last InvokeLater is run anyway. -DISABLE_RUNNABLE_METHOD_REFCOUNT(CreateShortcutCommand); - -void GearsCreateShortcut( - const WebApplicationInfo& app_info, - const string16& fallback_name, - const GURL& fallback_url, - const SkBitmap& fallback_icon, - GearsCreateShortcutCallback* callback) { - string16 name = - !app_info.title.empty() ? app_info.title : fallback_name; - std::string orig_name_utf8 = UTF16ToUTF8(name); - EnsureStringValidPathComponent(name); - - std::string name_utf8 = UTF16ToUTF8(name); - std::string description_utf8 = UTF16ToUTF8(app_info.description); - const GURL& url = - !app_info.app_url.is_empty() ? app_info.app_url : fallback_url; - - CreateShortcutCommand* command = - new CreateShortcutCommand(name_utf8, orig_name_utf8, url.spec(), - description_utf8, - app_info.icons, fallback_icon, callback); - CPHandleCommand(GEARSPLUGINCOMMAND_CREATE_SHORTCUT, command, 0); -} - -// This class holds and manages the data passed to the -// GEARSPLUGINCOMMAND_GET_SHORTCUT_LIST plugin command. When the command is -// invoked, we proxy the results over to the calling thread. -class QueryShortcutsCommand : public CPCommandInterface { - public: - explicit QueryShortcutsCommand(GearsQueryShortcutsCallback* callback) : - callback_(callback), calling_loop_(MessageLoop::current()) { - shortcut_list_.shortcuts = NULL; - shortcut_list_.num_shortcuts = 0; - } - virtual ~QueryShortcutsCommand() { } - virtual void* GetData() { return &shortcut_list_; } - virtual void OnCommandInvoked(CPError retval) { - calling_loop_->PostTask(FROM_HERE, NewRunnableMethod( - this, &QueryShortcutsCommand::ReportResults, retval)); - } - - private: - void ReportResults(CPError retval) { - callback_->Run(retval == CPERR_SUCCESS ? &shortcut_list_ : NULL); - FreeGearsShortcutList(); - delete this; - } - - void FreeGearsShortcutList() { - for (size_t i = 0; i < shortcut_list_.num_shortcuts; ++i) { - CPB_Free(const_cast<char*>(shortcut_list_.shortcuts[i].description)); - CPB_Free(const_cast<char*>(shortcut_list_.shortcuts[i].name)); - CPB_Free(const_cast<char*>(shortcut_list_.shortcuts[i].url)); - for (size_t j = 0; j < 4; ++j) - CPB_Free(const_cast<char*>(shortcut_list_.shortcuts[i].icons[j].url)); - } - CPB_Free(shortcut_list_.shortcuts); - } - - GearsShortcutList shortcut_list_; - scoped_ptr<GearsQueryShortcutsCallback> callback_; - MessageLoop* calling_loop_; -}; - -// Allows InvokeLater without adding refcounting. The object is only deleted -// when its last InvokeLater is run anyway. -template <> -struct RunnableMethodTraits<QueryShortcutsCommand> { - void RetainCallee(QueryShortcutsCommand* command) {} - void ReleaseCallee(QueryShortcutsCommand* command) {} -}; - -void GearsQueryShortcuts(GearsQueryShortcutsCallback* callback) { - CPHandleCommand(GEARSPLUGINCOMMAND_GET_SHORTCUT_LIST, - new QueryShortcutsCommand(callback), - 0); -} diff --git a/chrome/browser/gears_integration.h b/chrome/browser/gears_integration.h deleted file mode 100644 index 3c20555..0000000 --- a/chrome/browser/gears_integration.h +++ /dev/null @@ -1,57 +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_BROWSER_GEARS_INTEGRATION_H__ -#define CHROME_BROWSER_GEARS_INTEGRATION_H__ -#pragma once - -#include "base/callback.h" -#include "base/string16.h" -#include "chrome/common/gears_api.h" -#include "ui/gfx/native_widget_types.h" - -// TODO(michaeln): Rework this interface to match how other first class -// citizens of chrome are structured, as a GearsService with an accessor -// available via browser.gears_service(). - -class CPCommandInterface; -class GURL; -class SkBitmap; -struct WebApplicationInfo; - -// We use this in place of GearsShortcutData so we can keep browser-specific -// data on the structure. -struct GearsCreateShortcutData : public GearsShortcutData2 { - CPCommandInterface* command_interface; -}; - -// Called when the Gears Settings button is pressed. |parent_wnd| is the -// window the Gears Settings dialog should be parented to. -void GearsSettingsPressed(gfx::NativeWindow parent_wnd); - -// Calls into the Gears API to create a shortcut with the given parameters. -// 'app_info' is the optional information provided by the page. If any info is -// missing, we fallback to the given fallback params. 'fallback_icon' must be a -// 16x16 favicon. 'callback' will be called with a value indicating whether the -// shortcut has been created successfully. -typedef Callback2<const GearsShortcutData2&, bool>::Type - GearsCreateShortcutCallback; - -void GearsCreateShortcut(const WebApplicationInfo& app_info, - const string16& fallback_name, - const GURL& fallback_url, - const SkBitmap& fallback_icon, - GearsCreateShortcutCallback* callback); - -// Call into Gears to query the list of shortcuts. Results will be returned -// asynchronously via the callback. The callback's arguments will be NULL -// if there was an error. -typedef Callback1<GearsShortcutList*>::Type GearsQueryShortcutsCallback; - -void GearsQueryShortcuts(GearsQueryShortcutsCallback* callback); - -// When the Gears shortcut database is modified, the main thread is notified -// via the NotificationService, NOTIFY_WEB_APP_INSTALL_CHANGED. - -#endif // CHROME_BROWSER_GEARS_INTEGRATION_H__ diff --git a/chrome/browser/renderer_host/browser_render_process_host.cc b/chrome/browser/renderer_host/browser_render_process_host.cc index 08317f7..dcb8ba7 100644 --- a/chrome/browser/renderer_host/browser_render_process_host.cc +++ b/chrome/browser/renderer_host/browser_render_process_host.cc @@ -101,6 +101,7 @@ #include "media/base/media_switches.h" #include "ui/base/ui_base_switches.h" #include "webkit/fileapi/file_system_path_manager.h" +#include "webkit/glue/resource_type.h" #include "webkit/plugins/plugin_switches.h" #if defined(OS_WIN) @@ -247,12 +248,12 @@ class RendererURLRequestContextOverride } virtual net::URLRequestContext* GetRequestContext( - const ResourceHostMsg_Request& resource_request) { + ResourceType::Type resource_type) { URLRequestContextGetter* request_context = request_context_; // If the request has resource type of ResourceType::MEDIA, we use a request // context specific to media for handling it because these resources have // specific needs for caching. - if (resource_request.resource_type == ResourceType::MEDIA) + if (resource_type == ResourceType::MEDIA) request_context = media_request_context_; return request_context->GetURLRequestContext(); } diff --git a/chrome/browser/resources/options/advanced_options.css b/chrome/browser/resources/options/advanced_options.css index bce0033..e2b6188 100644 --- a/chrome/browser/resources/options/advanced_options.css +++ b/chrome/browser/resources/options/advanced_options.css @@ -32,7 +32,6 @@ } #fontSettingsCustomizeFontsButton, -#gearSettingsConfigureGearsButton, #privacyClearDataButton { margin-left: 10px; } diff --git a/chrome/browser/resources/options/advanced_options.html b/chrome/browser/resources/options/advanced_options.html index 72c2d03..5f1030d 100644 --- a/chrome/browser/resources/options/advanced_options.html +++ b/chrome/browser/resources/options/advanced_options.html @@ -107,10 +107,6 @@ <button id="language-button" i18n-content="languageAndSpellCheckSettingsButton"></button> </if> -<if expr="os == 'win32'"> - <button id="gearSettingsConfigureGearsButton" - i18n-content="gearSettingsConfigureGearsButton"></button> -</if> <if expr="not pp_ifdef('chromeos') or os == 'win32'"> </div> </if> diff --git a/chrome/browser/resources/options/advanced_options.js b/chrome/browser/resources/options/advanced_options.js index 9082138..086a408 100644 --- a/chrome/browser/resources/options/advanced_options.js +++ b/chrome/browser/resources/options/advanced_options.js @@ -121,9 +121,6 @@ var OptionsPage = options.OptionsPage; chrome.send('useTLS1CheckboxAction', [String($('sslUseTLS1').checked)]); }; - $('gearSettingsConfigureGearsButton').onclick = function(event) { - chrome.send('showGearsSettings'); - }; } // 'cloudPrintProxyEnabled' is true for Chrome branded builds on diff --git a/chrome/browser/shell_integration_linux.cc b/chrome/browser/shell_integration_linux.cc index c4fe208..45f3988 100644 --- a/chrome/browser/shell_integration_linux.cc +++ b/chrome/browser/shell_integration_linux.cc @@ -31,7 +31,6 @@ #include "base/utf_string_conversions.h" #include "chrome/common/chrome_constants.h" #include "chrome/common/chrome_paths.h" -#include "chrome/common/chrome_plugin_util.h" #include "content/browser/browser_thread.h" #include "googleurl/src/gurl.h" #include "ui/gfx/codec/png_codec.h" diff --git a/chrome/browser/tab_contents/render_view_context_menu.cc b/chrome/browser/tab_contents/render_view_context_menu.cc index 391f904d..c9266a9 100644 --- a/chrome/browser/tab_contents/render_view_context_menu.cc +++ b/chrome/browser/tab_contents/render_view_context_menu.cc @@ -1475,10 +1475,6 @@ bool RenderViewContextMenu::IsDevCommandEnabled(int id) const { if (active_entry->IsViewSourceMode()) return false; - // Don't inspect HTML dialogs (doesn't work anyway). - if (active_entry->url().SchemeIs(chrome::kGearsScheme)) - return false; - // Don't inspect about:network, about:memory, etc. // However, we do want to inspect about:blank, which is often // used by ordinary web pages. diff --git a/chrome/browser/tab_contents/web_drop_target_win.cc b/chrome/browser/tab_contents/web_drop_target_win.cc index b137317..dfb85005 100644 --- a/chrome/browser/tab_contents/web_drop_target_win.cc +++ b/chrome/browser/tab_contents/web_drop_target_win.cc @@ -106,7 +106,7 @@ DWORD WebDropTarget::OnDragEnter(IDataObject* data_object, // TODO(tc): PopulateWebDropData can be slow depending on what is in the // IDataObject. Maybe we can do this in a background thread. - WebDropData drop_data(GetDragIdentity()); + WebDropData drop_data; WebDropData::PopulateWebDropData(data_object, &drop_data); if (drop_data.url.is_empty()) diff --git a/chrome/browser/ui/browser_window.h b/chrome/browser/ui/browser_window.h index 9e7f252..86ddc67 100644 --- a/chrome/browser/ui/browser_window.h +++ b/chrome/browser/ui/browser_window.h @@ -245,9 +245,8 @@ class BrowserWindow { // has confirmed. virtual void ConfirmBrowserCloseWithPendingDownloads() = 0; - // Shows a dialog box with HTML content, e.g. for Gears. |parent_window| is - // the window the dialog should be opened modal to and is a native window - // handle. + // Shows a dialog box with HTML content. |parent_window| is the window the + // dialog should be opened modal to and is a native window handle. virtual void ShowHTMLDialog(HtmlDialogUIDelegate* delegate, gfx::NativeWindow parent_window) = 0; diff --git a/chrome/browser/ui/cocoa/page_info_bubble_controller.mm b/chrome/browser/ui/cocoa/page_info_bubble_controller.mm index 5a883a6..30b5b97 100644 --- a/chrome/browser/ui/cocoa/page_info_bubble_controller.mm +++ b/chrome/browser/ui/cocoa/page_info_bubble_controller.mm @@ -382,8 +382,7 @@ void ShowPageInfoBubble(gfx::NativeWindow parent, scoped_refptr<net::X509Certificate> cert; CertStore::GetInstance()->RetrieveCert(certID_, &cert); - // Don't bother showing certificates if there isn't one. Gears runs - // with no OS root certificate. + // Don't bother showing certificates if there isn't one. if (!cert.get() || !cert->os_cert_handle()) { // This should only ever happen in unit tests. [certButton setEnabled:NO]; diff --git a/chrome/browser/ui/views/page_info_bubble_view.cc b/chrome/browser/ui/views/page_info_bubble_view.cc index b112a00..f6e2842 100644 --- a/chrome/browser/ui/views/page_info_bubble_view.cc +++ b/chrome/browser/ui/views/page_info_bubble_view.cc @@ -98,9 +98,9 @@ PageInfoBubbleView::PageInfoBubbleView(gfx::NativeWindow parent_window, if (cert_id_ > 0) { scoped_refptr<net::X509Certificate> cert; CertStore::GetInstance()->RetrieveCert(cert_id_, &cert); - // When running with fake certificate (Chrome Frame) or Gears in offline - // mode, we have no os certificate, so there is no cert to show. Don't - // bother showing the cert info link in that case. + // When running with fake certificate (Chrome Frame), we have no os + // certificate, so there is no cert to show. Don't bother showing the cert + // info link in that case. if (!cert.get() || !cert->os_cert_handle()) cert_id_ = 0; } diff --git a/chrome/browser/ui/webui/options/advanced_options_handler.cc b/chrome/browser/ui/webui/options/advanced_options_handler.cc index d6e3b6d..f5cd522 100644 --- a/chrome/browser/ui/webui/options/advanced_options_handler.cc +++ b/chrome/browser/ui/webui/options/advanced_options_handler.cc @@ -45,7 +45,6 @@ #endif #if defined(OS_WIN) -#include "chrome/browser/gears_integration.h" #include "net/base/ssl_config_service_win.h" #endif @@ -81,8 +80,6 @@ void AdvancedOptionsHandler::GetLocalizedValues( IDS_OPTIONS_OPEN_FILE_TYPES_AUTOMATICALLY }, { "autoOpenFileTypesResetToDefault", IDS_OPTIONS_AUTOOPENFILETYPES_RESETTODEFAULT }, - { "gearSettingsConfigureGearsButton", - IDS_OPTIONS_GEARSSETTINGS_CONFIGUREGEARS_BUTTON }, { "translateEnableTranslate", IDS_OPTIONS_TRANSLATE_ENABLE_TRANSLATE }, { "certificatesManageButton", @@ -307,9 +304,6 @@ void AdvancedOptionsHandler::RegisterMessages() { web_ui_->RegisterMessageCallback("useTLS1CheckboxAction", NewCallback(this, &AdvancedOptionsHandler::HandleUseTLS1Checkbox)); - web_ui_->RegisterMessageCallback("showGearsSettings", - NewCallback(this, - &AdvancedOptionsHandler::HandleShowGearsSettings)); #endif } @@ -433,12 +427,6 @@ void AdvancedOptionsHandler::HandleUseTLS1Checkbox(const ListValue* args) { UserMetricsRecordAction(UserMetricsAction(metric.c_str())); net::SSLConfigServiceWin::SetTLS1Enabled(enabled); } - -void AdvancedOptionsHandler::HandleShowGearsSettings(const ListValue* args) { - UserMetricsRecordAction(UserMetricsAction("Options_GearsSettings")); - GearsSettingsPressed( - web_ui_->tab_contents()->view()->GetTopLevelNativeWindow()); -} #endif #if !defined(OS_CHROMEOS) diff --git a/chrome/browser/ui/webui/options/advanced_options_handler.h b/chrome/browser/ui/webui/options/advanced_options_handler.h index d177c50..90049ab 100644 --- a/chrome/browser/ui/webui/options/advanced_options_handler.h +++ b/chrome/browser/ui/webui/options/advanced_options_handler.h @@ -77,9 +77,6 @@ class AdvancedOptionsHandler // Callback for the "Use TLS1" checkbox. This is needed so we can support // manual handling on Windows. void HandleUseTLS1Checkbox(const ListValue* args); - - // Callback for the "Show Gears Settings" button. - void HandleShowGearsSettings(const ListValue* args); #endif #if !defined(OS_CHROMEOS) diff --git a/chrome/browser/web_applications/web_app.cc b/chrome/browser/web_applications/web_app.cc index 1f930e2..d2da2ca 100644 --- a/chrome/browser/web_applications/web_app.cc +++ b/chrome/browser/web_applications/web_app.cc @@ -27,7 +27,6 @@ #include "chrome/browser/profiles/profile.h" #include "chrome/common/chrome_constants.h" #include "chrome/common/chrome_paths.h" -#include "chrome/common/chrome_plugin_util.h" #include "chrome/common/extensions/extension.h" #include "chrome/common/url_constants.h" #include "chrome/common/web_apps.h" @@ -642,7 +641,7 @@ void UpdateShortcutWorker::UpdateShortcutsOnFileThread() { web_app::GetDataDir(profile_path_), shortcut_info_); // Ensure web_app_path exists. web_app_path could be missing for a legacy - // shortcut created by gears. + // shortcut created by Gears. if (!file_util::PathExists(web_app_path) && !file_util::CreateDirectory(web_app_path)) { NOTREACHED(); diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp index f7a2c0f..daaab35 100644 --- a/chrome/chrome.gyp +++ b/chrome/chrome.gyp @@ -566,8 +566,6 @@ 'sources': [ # All .cc, .h, .m, and .mm files under plugins except for tests and # mocks. - 'plugin/chrome_plugin_host.cc', - 'plugin/chrome_plugin_host.h', 'plugin/npobject_base.h', 'plugin/npobject_proxy.cc', 'plugin/npobject_proxy.h', @@ -1646,7 +1644,6 @@ '../breakpad/breakpad.gyp:*', '../courgette/courgette.gyp:*', - '../gears/gears.gyp:*', '../rlz/rlz.gyp:*', '../sandbox/sandbox.gyp:*', '../tools/memory_watcher/memory_watcher.gyp:*', diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index e47898e..4f0f7f4 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -344,10 +344,6 @@ 'browser/character_encoding.h', 'browser/chrome_browser_application_mac.h', 'browser/chrome_browser_application_mac.mm', - 'browser/chrome_plugin_browsing_context.cc', - 'browser/chrome_plugin_browsing_context.h', - 'browser/chrome_plugin_host.cc', - 'browser/chrome_plugin_host.h', 'browser/chromeos/audio_handler.cc', 'browser/chromeos/audio_handler.h', 'browser/chromeos/audio_mixer.h', @@ -1090,8 +1086,6 @@ 'browser/fullscreen_linux.cc', 'browser/fullscreen_mac.mm', 'browser/fullscreen_win.cc', - 'browser/gears_integration.cc', - 'browser/gears_integration.h', 'browser/geolocation/access_token_store.cc', 'browser/geolocation/geolocation_content_settings_map.cc', 'browser/geolocation/geolocation_content_settings_map.h', @@ -3616,7 +3610,6 @@ '<(DEPTH)/third_party/wtl/include', ], 'dependencies': [ - '../gears/gears.gyp:gears', '../google_update/google_update.gyp:google_update', '../third_party/iaccessible2/iaccessible2.gyp:iaccessible2', '../third_party/isimpledom/isimpledom.gyp:isimpledom', diff --git a/chrome/chrome_common.gypi b/chrome/chrome_common.gypi index cfa8da4..25a2cc1 100644 --- a/chrome/chrome_common.gypi +++ b/chrome/chrome_common.gypi @@ -195,11 +195,6 @@ 'common/chrome_content_client.cc', 'common/chrome_content_client.h', 'common/chrome_descriptors.h', - 'common/chrome_plugin_api.h', - 'common/chrome_plugin_lib.cc', - 'common/chrome_plugin_lib.h', - 'common/chrome_plugin_util.cc', - 'common/chrome_plugin_util.h', 'common/common_glue.cc', 'common/css_colors.h', 'common/database_util.cc', @@ -248,7 +243,6 @@ 'common/extensions/url_pattern.h', 'common/extensions/user_script.cc', 'common/extensions/user_script.h', - 'common/gears_api.h', 'common/important_file_writer.cc', 'common/important_file_writer.h', 'common/json_pref_store.cc', @@ -451,8 +445,6 @@ 'common/net/url_fetcher.h', 'common/net/url_request_context_getter.cc', 'common/net/url_request_context_getter.h', - 'common/net/url_request_intercept_job.cc', - 'common/net/url_request_intercept_job.h', 'common/net/gaia/gaia_auth_consumer.cc', 'common/net/gaia/gaia_auth_consumer.h', 'common/net/gaia/gaia_auth_fetcher.cc', diff --git a/chrome/chrome_dll.gypi b/chrome/chrome_dll.gypi index 0661678d..eb0ed41 100644 --- a/chrome/chrome_dll.gypi +++ b/chrome/chrome_dll.gypi @@ -87,7 +87,6 @@ '../third_party/cld/cld.gyp:cld', '../views/views.gyp:views', '../webkit/support/webkit_support.gyp:webkit_resources', - '../gears/gears.gyp:gears', ], 'sources': [ 'app/chrome_command_ids.h', diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi index 37027d9..9073e09 100644 --- a/chrome/chrome_tests.gypi +++ b/chrome/chrome_tests.gypi @@ -1198,7 +1198,6 @@ 'browser/browsing_data_indexed_db_helper_unittest.cc', 'browser/browsing_data_local_storage_helper_unittest.cc', 'browser/chrome_browser_application_mac_unittest.mm', - 'browser/chrome_plugin_unittest.cc', 'browser/chromeos/customization_document_unittest.cc', 'browser/chromeos/external_metrics_unittest.cc', 'browser/chromeos/gview_request_interceptor_unittest.cc', @@ -1996,7 +1995,6 @@ 'installer_util_strings', '../third_party/iaccessible2/iaccessible2.gyp:iaccessible2', '../third_party/isimpledom/isimpledom.gyp:isimpledom', - 'test_chrome_plugin', # run time dependency ], 'conditions': [ ['win_use_allocator_shim==1', { @@ -3441,28 +3439,6 @@ },], ], }, - { - 'target_name': 'test_chrome_plugin', - 'type': 'shared_library', - 'msvs_guid': '7F0A70F6-BE3F-4C19-B435-956AB8F30BA4', - 'dependencies': [ - '../base/base.gyp:base', - '../build/temp_gyp/googleurl.gyp:googleurl', - ], - 'include_dirs': [ - '..', - ], - 'link_settings': { - 'libraries': [ - '-lwinmm.lib', - ], - }, - 'sources': [ - 'test/chrome_plugin/test_chrome_plugin.cc', - 'test/chrome_plugin/test_chrome_plugin.def', - 'test/chrome_plugin/test_chrome_plugin.h', - ], - }, ]}, # 'targets' ], # OS=="win" # If you change this condition, make sure you also change it in all.gyp diff --git a/chrome/common/chrome_constants.cc b/chrome/common/chrome_constants.cc index c219f34..648ee3d 100644 --- a/chrome/common/chrome_constants.cc +++ b/chrome/common/chrome_constants.cc @@ -82,7 +82,6 @@ const FilePath::CharType kMediaCacheDirname[] = FPL("Media Cache"); const FilePath::CharType kOffTheRecordMediaCacheDirname[] = FPL("Incognito Media Cache"); const FilePath::CharType kAppCacheDirname[] = FPL("Application Cache"); -const FilePath::CharType kChromePluginDataDirname[] = FPL("Plugin Data"); const FilePath::CharType kThemePackFilename[] = FPL("Cached Theme.pak"); const FilePath::CharType kCookieFilename[] = FPL("Cookies"); const FilePath::CharType kExtensionsCookieFilename[] = FPL("Extension Cookies"); diff --git a/chrome/common/chrome_constants.h b/chrome/common/chrome_constants.h index b1cbdda..530c69d 100644 --- a/chrome/common/chrome_constants.h +++ b/chrome/common/chrome_constants.h @@ -44,7 +44,6 @@ extern const FilePath::CharType kCacheDirname[]; extern const FilePath::CharType kMediaCacheDirname[]; extern const FilePath::CharType kOffTheRecordMediaCacheDirname[]; extern const FilePath::CharType kAppCacheDirname[]; -extern const FilePath::CharType kChromePluginDataDirname[]; extern const FilePath::CharType kThemePackFilename[]; extern const FilePath::CharType kCookieFilename[]; extern const FilePath::CharType kExtensionsCookieFilename[]; diff --git a/chrome/common/chrome_counters.cc b/chrome/common/chrome_counters.cc index 91ebf55..da6ee3b 100644 --- a/chrome/common/chrome_counters.cc +++ b/chrome/common/chrome_counters.cc @@ -42,14 +42,4 @@ StatsRate& Counters::spellcheck_lookup() { return *ctr; } -StatsCounterTimer& Counters::plugin_load() { - static StatsCounterTimer* ctr = new StatsCounterTimer("ChromePlugin.Load"); - return *ctr; -} - -StatsRate& Counters::plugin_intercept() { - static StatsRate* ctr = new StatsRate("ChromePlugin.Intercept"); - return *ctr; -} - } // namespace chrome diff --git a/chrome/common/chrome_counters.h b/chrome/common/chrome_counters.h index e53d5b2..742cbb4 100644 --- a/chrome/common/chrome_counters.h +++ b/chrome/common/chrome_counters.h @@ -29,12 +29,6 @@ class Counters { // Time/Count of spellcheck lookups. static base::StatsRate& spellcheck_lookup(); - - // Time spent loading the Chrome plugins. - static base::StatsCounterTimer& plugin_load(); - - // Time/Count of plugin network interception. - static base::StatsRate& plugin_intercept(); }; } // namespace chrome diff --git a/chrome/common/chrome_paths.cc b/chrome/common/chrome_paths.cc index afa0b7a..35c01d1 100644 --- a/chrome/common/chrome_paths.cc +++ b/chrome/common/chrome_paths.cc @@ -73,19 +73,6 @@ bool GetInternalPluginsDirectory(FilePath* result) { return PathService::Get(base::DIR_MODULE, result); } -bool GetGearsPluginPathFromCommandLine(FilePath* path) { -#ifndef NDEBUG - // for debugging, support a cmd line based override - FilePath plugin_path = - CommandLine::ForCurrentProcess()->GetSwitchValuePath( - switches::kGearsPluginPathOverride); - *path = plugin_path; - return !plugin_path.empty(); -#else - return false; -#endif -} - bool PathProvider(int key, FilePath* result) { // Some keys are just aliases... switch (key) { @@ -218,29 +205,6 @@ bool PathProvider(int key, FilePath* result) { return false; cur = cur.Append(FILE_PATH_LITERAL("script.log")); break; - case chrome::FILE_GEARS_PLUGIN: - if (!GetGearsPluginPathFromCommandLine(&cur)) { -#if defined(OS_WIN) - // Search for gears.dll alongside chrome.dll first. This new model - // allows us to package gears.dll with the Chrome installer and update - // it while Chrome is running. - if (!GetInternalPluginsDirectory(&cur)) - return false; - cur = cur.Append(FILE_PATH_LITERAL("gears.dll")); - - if (!file_util::PathExists(cur)) { - if (!PathService::Get(base::DIR_EXE, &cur)) - return false; - cur = cur.Append(FILE_PATH_LITERAL("plugins")); - cur = cur.Append(FILE_PATH_LITERAL("gears")); - cur = cur.Append(FILE_PATH_LITERAL("gears.dll")); - } -#else - // No gears.dll on non-Windows systems. - return false; -#endif - } - break; case chrome::FILE_FLASH_PLUGIN: if (!GetInternalPluginsDirectory(&cur)) return false; diff --git a/chrome/common/chrome_paths.h b/chrome/common/chrome_paths.h index 74f7920..008fea1 100644 --- a/chrome/common/chrome_paths.h +++ b/chrome/common/chrome_paths.h @@ -63,7 +63,6 @@ enum { FILE_RECORDED_SCRIPT, // Full path to the script.log file that // contains recorded browser events for // playback. - FILE_GEARS_PLUGIN, // Full path to the gears.dll plugin file. FILE_FLASH_PLUGIN, // Full path to the internal Flash plugin file. FILE_PDF_PLUGIN, // Full path to the internal PDF plugin file. FILE_NACL_PLUGIN, // Full path to the internal NaCl plugin file. diff --git a/chrome/common/chrome_plugin_api.h b/chrome/common/chrome_plugin_api.h deleted file mode 100644 index 2b3da55..0000000 --- a/chrome/common/chrome_plugin_api.h +++ /dev/null @@ -1,567 +0,0 @@ -// Copyright (c) 2009 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 header specifies the Chrome Plugin API. It is based heavily on NPAPI. -// The key difference is that Chrome plugins can be loaded for the lifetime -// of the browser, and are not tied to a specific web page. -// -// NOTE: This API is not final and may change or go away at any point. -// -// All strings in the API are UTF8-encoded unless otherwise noted. - -#ifndef CHROME_COMMON_CHROME_PLUGIN_API_H__ -#define CHROME_COMMON_CHROME_PLUGIN_API_H__ -#pragma once - -#include "base/basictypes.h" - -#ifndef STDCALL -#ifdef WIN32 -#define STDCALL __stdcall -#else -#define STDCALL -#endif // WIN32 -#endif // STDCALL - -#ifdef __cplusplus -extern "C" { -#endif - -// The current version of the API, used by the 'version' field of CPPluginFuncs -// and CPBrowserFuncs. -#define CP_MAJOR_VERSION 0 -#define CP_MINOR_VERSION 11 -#define CP_VERSION ((CP_MAJOR_VERSION << 8) | (CP_MINOR_VERSION)) - -#define CP_GET_MAJOR_VERSION(version) ((version & 0xff00) >> 8) -#define CP_GET_MINOR_VERSION(version) (version & 0x00ff) - -typedef unsigned char CPBool; - -// Chrome plugins can be loaded into different process types. -typedef enum { - CP_PROCESS_BROWSER = 0, - CP_PROCESS_PLUGIN, - CP_PROCESS_RENDERER, -} CPProcessType; - -// Return codes. Error values are negative. -typedef enum { - // No error - CPERR_SUCCESS = 0, - - // (network) An asynchronous IO operation is not complete - CPERR_IO_PENDING = -1, - - // Generic failure - CPERR_FAILURE = -2, - - // The API versions used by plugin and host are incompatible - CPERR_INVALID_VERSION = -3, - - // The operation was cancelled - CPERR_CANCELLED = -4, - - // An invalid parameter was passed - CPERR_INVALID_PARAMETER = -5, -} CPError; - -// Types of response info metadata to query using CPP_GetResponseInfo. -typedef enum { - // HTTP status code. - CPRESPONSEINFO_HTTP_STATUS = 0, - - // Raw headers from the server, including the status line. Headers should - // be delimited by "\0", and end with "\0\0" (a blank line). - CPRESPONSEINFO_HTTP_RAW_HEADERS = 1, -} CPResponseInfoType; - -// An identifier for the plugin used by the browser. -typedef struct _CPID_t { - int unused; -} CPID_t; -typedef struct _CPID_t* CPID; - -// An identifier that encapsulates the browsing context needed by various APIs. -// This includes information about what tab a request was made from, and what -// profile is active. Note that this ID is global to all processes, so it can -// be passed from one process to another. The value 0 is reserved for an -// undefined context. -typedef uint32 CPBrowsingContext; - -// Types of context info to query using CPB_GetBrowsingContextInfo. -typedef enum { - // The data directory for the profile associated with this context as a - // pointer to a null-terminated string. The plugin can save persistent data - // to this directory. The returned pointer should be freed using CPB_Free. - CPBROWSINGCONTEXT_DATA_DIR_PTR = 0, - - // The locale language code used for the browser UI. The returned pointer - // should be freed using CPB_Free. - CPBROWSINGCONTEXT_UI_LOCALE_PTR = 1, -} CPBrowsingContextInfoType; - -// A network request object. -typedef struct _CPRequest { - void* pdata; // plugin private data - const char* url; // the URL being requested - const char* method; // the request method as an uppercase string (ex: "GET") - CPBrowsingContext context; // context in which this request was made -} CPRequest; - -typedef enum { - CPREQUESTLOAD_NORMAL = 0, - - // This is "normal reload", meaning an if-none-match/if-modified-since query - CPREQUESTLOAD_VALIDATE_CACHE = 1 << 0, - - // This is "shift-reload", meaning a "pragma: no-cache" end-to-end fetch - CPREQUESTLOAD_BYPASS_CACHE = 1 << 1, - - // This is a back/forward style navigation where the cached content should - // be preferred over any protocol specific cache validation. - CPREQUESTLOAD_PREFERRING_CACHE = 1 << 2, - - // This is a navigation that will fail if it cannot serve the requested - // resource from the cache (or some equivalent local store). - CPREQUESTLOAD_ONLY_FROM_CACHE = 1 << 3, - - // This is a navigation that will not use the cache at all. It does not - // impact the HTTP request headers. - CPREQUESTLOAD_DISABLE_CACHE = 1 << 4, - - // This navigation should not be intercepted by plugins. - CPREQUESTLOAD_DISABLE_INTERCEPT = 1 << 5, - - // This request should be loaded synchronously. What this means is that - // CPR_StartRequest and CPR_Read will never return CPERR_IO_PENDING - they - // will block until a response is available, and return success or failure. - CPREQUESTLOAD_SYNCHRONOUS = 1 << 20, -} CPRequestLoadFlags; - -// -// Functions provided by plugin to host. -// - -// Called when the browser is unloading the plugin. -typedef CPError (STDCALL *CPP_ShutdownFunc)(void); - -// Returns true if the plugin is interested in handling this request. -typedef CPBool (STDCALL *CPP_ShouldInterceptRequestFunc)(CPRequest* request); - -// Called when an HTML dialog was closed. json_retval is the JSON string -// containing the return value sent back by the dialog (using Chrome's -// JavaScript DOM bindings). -typedef void (STDCALL *CPP_HtmlDialogClosedFunc)( - void* plugin_context, const char* json_retval); - -// Asks the plugin to handle the given command. 'command_data' is command- -// specific data used for some builtin commands: see gears_api.h for -// possible types. It is only valid for the duration of this call. -typedef CPError (STDCALL *CPP_HandleCommandFunc)( - CPBrowsingContext context, int command, void* command_data); - -// -// Functions provided by host to plugin. -// - -// Asks the host to handle the given command. 'command_data' is -// command-specific data used for some builtin commands: see gears_api.h for -// possible types. It is only valid for the duration of this call. -typedef CPError (STDCALL *CPB_HandleCommandFunc)( - CPID id, CPBrowsingContext context, int command, void* command_data); - -// Asks the browser to enable/disable request interception for this plugin for -// the given schemes. 'schemes' is an array of strings containing the scheme -// names the plugin wishes to handle; case is ignored. If 'schemes' is NULL or -// empty, request interception is disabled for this plugin. Multiple calls to -// this function will add to the existing set of enabled schemes. The browser -// should call the plugin's CPP_ShouldInterceptRequestFunc for any network -// requests it makes that match a given scheme. The browser may choose not to -// allow the plugin to intercept certain protocols. -typedef void (STDCALL *CPB_EnableRequestInterceptFunc)( - CPID id, const char** schemes, uint32 num_schemes); - -// Asks the browser to create a request object for the given method/url. -// Returns CPERR_SUCCESS and puts the new object into the 'request' field on -// success, or an error code on failure. The plugin must call CPR_EndRequest -// to clean up the request object when it is done with it. -typedef CPError (STDCALL *CPB_CreateRequestFunc)( - CPID id, CPBrowsingContext context, const char* method, const char* url, - CPRequest** request); - -// Queries the browser's cookie store for cookies set for the given URL. -// Sets 'cookies' to an allocated string containing the cookies as -// semicolon-delimited "name=value" pairs on success, NULL on failure. -// The memory should be freed using CPB_Free when done. -typedef CPError (STDCALL *CPB_GetCookiesFunc)( - CPID id, CPBrowsingContext context, const char* url, char** cookies); - -// Allocates memory for the given size using the browser's allocator. Call -// CPB_Free when done. -typedef void* (STDCALL *CPB_AllocFunc)(uint32 size); - -// Frees a pointer allocated by CPB_Alloc. -typedef void (STDCALL *CPB_FreeFunc)(void* memory); - - -// Sets a flag that influences when the plugin process created to host -// the plugin is shutdown. Generally, the plugin process is terminated -// when no more plugin instances exist, this is the default behavior. -// If keep_alive is non-zero, the process will not be terminated when -// the instance count goes to zero. Note: a non-zero keep_alive value -// does not prevent the plugin process from being terminated upon -// overall browser shutdown. -typedef void (STDCALL *CPB_SetKeepProcessAliveFunc)(CPID id, - CPBool keep_alive); - -// Asks the browser to show an HTML dialog to the user. The dialog contents -// should be loaded from the given URL. The 'json_arguments' is a JSON string -// that the dialog can fetch using Chrome's JavaScript DOM bindings. This call -// will block until the dialog is closed. On success, 'json_retval' will -// contain the JSON string sent back by the dialog (using Chrome's JavaScript -// DOM bindings), and CPERR_SUCCESS is returned. 'json_retval' should be freed -// using CPB_Free when done. -typedef CPError (STDCALL *CPB_ShowHtmlDialogModalFunc)( - CPID id, CPBrowsingContext context, const char* url, int width, int height, - const char* json_arguments, char** json_retval); - -// Similar to CPB_ShowHtmlDialogModalFunc, but does not block. When the dialog -// is closed, CPP_HtmlDialogClosed is called with the JSON return value and the -// given 'plugin_context', which may be used by the plugin to associate other -// data with the dialog. -typedef CPError (STDCALL *CPB_ShowHtmlDialogFunc)( - CPID id, CPBrowsingContext context, const char* url, int width, int height, - const char* json_arguments, void* plugin_context); - -// Get the browsing context associated with the given NPAPI instance. -typedef CPBrowsingContext (STDCALL *CPB_GetBrowsingContextFromNPPFunc)( - struct _NPP* npp); - -// Queries for some meta data associated with the given browsing context. See -// CPBrowsingContextInfoType for possible queries. If buf_size is too small to -// contain the entire data, the return value will indicate the size required. -// Otherwise, the return value is a CPError or CPERR_SUCCESS. -typedef int (STDCALL *CPB_GetBrowsingContextInfoFunc)( - CPID id, CPBrowsingContext context, CPBrowsingContextInfoType type, - void* buf, uint32 buf_size); - -// Given an URL string, returns the string of command-line arguments that should -// be passed to start the browser at the given URL. 'arguments' should be freed -// using CPB_Free when done. -typedef CPError (STDCALL *CPB_GetCommandLineArgumentsFunc)( - CPID id, CPBrowsingContext context, const char* url, char** arguments); - -// Asks the browser to let the plugin handle the given UI command. When the -// command is invoked, the browser will call CPP_HandleCommand. 'command' -// should be an integer identifier. Currently only builtin commands are -// supported, but in the future we may want to let plugins add custom menu -// commands with their own descriptions. -typedef CPError (STDCALL *CPB_AddUICommandFunc)(CPID id, int command); - -// -// Functions related to making network requests. -// Both the host and plugin will implement their own versions of these. -// - -// Starts the request. Returns CPERR_SUCCESS if the request could be started -// immediately, at which point the response info is available to be read. -// Returns CPERR_IO_PENDING if an asynchronous operation was started, and the -// caller should wait for CPRR_StartCompleted to be called before reading the -// response info. Returns an error code on failure. -typedef CPError (STDCALL *CPR_StartRequestFunc)(CPRequest* request); - -// Stops or cancels the request. The caller should not access the request -// object after this call. If an asynchronous IO operation is pending, the -// operation is aborted and the caller will not receive a callback for it. -typedef void (STDCALL *CPR_EndRequestFunc)(CPRequest* request, CPError reason); - -// Sets the additional request headers to append to the standard headers that -// would normally be made with this request. Headers should be \r\n-delimited, -// with no terminating \r\n. Extra headers are not checked against the standard -// headers for duplicates. Must be called before CPRR_StartCompletedFunc. -// Plugins should avoid setting the following headers: User-Agent, -// Content-Length. -typedef void (STDCALL *CPR_SetExtraRequestHeadersFunc)(CPRequest* request, - const char* headers); - -// Sets the load flags for this request. 'flags' is a bitwise-OR of -// CPRequestLoadFlags. Must be called before CPRR_StartCompletedFunc. -typedef void (STDCALL *CPR_SetRequestLoadFlagsFunc)(CPRequest* request, - uint32 flags); - -// Appends binary data to the request body of a POST or PUT request. The caller -// should set the "Content-Type" header to the appropriate mime type using -// CPR_SetExtraRequestHeadersFunc. This can be called multiple times to append -// a sequence of data segments to upload. Must be called before -// CPR_StartRequestFunc. -typedef void (STDCALL *CPR_AppendDataToUploadFunc)( - CPRequest* request, const char* bytes, int bytes_len); - -// Appends the contents of a file to the request body of a POST or PUT request. -// 'offset' and 'length' can be used to append a subset of the file. Pass zero -// for 'length' and 'offset' to upload the entire file. 'offset' -// indicates where the data to upload begins in the file. 'length' indicates -// how much of the file to upload. A 'length' of zero is interpretted as to -// end-of-file. If 'length' and 'offset' indicate a range beyond end of file, -// the amount sent is clipped at eof. -// See CPR_AppendDataToUploadFunc for additional usage information. -// (added in v0.4) -typedef CPError (STDCALL *CPR_AppendFileToUploadFunc)( - CPRequest* request, const char* filepath, uint64 offset, uint64 length); - -// Queries for some response meta data. See CPResponseInfoType for possible -// queries. If buf_size is too small to contain the entire data, the return -// value will indicate the size required. Otherwise, the return value is a -// CPError or CPERR_SUCCESS. -typedef int (STDCALL *CPR_GetResponseInfoFunc)( - CPRequest* request, CPResponseInfoType type, - void* buf, uint32 buf_size); - -// Attempts to read a request's response data. The number of bytes read is -// returned; 0 indicates an EOF. CPERR_IO_PENDING is returned if an -// asynchronous operation was started, and CPRR_ReadCompletedFunc will be called -// when it completes; 'buf' must be available until the operation completes. -// Returns an error code on failure. -typedef int (STDCALL *CPR_ReadFunc)( - CPRequest* request, void* buf, uint32 buf_size); - -// -// Functions related to serving network requests. -// Both the host and plugin will implement their own versions of these. -// - -// Called upon a server-initiated redirect. The request will still hold the -// original URL, and 'new_url' will be the redirect destination. -typedef void (STDCALL *CPRR_ReceivedRedirectFunc)(CPRequest* request, - const char* new_url); - -// Called when an asynchronous CPR_StartRequest call has completed, once all -// redirects are followed. On success, 'result' holds CPERR_SUCCESS and the -// response info is available to be read via CPR_GetResponseInfo. On error, -// 'result' holds the error code. -typedef void (STDCALL *CPRR_StartCompletedFunc)(CPRequest* request, - CPError result); - -// Called when an asynchronous CPR_Read call has completed. On success, -// 'bytes_read' will hold the number of bytes read into the buffer that was -// passed to CPR_Read; 0 indicates an EOF, and the request object will be -// destroyed after the call completes. On failure, 'bytes_read' holds the error -// code. -typedef void (STDCALL *CPRR_ReadCompletedFunc)(CPRequest* request, - int bytes_read); - -// Called as upload progress is being made for async POST requests. -// (added in v0.5) -typedef void (STDCALL *CPRR_UploadProgressFunc)(CPRequest* request, - uint64 position, - uint64 size); - -// -// Functions to support the sending and receipt of messages between processes. -// - -// Returns true if the plugin process is running -typedef CPBool (STDCALL *CPB_IsPluginProcessRunningFunc)(CPID id); - -// Returns the type of the current process. -typedef CPProcessType (STDCALL *CPB_GetProcessTypeFunc)(CPID id); - -// Asks the browser to send raw data to the other process hosting an instance of -// this plugin. If needed, the plugin process will be started prior to sending -// the message. -typedef CPError (STDCALL *CPB_SendMessageFunc)(CPID id, - const void *data, - uint32 data_len); - -// Asks the browser to send raw data to the other process hosting an instance of -// this plugin. This function only works from the plugin or renderer process. -// This function blocks until the message is processed. The memory should be -// freed using CPB_Free when done. -typedef CPError (STDCALL *CPB_SendSyncMessageFunc)(CPID id, - const void *data, - uint32 data_len, - void **retval, - uint32 *retval_len); - -// This function asynchronously calls the provided function on the plugin -// thread. user_data is passed as the argument to the function. -typedef CPError (STDCALL *CPB_PluginThreadAsyncCallFunc)(CPID id, - void (*func)(void *), - void *user_data); - -// This function creates an open file dialog. The process is granted access -// to any files that are selected. |multiple_files| determines if more than -// one file can be selected. -typedef CPError (STDCALL *CPB_OpenFileDialogFunc)(CPID id, - CPBrowsingContext context, - bool multiple_files, - const char *title, - const char *filter, - void *user_data); - -// Informs the plugin of raw data having been sent from another process. -typedef void (STDCALL *CPP_OnMessageFunc)(void *data, uint32 data_len); - -// Informs the plugin of raw data having been sent from another process. -typedef void (STDCALL *CPP_OnSyncMessageFunc)(void *data, uint32 data_len, - void **retval, - uint32 *retval_len); - -// Informs the plugin that the file dialog has completed, and contains the -// results. -typedef void (STDCALL *CPP_OnFileDialogResultFunc)(void *data, - const char **files, - uint32 files_len); - -// Asks the browser to verify that NPObject* 'event' is the current drag event -// the browser is dispatching, and extract drag data from the event if so. On -// success, returns the drag 'identity' (an up-counter that the browser chrome -// increases each time a user drag enters a renderer tab), the drag 'event_id' -// and the 'drag_type' being a utf8 encoded string with values "Files", "Text" -// or "URL". If 'add_data' is true, also return the 'drag_data', again a utf8 -// encoded string with the data for the drag type. For drag type "Files", the -// data is a backspace delimited list of file paths. -// -// The call fails with a CPError if 'event' is an invalid drag event, and sets -// the 'identity' and 'event_id' to 0. Note: on success, non-NULL 'drag_type' -// and 'drag_data' should be freed with CPB_Free() when done. -typedef CPError (STDCALL *CPB_GetDragDataFunc)( - CPID id, CPBrowsingContext context, struct NPObject* event, bool add_data, - int32* identity, int32* event_id, char** drag_type, char** drag_data); - -// Asks the browser to verify that NPObject* 'event' is the current drag event -// the browser is dispatching and show the requested drop 'effect' if so. The -// browser displays drop effects during dragenter and dragover events, to give -// user visible feedback (with a drag cursor, typically) to indicate whether a -// subsequent drop event will succeed or not. The implementation supports the -// so-called "copy" and "none" effects. When 'effect' is non-zero, the "copy" -// effect is shown. Otherwise, the "none" effect is shown, which prevents the -// subsequent drop event from succeeding. Returns CPError on failure, meaning -// the 'event' is an invalid drag event. -// -// Note: 'effect' is int to allow for new effects in future. For example, the -// HTML5-defined drop effects "move" and "link". -typedef CPError (STDCALL *CPB_SetDropEffectFunc)( - CPID id, CPBrowsingContext context, struct NPObject* event, int effect); - -// For drag type "Files", the drag data returned by CPB_GetDragDataFunc() is a -// backspace delimited list of file paths. Use this routine to pass that data -// to the browser process to verify that the renderer has permission to access -// the files. Returns CPERR_SUCCESS if access is allowed. -typedef CPError (STDCALL *CPB_AllowFileDropFunc)( - CPID id, CPBrowsingContext context, const char* file_drag_data); - -// Function table for issuing requests using via the other side's network stack. -// For the plugin, this functions deal with issuing requests through the -// browser. For the browser, these functions deal with allowing the plugin to -// intercept requests. -typedef struct _CPRequestFuncs { - uint16 size; - CPR_SetExtraRequestHeadersFunc set_extra_request_headers; - CPR_SetRequestLoadFlagsFunc set_request_load_flags; - CPR_AppendDataToUploadFunc append_data_to_upload; - CPR_StartRequestFunc start_request; - CPR_EndRequestFunc end_request; - CPR_GetResponseInfoFunc get_response_info; - CPR_ReadFunc read; - CPR_AppendFileToUploadFunc append_file_to_upload; -} CPRequestFuncs; - -// Function table for handling requests issued by the other side. For the -// plugin, these deal with serving requests that the plugin has intercepted. For -// the browser, these deal with serving requests that the plugin has issued -// through us. -typedef struct _CPResponseFuncs { - uint16 size; - CPRR_ReceivedRedirectFunc received_redirect; - CPRR_StartCompletedFunc start_completed; - CPRR_ReadCompletedFunc read_completed; - CPRR_UploadProgressFunc upload_progress; -} CPResponseFuncs; - -// Function table of CPP functions (functions provided by plugin to host). This -// structure is filled in by the plugin in the CP_Initialize call, except for -// the 'size' field, which is set by the browser. The version fields should be -// set to those that the plugin was compiled using. -typedef struct _CPPluginFuncs { - uint16 size; - uint16 version; - CPRequestFuncs* request_funcs; - CPResponseFuncs* response_funcs; - CPP_ShutdownFunc shutdown; - CPP_ShouldInterceptRequestFunc should_intercept_request; - CPP_OnMessageFunc on_message; - CPP_HtmlDialogClosedFunc html_dialog_closed; - CPP_HandleCommandFunc handle_command; - CPP_OnSyncMessageFunc on_sync_message; - CPP_OnFileDialogResultFunc on_file_dialog_result; -} CPPluginFuncs; - -// Function table CPB functions (functions provided by host to plugin). -// This structure is filled in by the browser and provided to the plugin. The -// plugin will likely want to save a copy of this structure to make calls -// back to the browser. -typedef struct _CPBrowserFuncs { - uint16 size; - uint16 version; - CPRequestFuncs* request_funcs; - CPResponseFuncs* response_funcs; - CPB_EnableRequestInterceptFunc enable_request_intercept; - CPB_CreateRequestFunc create_request; - CPB_GetCookiesFunc get_cookies; - CPB_AllocFunc alloc; - CPB_FreeFunc free; - CPB_SetKeepProcessAliveFunc set_keep_process_alive; - CPB_ShowHtmlDialogModalFunc show_html_dialog_modal; - CPB_ShowHtmlDialogFunc show_html_dialog; - CPB_IsPluginProcessRunningFunc is_plugin_process_running; - CPB_GetProcessTypeFunc get_process_type; - CPB_SendMessageFunc send_message; - CPB_GetBrowsingContextFromNPPFunc get_browsing_context_from_npp; - CPB_GetBrowsingContextInfoFunc get_browsing_context_info; - CPB_GetCommandLineArgumentsFunc get_command_line_arguments; - CPB_AddUICommandFunc add_ui_command; - CPB_HandleCommandFunc handle_command; - CPB_SendSyncMessageFunc send_sync_message; - CPB_PluginThreadAsyncCallFunc plugin_thread_async_call; - CPB_OpenFileDialogFunc open_file_dialog; - CPB_GetDragDataFunc get_drag_data; - CPB_SetDropEffectFunc set_drop_effect; - CPB_AllowFileDropFunc allow_file_drop; -} CPBrowserFuncs; - - -// -// DLL exports -// - -// This export is optional. -// Prior to calling CP_Initialize, the browser may negotiate with the plugin -// regarding which version of the CPAPI to utilize. 'min_version' is the -// lowest version of the interface supported by the browser, 'max_version' is -// the highest supported version. The plugin can specify which version within -// the range should be used. This version will be reflected in the version field -// of the CPBrowserFuncs struct passed to CP_Initialize. If this function -// returns an error code, CP_Initialize will not be called. If function is not -// exported by the chrome plugin module, CP_Initiailize will be called with -// a version of the host's choosing. -typedef CPError (STDCALL *CP_VersionNegotiateFunc)( - uint16 min_version, uint16 max_version, uint16 *selected_version); - -// 'bfuncs' are the browser functions provided to the plugin. 'id' is the -// plugin identifier that the plugin should use when calling browser functions. -// The plugin should initialize 'pfuncs' with pointers to its own functions, -// or return an error code. -// All functions and entry points should be called on the same thread. The -// plugin should not attempt to call a browser function from a thread other -// than the one CP_InitializeFunc is called from. -typedef CPError (STDCALL *CP_InitializeFunc)( - CPID id, const CPBrowserFuncs* bfuncs, CPPluginFuncs* pfuncs); - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif // CHROME_COMMON_CHROME_PLUGIN_API_H_ diff --git a/chrome/common/chrome_plugin_lib.cc b/chrome/common/chrome_plugin_lib.cc deleted file mode 100644 index 7df1837..0000000 --- a/chrome/common/chrome_plugin_lib.cc +++ /dev/null @@ -1,292 +0,0 @@ -// Copyright (c) 2011 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/common/chrome_plugin_lib.h" - -#include "base/command_line.h" -#include "base/hash_tables.h" -#include "base/message_loop.h" -#include "base/metrics/histogram.h" -#include "base/path_service.h" -#include "base/perftimer.h" -#include "base/string_util.h" -#include "base/threading/platform_thread.h" -#include "base/threading/thread.h" -#include "chrome/common/chrome_counters.h" -#include "chrome/common/chrome_paths.h" -#include "chrome/common/chrome_switches.h" -#include "content/common/notification_service.h" -#include "webkit/plugins/npapi/plugin_list.h" - -#if defined(OS_WIN) -#include "base/win/registry.h" -#endif - -using base::TimeDelta; - -// TODO(port): revisit when plugins happier -#if defined(OS_WIN) -const wchar_t ChromePluginLib::kRegistryChromePlugins[] = - L"Software\\Google\\Chrome\\Plugins"; -static const wchar_t kRegistryLoadOnStartup[] = L"LoadOnStartup"; -static const wchar_t kRegistryPath[] = L"Path"; -#endif - -typedef base::hash_map<FilePath, scoped_refptr<ChromePluginLib> > - PluginMap; - -// A map of all the instantiated plugins. -static PluginMap* g_loaded_libs; - -// The thread plugins are loaded and used in, lazily initialized upon -// the first creation call. -static base::PlatformThreadId g_plugin_thread_id = 0; -static MessageLoop* g_plugin_thread_loop = NULL; - -static bool IsSingleProcessMode() { - // We don't support ChromePlugins in single-process mode. - return CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess); -} - -// static -bool ChromePluginLib::IsInitialized() { - return (g_loaded_libs != NULL); -} - -// static -ChromePluginLib* ChromePluginLib::Create(const FilePath& filename, - const CPBrowserFuncs* bfuncs) { - // Keep a map of loaded plugins to ensure we only load each library once. - if (!g_loaded_libs) { - g_loaded_libs = new PluginMap(); - g_plugin_thread_id = base::PlatformThread::CurrentId(); - g_plugin_thread_loop = MessageLoop::current(); - } - DCHECK(IsPluginThread()); - - PluginMap::const_iterator iter = g_loaded_libs->find(filename); - if (iter != g_loaded_libs->end()) - return iter->second; - - scoped_refptr<ChromePluginLib> plugin(new ChromePluginLib(filename)); - if (!plugin->CP_Initialize(bfuncs)) - return NULL; - - (*g_loaded_libs)[filename] = plugin; - return plugin; -} - -// static -ChromePluginLib* ChromePluginLib::Find(const FilePath& filename) { - if (g_loaded_libs) { - PluginMap::const_iterator iter = g_loaded_libs->find(filename); - if (iter != g_loaded_libs->end()) - return iter->second; - } - return NULL; -} - -// static -void ChromePluginLib::Destroy(const FilePath& filename) { - DCHECK(g_loaded_libs); - PluginMap::iterator iter = g_loaded_libs->find(filename); - if (iter != g_loaded_libs->end()) { - iter->second->Unload(); - g_loaded_libs->erase(iter); - } -} - -// static -bool ChromePluginLib::IsPluginThread() { - return base::PlatformThread::CurrentId() == g_plugin_thread_id; -} - -// static -MessageLoop* ChromePluginLib::GetPluginThreadLoop() { - return g_plugin_thread_loop; -} - -// static -void ChromePluginLib::RegisterPluginsWithNPAPI() { - // We don't support ChromePlugins in single-process mode. - if (IsSingleProcessMode()) - return; - - FilePath path; - // Register Gears, if available. - if (PathService::Get(chrome::FILE_GEARS_PLUGIN, &path)) - webkit::npapi::PluginList::Singleton()->AddExtraPluginPath(path); -} - -static void LogPluginLoadTime(const TimeDelta &time) { - UMA_HISTOGRAM_TIMES("Gears.LoadTime", time); -} - -// static -void ChromePluginLib::LoadChromePlugins(const CPBrowserFuncs* bfuncs) { - static bool loaded = false; - if (loaded) - return; - loaded = true; - - // We don't support ChromePlugins in single-process mode. - if (IsSingleProcessMode()) - return; - - FilePath path; - if (!PathService::Get(chrome::FILE_GEARS_PLUGIN, &path)) - return; - - PerfTimer timer; - ChromePluginLib::Create(path, bfuncs); - LogPluginLoadTime(timer.Elapsed()); - - // TODO(mpcomplete): disabled loading of plugins from the registry until we - // phase out registry keys from the gears installer. -#if 0 - for (RegistryKeyIterator iter(HKEY_CURRENT_USER, kRegistryChromePlugins); - iter.Valid(); ++iter) { - // Use the registry to gather plugin across the file system. - std::wstring reg_path = kRegistryChromePlugins; - reg_path.append(L"\\"); - reg_path.append(iter.Name()); - base::win::RegKey key(HKEY_CURRENT_USER, reg_path.c_str()); - - DWORD is_persistent = 0; - key.ReadValueDW(kRegistryLoadOnStartup, &is_persistent); - if (is_persistent) { - std::wstring path; - if (key.ReadValue(kRegistryPath, &path) == ERROR_SUCCESS) { - ChromePluginLib::Create(path, bfuncs); - } - } - } -#endif -} - -// static -void ChromePluginLib::UnloadAllPlugins() { - if (g_loaded_libs) { - PluginMap::iterator it; - for (PluginMap::iterator it = g_loaded_libs->begin(); - it != g_loaded_libs->end(); ++it) { - it->second->Unload(); - } - delete g_loaded_libs; - g_loaded_libs = NULL; - } -} - -const CPPluginFuncs& ChromePluginLib::functions() const { - DCHECK(initialized_); - DCHECK(IsPluginThread()); - return plugin_funcs_; -} - -ChromePluginLib::ChromePluginLib(const FilePath& filename) - : filename_(filename), -#if defined(OS_WIN) - module_(0), -#endif - initialized_(false), - CP_VersionNegotiate_(NULL), - CP_Initialize_(NULL), - CP_Test_(NULL) { - memset((void*)&plugin_funcs_, 0, sizeof(plugin_funcs_)); -} - -ChromePluginLib::~ChromePluginLib() { -} - -bool ChromePluginLib::CP_Initialize(const CPBrowserFuncs* bfuncs) { - VLOG(1) << "ChromePluginLib::CP_Initialize(" << filename_.value() - << "): initialized=" << initialized_; - if (initialized_) - return true; - - if (!Load()) - return false; - - if (CP_VersionNegotiate_) { - uint16 selected_version = 0; - CPError rv = CP_VersionNegotiate_(CP_VERSION, CP_VERSION, - &selected_version); - if ((rv != CPERR_SUCCESS) || (selected_version != CP_VERSION)) - return false; - } - - plugin_funcs_.size = sizeof(plugin_funcs_); - CPError rv = CP_Initialize_(cpid(), bfuncs, &plugin_funcs_); - initialized_ = (rv == CPERR_SUCCESS) && - (CP_GET_MAJOR_VERSION(plugin_funcs_.version) == CP_MAJOR_VERSION) && - (CP_GET_MINOR_VERSION(plugin_funcs_.version) <= CP_MINOR_VERSION); - VLOG(1) << "ChromePluginLib::CP_Initialize(" << filename_.value() - << "): initialized=" << initialized_ << "): result=" << rv; - - return initialized_; -} - -void ChromePluginLib::CP_Shutdown() { - DCHECK(initialized_); - functions().shutdown(); - initialized_ = false; - memset((void*)&plugin_funcs_, 0, sizeof(plugin_funcs_)); -} - -int ChromePluginLib::CP_Test(void* param) { - DCHECK(initialized_); - if (!CP_Test_) - return -1; - return CP_Test_(param); -} - -bool ChromePluginLib::Load() { -#if !defined(OS_WIN) - // Mac and Linux won't implement Gears. - return false; -#else - DCHECK(module_ == 0); - - module_ = LoadLibrary(filename_.value().c_str()); - if (module_ == 0) - return false; - - // required initialization function - CP_Initialize_ = reinterpret_cast<CP_InitializeFunc> - (GetProcAddress(module_, "CP_Initialize")); - - if (!CP_Initialize_) { - FreeLibrary(module_); - module_ = 0; - return false; - } - - // optional version negotiation function - CP_VersionNegotiate_ = reinterpret_cast<CP_VersionNegotiateFunc> - (GetProcAddress(module_, "CP_VersionNegotiate")); - - // optional test function - CP_Test_ = reinterpret_cast<CP_TestFunc> - (GetProcAddress(module_, "CP_Test")); - - return true; -#endif -} - -void ChromePluginLib::Unload() { - NotificationService::current()->Notify( - NotificationType::CHROME_PLUGIN_UNLOADED, - Source<ChromePluginLib>(this), - NotificationService::NoDetails()); - - if (initialized_) - CP_Shutdown(); - -#if defined(OS_WIN) - if (module_) { - FreeLibrary(module_); - module_ = 0; - } -#endif -} diff --git a/chrome/common/chrome_plugin_lib.h b/chrome/common/chrome_plugin_lib.h deleted file mode 100644 index b8e447b..0000000 --- a/chrome/common/chrome_plugin_lib.h +++ /dev/null @@ -1,105 +0,0 @@ -// Copyright (c) 2010 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_COMMON_CHROME_PLUGIN_LIB_H_ -#define CHROME_COMMON_CHROME_PLUGIN_LIB_H_ -#pragma once - -#include "base/basictypes.h" -#include "base/file_path.h" -#include "base/ref_counted.h" -#include "chrome/common/chrome_plugin_api.h" - -class MessageLoop; - -// A ChromePluginLib is a single Chrome Plugin Library. -// This class is used in the browser process (IO thread), and the plugin process -// (plugin thread). It should not be accessed on other threads, because it -// issues a NOTIFY_CHROME_PLUGIN_UNLOADED notification. -class ChromePluginLib : public base::RefCounted<ChromePluginLib> { - public: - static bool IsInitialized(); - static ChromePluginLib* Create(const FilePath& filename, - const CPBrowserFuncs* bfuncs); - static ChromePluginLib* Find(const FilePath& filename); - static void Destroy(const FilePath& filename); - static bool IsPluginThread(); - static MessageLoop* GetPluginThreadLoop(); - - static ChromePluginLib* FromCPID(CPID id) { - return reinterpret_cast<ChromePluginLib*>(id); - } - - // Adds Chrome plugins to the NPAPI plugin list. - static void RegisterPluginsWithNPAPI(); - - // Loads all the plugins that are marked as "LoadOnStartup" in the - // registry. This should only be called in the browser process. - static void LoadChromePlugins(const CPBrowserFuncs* bfuncs); - - // Unloads all the loaded plugins and cleans up the plugin map. - static void UnloadAllPlugins(); - - // Returns true if the plugin is currently loaded. - bool is_loaded() const { return initialized_; } - - // Get the Plugin's function pointer table. - const CPPluginFuncs& functions() const; - - CPID cpid() { return reinterpret_cast<CPID>(this); } - - const FilePath& filename() { return filename_; } - - // Plugin API functions - - // Method to call a test function in the plugin, used for unit tests. - int CP_Test(void* param); - -#if defined(OS_WIN) - // The registry path to search for Chrome Plugins/ - static const TCHAR kRegistryChromePlugins[]; -#endif // defined(OS_WIN) - - private: - friend class base::RefCounted<ChromePluginLib>; - - explicit ChromePluginLib(const FilePath& filename); - ~ChromePluginLib(); - - // Method to initialize a Plugin. - // Initialize can be safely called multiple times. - bool CP_Initialize(const CPBrowserFuncs* bfuncs); - - // Method to shutdown a Plugin. - void CP_Shutdown(); - - // Attempts to load the plugin. - // Returns true if it is a legitimate plugin, false otherwise - bool Load(); - - // Unloads the plugin. - void Unload(); - - FilePath filename_; // the path to the plugin -#if defined(OS_WIN) - // TODO(port): Remove ifdefs when we have portable replacement for HMODULE. - HMODULE module_; // the opened plugin handle -#endif // defined(OS_WIN) - bool initialized_; // is the plugin initialized - - // Exported symbols from the plugin, looked up by name. - CP_VersionNegotiateFunc CP_VersionNegotiate_; - CP_InitializeFunc CP_Initialize_; - - // Additional function pointers provided by the plugin. - CPPluginFuncs plugin_funcs_; - - // Used for unit tests. - typedef int (STDCALL *CP_TestFunc)(void*); - CP_TestFunc CP_Test_; - - DISALLOW_COPY_AND_ASSIGN(ChromePluginLib); -}; - -#endif // CHROME_COMMON_CHROME_PLUGIN_LIB_H_ diff --git a/chrome/common/chrome_plugin_util.cc b/chrome/common/chrome_plugin_util.cc deleted file mode 100644 index 1ed4b81..0000000 --- a/chrome/common/chrome_plugin_util.cc +++ /dev/null @@ -1,180 +0,0 @@ -// Copyright (c) 2011 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/common/chrome_plugin_util.h" - -#include <algorithm> - -#include "base/command_line.h" -#include "base/file_util.h" -#include "base/message_loop.h" -#include "base/string_util.h" -#include "base/utf_string_conversions.h" -#include "chrome/common/chrome_plugin_lib.h" -#include "chrome/common/chrome_switches.h" -#include "content/common/notification_service.h" -#include "net/base/load_flags.h" -#include "net/http/http_response_headers.h" - -// -// ScopableCPRequest -// - -ScopableCPRequest::ScopableCPRequest(const char* u, const char* m, - CPBrowsingContext c) { - pdata = NULL; - data = NULL; -#if defined(OS_WIN) - url = _strdup(u); - method = _strdup(m); -#else - url = strdup(u); - method = strdup(m); -#endif - context = c; -} - -ScopableCPRequest::~ScopableCPRequest() { - pdata = NULL; - data = NULL; - free(const_cast<char*>(url)); - free(const_cast<char*>(method)); -} - -// -// PluginHelper -// - -// static -void PluginHelper::DestroyAllHelpersForPlugin(ChromePluginLib* plugin) { - NotificationService::current()->Notify( - NotificationType::CHROME_PLUGIN_UNLOADED, - Source<ChromePluginLib>(plugin), - NotificationService::NoDetails()); -} - -PluginHelper::PluginHelper(ChromePluginLib* plugin) : plugin_(plugin) { - DCHECK(CalledOnValidThread()); - registrar_.Add(this, NotificationType::CHROME_PLUGIN_UNLOADED, - Source<ChromePluginLib>(plugin_)); -} - -PluginHelper::~PluginHelper() { - DCHECK(CalledOnValidThread()); -} - -void PluginHelper::Observe(NotificationType type, - const NotificationSource& source, - const NotificationDetails& details) { - DCHECK(CalledOnValidThread()); - DCHECK(type == NotificationType::CHROME_PLUGIN_UNLOADED); - DCHECK(plugin_ == Source<ChromePluginLib>(source).ptr()); - - delete this; -} - -// -// PluginResponseUtils -// - -uint32 PluginResponseUtils::CPLoadFlagsToNetFlags(uint32 flags) { - uint32 net_flags = 0; -#define HANDLE_FLAG(name) \ - if (flags & CPREQUEST##name) \ - net_flags |= net::name - - HANDLE_FLAG(LOAD_VALIDATE_CACHE); - HANDLE_FLAG(LOAD_BYPASS_CACHE); - HANDLE_FLAG(LOAD_PREFERRING_CACHE); - HANDLE_FLAG(LOAD_ONLY_FROM_CACHE); - HANDLE_FLAG(LOAD_DISABLE_CACHE); - HANDLE_FLAG(LOAD_DISABLE_INTERCEPT); - - net_flags |= net::LOAD_ENABLE_UPLOAD_PROGRESS; - - return net_flags; -} - -int PluginResponseUtils::GetResponseInfo( - const net::HttpResponseHeaders* response_headers, - CPResponseInfoType type, void* buf, size_t buf_size) { - if (!response_headers) - return CPERR_FAILURE; - - switch (type) { - case CPRESPONSEINFO_HTTP_STATUS: - if (buf && buf_size) { - int status = response_headers->response_code(); - memcpy(buf, &status, std::min(buf_size, sizeof(status))); - } - break; - case CPRESPONSEINFO_HTTP_RAW_HEADERS: { - const std::string& headers = response_headers->raw_headers(); - if (buf_size < headers.size()+1) - return static_cast<int>(headers.size()+1); - if (buf) - memcpy(buf, headers.c_str(), headers.size()+1); - break; - } - default: - return CPERR_INVALID_VERSION; - } - - return CPERR_SUCCESS; -} - -CPError CPB_GetCommandLineArgumentsCommon(const char* url, - std::string* arguments) { - // TODO(aa): all of this code is only used by Gears, which we are removing. -#if defined(OS_WIN) - const CommandLine cmd = *CommandLine::ForCurrentProcess(); - std::wstring arguments_w; - - // Use the same UserDataDir for new launches that we currently have set. - FilePath user_data_dir = cmd.GetSwitchValuePath(switches::kUserDataDir); - if (!user_data_dir.empty()) { - // Make sure user_data_dir is an absolute path. - if (file_util::AbsolutePath(&user_data_dir) && - file_util::PathExists(user_data_dir)) { - // TODO(evanm): use CommandLine APIs instead of this. - arguments_w += std::wstring(L"--") + ASCIIToWide(switches::kUserDataDir) + - L"=\"" + user_data_dir.value() + L"\" "; - } - } - - // Use '--app=url' instead of just 'url' to launch the browser with minimal - // chrome. - // Note: Do not change this flag! Old Gears shortcuts will break if you do! - std::string url_string(url); - ReplaceSubstringsAfterOffset(&url_string, 0, "\\", "%5C"); - ReplaceSubstringsAfterOffset(&url_string, 0, "\"", "%22"); - ReplaceSubstringsAfterOffset(&url_string, 0, ";", "%3B"); - ReplaceSubstringsAfterOffset(&url_string, 0, "$", "%24"); - // Windows shortcuts can't escape % so we use \x instead. - ReplaceSubstringsAfterOffset(&url_string, 0, "%", "\\x"); - std::wstring url_w = UTF8ToWide(url_string); - // TODO(evanm): use CommandLine APIs instead of this. - arguments_w += std::wstring(L"--") + ASCIIToWide(switches::kApp) + - L"=\"" + url_w + L"\""; - - *arguments = WideToUTF8(arguments_w); -#else - // None of this code is used on non-Windows platforms. - NOTREACHED(); -#endif - - return CPERR_SUCCESS; -} - -// -// Host functions shared by browser and plugin processes -// - -void* STDCALL CPB_Alloc(uint32 size) { - return malloc(size); -} - -void STDCALL CPB_Free(void* memory) { - free(memory); -} diff --git a/chrome/common/chrome_plugin_util.h b/chrome/common/chrome_plugin_util.h deleted file mode 100644 index 17fdbe5..0000000 --- a/chrome/common/chrome_plugin_util.h +++ /dev/null @@ -1,90 +0,0 @@ -// Copyright (c) 2011 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_COMMON_CHROME_PLUGIN_UTIL_H_ -#define CHROME_COMMON_CHROME_PLUGIN_UTIL_H_ -#pragma once - -#include <string> - -#include "base/basictypes.h" -#include "base/ref_counted.h" -#include "base/threading/non_thread_safe.h" -#include "chrome/common/chrome_plugin_api.h" -#include "content/common/notification_observer.h" -#include "content/common/notification_registrar.h" - -class ChromePluginLib; -class MessageLoop; -namespace net { -class HttpResponseHeaders; -} - -// A helper struct to ensure the CPRequest data is cleaned up when done. -// This class is reused for requests made by the browser (and intercepted by the -// plugin) as well as those made by the plugin. -struct ScopableCPRequest : public CPRequest { - template<class T> - static T GetData(CPRequest* request) { - return static_cast<T>(static_cast<ScopableCPRequest*>(request)->data); - } - - ScopableCPRequest(const char* url, const char* method, - CPBrowsingContext context); - ~ScopableCPRequest(); - - void* data; -}; - -// This is a base class for plugin-related objects that need to go away when -// the plugin unloads. This object also verifies that it is created and -// destroyed on the same thread. -class PluginHelper : public NotificationObserver, - public base::NonThreadSafe { - public: - static void DestroyAllHelpersForPlugin(ChromePluginLib* plugin); - - explicit PluginHelper(ChromePluginLib* plugin); - virtual ~PluginHelper(); - - // NotificationObserver - virtual void Observe(NotificationType type, - const NotificationSource& source, - const NotificationDetails& details); - - protected: - NotificationRegistrar registrar_; - - scoped_refptr<ChromePluginLib> plugin_; - - DISALLOW_COPY_AND_ASSIGN(PluginHelper); -}; - -// A class of utility functions for dealing with request responses. -class PluginResponseUtils { - public: - // Helper to convert request load flags from the plugin API to the net API - // versions. - static uint32 CPLoadFlagsToNetFlags(uint32 flags); - - // Common implementation of a CPR_GetResponseInfo call. - static int GetResponseInfo( - const net::HttpResponseHeaders* response_headers, - CPResponseInfoType type, void* buf, size_t buf_size); -}; - -// Helper to allocate a string using the given CPB_Alloc function. -inline char* CPB_StringDup(CPB_AllocFunc alloc, const std::string& str) { - char* cstr = static_cast<char*>(alloc(static_cast<uint32>(str.length() + 1))); - memcpy(cstr, str.c_str(), str.length() + 1); // Include null terminator. - return cstr; -} - -CPError CPB_GetCommandLineArgumentsCommon(const char* url, - std::string* arguments); - -void* STDCALL CPB_Alloc(uint32 size); -void STDCALL CPB_Free(void* memory); - -#endif // CHROME_COMMON_CHROME_PLUGIN_UTIL_H_ diff --git a/chrome/common/chrome_switches.cc b/chrome/common/chrome_switches.cc index 5c845cd..ca1c6bf 100644 --- a/chrome/common/chrome_switches.cc +++ b/chrome/common/chrome_switches.cc @@ -817,10 +817,6 @@ const char kParentProfile[] = "parent-profile"; // See kRecordMode. const char kPlaybackMode[] = "playback-mode"; -// Specifies the plugin data directory, which is where plugins (Gears -// specifically) will store its state. -const char kPluginDataDir[] = "plugin-data-dir"; - // Controls speculative prerendering of pages, and content prefetching. Both // are dispatched from <link rel=prefetch href=...> elements. const char kPrerender[] = "prerender"; @@ -1188,9 +1184,6 @@ const char kDebugViewsPaint[] = "debug-views-paint"; // the expiration of credentials during testing. const char kClearTokenService[] = "clear-token-service"; -// Debug only switch to specify which gears plugin dll to load. -const char kGearsPluginPathOverride[] = "gears-plugin-path"; - // Sets a token in the token service, for testing. const char kSetToken[] = "set-token"; diff --git a/chrome/common/chrome_switches.h b/chrome/common/chrome_switches.h index 0a50a3f..855a94e 100644 --- a/chrome/common/chrome_switches.h +++ b/chrome/common/chrome_switches.h @@ -232,7 +232,6 @@ extern const char kPackExtension[]; extern const char kPackExtensionKey[]; extern const char kParentProfile[]; extern const char kPlaybackMode[]; -extern const char kPluginDataDir[]; extern const char kPrerender[]; extern const char kPrerenderSwitchValueAuto[]; extern const char kPrerenderSwitchValueDisabled[]; @@ -354,7 +353,6 @@ extern const char kDebugViewsPaint[]; #ifndef NDEBUG extern const char kClearTokenService[]; -extern const char kGearsPluginPathOverride[]; extern const char kSetToken[]; extern const char kWebSocketLiveExperimentHost[]; #endif diff --git a/chrome/common/gears_api.h b/chrome/common/gears_api.h deleted file mode 100644 index 2b2f425..0000000 --- a/chrome/common/gears_api.h +++ /dev/null @@ -1,98 +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. -// -// This header specifies extensions to the Chrome Plugin API to support Gears. - -#ifndef CHROME_COMMON_GEARS_API_H__ -#define CHROME_COMMON_GEARS_API_H__ -#pragma once - -#include "chrome/common/chrome_plugin_api.h" - -#ifdef __cplusplus -extern "C" { -#endif - -// CommandIDs used when Chrome calls into Gears using CPP_HandleCommand. -// Note: do not change the enum values. We want to preserve backwards -// compatibility. -typedef enum { - // Ask gears to show its settings dialog. Typical usage is for the plugin - // to display it using a call to CPB_ShowHtmlDialog. No command_data is - // provided. - GEARSPLUGINCOMMAND_SHOW_SETTINGS = 0, - - // Ask gears to create a shortcut to a web page. command_data points - // to a GearsShortcutData struct. - GEARSPLUGINCOMMAND_CREATE_SHORTCUT = 1, - - // Query gears for the list of installed shortcuts. command_data points - // to a GearsShortcutList struct. - GEARSPLUGINCOMMAND_GET_SHORTCUT_LIST = 2, -} GearsPluginCommand; - -// CommandIDs used when Gears calls into Chrome using CPB_HandleCommand. -// Note: do not change the enum values. We want to preserve backwards -// compatibility. -typedef enum { - // Tell chrome that the GEARSPLUGINCOMMAND_CREATE_SHORTCUT command is done, - // and the user has closed the dialog. command_data points to the same - // GearsShortcutData struct that was passed to the plugin command. - GEARSBROWSERCOMMAND_CREATE_SHORTCUT_DONE = 1, - - // Notifies the browser of changes to the gears shortcuts database. - // command_data is null. - GEARSBROWSERCOMMAND_NOTIFY_SHORTCUTS_CHANGED = 3, -} GearsBrowserCommand; - -// Note: currently only 16x16, 32x32, 48x48, and 128x128 icons are supported. -typedef struct _GearsShortcutIcon { - const char* size; // unused - const char* url; // the URL of the icon, which should be a PNG image - int width; // width of the icon - int height; // height of the icon -} GearsShortcutIcon; - -// Command data for GEARSPLUGINCOMMAND_CREATE_SHORTCUT. -typedef struct _GearsShortcutData { - const char* name; // the shortcut's name (also used as the filename) - const char* url; // the URL that the shortcut should launch - const char* description; // an optional description - GearsShortcutIcon icons[4]; // list of icons to use for this shortcut -} GearsShortcutData; - -// Command data for GEARSPLUGINCOMMAND_CREATE_SHORTCUT used in 0.6 and later. -// This struct is backwards compatible with the first version. -// http://b/viewIssue?id=1331408 - Chrome sanitizes 'name' for compatibility -// with older versions of Gears that expect this. 'orig_name' is unsanitized, -// which allows Gears to do its own validation. -typedef struct _GearsShortcutData2 { - const char* name; // unused - for back compat with above struct - const char* url; // the URL that the shortcut should launch - const char* description; // an optional description - GearsShortcutIcon icons[4]; // list of icons to use for this shortcut - const char* orig_name; // the shortcut's unmodified filename (added in 0.6) -} GearsShortcutData2; - -// Command data for GEARSPLUGINCOMMAND_GET_SHORTCUT_LIST. -typedef struct _GearsShortcutList { - // Note: these are output params, set by Gears. There are no input params. - // Memory for these shortcuts, including the strings they hold, should be - // freed by the browser using CPB_Free. - GearsShortcutData* shortcuts; // array of installed shortcuts - uint32 num_shortcuts; // size of the array -} GearsShortcutList; - -// Command data for GEARSBROWSERCOMMAND_CREATE_SHORTCUT_DONE -typedef struct _GearsCreateShortcutResult { - GearsShortcutData2* shortcut; // pointer to struct passed to - // GEARSPLUGINCOMMAND_CREATE_SHORTCUT - CPError result; // CPERR_SUCCESS if shortcut was created, or error otherwise -} GearsCreateShortcutResult; - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif // CHROME_COMMON_GEARS_API_H_ diff --git a/chrome/common/geoposition.cc b/chrome/common/geoposition.cc index f8f087c..e3a2020 100644 --- a/chrome/common/geoposition.cc +++ b/chrome/common/geoposition.cc @@ -7,7 +7,7 @@ namespace { // Sentinel values to mark invalid data. (WebKit carries companion is_valid // bools for this purpose; we may eventually follow that approach, but -// sentinels worked OK in the gears code this is based on.) +// sentinels worked OK in the Gears code this is based on.) const double kBadLatitudeLongitude = 200; // Lowest point on land is at approximately -400 meters. const int kBadAltitude = -10000; diff --git a/chrome/common/net/url_fetcher_unittest.cc b/chrome/common/net/url_fetcher_unittest.cc index 5a3adbb..8e86d93 100644 --- a/chrome/common/net/url_fetcher_unittest.cc +++ b/chrome/common/net/url_fetcher_unittest.cc @@ -6,7 +6,6 @@ #include "base/synchronization/waitable_event.h" #include "base/threading/thread.h" #include "build/build_config.h" -#include "chrome/common/chrome_plugin_lib.h" #include "chrome/common/net/url_fetcher.h" #include "chrome/common/net/url_request_context_getter.h" #include "net/http/http_response_headers.h" @@ -96,8 +95,6 @@ class URLFetcherTest : public testing::Test, public URLFetcher::Delegate { io_message_loop_proxy_ = base::MessageLoopProxy::CreateForCurrentThread(); - // Ensure that any plugin operations done by other tests are cleaned up. - ChromePluginLib::UnloadAllPlugins(); #if defined(USE_NSS) net::EnsureOCSPInit(); #endif diff --git a/chrome/common/net/url_request_intercept_job.cc b/chrome/common/net/url_request_intercept_job.cc deleted file mode 100644 index 8b335a4..0000000 --- a/chrome/common/net/url_request_intercept_job.cc +++ /dev/null @@ -1,238 +0,0 @@ -// Copyright (c) 2011 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 job type handles Chrome plugin network interception. When a plugin -// wants to intercept a request, a job of this type is created. The intercept -// job communicates with the plugin to retrieve the response headers and data. - -#include "chrome/common/net/url_request_intercept_job.h" - -#include <vector> - -#include "base/compiler_specific.h" -#include "base/message_loop.h" -#include "base/string_util.h" -#include "chrome/common/chrome_plugin_lib.h" -#include "content/common/notification_source.h" -#include "net/base/io_buffer.h" -#include "net/base/net_errors.h" -#include "net/base/x509_certificate.h" -#include "net/http/http_response_headers.h" -#include "net/url_request/url_request.h" - -using base::Time; -using base::TimeDelta; - -// -// URLRequestInterceptJob -// - -URLRequestInterceptJob::URLRequestInterceptJob(net::URLRequest* request, - ChromePluginLib* plugin, - ScopableCPRequest* cprequest) - : net::URLRequestJob(request), - cprequest_(cprequest), - plugin_(plugin), - read_buffer_(NULL), - ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) { - cprequest_->data = this; // see FromCPRequest(). - - registrar_.Add(this, NotificationType::CHROME_PLUGIN_UNLOADED, - Source<ChromePluginLib>(plugin_)); -} - -URLRequestInterceptJob::~URLRequestInterceptJob() { - if (plugin_) { - plugin_->functions().request_funcs->end_request(cprequest_.get(), - CPERR_SUCCESS); - } -} - -void URLRequestInterceptJob::DetachPlugin() { - registrar_.RemoveAll(); - plugin_ = NULL; -} - -void URLRequestInterceptJob::Start() { - // Start reading asynchronously so that all error reporting and data - // callbacks happen as they would for network requests. - MessageLoop::current()->PostTask( - FROM_HERE, - method_factory_.NewRunnableMethod( - &URLRequestInterceptJob::StartAsync)); -} - -void URLRequestInterceptJob::Kill() { - if (plugin_) { - plugin_->functions().request_funcs->end_request(cprequest_.get(), - CPERR_CANCELLED); - DetachPlugin(); - } - net::URLRequestJob::Kill(); - method_factory_.RevokeAll(); -} - -bool URLRequestInterceptJob::ReadRawData(net::IOBuffer* dest, int dest_size, - int* bytes_read) { - DCHECK_NE(dest_size, 0); - DCHECK(bytes_read); - - if (!plugin_) - return false; - - int rv = plugin_->functions().request_funcs->read(cprequest_.get(), - dest->data(), dest_size); - if (rv >= 0) { - *bytes_read = rv; - return true; - } - - if (rv == CPERR_IO_PENDING) { - read_buffer_ = dest; - read_buffer_size_ = dest_size; - SetStatus(net::URLRequestStatus(net::URLRequestStatus::IO_PENDING, 0)); - } else { - // TODO(mpcomplete): better error code - NotifyDone(net::URLRequestStatus(net::URLRequestStatus::FAILED, - net::ERR_FAILED)); - } - - return false; -} - -bool URLRequestInterceptJob::GetMimeType(std::string* mime_type) const { - return request_->response_headers()->GetMimeType(mime_type); -} - -bool URLRequestInterceptJob::GetCharset(std::string* charset) { - return request_->response_headers()->GetCharset(charset); -} - -bool URLRequestInterceptJob::GetContentEncodings( - std::vector<net::Filter::FilterType>* encoding_types) { - DCHECK(encoding_types->empty()); - if (!request_->response_headers()) - return false; - - std::string encoding_type; - void* iter = NULL; - while (request_->response_headers()->EnumerateHeader( - &iter, "Content-Encoding", &encoding_type)) { - encoding_types->push_back( - net::Filter::ConvertEncodingToType(encoding_type)); - } - - // Even if encoding types are empty, there is a chance that we need to add - // some decoding, as some proxies strip encoding completely. In such cases, - // we may need to add (for example) SDCH filtering (when the context suggests - // it is appropriate). - net::Filter::FixupEncodingTypes(*this, encoding_types); - return !encoding_types->empty(); -} - -void URLRequestInterceptJob::GetResponseInfo(net::HttpResponseInfo* info) { - if (!plugin_) - return; - - std::string raw_headers; - int size = plugin_->functions().request_funcs->get_response_info( - cprequest_.get(), CPRESPONSEINFO_HTTP_RAW_HEADERS, NULL, 0); - int rv = size < 0 ? size : - plugin_->functions().request_funcs->get_response_info( - cprequest_.get(), CPRESPONSEINFO_HTTP_RAW_HEADERS, - WriteInto(&raw_headers, size+1), size); - if (rv != CPERR_SUCCESS) { - // TODO(mpcomplete): what should we do here? - raw_headers = "HTTP/1.1 404 Not Found"; - raw_headers.push_back('\0'); - } - - info->headers = new net::HttpResponseHeaders(raw_headers); - - if (request_->url().SchemeIsSecure()) { - // Make up a fake certificate for intercepted data since we don't have - // access to the real SSL info. - // TODO(mpcomplete): we should probably have the interception API transmit - // the SSL info, but the only consumer of this API (Gears) doesn't keep that - // around. We should change that. - const char* kCertIssuer = "Chrome Internal"; - const int kLifetimeDays = 100; - - DLOG(WARNING) << "Issuing a fake SSL certificate for interception of URL " - << request_->url(); - - info->ssl_info.cert = - new net::X509Certificate(request_->url().GetWithEmptyPath().spec(), - kCertIssuer, - Time::Now(), - Time::Now() + - TimeDelta::FromDays(kLifetimeDays)); - info->ssl_info.cert_status = 0; - info->ssl_info.security_bits = -1; - } -} - -int URLRequestInterceptJob::GetResponseCode() const { - if (!plugin_) - return -1; - - int status = 200; - plugin_->functions().request_funcs->get_response_info( - cprequest_.get(), CPRESPONSEINFO_HTTP_STATUS, &status, sizeof(status)); - - return status; -} - -bool URLRequestInterceptJob::IsRedirectResponse(GURL* location, - int* http_status_code) { - if (!request_->response_headers()) - return false; - - std::string value; - if (!request_->response_headers()->IsRedirect(&value)) - return false; - - *location = request_->url().Resolve(value); - *http_status_code = request_->response_headers()->response_code(); - return true; -} - -void URLRequestInterceptJob::StartAsync() { - // We may have been orphaned... - if (!request_ || !plugin_) - return; - - int rv = plugin_->functions().request_funcs->start_request(cprequest_.get()); - if (rv != CPERR_IO_PENDING) - OnStartCompleted(rv); -} - -void URLRequestInterceptJob::OnStartCompleted(int result) { - if (result != CPERR_SUCCESS) { - NotifyDone(net::URLRequestStatus(net::URLRequestStatus::FAILED, - net::ERR_CONNECTION_FAILED)); - return; - } - - NotifyHeadersComplete(); -} - -void URLRequestInterceptJob::OnReadCompleted(int bytes_read) { - if (bytes_read < 0) { - NotifyDone(net::URLRequestStatus(net::URLRequestStatus::FAILED, - net::ERR_FAILED)); - return; - } - - SetStatus(net::URLRequestStatus()); // clear the async flag - NotifyReadComplete(bytes_read); -} - -void URLRequestInterceptJob::Observe(NotificationType type, - const NotificationSource& source, - const NotificationDetails& details) { - DCHECK(type == NotificationType::CHROME_PLUGIN_UNLOADED); - DCHECK(plugin_ == Source<ChromePluginLib>(source).ptr()); - DetachPlugin(); -} diff --git a/chrome/common/net/url_request_intercept_job.h b/chrome/common/net/url_request_intercept_job.h deleted file mode 100644 index cc7312a..0000000 --- a/chrome/common/net/url_request_intercept_job.h +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright (c) 2011 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_COMMON_NET_URL_REQUEST_INTERCEPT_JOB_H_ -#define CHROME_COMMON_NET_URL_REQUEST_INTERCEPT_JOB_H_ -#pragma once - -#include <string> - -#include "base/scoped_ptr.h" -#include "base/task.h" -#include "chrome/common/chrome_plugin_api.h" -#include "chrome/common/chrome_plugin_util.h" -#include "content/common/notification_registrar.h" -#include "net/url_request/url_request_job.h" - -namespace net { -class URLRequest; -} // namespace net - -class ChromePluginLib; - -// A request job that handles network requests intercepted by a Chrome plugin. -class URLRequestInterceptJob : public net::URLRequestJob, - public NotificationObserver { - public: - static URLRequestInterceptJob* FromCPRequest(CPRequest* request) { - return ScopableCPRequest::GetData<URLRequestInterceptJob*>(request); - } - - URLRequestInterceptJob(net::URLRequest* request, ChromePluginLib* plugin, - ScopableCPRequest* cprequest); - virtual ~URLRequestInterceptJob(); - - // Plugin callbacks. - void OnStartCompleted(int result); - void OnReadCompleted(int bytes_read); - - // net::URLRequestJob - virtual void Start(); - virtual void Kill(); - virtual bool GetMimeType(std::string* mime_type) const; - virtual bool GetCharset(std::string* charset); - virtual void GetResponseInfo(net::HttpResponseInfo* info); - virtual int GetResponseCode() const; - virtual bool GetContentEncodings( - std::vector<net::Filter::FilterType>* encoding_types); - virtual bool IsRedirectResponse(GURL* location, int* http_status_code); - - // NotificationObserver - virtual void Observe(NotificationType type, - const NotificationSource& source, - const NotificationDetails& details); - - protected: - virtual bool ReadRawData(net::IOBuffer* buf, int buf_size, int* bytes_read); - - private: - void StartAsync(); - void DetachPlugin(); - - NotificationRegistrar registrar_; - scoped_ptr<ScopableCPRequest> cprequest_; - ChromePluginLib* plugin_; - net::IOBuffer* read_buffer_; - int read_buffer_size_; - ScopedRunnableMethodFactory<URLRequestInterceptJob> method_factory_; - - DISALLOW_COPY_AND_ASSIGN(URLRequestInterceptJob); -}; - -#endif // CHROME_COMMON_NET_URL_REQUEST_INTERCEPT_JOB_H_ diff --git a/chrome/common/plugin_messages_internal.h b/chrome/common/plugin_messages_internal.h index f0f4f79..111c4c2 100644 --- a/chrome/common/plugin_messages_internal.h +++ b/chrome/common/plugin_messages_internal.h @@ -27,11 +27,6 @@ IPC_MESSAGE_CONTROL2(PluginProcessMsg_CreateChannel, int /* renderer_id */, bool /* off_the_record */) -// Allows a chrome plugin loaded in the browser process to send arbitrary -// data to an instance of the same plugin loaded in a plugin process. -IPC_MESSAGE_CONTROL1(PluginProcessMsg_PluginMessage, - std::vector<uint8> /* opaque data */) - // Tells the plugin process to notify every connected renderer of the pending // shutdown, so we don't mistake it for a crash. IPC_MESSAGE_CONTROL0(PluginProcessMsg_NotifyRenderersOfPendingShutdown) @@ -47,30 +42,7 @@ IPC_MESSAGE_CONTROL1(PluginProcessHostMsg_ChannelCreated, IPC_SYNC_MESSAGE_CONTROL0_1(PluginProcessHostMsg_GetPluginFinderUrl, std::string /* plugin finder URL */) -// Allows a chrome plugin loaded in a plugin process to send arbitrary -// data to an instance of the same plugin loaded in the browser process. -IPC_MESSAGE_CONTROL1(PluginProcessHostMsg_PluginMessage, - std::vector<uint8> /* opaque data */) - -// Allows a chrome plugin loaded in a plugin process to send arbitrary -// data to an instance of the same plugin loaded in the browser process. -IPC_SYNC_MESSAGE_CONTROL1_1(PluginProcessHostMsg_PluginSyncMessage, - std::vector<uint8> /* opaque data */, - std::vector<uint8> /* opaque data response */) - -// Used to get cookies for the given URL. The request_context is a -// CPBrowsingContext, but is passed as int32 to avoid compilation errors. -IPC_SYNC_MESSAGE_CONTROL2_1(PluginProcessHostMsg_GetCookies, - int32 /* request_context */, - GURL /* url */, - std::string /* cookies */) - -// Used by the plugin process to verify that its renderer |renderer_id| has -// permission to access the given |files|. -IPC_SYNC_MESSAGE_CONTROL2_1(PluginProcessHostMsg_AccessFiles, - int /* renderer_id */, - std::vector<std::string> /* files */, - bool /* allowed */) +IPC_MESSAGE_CONTROL0(PluginProcessHostMsg_ShutdownRequest) // Get the list of proxies to use for |url|, as a semicolon delimited list // of "<TYPE> <HOST>:<PORT>" | "DIRECT". See also ViewHostMsg_ResolveProxy @@ -81,11 +53,6 @@ IPC_SYNC_MESSAGE_CONTROL1_2(PluginProcessHostMsg_ResolveProxy, std::string /* proxy list */) #if defined(OS_WIN) -// Creates a child window of the given parent window on the UI thread. -IPC_SYNC_MESSAGE_CONTROL1_1(PluginProcessHostMsg_CreateWindow, - HWND /* parent */, - HWND /* child */) - // Destroys the given window's parent on the UI thread. IPC_MESSAGE_CONTROL2(PluginProcessHostMsg_PluginWindowDestroyed, HWND /* window */, @@ -333,33 +300,9 @@ IPC_SYNC_MESSAGE_ROUTED2_1(PluginHostMsg_GetCookies, GURL /* first_party_for_cookies */, std::string /* cookies */) -// Asks the browser to show a modal HTML dialog. The dialog is passed the -// given arguments as a JSON string, and returns its result as a JSON string -// through json_retval. -IPC_SYNC_MESSAGE_ROUTED4_1(PluginHostMsg_ShowModalHTMLDialog, - GURL /* url */, - int /* width */, - int /* height */, - std::string /* json_arguments */, - std::string /* json_retval */) - -IPC_SYNC_MESSAGE_ROUTED2_2(PluginHostMsg_GetDragData, - NPVariant_Param /* event */, - bool /* add_data */, - std::vector<NPVariant_Param> /* result_values */, - bool /* result_success */) - -IPC_SYNC_MESSAGE_ROUTED2_1(PluginHostMsg_SetDropEffect, - NPVariant_Param /* event */, - int /* effect */, - bool /* result_success */) - IPC_MESSAGE_ROUTED1(PluginHostMsg_MissingPluginStatus, int /* status */) -IPC_SYNC_MESSAGE_ROUTED0_1(PluginHostMsg_GetCPBrowsingContext, - uint32 /* context */) - IPC_MESSAGE_ROUTED0(PluginHostMsg_CancelDocumentLoad) IPC_MESSAGE_ROUTED3(PluginHostMsg_InitiateHTTPRangeRequest, diff --git a/chrome/common/render_messages.cc b/chrome/common/render_messages.cc index e7068d5..3ec8c79 100644 --- a/chrome/common/render_messages.cc +++ b/chrome/common/render_messages.cc @@ -482,7 +482,6 @@ void ParamTraits<WebPreferences>::Log(const param_type& p, std::string* l) { } void ParamTraits<WebDropData>::Write(Message* m, const param_type& p) { - WriteParam(m, p.identity); WriteParam(m, p.url); WriteParam(m, p.url_title); WriteParam(m, p.download_metadata); @@ -498,7 +497,6 @@ void ParamTraits<WebDropData>::Write(Message* m, const param_type& p) { bool ParamTraits<WebDropData>::Read(const Message* m, void** iter, param_type* p) { return - ReadParam(m, iter, &p->identity) && ReadParam(m, iter, &p->url) && ReadParam(m, iter, &p->url_title) && ReadParam(m, iter, &p->download_metadata) && diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h index dcbca37..f3dfdc8 100644 --- a/chrome/common/render_messages_internal.h +++ b/chrome/common/render_messages_internal.h @@ -1655,13 +1655,6 @@ IPC_MESSAGE_ROUTED3(ViewHostMsg_SendSerializedHtmlData, std::string /* data buffer */, int32 /* complete status */) -IPC_SYNC_MESSAGE_ROUTED4_1(ViewHostMsg_ShowModalHTMLDialog, - GURL /* url */, - int /* width */, - int /* height */, - std::string /* json_arguments */, - std::string /* json_retval */) - IPC_MESSAGE_ROUTED2(ViewHostMsg_DidGetApplicationInfo, int32 /* page_id */, WebApplicationInfo) @@ -1688,10 +1681,10 @@ IPC_MESSAGE_ROUTED4(ViewHostMsg_DidDownloadFavIcon, bool /* true if there was a network error */, SkBitmap /* image_data */) -// Get the CPBrowsingContext associated with the renderer sending this +// Sent when the renderer process is done processing a DataReceived // message. -IPC_SYNC_MESSAGE_CONTROL0_1(ViewHostMsg_GetCPBrowsingContext, - uint32 /* context */) +IPC_MESSAGE_ROUTED1(ViewHostMsg_DataReceived_ACK, + int /* request_id */) IPC_MESSAGE_CONTROL1(ViewHostMsg_RevealFolderInOS, FilePath /* path */) diff --git a/chrome/common/url_constants.cc b/chrome/common/url_constants.cc index 18fdc80..7f5052d 100644 --- a/chrome/common/url_constants.cc +++ b/chrome/common/url_constants.cc @@ -19,7 +19,6 @@ const char kExtensionScheme[] = "chrome-extension"; const char kFileScheme[] = "file"; const char kFileSystemScheme[] = "filesystem"; const char kFtpScheme[] = "ftp"; -const char kGearsScheme[] = "gears"; const char kHttpScheme[] = "http"; const char kHttpsScheme[] = "https"; const char kJavaScriptScheme[] = "javascript"; @@ -254,7 +253,6 @@ void RegisterChromeSchemes() { // the new tab page. url_util::AddStandardScheme(kChromeDevToolsScheme); url_util::AddStandardScheme(kChromeUIScheme); - url_util::AddStandardScheme(kGearsScheme); url_util::AddStandardScheme(kExtensionScheme); url_util::AddStandardScheme(kMetadataScheme); #if defined(OS_CHROMEOS) diff --git a/chrome/common/url_constants.h b/chrome/common/url_constants.h index c4c8d4f..8c676a9 100644 --- a/chrome/common/url_constants.h +++ b/chrome/common/url_constants.h @@ -22,7 +22,6 @@ extern const char kExtensionScheme[]; extern const char kFileScheme[]; extern const char kFileSystemScheme[]; extern const char kFtpScheme[]; -extern const char kGearsScheme[]; extern const char kHttpScheme[]; extern const char kHttpsScheme[]; extern const char kJavaScriptScheme[]; diff --git a/chrome/installer/mini_installer/chrome.release b/chrome/installer/mini_installer/chrome.release index aa3589f..f30b33a 100644 --- a/chrome/installer/mini_installer/chrome.release +++ b/chrome/installer/mini_installer/chrome.release @@ -35,8 +35,7 @@ chrome.dll: %(VersionDir)s\ nacl64.exe: %(VersionDir)s\ nacl64.dll: %(VersionDir)s\ ppGoogleNaClPluginChrome.dll: %(VersionDir)s\ -icudt.dll: %(VersionDir)s\ -gears.dll: %(VersionDir)s\ +icudt46.dll: %(VersionDir)s\ resources.pak: %(VersionDir)s\ locales\*.dll: %(VersionDir)s\Locales Resources\Inspector\*.*: %(VersionDir)s\Resources\Inspector diff --git a/chrome/installer/util/google_update_constants.cc b/chrome/installer/util/google_update_constants.cc index a8fec38..cc73915 100644 --- a/chrome/installer/util/google_update_constants.cc +++ b/chrome/installer/util/google_update_constants.cc @@ -6,7 +6,6 @@ namespace google_update { -const wchar_t kGearsUpgradeCode[] = L"{D92DBAED-3E3E-4530-B30D-072D16C7DDD0}"; const wchar_t kChromeUpgradeCode[] = L"{8A69D345-D564-463C-AFF1-A69D9E530F96}"; const wchar_t kRegPathClients[] = L"Software\\Google\\Update\\Clients"; diff --git a/chrome/installer/util/google_update_constants.h b/chrome/installer/util/google_update_constants.h index 4ed18af..90580cc 100644 --- a/chrome/installer/util/google_update_constants.h +++ b/chrome/installer/util/google_update_constants.h @@ -10,10 +10,6 @@ namespace google_update { -// Strictly speaking Google Update doesn't care about this GUID but it is still -// related to install as it is used by MSI to identify Gears. -extern const wchar_t kGearsUpgradeCode[]; - // The GUID Google Update uses to keep track of Chrome upgrades. extern const wchar_t kChromeUpgradeCode[]; diff --git a/chrome/plugin/chrome_plugin_host.cc b/chrome/plugin/chrome_plugin_host.cc deleted file mode 100644 index f402f16e..0000000 --- a/chrome/plugin/chrome_plugin_host.cc +++ /dev/null @@ -1,731 +0,0 @@ -// Copyright (c) 2011 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/command_line.h" -#include "base/file_path.h" -#include "base/file_util.h" -#include "base/message_loop.h" -#include "base/process_util.h" -#include "base/utf_string_conversions.h" -#include "base/string_split.h" -#include "chrome/common/chrome_constants.h" -#include "chrome/common/chrome_plugin_lib.h" -#include "chrome/common/chrome_plugin_util.h" -#include "chrome/common/chrome_switches.h" -#include "chrome/common/plugin_messages.h" -#include "chrome/plugin/plugin_thread.h" -#include "chrome/plugin/webplugin_proxy.h" -#include "content/common/child_process.h" -#include "content/common/resource_dispatcher.h" -#include "net/base/data_url.h" -#include "net/base/io_buffer.h" -#include "net/base/upload_data.h" -#include "net/http/http_response_headers.h" -#include "webkit/appcache/appcache_interfaces.h" -#include "webkit/plugins/npapi/plugin_instance.h" -#include "webkit/glue/resource_loader_bridge.h" -#include "webkit/glue/resource_type.h" -#include "webkit/glue/webkit_glue.h" - -namespace { - -using webkit_glue::ResourceLoaderBridge; -using webkit_glue::ResourceResponseInfo; - -static MessageLoop* g_plugin_thread_message_loop; - -// 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) - : PluginHelper(plugin), - cprequest_(cprequest), - sync_(false), - response_data_offset_(0), - completed_(false), - read_buffer_(NULL), - read_buffer_size_(0) { - 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 bool OnReceivedRedirect( - const GURL& new_url, - const ResourceResponseInfo& info, - bool* has_new_first_party_for_cookies, - GURL* new_first_party_for_cookies) { - plugin_->functions().response_funcs->received_redirect( - cprequest_.get(), new_url.spec().c_str()); - // TODO(wtc): should we return a new first party for cookies URL? - *has_new_first_party_for_cookies = false; - return true; - } - - virtual void OnReceivedResponse(const ResourceResponseInfo& info) { - response_headers_ = info.headers; - plugin_->functions().response_funcs->start_completed( - cprequest_.get(), CPERR_SUCCESS); - } - - virtual void OnDownloadedData(int len) { - } - - 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 net::URLRequestStatus& status, - const std::string& security_info, - const base::Time& completion_time) { - 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); - } - } - - 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 FilePath &filepath) { - AppendFileRangeToUpload(filepath, 0, kuint64max); - } - - void AppendFileRangeToUpload(const FilePath &filepath, - uint64 offset, uint64 length) { - upload_content_.push_back(net::UploadData::Element()); - upload_content_.back().SetToFilePathRange(filepath, offset, length, - base::Time()); - } - - CPError Start(int renderer_id, int render_view_id) { - webkit_glue::ResourceLoaderBridge::RequestInfo request_info; - request_info.method = cprequest_->method; - request_info.url = GURL(cprequest_->url); - request_info.first_party_for_cookies = - GURL(cprequest_->url); // TODO(jackson): policy url? - request_info.referrer = GURL(); // TODO(mpcomplete): referrer? - request_info.headers = extra_headers_; - request_info.load_flags = load_flags_; - request_info.requestor_pid = base::GetCurrentProcId(); - request_info.request_type = ResourceType::OBJECT; - request_info.request_context = cprequest_->context; - request_info.appcache_host_id = appcache::kNoHostId; - request_info.routing_id = MSG_ROUTING_CONTROL; - bridge_.reset( - PluginThread::current()->resource_dispatcher()->CreateBridge( - request_info, - renderer_id, - render_view_id)); - 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(), - upload_content_[i].expected_file_modification_time()); - 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; - - 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_; - 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_; - size_t response_data_offset_; - bool completed_; - void* read_buffer_; - uint32 read_buffer_size_; -}; - -// -// Generic functions -// - -void STDCALL CPB_SetKeepProcessAlive(CPID id, CPBool keep_alive) { - CHECK(ChromePluginLib::IsPluginThread()); - static bool g_keep_process_alive = false; - bool desired_value = keep_alive ? true : false; // smash to bool - if (desired_value != g_keep_process_alive) { - g_keep_process_alive = desired_value; - if (g_keep_process_alive) - ChildProcess::current()->AddRefProcess(); - else - ChildProcess::current()->ReleaseProcess(); - } -} - -CPError STDCALL CPB_GetCookies(CPID id, CPBrowsingContext context, - const char* url, char** cookies) { - CHECK(ChromePluginLib::IsPluginThread()); - std::string cookies_str; - - WebPluginProxy* webplugin = WebPluginProxy::FromCPBrowsingContext(context); - // There are two contexts in which we can be asked for cookies: - // 1. From a script context. webplugin will be non-NULL. - // 2. From a global browser context (think: Gears UpdateTask). webplugin will - // be NULL and context will (loosely) represent a browser Profile. - // In case 1, we *must* route through the renderer process, otherwise we race - // with renderer script that may have set cookies. In case 2, we are running - // out-of-band with script, so we don't need to stay in sync with any - // particular renderer. - // See http://b/issue?id=1487502. - if (webplugin) { - cookies_str = webplugin->GetCookies(GURL(url), GURL(url)); - } else { - PluginThread::current()->Send( - new PluginProcessHostMsg_GetCookies(context, 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()); - - WebPluginProxy* webplugin = WebPluginProxy::FromCPBrowsingContext(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_GetDragData( - CPID id, CPBrowsingContext context, struct NPObject* event, bool add_data, - int32 *identity, int32 *event_id, char **drag_type, char **drag_data) { - CHECK(ChromePluginLib::IsPluginThread()); - - *identity = *event_id = 0; - WebPluginProxy* webplugin = WebPluginProxy::FromCPBrowsingContext(context); - if (!event || !webplugin) - return CPERR_INVALID_PARAMETER; - - std::string type_str, data_str; - if (!webplugin->GetDragData(event, add_data, - identity, event_id, &type_str, &data_str)) { - return CPERR_FAILURE; - } - - if (add_data) - *drag_data = CPB_StringDup(CPB_Alloc, data_str); - *drag_type = CPB_StringDup(CPB_Alloc, type_str); - return CPERR_SUCCESS; -} - -CPError STDCALL CPB_SetDropEffect( - CPID id, CPBrowsingContext context, struct NPObject* event, int effect) { - CHECK(ChromePluginLib::IsPluginThread()); - - WebPluginProxy* webplugin = WebPluginProxy::FromCPBrowsingContext(context); - if (!event || !webplugin) - return CPERR_INVALID_PARAMETER; - - if (webplugin->SetDropEffect(event, effect)) - return CPERR_SUCCESS; - return CPERR_FAILURE; -} - -CPError STDCALL CPB_AllowFileDrop( - CPID id, CPBrowsingContext context, const char* file_drag_data) { - CHECK(ChromePluginLib::IsPluginThread()); - - WebPluginProxy* webplugin = WebPluginProxy::FromCPBrowsingContext(context); - if (!webplugin || !file_drag_data) - return CPERR_INVALID_PARAMETER; - - const int renderer = webplugin->GetRendererId(); - if (renderer == -1) - return CPERR_FAILURE; - - static const char kDelimiter('\b'); - std::vector<std::string> files; - base::SplitStringDontTrim(file_drag_data, kDelimiter, &files); - - bool allowed = false; - if (!PluginThread::current()->Send( - new PluginProcessHostMsg_AccessFiles(renderer, files, &allowed))) { - return CPERR_FAILURE; - } - - if (allowed) - return CPERR_SUCCESS; - 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; - - webkit::npapi::PluginInstance* instance = - static_cast<webkit::npapi::PluginInstance *>(npp->ndata); - WebPluginProxy* webplugin = - static_cast<WebPluginProxy*>(instance->webplugin()); - - return webplugin->GetCPBrowsingContext(); -} - -int STDCALL CPB_GetBrowsingContextInfo( - CPID id, CPBrowsingContext context, CPBrowsingContextInfoType type, - void* buf, uint32 buf_size) { - CHECK(ChromePluginLib::IsPluginThread()); - -#if defined(OS_WIN) - switch (type) { - case CPBROWSINGCONTEXT_DATA_DIR_PTR: { - if (buf_size < sizeof(char*)) - return sizeof(char*); - - FilePath path = CommandLine::ForCurrentProcess()-> - GetSwitchValuePath(switches::kPluginDataDir); - DCHECK(!path.empty()); - std::string retval = WideToUTF8( - path.Append(chrome::kChromePluginDataDirname).value()); - *static_cast<char**>(buf) = CPB_StringDup(CPB_Alloc, retval); - - return CPERR_SUCCESS; - } - case CPBROWSINGCONTEXT_UI_LOCALE_PTR: { - if (buf_size < sizeof(char*)) - return sizeof(char*); - - std::string retval = webkit_glue::GetWebKitLocale(); - *static_cast<char**>(buf) = CPB_StringDup(CPB_Alloc, retval); - return CPERR_SUCCESS; - } - } -#else - // TODO(aa): this code is only used by Gears, which we are removing. - NOTREACHED(); -#endif - - return CPERR_FAILURE; -} - -CPError STDCALL CPB_AddUICommand(CPID id, int command) { - // Not implemented in the plugin process - return CPERR_FAILURE; -} - -CPError STDCALL CPB_HandleCommand( - CPID id, CPBrowsingContext context, int command, void *data) { - // Not implemented in the plugin 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 plugin process."; -} - -void STDCALL CPRR_StartCompleted(CPRequest* request, CPError result) { - NOTREACHED() << "Network interception should not happen in plugin process."; -} - -void STDCALL CPRR_ReadCompleted(CPRequest* request, int bytes_read) { - NOTREACHED() << "Network interception should not happen in plugin process."; -} - -void STDCALL CPRR_UploadProgress(CPRequest* request, uint64 pos, uint64 size) { - NOTREACHED() << "Network interception should not happen in plugin 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); - - ScopableCPRequest* cprequest = new ScopableCPRequest(url, method, context); - new PluginRequestHandlerProxy(plugin, cprequest); - - *request = cprequest; - return CPERR_SUCCESS; -} - -CPError STDCALL CPR_StartRequest(CPRequest* request) { - CHECK(ChromePluginLib::IsPluginThread()); - PluginRequestHandlerProxy* handler = - PluginRequestHandlerProxy::FromCPRequest(request); - CHECK(handler); - - int renderer_id = -1; - int render_view_id = -1; - - WebPluginProxy* webplugin = WebPluginProxy::FromCPBrowsingContext( - request->context); - if (webplugin) { - renderer_id = webplugin->GetRendererId(); - if (renderer_id == -1) - return CPERR_FAILURE; - - render_view_id = webplugin->host_render_view_routing_id(); - if (render_view_id == -1) - return CPERR_FAILURE; - } - - return handler->Start(renderer_id, render_view_id); -} - -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(FilePath::FromWStringHack(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_PLUGIN; -} - -CPError STDCALL CPB_SendMessage(CPID id, const void *data, uint32 data_len) { - CHECK(ChromePluginLib::IsPluginThread()); - const uint8* data_ptr = static_cast<const uint8*>(data); - std::vector<uint8> v(data_ptr, data_ptr + data_len); - if (!PluginThread::current()->Send(new PluginProcessHostMsg_PluginMessage(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()); - const uint8* data_ptr = static_cast<const uint8*>(data); - std::vector<uint8> v(data_ptr, data_ptr + data_len); - std::vector<uint8> r; - if (!PluginThread::current()->Send( - new PluginProcessHostMsg_PluginSyncMessage(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) { - g_plugin_thread_message_loop->PostTask( - FROM_HERE, NewRunnableFunction(func, user_data)); - - return CPERR_SUCCESS; -} - -CPError STDCALL CPB_OpenFileDialog(CPID id, - CPBrowsingContext context, - bool multiple_files, - const char *title, - const char *filter, - void *user_data) { - NOTREACHED() << - "Open file dialog should only be called from the renderer process."; - - return CPERR_FAILURE; -} - -} // namespace - -CPBrowserFuncs* GetCPBrowserFuncsForPlugin() { - static CPBrowserFuncs browser_funcs; - static CPRequestFuncs request_funcs; - static CPResponseFuncs response_funcs; - static bool initialized = false; - if (!initialized) { - initialized = true; - - g_plugin_thread_message_loop = PluginThread::current()->message_loop(); - - 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.get_drag_data = CPB_GetDragData; - browser_funcs.set_drop_effect = CPB_SetDropEffect; - browser_funcs.allow_file_drop = CPB_AllowFileDrop; - - 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/plugin/chrome_plugin_host.h b/chrome/plugin/chrome_plugin_host.h deleted file mode 100644 index 29a0958..0000000 --- a/chrome/plugin/chrome_plugin_host.h +++ /dev/null @@ -1,14 +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_PLUGIN_CHROME_PLUGIN_HOST_H_ -#define CHROME_PLUGIN_CHROME_PLUGIN_HOST_H_ -#pragma once - -#include "chrome/common/chrome_plugin_api.h" - -// Returns the table of browser functions for use from the plugin process. -CPBrowserFuncs* GetCPBrowserFuncsForPlugin(); - -#endif // CHROME_PLUGIN_CHROME_PLUGIN_HOST_H_ diff --git a/chrome/plugin/plugin_thread.cc b/chrome/plugin/plugin_thread.cc index cbbb2fb..9d60b0e 100644 --- a/chrome/plugin/plugin_thread.cc +++ b/chrome/plugin/plugin_thread.cc @@ -19,11 +19,9 @@ #include "base/lazy_instance.h" #include "base/process_util.h" #include "base/threading/thread_local.h" -#include "chrome/common/chrome_plugin_lib.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/plugin_messages.h" #include "chrome/common/render_messages.h" -#include "chrome/plugin/chrome_plugin_host.h" #include "chrome/plugin/npobject_util.h" #include "chrome/renderer/render_thread.h" #include "content/common/child_process.h" @@ -84,8 +82,6 @@ PluginThread::PluginThread() // Preload the library to avoid loading, unloading then reloading preloaded_plugin_module_ = base::LoadNativeLibrary(plugin_path_); - ChromePluginLib::Create(plugin_path_, GetCPBrowserFuncsForPlugin()); - scoped_refptr<webkit::npapi::PluginLib> plugin( webkit::npapi::PluginLib::CreatePluginLib(plugin_path_)); if (plugin.get()) { @@ -116,7 +112,6 @@ PluginThread::~PluginThread() { } PluginChannelBase::CleanupChannels(); webkit::npapi::PluginLib::UnloadAllPlugins(); - ChromePluginLib::UnloadAllPlugins(); if (webkit_glue::ShouldForcefullyTerminatePluginProcess()) base::KillProcess(base::GetCurrentProcessHandle(), 0, /* wait= */ false); @@ -132,7 +127,6 @@ bool PluginThread::OnControlMessageReceived(const IPC::Message& msg) { bool handled = true; IPC_BEGIN_MESSAGE_MAP(PluginThread, msg) IPC_MESSAGE_HANDLER(PluginProcessMsg_CreateChannel, OnCreateChannel) - IPC_MESSAGE_HANDLER(PluginProcessMsg_PluginMessage, OnPluginMessage) IPC_MESSAGE_HANDLER(PluginProcessMsg_NotifyRenderersOfPendingShutdown, OnNotifyRenderersOfPendingShutdown) IPC_MESSAGE_UNHANDLED(handled = false) @@ -157,20 +151,6 @@ void PluginThread::OnCreateChannel(int renderer_id, Send(new PluginProcessHostMsg_ChannelCreated(channel_handle)); } -void PluginThread::OnPluginMessage(const std::vector<unsigned char> &data) { - // We Add/Release ref here to ensure that something will trigger the - // shutdown mechanism for processes started in the absence of renderer's - // opening a plugin channel. - ChildProcess::current()->AddRefProcess(); - 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); - } - ChildProcess::current()->ReleaseProcess(); -} - void PluginThread::OnNotifyRenderersOfPendingShutdown() { PluginChannel::NotifyRenderersOfPendingShutdown(); } diff --git a/chrome/plugin/webplugin_proxy.cc b/chrome/plugin/webplugin_proxy.cc index c0919d3..390b2be 100644 --- a/chrome/plugin/webplugin_proxy.cc +++ b/chrome/plugin/webplugin_proxy.cc @@ -45,9 +45,6 @@ using webkit::npapi::WebPluginResourceClient; using webkit::npapi::WebPluginAcceleratedSurface; #endif -typedef std::map<CPBrowsingContext, WebPluginProxy*> ContextMap; -static base::LazyInstance<ContextMap> g_context_map(base::LINKER_INITIALIZED); - WebPluginProxy::WebPluginProxy( PluginChannel* channel, int route_id, @@ -56,7 +53,6 @@ WebPluginProxy::WebPluginProxy( int host_render_view_routing_id) : channel_(channel), route_id_(route_id), - cp_browsing_context_(0), window_npobject_(NULL), plugin_element_(NULL), delegate_(NULL), @@ -88,9 +84,6 @@ WebPluginProxy::WebPluginProxy( } WebPluginProxy::~WebPluginProxy() { - if (cp_browsing_context_) - g_context_map.Get().erase(cp_browsing_context_); - #if defined(USE_X11) if (windowless_shm_pixmap_ != None) XFreePixmap(ui::GetXDisplay(), windowless_shm_pixmap_); @@ -246,37 +239,10 @@ std::string WebPluginProxy::GetCookies(const GURL& url, return cookies; } -void WebPluginProxy::ShowModalHTMLDialog(const GURL& url, int width, int height, - const std::string& json_arguments, - std::string* json_retval) { - PluginHostMsg_ShowModalHTMLDialog* msg = - new PluginHostMsg_ShowModalHTMLDialog( - route_id_, url, width, height, json_arguments, json_retval); - - // Pump messages while waiting for a response (which won't come until the - // dialog is closed). This avoids a deadlock. - msg->EnableMessagePumping(); - Send(msg); -} - void WebPluginProxy::OnMissingPluginStatus(int status) { Send(new PluginHostMsg_MissingPluginStatus(route_id_, status)); } -CPBrowsingContext WebPluginProxy::GetCPBrowsingContext() { - if (cp_browsing_context_ == 0) { - Send(new PluginHostMsg_GetCPBrowsingContext(route_id_, - &cp_browsing_context_)); - g_context_map.Get()[cp_browsing_context_] = this; - } - return cp_browsing_context_; -} - -WebPluginProxy* WebPluginProxy::FromCPBrowsingContext( - CPBrowsingContext context) { - return g_context_map.Get()[context]; -} - WebPluginResourceClient* WebPluginProxy::GetResourceClient(int id) { ResourceClientMap::iterator iterator = resource_clients_.find(id); // The IPC messages which deal with streams are now asynchronous. It is @@ -350,54 +316,6 @@ void WebPluginProxy::HandleURLRequest(const char* url, Send(new PluginHostMsg_URLRequest(route_id_, params)); } -bool WebPluginProxy::GetDragData(struct NPObject* event, bool add_data, - int32* identity, int32* event_id, - std::string* type, std::string* data) { - DCHECK(event); - NPObjectProxy* proxy = NPObjectProxy::GetProxy(event); - if (!proxy) // NPObject* event should have/be a renderer proxy. - return false; - - NPVariant_Param event_param; - event_param.type = NPVARIANT_PARAM_RECEIVER_OBJECT_ROUTING_ID; - event_param.npobject_routing_id = proxy->route_id(); - - std::vector<NPVariant_Param> values; - bool success = false; - Send(new PluginHostMsg_GetDragData(route_id_, event_param, add_data, - &values, &success)); - if (!success) - return false; - - DCHECK(values.size() == 4); - DCHECK(values[0].type == NPVARIANT_PARAM_INT); - *identity = static_cast<int32>(values[0].int_value); - DCHECK(values[1].type == NPVARIANT_PARAM_INT); - *event_id = static_cast<int32>(values[1].int_value); - DCHECK(values[2].type == NPVARIANT_PARAM_STRING); - type->swap(values[2].string_value); - if (add_data && (values[3].type == NPVARIANT_PARAM_STRING)) - data->swap(values[3].string_value); - - return true; -} - -bool WebPluginProxy::SetDropEffect(struct NPObject* event, int effect) { - DCHECK(event); - NPObjectProxy* proxy = NPObjectProxy::GetProxy(event); - if (!proxy) // NPObject* event should have/be a renderer proxy. - return false; - - NPVariant_Param event_param; - event_param.type = NPVARIANT_PARAM_RECEIVER_OBJECT_ROUTING_ID; - event_param.npobject_routing_id = proxy->route_id(); - - bool success = false; - Send(new PluginHostMsg_SetDropEffect(route_id_, event_param, effect, - &success)); - return success; -} - void WebPluginProxy::Paint(const gfx::Rect& rect) { #if defined(OS_MACOSX) if (!windowless_context_.get()) @@ -737,4 +655,3 @@ void WebPluginProxy::ResourceClientDeleted( void WebPluginProxy::URLRedirectResponse(bool allow, int resource_id) { Send(new PluginHostMsg_URLRedirectResponse(route_id_, allow, resource_id)); } - diff --git a/chrome/plugin/webplugin_proxy.h b/chrome/plugin/webplugin_proxy.h index acc89ab..4b3f2b4 100644 --- a/chrome/plugin/webplugin_proxy.h +++ b/chrome/plugin/webplugin_proxy.h @@ -21,7 +21,6 @@ #include "base/scoped_ptr.h" #include "base/shared_memory.h" #include "base/timer.h" -#include "chrome/common/chrome_plugin_api.h" #include "googleurl/src/gurl.h" #include "ipc/ipc_message.h" #include "webkit/plugins/npapi/webplugin.h" @@ -75,28 +74,9 @@ class WebPluginProxy : public webkit::npapi::WebPlugin { virtual std::string GetCookies(const GURL& url, const GURL& first_party_for_cookies); - virtual void ShowModalHTMLDialog(const GURL& url, int width, int height, - const std::string& json_arguments, - std::string* json_retval); - - // Called by gears over the CPAPI interface to verify that the given event is - // the current (javascript) drag event the browser is dispatching, and return - // the drag data, or control the drop effect (drag cursor), if so. - bool GetDragData(struct NPObject* event, bool add_data, int32* identity, - int32* event_id, std::string* type, std::string* data); - bool SetDropEffect(struct NPObject* event, int effect); - virtual void OnMissingPluginStatus(int status); // class-specific methods - // Retrieves the browsing context associated with the renderer this plugin - // is in. Calling multiple times will return the same value. - CPBrowsingContext GetCPBrowsingContext(); - - // Retrieves the WebPluginProxy for the given context that was returned by - // GetCPBrowsingContext, or NULL if not found. - static WebPluginProxy* FromCPBrowsingContext(CPBrowsingContext context); - // Returns a WebPluginResourceClient object given its id, or NULL if no // object with that id exists. webkit::npapi::WebPluginResourceClient* GetResourceClient(int id); @@ -203,7 +183,6 @@ class WebPluginProxy : public webkit::npapi::WebPlugin { scoped_refptr<PluginChannel> channel_; int route_id_; - uint32 cp_browsing_context_; NPObject* window_npobject_; NPObject* plugin_element_; webkit::npapi::WebPluginDelegateImpl* delegate_; diff --git a/chrome/renderer/render_thread.cc b/chrome/renderer/render_thread.cc index 27d0a12..3a59fdb 100644 --- a/chrome/renderer/render_thread.cc +++ b/chrome/renderer/render_thread.cc @@ -90,7 +90,6 @@ #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" #include "webkit/extensions/v8/benchmarking_extension.h" -#include "webkit/extensions/v8/gears_extension.h" #include "webkit/extensions/v8/playback_extension.h" #include "webkit/glue/webkit_glue.h" #include "v8/include/v8.h" @@ -908,10 +907,6 @@ void RenderThread::EnsureWebKitInitialized() { WebString extension_scheme(ASCIIToUTF16(chrome::kExtensionScheme)); WebSecurityPolicy::registerURLSchemeAsSecure(extension_scheme); -#if defined(OS_WIN) - // We don't yet support Gears on non-Windows, so don't tell pages that we do. - RegisterExtension(extensions_v8::GearsExtension::Get(), false); -#endif RegisterExtension(extensions_v8::LoadTimesExtension::Get(), false); RegisterExtension(extensions_v8::ChromeAppExtension::Get(), false); RegisterExtension(extensions_v8::ExternalExtension::Get(), false); diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc index 5934412..fa75844 100644 --- a/chrome/renderer/render_view.cc +++ b/chrome/renderer/render_view.cc @@ -1979,12 +1979,6 @@ void RenderView::OnAllowScriptToClose(bool script_can_close) { script_can_close_ = script_can_close; } -uint32 RenderView::GetCPBrowsingContext() { - uint32 context = 0; - Send(new ViewHostMsg_GetCPBrowsingContext(&context)); - return context; -} - void RenderView::AddSearchProvider( const std::string& url, const ViewHostMsg_PageHasOSDD_Type& provider_type) { @@ -3465,7 +3459,6 @@ void RenderView::didClearWindowObject(WebFrame* frame) { GURL frame_url = frame->url(); if (BindingsPolicy::is_web_ui_enabled(enabled_bindings_) && (frame_url.SchemeIs(chrome::kChromeUIScheme) || - frame_url.SchemeIs(chrome::kGearsScheme) || frame_url.SchemeIs(chrome::kDataScheme))) { GetWebUIBindings()->set_message_sender(this); GetWebUIBindings()->set_routing_id(routing_id_); @@ -3975,16 +3968,6 @@ void RenderView::DidStopLoadingForPlugin() { didStopLoading(); } -void RenderView::ShowModalHTMLDialogForPlugin( - const GURL& url, - const gfx::Size& size, - const std::string& json_arguments, - std::string* json_retval) { - SendAndRunNestedMessageLoop(new ViewHostMsg_ShowModalHTMLDialog( - routing_id_, url, size.width(), size.height(), json_arguments, - json_retval)); -} - WebCookieJar* RenderView::GetCookieJar() { return &cookie_jar_; } @@ -4602,7 +4585,7 @@ void RenderView::OnDragTargetDragEnter(const WebDropData& drop_data, WebDragOperationsMask ops) { WebDragOperation operation = webview()->dragTargetDragEnter( drop_data.ToDragData(), - drop_data.identity, + 0, // drag identity, unused client_point, screen_point, ops); diff --git a/chrome/renderer/render_view.h b/chrome/renderer/render_view.h index 42e3ddb..705f12e 100644 --- a/chrome/renderer/render_view.h +++ b/chrome/renderer/render_view.h @@ -340,12 +340,6 @@ class RenderView : public RenderWidget, WebKit::WebPlugin* CreatePluginNoCheck(WebKit::WebFrame* frame, const WebKit::WebPluginParams& params); - // Asks the browser for the CPBrowsingContext associated with this renderer. - // This is an opaque identifier associated with the renderer for sending - // messages for the given "Chrome Plugin." The Chrome Plugin API is used - // only by gears and this function can be deleted when we remove gears. - uint32 GetCPBrowsingContext(); - #if defined(OS_MACOSX) // Informs the render view that the given plugin has gained or lost focus. void PluginFocusChanged(bool focused, int plugin_id); @@ -636,11 +630,6 @@ class RenderView : public RenderWidget, virtual void DidMovePlugin(const webkit::npapi::WebPluginGeometry& move); virtual void DidStartLoadingForPlugin(); virtual void DidStopLoadingForPlugin(); - virtual void ShowModalHTMLDialogForPlugin( - const GURL& url, - const gfx::Size& size, - const std::string& json_arguments, - std::string* json_retval); virtual WebKit::WebCookieJar* GetCookieJar(); // Please do not add your stuff randomly to the end here. If there is an diff --git a/chrome/renderer/renderer_glue.cc b/chrome/renderer/renderer_glue.cc index 6b325b8..f61a011 100644 --- a/chrome/renderer/renderer_glue.cc +++ b/chrome/renderer/renderer_glue.cc @@ -229,7 +229,7 @@ bool IsProtocolSupportedForMedia(const GURL& url) { // static factory function ResourceLoaderBridge* ResourceLoaderBridge::Create( const ResourceLoaderBridge::RequestInfo& request_info) { - return ChildThread::current()->CreateBridge(request_info, -1, -1); + return ChildThread::current()->CreateBridge(request_info); } // static factory function diff --git a/chrome/renderer/webplugin_delegate_proxy.cc b/chrome/renderer/webplugin_delegate_proxy.cc index 43929c8..f4ad26a 100644 --- a/chrome/renderer/webplugin_delegate_proxy.cc +++ b/chrome/renderer/webplugin_delegate_proxy.cc @@ -40,7 +40,6 @@ #include "third_party/WebKit/Source/WebKit/chromium/public/WebDragData.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebVector.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" #include "ui/base/resource/resource_bundle.h" #include "ui/gfx/blit.h" @@ -64,7 +63,6 @@ using WebKit::WebCursorInfo; using WebKit::WebDragData; using WebKit::WebInputEvent; using WebKit::WebString; -using WebKit::WebVector; using WebKit::WebView; // Proxy for WebPluginResourceClient. The object owns itself after creation, @@ -453,15 +451,9 @@ bool WebPluginDelegateProxy::OnMessageReceived(const IPC::Message& msg) { OnGetPluginElement) IPC_MESSAGE_HANDLER(PluginHostMsg_SetCookie, OnSetCookie) IPC_MESSAGE_HANDLER(PluginHostMsg_GetCookies, OnGetCookies) - IPC_MESSAGE_HANDLER(PluginHostMsg_ShowModalHTMLDialog, - OnShowModalHTMLDialog) - IPC_MESSAGE_HANDLER(PluginHostMsg_GetDragData, OnGetDragData); - IPC_MESSAGE_HANDLER(PluginHostMsg_SetDropEffect, OnSetDropEffect); IPC_MESSAGE_HANDLER(PluginHostMsg_MissingPluginStatus, OnMissingPluginStatus) IPC_MESSAGE_HANDLER(PluginHostMsg_URLRequest, OnHandleURLRequest) - IPC_MESSAGE_HANDLER(PluginHostMsg_GetCPBrowsingContext, - OnGetCPBrowsingContext) IPC_MESSAGE_HANDLER(PluginHostMsg_CancelDocumentLoad, OnCancelDocumentLoad) IPC_MESSAGE_HANDLER(PluginHostMsg_InitiateHTTPRangeRequest, OnInitiateHTTPRangeRequest) @@ -1152,137 +1144,11 @@ void WebPluginDelegateProxy::OnGetCookies(const GURL& url, *cookies = plugin_->GetCookies(url, first_party_for_cookies); } -void WebPluginDelegateProxy::OnShowModalHTMLDialog( - const GURL& url, int width, int height, const std::string& json_arguments, - std::string* json_retval) { - DCHECK(json_retval); - if (render_view_) { - render_view_->ShowModalHTMLDialogForPlugin( - url, gfx::Size(width, height), json_arguments, json_retval); - } -} - -static void EncodeDragData(const WebDragData& data, bool add_data, - NPVariant* drag_type, NPVariant* drag_data) { - const NPString* np_drag_type; - if (data.containsFilenames()) { - static const NPString kFiles = { "Files", 5 }; - np_drag_type = &kFiles; - } else { - static const NPString kEmpty = { "" , 0 }; - np_drag_type = &kEmpty; - add_data = false; - } - - STRINGN_TO_NPVARIANT(np_drag_type->UTF8Characters, - np_drag_type->UTF8Length, - *drag_type); - if (!add_data) { - VOID_TO_NPVARIANT(*drag_data); - return; - } - - WebVector<WebString> files; - data.filenames(files); - - static std::string utf8; - utf8.clear(); - for (size_t i = 0; i < files.size(); ++i) { - static const char kBackspaceDelimiter('\b'); - if (i != 0) - utf8.append(1, kBackspaceDelimiter); - utf8.append(files[i].utf8()); - } - - STRINGN_TO_NPVARIANT(utf8.data(), utf8.length(), *drag_data); -} - -void WebPluginDelegateProxy::OnGetDragData(const NPVariant_Param& object, - bool add_data, - std::vector<NPVariant_Param>* values, - bool* success) { - DCHECK(values && success); - *success = false; - - WebView* webview = NULL; - if (render_view_) - webview = render_view_->webview(); - if (!webview) - return; - - int event_id; - WebDragData data; - - DCHECK(object.type == NPVARIANT_PARAM_RECEIVER_OBJECT_ROUTING_ID); - NPObjectBase* npobject_base = - channel_host_->GetNPObjectListenerForRoute(object.npobject_routing_id); - if (!npobject_base) { - DLOG(WARNING) << "Invalid routing id passed in" - << object.npobject_routing_id; - return; - } - - NPObject* event = npobject_base->GetUnderlyingNPObject(); - DCHECK(event != NULL); - - const int32 drag_id = webview->dragIdentity(); - if (!drag_id || !WebBindings::getDragData(event, &event_id, &data)) - return; - - NPVariant results[4]; - INT32_TO_NPVARIANT(drag_id, results[0]); - INT32_TO_NPVARIANT(event_id, results[1]); - EncodeDragData(data, add_data, &results[2], &results[3]); - - for (size_t i = 0; i < arraysize(results); ++i) { - values->push_back(NPVariant_Param()); - CreateNPVariantParam( - results[i], NULL, &values->back(), false, 0, page_url_); - } - - *success = true; -} - -void WebPluginDelegateProxy::OnSetDropEffect(const NPVariant_Param& object, - int effect, - bool* success) { - DCHECK(success); - *success = false; - - WebView* webview = NULL; - if (render_view_) - webview = render_view_->webview(); - if (!webview) - return; - - DCHECK(object.type == NPVARIANT_PARAM_RECEIVER_OBJECT_ROUTING_ID); - NPObjectBase* npobject_base = - channel_host_->GetNPObjectListenerForRoute(object.npobject_routing_id); - if (!npobject_base) { - DLOG(WARNING) << "Invalid routing id passed in" - << object.npobject_routing_id; - return; - } - - NPObject* event = npobject_base->GetUnderlyingNPObject(); - DCHECK(event != NULL); - - const int32 drag_id = webview->dragIdentity(); - if (!drag_id || !WebBindings::isDragEvent(event)) - return; - - *success = webview->setDropEffect(effect != 0); -} - void WebPluginDelegateProxy::OnMissingPluginStatus(int status) { if (render_view_) render_view_->OnMissingPluginStatus(this, status); } -void WebPluginDelegateProxy::OnGetCPBrowsingContext(uint32* context) { - *context = render_view_ ? render_view_->GetCPBrowsingContext() : 0; -} - void WebPluginDelegateProxy::PaintSadPlugin(WebKit::WebCanvas* native_context, const gfx::Rect& rect) { // Lazily load the sad plugin image. diff --git a/chrome/renderer/webplugin_delegate_proxy.h b/chrome/renderer/webplugin_delegate_proxy.h index 1c99113..3a84996 100644 --- a/chrome/renderer/webplugin_delegate_proxy.h +++ b/chrome/renderer/webplugin_delegate_proxy.h @@ -145,15 +145,7 @@ class WebPluginDelegateProxy const std::string& cookie); void OnGetCookies(const GURL& url, const GURL& first_party_for_cookies, std::string* cookies); - void OnShowModalHTMLDialog(const GURL& url, int width, int height, - const std::string& json_arguments, - std::string* json_retval); - void OnGetDragData(const NPVariant_Param& event, bool add_data, - std::vector<NPVariant_Param>* values, bool* success); - void OnSetDropEffect(const NPVariant_Param& event, int effect, - bool* success); void OnMissingPluginStatus(int status); - void OnGetCPBrowsingContext(uint32* context); void OnCancelDocumentLoad(); void OnInitiateHTTPRangeRequest(const std::string& url, const std::string& range_info, diff --git a/chrome/test/chrome_plugin/test_chrome_plugin.cc b/chrome/test/chrome_plugin/test_chrome_plugin.cc deleted file mode 100644 index 751a9c2..0000000 --- a/chrome/test/chrome_plugin/test_chrome_plugin.cc +++ /dev/null @@ -1,383 +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/test/chrome_plugin/test_chrome_plugin.h" - -#include "base/at_exit.h" -#include "base/basictypes.h" -#include "base/logging.h" -#include "base/message_loop.h" -#include "base/string_util.h" -#include "chrome/common/chrome_plugin_api.h" -#include "googleurl/src/gurl.h" - -static CPID g_cpid; -static CPBrowserFuncs g_cpbrowser_funcs; -static CPRequestFuncs g_cprequest_funcs; -static CPResponseFuncs g_cpresponse_funcs; -static TestFuncParams::BrowserFuncs g_cptest_funcs; - -// Create a global AtExitManager so that our code can use code from base that -// uses Singletons, for example. We don't care about static constructors here. -static base::AtExitManager global_at_exit_manager; - -const TestResponsePayload* FindPayload(const char* url) { - for (size_t i = 0; i < arraysize(kChromeTestPluginPayloads); ++i) { - if (strcmp(kChromeTestPluginPayloads[i].url, url) == 0) - return &kChromeTestPluginPayloads[i]; - } - return NULL; -} - -std::string GetPayloadHeaders(const TestResponsePayload* payload) { - return StringPrintf( - "HTTP/1.1 200 OK%c" - "Content-type: %s%c" - "%c", 0, payload->mime_type, 0, 0); -} - -void STDCALL InvokeLaterCallback(void* data) { - Task* task = static_cast<Task*>(data); - task->Run(); - delete task; -} - -// ResponseStream: Manages the streaming of the payload data. - -class ResponseStream : public base::RefCounted<ResponseStream> { - public: - ResponseStream(const TestResponsePayload* payload, CPRequest* request); - - void Init(); - int GetResponseInfo(CPResponseInfoType type, void* buf, uint32 buf_size); - int ReadData(void* buf, uint32 buf_size); - - private: - friend class base::RefCounted<ResponseStream>; - - ~ResponseStream() { - request_->pdata = NULL; - } - - // Called asynchronously via InvokeLater. - void ResponseStarted(); - int ReadCompleted(void* buf, uint32 buf_size); - - enum ReadyStates { - READY_INVALID = 0, - READY_WAITING = 1, - READY_GOT_HEADERS = 2, - READY_GOT_DATA = 3, - }; - const TestResponsePayload* payload_; - uint32 offset_; - int ready_state_; - CPRequest* request_; -}; - -ResponseStream::ResponseStream(const TestResponsePayload* payload, - CPRequest* request) - : payload_(payload), offset_(0), ready_state_(READY_INVALID), - request_(request) { -} - -void ResponseStream::Init() { - if (payload_->async) { - // simulate an asynchronous start complete - ready_state_ = READY_WAITING; - g_cptest_funcs.invoke_later( - InvokeLaterCallback, - // downcast to Task before void, since we upcast from void to Task. - static_cast<Task*>( - NewRunnableMethod(this, &ResponseStream::ResponseStarted)), - 500); - } else { - ready_state_ = READY_GOT_DATA; - } -} - -int ResponseStream::GetResponseInfo(CPResponseInfoType type, void* buf, - uint32 buf_size) { - if (ready_state_ < READY_GOT_HEADERS) - return CPERR_FAILURE; - - switch (type) { - case CPRESPONSEINFO_HTTP_STATUS: - if (buf) - memcpy(buf, &payload_->status, buf_size); - break; - case CPRESPONSEINFO_HTTP_RAW_HEADERS: { - std::string headers = GetPayloadHeaders(payload_); - if (buf_size < headers.size()+1) - return static_cast<int>(headers.size()+1); - if (buf) - memcpy(buf, headers.c_str(), headers.size()+1); - break; - } - default: - return CPERR_INVALID_VERSION; - } - - return CPERR_SUCCESS; -} - -int ResponseStream::ReadData(void* buf, uint32 buf_size) { - if (ready_state_ < READY_GOT_DATA) { - // simulate an asynchronous read complete - g_cptest_funcs.invoke_later( - InvokeLaterCallback, - // downcast to Task before void, since we upcast from void to Task. - static_cast<Task*>( - NewRunnableMethod(this, &ResponseStream::ReadCompleted, - buf, buf_size)), - 500); - return CPERR_IO_PENDING; - } - - // synchronously complete the read - return ReadCompleted(buf, buf_size); -} - -void ResponseStream::ResponseStarted() { - ready_state_ = READY_GOT_HEADERS; - g_cpresponse_funcs.start_completed(request_, CPERR_SUCCESS); -} - -int ResponseStream::ReadCompleted(void* buf, uint32 buf_size) { - uint32 size = static_cast<uint32>(strlen(payload_->body)); - uint32 avail = size - offset_; - uint32 count = buf_size; - if (count > avail) - count = avail; - - if (count) { - memcpy(buf, payload_->body + offset_, count); - } - - offset_ += count; - - if (ready_state_ < READY_GOT_DATA) { - ready_state_ = READY_GOT_DATA; - g_cpresponse_funcs.read_completed(request_, static_cast<int>(count)); - } - - return count; -} - -// CPP Funcs - -CPError STDCALL CPP_Shutdown() { - return CPERR_SUCCESS; -} - -CPBool STDCALL CPP_ShouldInterceptRequest(CPRequest* request) { - DCHECK(base::strncasecmp(request->url, kChromeTestPluginProtocol, - arraysize(kChromeTestPluginProtocol) - 1) == 0); - return FindPayload(request->url) != NULL; -} - -CPError STDCALL CPR_StartRequest(CPRequest* request) { - const TestResponsePayload* payload = FindPayload(request->url); - DCHECK(payload); - ResponseStream* stream = new ResponseStream(payload, request); - stream->AddRef(); // Released in CPR_EndRequest - stream->Init(); - request->pdata = stream; - return payload->async ? CPERR_IO_PENDING : CPERR_SUCCESS; -} - -void STDCALL CPR_EndRequest(CPRequest* request, CPError reason) { - ResponseStream* stream = static_cast<ResponseStream*>(request->pdata); - request->pdata = NULL; - stream->Release(); // balances AddRef in CPR_StartRequest -} - -void STDCALL CPR_SetExtraRequestHeaders(CPRequest* request, - const char* headers) { - // doesn't affect us -} - -void STDCALL CPR_SetRequestLoadFlags(CPRequest* request, uint32 flags) { - // doesn't affect us -} - -void STDCALL CPR_AppendDataToUpload(CPRequest* request, const char* bytes, - int bytes_len) { - // doesn't affect us -} - -CPError STDCALL CPR_AppendFileToUpload(CPRequest* request, const char* filepath, - uint64 offset, uint64 length) { - // doesn't affect us - return CPERR_FAILURE; -} - -int STDCALL CPR_GetResponseInfo(CPRequest* request, CPResponseInfoType type, - void* buf, uint32 buf_size) { - ResponseStream* stream = static_cast<ResponseStream*>(request->pdata); - return stream->GetResponseInfo(type, buf, buf_size); -} - -int STDCALL CPR_Read(CPRequest* request, void* buf, uint32 buf_size) { - ResponseStream* stream = static_cast<ResponseStream*>(request->pdata); - return stream->ReadData(buf, buf_size); -} - -// RequestResponse: manages the retrieval of response data from the host - -class RequestResponse { - public: - explicit RequestResponse(const std::string& raw_headers) - : raw_headers_(raw_headers), offset_(0) {} - void StartReading(CPRequest* request); - void ReadCompleted(CPRequest* request, int bytes_read); - - private: - std::string raw_headers_; - std::string body_; - int offset_; -}; - -void RequestResponse::StartReading(CPRequest* request) { - int rv = 0; - const uint32 kReadSize = 4096; - do { - body_.resize(offset_ + kReadSize); - rv = g_cprequest_funcs.read(request, &body_[offset_], kReadSize); - if (rv > 0) - offset_ += rv; - } while (rv > 0); - - if (rv != CPERR_IO_PENDING) { - // Either an error occurred, or we are done. - ReadCompleted(request, rv); - } -} - -void RequestResponse::ReadCompleted(CPRequest* request, int bytes_read) { - if (bytes_read > 0) { - offset_ += bytes_read; - StartReading(request); - return; - } - - body_.resize(offset_); - bool success = (bytes_read == 0); - g_cptest_funcs.test_complete(request, success, raw_headers_, body_); - g_cprequest_funcs.end_request(request, CPERR_CANCELLED); - delete this; -} - -void STDCALL CPRR_ReceivedRedirect(CPRequest* request, const char* new_url) { -} - -void STDCALL CPRR_StartCompleted(CPRequest* request, CPError result) { - DCHECK(!request->pdata); - - std::string raw_headers; - int size = g_cprequest_funcs.get_response_info( - request, CPRESPONSEINFO_HTTP_RAW_HEADERS, NULL, 0); - int rv = size < 0 ? size : g_cprequest_funcs.get_response_info( - request, CPRESPONSEINFO_HTTP_RAW_HEADERS, - WriteInto(&raw_headers, size+1), size); - if (rv != CPERR_SUCCESS) { - g_cptest_funcs.test_complete(request, false, std::string(), std::string()); - g_cprequest_funcs.end_request(request, CPERR_CANCELLED); - return; - } - - RequestResponse* response = new RequestResponse(raw_headers); - request->pdata = response; - response->StartReading(request); -} - -void STDCALL CPRR_ReadCompleted(CPRequest* request, int bytes_read) { - RequestResponse* response = - reinterpret_cast<RequestResponse*>(request->pdata); - response->ReadCompleted(request, bytes_read); -} - -int STDCALL CPT_MakeRequest(const char* method, const GURL& url) { - CPRequest* request = NULL; - if (g_cpbrowser_funcs.create_request(g_cpid, NULL, method, url.spec().c_str(), - &request) != CPERR_SUCCESS || - !request) { - return CPERR_FAILURE; - } - - g_cprequest_funcs.set_request_load_flags(request, - CPREQUESTLOAD_DISABLE_INTERCEPT); - - if (strcmp(method, "POST") == 0) { - g_cprequest_funcs.set_extra_request_headers( - request, "Content-Type: text/plain"); - g_cprequest_funcs.append_data_to_upload( - request, kChromeTestPluginPostData, - arraysize(kChromeTestPluginPostData) - 1); - } - - int rv = g_cprequest_funcs.start_request(request); - if (rv == CPERR_SUCCESS) { - CPRR_StartCompleted(request, CPERR_SUCCESS); - } else if (rv != CPERR_IO_PENDING) { - g_cprequest_funcs.end_request(request, CPERR_CANCELLED); - return CPERR_FAILURE; - } - - return CPERR_SUCCESS; -} - -// DLL entry points - -CPError STDCALL CP_Initialize(CPID id, const CPBrowserFuncs* bfuncs, - CPPluginFuncs* pfuncs) { - if (bfuncs == NULL || pfuncs == NULL) - return CPERR_FAILURE; - - if (CP_GET_MAJOR_VERSION(bfuncs->version) > CP_MAJOR_VERSION) - return CPERR_INVALID_VERSION; - - if (bfuncs->size < sizeof(CPBrowserFuncs) || - pfuncs->size < sizeof(CPPluginFuncs)) - return CPERR_INVALID_VERSION; - - pfuncs->version = CP_VERSION; - pfuncs->shutdown = CPP_Shutdown; - pfuncs->should_intercept_request = CPP_ShouldInterceptRequest; - - static CPRequestFuncs 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; - pfuncs->request_funcs = &request_funcs; - - static CPResponseFuncs response_funcs; - response_funcs.received_redirect = CPRR_ReceivedRedirect; - response_funcs.start_completed = CPRR_StartCompleted; - response_funcs.read_completed = CPRR_ReadCompleted; - pfuncs->response_funcs = &response_funcs; - - g_cpid = id; - g_cpbrowser_funcs = *bfuncs; - g_cprequest_funcs = *bfuncs->request_funcs; - g_cpresponse_funcs = *bfuncs->response_funcs; - g_cpbrowser_funcs = *bfuncs; - - const char* protocols[] = {kChromeTestPluginProtocol}; - g_cpbrowser_funcs.enable_request_intercept(g_cpid, protocols, 1); - return CPERR_SUCCESS; -} - -int STDCALL CP_Test(void* vparam) { - TestFuncParams* param = reinterpret_cast<TestFuncParams*>(vparam); - param->pfuncs.test_make_request = CPT_MakeRequest; - - g_cptest_funcs = param->bfuncs; - return CPERR_SUCCESS; -} diff --git a/chrome/test/chrome_plugin/test_chrome_plugin.def b/chrome/test/chrome_plugin/test_chrome_plugin.def deleted file mode 100644 index 18a26cb..0000000 --- a/chrome/test/chrome_plugin/test_chrome_plugin.def +++ /dev/null @@ -1,4 +0,0 @@ -EXPORTS - CP_Initialize @1 - CP_Test @2 - diff --git a/chrome/test/chrome_plugin/test_chrome_plugin.h b/chrome/test/chrome_plugin/test_chrome_plugin.h deleted file mode 100644 index 19d3310..0000000 --- a/chrome/test/chrome_plugin/test_chrome_plugin.h +++ /dev/null @@ -1,71 +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. -// Shared by the plugin DLL and the unittest code. - -#ifndef CHROME_TEST_CHROME_PLUGIN_TEST_CHROME_PLUGIN_H__ -#define CHROME_TEST_CHROME_PLUGIN_TEST_CHROME_PLUGIN_H__ -#pragma once - -#include <string> - -#include "base/basictypes.h" -#include "chrome/common/chrome_plugin_api.h" - -class GURL; - -struct TestResponsePayload { - const char* url; - bool async; - int status; - const char* mime_type; - const char* body; -}; - -const char kChromeTestPluginProtocol[] = "cptest"; - -const TestResponsePayload kChromeTestPluginPayloads[] = { - { - "cptest:sync", - false, - 200, - "text/html", - "<head><title>cptest:sync</title></head><body>SUCCESS</body>" - }, - { - "cptest:async", - true, - 200, - "text/plain", - "<head><title>cptest:async</title></head><body>SUCCESS</body>" - }, - { - "cptest:blank", - false, - 200, - "text/plain", - "" - }, -}; - -struct TestFuncParams { - typedef void (STDCALL *CallbackFunc)(void* data); - - struct PluginFuncs { - int (STDCALL *test_make_request)(const char* method, const GURL& url); - }; - PluginFuncs pfuncs; - - struct BrowserFuncs { - void (STDCALL *test_complete)(CPRequest* request, bool success, - const std::string& raw_headers, - const std::string& body); - void (STDCALL *invoke_later)(CallbackFunc callback, void* callback_data, - int delay_ms); - }; - BrowserFuncs bfuncs; -}; - -const char kChromeTestPluginPostData[] = "Test Data"; - -#endif // CHROME_TEST_CHROME_PLUGIN_TEST_CHROME_PLUGIN_H__ diff --git a/chrome/test/startup/startup_test.cc b/chrome/test/startup/startup_test.cc index 8e0e826..9cc8541 100644 --- a/chrome/test/startup/startup_test.cc +++ b/chrome/test/startup/startup_test.cc @@ -44,7 +44,7 @@ class StartupTest : public UIPerfTest { }; // Load a file on startup rather than about:blank. This tests a longer - // startup path, including resource loading and the loading of gears.dll. + // startup path, including resource loading. void SetUpWithFileURL() { const FilePath file_url = ui_test_utils::GetTestFilePath( FilePath(FilePath::kCurrentDirectory), @@ -141,15 +141,6 @@ class StartupTest : public UIPerfTest { FilePath chrome_dll(dir_app.Append(FILE_PATH_LITERAL("chrome.dll"))); ASSERT_TRUE(EvictFileFromSystemCacheWrapper(chrome_dll)); #endif - -#if defined(OS_WIN) - // TODO(port): Re-enable once gears is working on mac/linux. - FilePath gears_dll; - ASSERT_TRUE(PathService::Get(chrome::FILE_GEARS_PLUGIN, &gears_dll)); - ASSERT_TRUE(EvictFileFromSystemCacheWrapper(gears_dll)); -#else - NOTIMPLEMENTED() << "gears not enabled yet"; -#endif } UITest::SetUp(); TimeTicks end_time = TimeTicks::Now(); @@ -370,21 +361,6 @@ TEST_F(StartupTest, MAYBE_PerfExtensionContentScript50) { ProxyLauncher::DEFAULT_THEME, 1, 0); } -#if defined(OS_WIN) -// TODO(port): Enable gears tests on linux/mac once gears is working. -TEST_F(StartupTest, PerfGears) { - SetUpWithFileURL(); - RunStartupTest("warm", "gears", WARM, NOT_IMPORTANT, - ProxyLauncher::DEFAULT_THEME, 1, 0); -} - -TEST_F(StartupTest, PerfColdGears) { - SetUpWithFileURL(); - RunStartupTest("cold", "gears", COLD, NOT_IMPORTANT, - ProxyLauncher::DEFAULT_THEME, 1, 0); -} -#endif - TEST_F(StartupTest, PerfComplexTheme) { RunStartupTest("warm", "t-theme", WARM, NOT_IMPORTANT, ProxyLauncher::COMPLEX_THEME, 0, 0); diff --git a/chrome/tools/build/win/FILES b/chrome/tools/build/win/FILES index 5136ca7..73ce368 100644 --- a/chrome/tools/build/win/FILES +++ b/chrome/tools/build/win/FILES @@ -7,7 +7,6 @@ chrome.dll nacl64.dll crash_service.exe First Run -gears.dll ppGoogleNaClPluginChrome.dll icudt.dll locales/ar.dll diff --git a/chrome/tools/build/win/FILES.cfg b/chrome/tools/build/win/FILES.cfg index 4817b15..41d9d18 100644 --- a/chrome/tools/build/win/FILES.cfg +++ b/chrome/tools/build/win/FILES.cfg @@ -61,12 +61,7 @@ FILES = [ 'buildtype': ['dev', 'official'], }, { - 'filename': 'gears.dll', - 'arch': ['32bit', '64bit'], - 'buildtype': ['dev', 'official'], - }, - { - 'filename': 'icudt.dll', + 'filename': 'icudt46.dll', 'arch': ['32bit', '64bit'], 'buildtype': ['dev', 'official'], }, diff --git a/chrome/tools/build/win/create_installer_archive.py b/chrome/tools/build/win/create_installer_archive.py index ac0683a..b9638dc 100755 --- a/chrome/tools/build/win/create_installer_archive.py +++ b/chrome/tools/build/win/create_installer_archive.py @@ -142,10 +142,10 @@ def GetPrevVersion(output_dir, temp_dir, last_chrome_installer): lzma_exec = GetLZMAExec(options.output_dir) prev_archive_file = os.path.join(options.last_chrome_installer, options.output_name + ARCHIVE_SUFFIX) - cmd = '%s x -o"%s" "%s" Chrome-bin/*/gears.dll' % (lzma_exec, temp_dir, - prev_archive_file) + cmd = '%s x -o"%s" "%s" Chrome-bin/*/chrome.dll' % (lzma_exec, temp_dir, + prev_archive_file) RunSystemCommand(cmd) - dll_path = glob.glob(os.path.join(temp_dir, 'Chrome-bin', '*', 'gears.dll')) + dll_path = glob.glob(os.path.join(temp_dir, 'Chrome-bin', '*', 'chrome.dll')) return os.path.split(os.path.split(dll_path[0])[0])[1] def MakeStagingDirectories(output_dir): |