diff options
42 files changed, 49 insertions, 1820 deletions
diff --git a/chrome/browser/automation/automation_extension_function.cc b/chrome/browser/automation/automation_extension_function.cc deleted file mode 100644 index 4ef67b4..0000000 --- a/chrome/browser/automation/automation_extension_function.cc +++ /dev/null @@ -1,185 +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. - -// Implements AutomationExtensionFunction. - -#include "chrome/browser/automation/automation_extension_function.h" - -#include "base/json/json_reader.h" -#include "base/json/json_writer.h" -#include "base/values.h" -#include "chrome/browser/automation/extension_automation_constants.h" -#include "chrome/browser/extensions/extension_function_dispatcher.h" -#include "chrome/browser/extensions/extension_tabs_module.h" -#include "content/browser/renderer_host/render_view_host.h" -#include "content/browser/renderer_host/render_view_host_delegate.h" -#include "content/browser/tab_contents/tab_contents.h" -#include "content/browser/tab_contents/tab_contents_delegate.h" - -TabContents* AutomationExtensionFunction::api_handler_tab_ = NULL; -AutomationExtensionFunction::PendingFunctionsMap - AutomationExtensionFunction::pending_functions_; - -AutomationExtensionFunction::AutomationExtensionFunction() { -} - -void AutomationExtensionFunction::SetArgs(const ListValue* args) { - // Need to JSON-encode for sending over the wire to the automation user. - base::JSONWriter::Write(args, false, &args_); -} - -const std::string AutomationExtensionFunction::GetResult() { - // Already JSON-encoded, so override the base class's implementation. - return json_result_; -} - -bool AutomationExtensionFunction::RunImpl() { - namespace keys = extension_automation_constants; - - DCHECK(api_handler_tab_) << - "Why is this function still enabled if no target tab?"; - if (!api_handler_tab_) { - error_ = "No longer automating functions."; - return false; - } - - // We are being driven through automation, so we send the extension API - // request over to the automation host. We do this before decoding the - // 'args' JSON, otherwise we'd be decoding it only to encode it again. - DictionaryValue message_to_host; - message_to_host.SetString(keys::kAutomationNameKey, name_); - message_to_host.SetString(keys::kAutomationArgsKey, args_); - message_to_host.SetInteger(keys::kAutomationRequestIdKey, request_id_); - message_to_host.SetBoolean(keys::kAutomationHasCallbackKey, has_callback_); - // Send the API request's associated tab along to the automation client, so - // that it can determine the execution context of the API call. - TabContents* contents = NULL; - ExtensionFunctionDispatcher* function_dispatcher = dispatcher(); - if (function_dispatcher && function_dispatcher->delegate()) { - contents = function_dispatcher->delegate()->associated_tab_contents(); - } else { - NOTREACHED() << "Extension function dispatcher delegate not found."; - } - if (contents) - message_to_host.Set(keys::kAutomationTabJsonKey, - ExtensionTabUtil::CreateTabValue(contents)); - - std::string message; - base::JSONWriter::Write(&message_to_host, false, &message); - if (api_handler_tab_->delegate()) { - api_handler_tab_->delegate()->ForwardMessageToExternalHost( - message, keys::kAutomationOrigin, keys::kAutomationRequestTarget); - } else { - NOTREACHED() << "ExternalTabContainer is supposed to correctly manage " - "lifetime of api_handler_tab_."; - } - - // Automation APIs are asynchronous so we need to stick around until - // our response comes back. Add ourselves to a static hash map keyed - // by request ID. The hash map keeps a reference count on us. - DCHECK(pending_functions_.find(request_id_) == pending_functions_.end()); - pending_functions_[request_id_] = this; - - return true; -} - -ExtensionFunction* AutomationExtensionFunction::Factory() { - return new AutomationExtensionFunction(); -} - -void AutomationExtensionFunction::Enable( - TabContents* api_handler_tab, - const std::vector<std::string>& functions_enabled) { - DCHECK(api_handler_tab); - if (api_handler_tab_ && api_handler_tab != api_handler_tab_) { - NOTREACHED() << "Don't call with different API handler."; - return; - } - api_handler_tab_ = api_handler_tab; - - std::vector<std::string> function_names; - if (functions_enabled.size() == 1 && functions_enabled[0] == "*") { - ExtensionFunctionDispatcher::GetAllFunctionNames(&function_names); - } else { - function_names = functions_enabled; - } - - for (std::vector<std::string>::iterator it = function_names.begin(); - it != function_names.end(); it++) { - // TODO(joi) Could make this a per-profile change rather than a global - // change. Could e.g. have the AutomationExtensionFunction store the - // profile pointer and dispatch to the original ExtensionFunction when the - // current profile is not that. - bool result = ExtensionFunctionDispatcher::OverrideFunction( - *it, AutomationExtensionFunction::Factory); - LOG_IF(WARNING, !result) << "Failed to override API function: " << *it; - } -} - -void AutomationExtensionFunction::Disable() { - api_handler_tab_ = NULL; - ExtensionFunctionDispatcher::ResetFunctions(); -} - -bool AutomationExtensionFunction::InterceptMessageFromExternalHost( - RenderViewHost* view_host, - const std::string& message, - const std::string& origin, - const std::string& target) { - namespace keys = extension_automation_constants; - - // We want only specially-tagged messages passed via the conduit tab. - if (api_handler_tab_ && - view_host == api_handler_tab_->render_view_host() && - origin == keys::kAutomationOrigin && - target == keys::kAutomationResponseTarget) { - // This is an extension API response being sent back via postMessage, - // so redirect it. - scoped_ptr<Value> message_value(base::JSONReader::Read(message, false)); - DCHECK(message_value->IsType(Value::TYPE_DICTIONARY)); - if (message_value->IsType(Value::TYPE_DICTIONARY)) { - DictionaryValue* message_dict = - reinterpret_cast<DictionaryValue*>(message_value.get()); - - int request_id = -1; - bool got_value = message_dict->GetInteger(keys::kAutomationRequestIdKey, - &request_id); - DCHECK(got_value); - if (got_value) { - std::string error; - bool success = !message_dict->GetString(keys::kAutomationErrorKey, - &error); - - std::string response; - got_value = message_dict->GetString(keys::kAutomationResponseKey, - &response); - DCHECK(!success || got_value); - - PendingFunctionsMap::iterator it = pending_functions_.find(request_id); - DCHECK(it != pending_functions_.end()); - - if (it != pending_functions_.end()) { - scoped_refptr<AutomationExtensionFunction> func = it->second; - pending_functions_.erase(it); - - // Our local ref should be the last remaining. - DCHECK(func && func->HasOneRef()); - - if (func) { - func->json_result_ = response; - func->error_ = error; - - func->SendResponse(success); - } - } - return true; - } - } - } - - return false; -} - -AutomationExtensionFunction::~AutomationExtensionFunction() { -} diff --git a/chrome/browser/automation/automation_extension_function.h b/chrome/browser/automation/automation_extension_function.h deleted file mode 100644 index 275d3c9..0000000 --- a/chrome/browser/automation/automation_extension_function.h +++ /dev/null @@ -1,78 +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. - -// Defines AutomationExtensionFunction. - -#ifndef CHROME_BROWSER_AUTOMATION_AUTOMATION_EXTENSION_FUNCTION_H_ -#define CHROME_BROWSER_AUTOMATION_AUTOMATION_EXTENSION_FUNCTION_H_ -#pragma once - -#include <map> -#include <string> -#include <vector> - -#include "chrome/browser/extensions/extension_function.h" - -class RenderViewHost; -class TabContents; - -// An extension function that pipes the extension API call through the -// automation interface, so that extensions can be tested using UITests. -class AutomationExtensionFunction : public AsyncExtensionFunction { - public: - AutomationExtensionFunction(); - - // ExtensionFunction implementation. - virtual void SetArgs(const ListValue* args); - virtual const std::string GetResult(); - virtual bool RunImpl(); - - static ExtensionFunction* Factory(); - - // Enable API automation of selected APIs. Overridden extension API messages - // will be routed to the automation client attached to |api_handler_tab|. - // - // If the list of enabled functions is non-empty, we enable according to the - // list ("*" means enable all, otherwise we enable individual named - // functions). An empty list makes this function a no-op. - // - // Note that all calls to this function are additive. Functions previously - // enabled will remain enabled until you call Disable(). - // - // Calling this function after enabling one or more functions with a - // tab other than the one previously used is an error. - static void Enable(TabContents* api_handler_tab, - const std::vector<std::string>& functions_enabled); - - // Restore the default API function implementations and reset the stored - // API handler. - static void Disable(); - - // Intercepts messages sent from the external host to check if they - // are actually responses to extension API calls. If they are, redirects - // the message to respond to the pending asynchronous API call and returns - // true, otherwise returns false to indicate the message was not intercepted. - static bool InterceptMessageFromExternalHost(RenderViewHost* view_host, - const std::string& message, - const std::string& origin, - const std::string& target); - - private: - ~AutomationExtensionFunction(); - - // Weak reference, lifetime managed by the ExternalTabContainer instance - // owning the TabContents in question. - static TabContents* api_handler_tab_; - - typedef std::map<int, scoped_refptr<AutomationExtensionFunction> > - PendingFunctionsMap; - static PendingFunctionsMap pending_functions_; - - std::string args_; - std::string json_result_; - - DISALLOW_COPY_AND_ASSIGN(AutomationExtensionFunction); -}; - -#endif // CHROME_BROWSER_AUTOMATION_AUTOMATION_EXTENSION_FUNCTION_H_ diff --git a/chrome/browser/automation/automation_provider.cc b/chrome/browser/automation/automation_provider.cc index e1b2bb5..bacc9eb 100644 --- a/chrome/browser/automation/automation_provider.cc +++ b/chrome/browser/automation/automation_provider.cc @@ -34,7 +34,6 @@ #include "chrome/browser/automation/automation_resource_message_filter.h" #include "chrome/browser/automation/automation_tab_tracker.h" #include "chrome/browser/automation/automation_window_tracker.h" -#include "chrome/browser/automation/extension_port_container.h" #include "chrome/browser/automation/ui_controls.h" #include "chrome/browser/blocked_content_container.h" #include "chrome/browser/bookmarks/bookmark_model.h" @@ -132,10 +131,6 @@ AutomationProvider::AutomationProvider(Profile* profile) } AutomationProvider::~AutomationProvider() { - STLDeleteContainerPairSecondPointers(port_containers_.begin(), - port_containers_.end()); - port_containers_.clear(); - if (channel_.get()) channel_->Close(); @@ -222,36 +217,6 @@ void AutomationProvider::RemoveLoginHandler(NavigationController* tab) { login_handler_map_.erase(tab); } -void AutomationProvider::AddPortContainer(ExtensionPortContainer* port) { - int port_id = port->port_id(); - DCHECK_NE(-1, port_id); - DCHECK(port_containers_.find(port_id) == port_containers_.end()); - - port_containers_[port_id] = port; -} - -void AutomationProvider::RemovePortContainer(ExtensionPortContainer* port) { - int port_id = port->port_id(); - DCHECK_NE(-1, port_id); - - PortContainerMap::iterator it = port_containers_.find(port_id); - DCHECK(it != port_containers_.end()); - - if (it != port_containers_.end()) { - delete it->second; - port_containers_.erase(it); - } -} - -ExtensionPortContainer* AutomationProvider::GetPortContainer( - int port_id) const { - PortContainerMap::const_iterator it = port_containers_.find(port_id); - if (it == port_containers_.end()) - return NULL; - - return it->second; -} - int AutomationProvider::GetIndexForNavigationController( const NavigationController* controller, const Browser* parent) const { DCHECK(parent); @@ -359,10 +324,6 @@ bool AutomationProvider::OnMessageReceived(const IPC::Message& message) { IPC_MESSAGE_HANDLER(AutomationMsg_SetPageFontSize, OnSetPageFontSize) IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_InstallExtension, InstallExtension) - IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_LoadExpandedExtension, - LoadExpandedExtension) - IPC_MESSAGE_HANDLER(AutomationMsg_GetEnabledExtensions, - GetEnabledExtensions) IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_WaitForExtensionTestResult, WaitForExtensionTestResult) IPC_MESSAGE_HANDLER_DELAY_REPLY( @@ -399,8 +360,6 @@ bool AutomationProvider::OnMessageReceived(const IPC::Message& message) { IPC_MESSAGE_HANDLER(AutomationMsg_NavigateExternalTabAtIndex, NavigateExternalTabAtIndex) IPC_MESSAGE_HANDLER(AutomationMsg_ConnectExternalTab, ConnectExternalTab) - IPC_MESSAGE_HANDLER(AutomationMsg_SetEnableExtensionAutomation, - SetEnableExtensionAutomation) IPC_MESSAGE_HANDLER(AutomationMsg_HandleMessageFromExternalHost, OnMessageFromExternalHost) IPC_MESSAGE_HANDLER(AutomationMsg_BrowserMove, OnBrowserMoved) @@ -821,44 +780,6 @@ void AutomationProvider::InstallExtension(const FilePath& crx_path, } } -void AutomationProvider::LoadExpandedExtension( - const FilePath& extension_dir, - IPC::Message* reply_message) { - if (profile_->GetExtensionService()) { - // The observer will delete itself when done. - new ExtensionInstallNotificationObserver( - this, - AutomationMsg_LoadExpandedExtension::ID, - reply_message); - - profile_->GetExtensionService()->LoadExtension(extension_dir); - } else { - AutomationMsg_LoadExpandedExtension::WriteReplyParams( - reply_message, AUTOMATION_MSG_EXTENSION_INSTALL_FAILED); - Send(reply_message); - } -} - -void AutomationProvider::GetEnabledExtensions( - std::vector<FilePath>* result) { - ExtensionService* service = profile_->GetExtensionService(); - DCHECK(service); - if (service->extensions_enabled()) { - const ExtensionList* extensions = service->extensions(); - DCHECK(extensions); - for (size_t i = 0; i < extensions->size(); ++i) { - const Extension* extension = (*extensions)[i]; - DCHECK(extension); - // AutomationProvider only exposes non app internal/loaded extensions. - if (!extension->is_app() && - (extension->location() == Extension::INTERNAL || - extension->location() == Extension::LOAD)) { - result->push_back(extension->path()); - } - } - } -} - void AutomationProvider::WaitForExtensionTestResult( IPC::Message* reply_message) { DCHECK(!reply_message_); diff --git a/chrome/browser/automation/automation_provider.h b/chrome/browser/automation/automation_provider.h index 0bd06c7..f66ccec 100644 --- a/chrome/browser/automation/automation_provider.h +++ b/chrome/browser/automation/automation_provider.h @@ -123,14 +123,6 @@ class AutomationProvider void AddLoginHandler(NavigationController* tab, LoginHandler* handler); void RemoveLoginHandler(NavigationController* tab); - // Add an extension port container. - // Takes ownership of the container. - void AddPortContainer(ExtensionPortContainer* port); - // Remove and delete the port container. - void RemovePortContainer(ExtensionPortContainer* port); - // Get the port container for the given port id. - ExtensionPortContainer* GetPortContainer(int port_id) const; - // IPC implementations virtual bool Send(IPC::Message* msg); virtual void OnChannelConnected(int pid); @@ -257,11 +249,6 @@ class AutomationProvider void InstallExtension(const FilePath& crx_path, IPC::Message* reply_message); - void LoadExpandedExtension(const FilePath& extension_dir, - IPC::Message* reply_message); - - void GetEnabledExtensions(std::vector<FilePath>* result); - void WaitForExtensionTestResult(IPC::Message* reply_message); void InstallExtensionAndGetHandle(const FilePath& crx_path, @@ -301,11 +288,6 @@ class AutomationProvider const std::string& encoding_name, bool* success); - // Enables extension automation (for e.g. UITests). - void SetEnableExtensionAutomation( - int tab_handle, - const std::vector<std::string>& functions_enabled); - // Selects all contents on the page. void SelectAll(int tab_handle); @@ -376,12 +358,6 @@ class AutomationProvider const std::string& origin, const std::string& target); - // Determine if the message from the external host represents a browser - // event, and if so dispatch it. - bool InterceptBrowserEventMessageFromExternalHost(const std::string& message, - const std::string& origin, - const std::string& target); - void OnBrowserMoved(int handle); void OnRunUnloadHandlers(int handle, IPC::Message* reply_message); @@ -391,15 +367,12 @@ class AutomationProvider ExternalTabContainer* GetExternalTabForHandle(int handle); #endif // defined(OS_WIN) - typedef std::map<int, ExtensionPortContainer*> PortContainerMap; - scoped_ptr<IPC::ChannelProxy> channel_; scoped_ptr<NotificationObserver> new_tab_ui_load_observer_; scoped_ptr<NotificationObserver> find_in_page_observer_; scoped_ptr<ExtensionTestResultNotificationObserver> extension_test_result_observer_; scoped_ptr<AutomationExtensionTracker> extension_tracker_; - PortContainerMap port_containers_; // True iff connected to an AutomationProxy. bool is_connected_; diff --git a/chrome/browser/automation/automation_provider_observers.cc b/chrome/browser/automation/automation_provider_observers.cc index cd32925..78c09c1 100644 --- a/chrome/browser/automation/automation_provider_observers.cc +++ b/chrome/browser/automation/automation_provider_observers.cc @@ -492,10 +492,6 @@ void ExtensionInstallNotificationObserver::SendResponse( AutomationMsg_InstallExtension::WriteReplyParams(reply_message_.get(), response); break; - case AutomationMsg_LoadExpandedExtension::ID: - AutomationMsg_LoadExpandedExtension::WriteReplyParams( - reply_message_.get(), response); - break; default: NOTREACHED(); break; diff --git a/chrome/browser/automation/automation_provider_win.cc b/chrome/browser/automation/automation_provider_win.cc index 6cc06d9..9d41e50 100644 --- a/chrome/browser/automation/automation_provider_win.cc +++ b/chrome/browser/automation/automation_provider_win.cc @@ -8,14 +8,10 @@ #include "base/json/json_reader.h" #include "base/utf_string_conversions.h" #include "chrome/browser/automation/automation_browser_tracker.h" -#include "chrome/browser/automation/automation_extension_function.h" #include "chrome/browser/automation/automation_tab_tracker.h" #include "chrome/browser/automation/automation_window_tracker.h" -#include "chrome/browser/automation/extension_automation_constants.h" -#include "chrome/browser/automation/extension_port_container.h" #include "chrome/browser/automation/ui_controls.h" #include "chrome/browser/browser_window.h" -#include "chrome/browser/extensions/extension_event_router.h" #include "chrome/browser/external_tab_container_win.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/browser.h" @@ -405,21 +401,6 @@ void AutomationProvider::ConnectExternalTab( TRACE_EVENT_END("AutomationProvider::ConnectExternalTab", 0, ""); } -void AutomationProvider::SetEnableExtensionAutomation( - int tab_handle, - const std::vector<std::string>& functions_enabled) { - ExternalTabContainer* external_tab = GetExternalTabForHandle(tab_handle); - if (external_tab) { - external_tab->SetEnableExtensionAutomation(functions_enabled); - } else { - // Tab must exist, and must be an external tab so that its - // delegate has an on-empty - // implementation of ForwardMessageToExternalHost. - DLOG(WARNING) << - "SetEnableExtensionAutomation called with invalid tab handle."; - } -} - void AutomationProvider::OnBrowserMoved(int tab_handle) { ExternalTabContainer* external_tab = GetExternalTabForHandle(tab_handle); if (external_tab) { @@ -438,69 +419,9 @@ void AutomationProvider::OnMessageFromExternalHost(int handle, if (!view_host) return; - if (AutomationExtensionFunction::InterceptMessageFromExternalHost( - view_host, message, origin, target)) { - // Message was diverted. - return; - } - - if (ExtensionPortContainer::InterceptMessageFromExternalHost( - message, origin, target, this, view_host, handle)) { - // Message was diverted. - return; - } - - if (InterceptBrowserEventMessageFromExternalHost(message, origin, target)) { - // Message was diverted. - return; - } - view_host->ForwardMessageFromExternalHost(message, origin, target); } -bool AutomationProvider::InterceptBrowserEventMessageFromExternalHost( - const std::string& message, const std::string& origin, - const std::string& target) { - if (target != - extension_automation_constants::kAutomationBrowserEventRequestTarget) - return false; - - if (origin != extension_automation_constants::kAutomationOrigin) { - LOG(WARNING) << "Wrong origin on automation browser event " << origin; - return false; - } - - // The message is a JSON-encoded array with two elements, both strings. The - // first is the name of the event to dispatch. The second is a JSON-encoding - // of the arguments specific to that event. - scoped_ptr<Value> message_value(base::JSONReader::Read(message, false)); - if (!message_value.get() || !message_value->IsType(Value::TYPE_LIST)) { - LOG(WARNING) << "Invalid browser event specified through automation"; - return false; - } - - const ListValue* args = static_cast<const ListValue*>(message_value.get()); - - std::string event_name; - if (!args->GetString(0, &event_name)) { - LOG(WARNING) << "No browser event name specified through automation"; - return false; - } - - std::string json_args; - if (!args->GetString(1, &json_args)) { - LOG(WARNING) << "No browser event args specified through automation"; - return false; - } - - if (profile()->GetExtensionEventRouter()) { - profile()->GetExtensionEventRouter()->DispatchEventToRenderers( - event_name, json_args, profile(), GURL()); - } - - return true; -} - void AutomationProvider::NavigateInExternalTab( int handle, const GURL& url, const GURL& referrer, AutomationMsg_NavigationResponseValues* status) { diff --git a/chrome/browser/automation/chrome_frame_automation_provider.cc b/chrome/browser/automation/chrome_frame_automation_provider.cc index 7b699f1..07ef8b62 100644 --- a/chrome/browser/automation/chrome_frame_automation_provider.cc +++ b/chrome/browser/automation/chrome_frame_automation_provider.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// 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. @@ -43,10 +43,6 @@ bool ChromeFrameAutomationProvider::IsValidMessage(uint32 type) { case AutomationMsg_NavigateInExternalTab::ID: case AutomationMsg_NavigateExternalTabAtIndex::ID: case AutomationMsg_Find::ID: - case AutomationMsg_InstallExtension::ID: - case AutomationMsg_LoadExpandedExtension::ID: - case AutomationMsg_GetEnabledExtensions::ID: - case AutomationMsg_SetEnableExtensionAutomation::ID: case AutomationMsg_SetInitialFocus::ID: case AutomationMsg_SetPageFontSize::ID: case AutomationMsg_SetProxyConfig::ID: @@ -77,4 +73,3 @@ bool ChromeFrameAutomationProvider::IsValidMessage(uint32 type) { return is_valid_message; } - diff --git a/chrome/browser/automation/extension_automation_constants.cc b/chrome/browser/automation/extension_automation_constants.cc deleted file mode 100644 index c4e6fce..0000000 --- a/chrome/browser/automation/extension_automation_constants.cc +++ /dev/null @@ -1,32 +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. - -#include "chrome/browser/automation/extension_automation_constants.h" - -namespace extension_automation_constants { - -const char kAutomationOrigin[] = "__priv_xtapi"; -const char kAutomationRequestIdKey[] = "rqid"; - -const char kAutomationHasCallbackKey[] = "hascb"; -const char kAutomationErrorKey[] = "err"; -const char kAutomationNameKey[] = "name"; -const char kAutomationArgsKey[] = "args"; -const char kAutomationResponseKey[] = "res"; -const char kAutomationRequestTarget[] = "__priv_xtreq"; -const char kAutomationResponseTarget[] = "__priv_xtres"; - -const char kAutomationConnectionIdKey[] = "connid"; -const char kAutomationMessageDataKey[] = "data"; -const char kAutomationExtensionIdKey[] = "extid"; -const char kAutomationPortIdKey[] = "portid"; -const char kAutomationChannelNameKey[] = "chname"; -const char kAutomationTabJsonKey[] = "tab"; - -const char kAutomationPortRequestTarget[] = "__priv_prtreq"; -const char kAutomationPortResponseTarget[] = "__priv_prtres"; - -const char kAutomationBrowserEventRequestTarget[] = "__priv_evtreq"; - -} // namespace extension_automation_constants diff --git a/chrome/browser/automation/extension_automation_constants.h b/chrome/browser/automation/extension_automation_constants.h deleted file mode 100644 index dea4d2d..0000000 --- a/chrome/browser/automation/extension_automation_constants.h +++ /dev/null @@ -1,55 +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. - -// Constants used to encode requests and responses for automation. - -#ifndef CHROME_BROWSER_AUTOMATION_EXTENSION_AUTOMATION_CONSTANTS_H_ -#define CHROME_BROWSER_AUTOMATION_EXTENSION_AUTOMATION_CONSTANTS_H_ -#pragma once - -namespace extension_automation_constants { - -// All extension automation related messages will have this origin. -extern const char kAutomationOrigin[]; -// Key used for all extension automation request types. -extern const char kAutomationRequestIdKey[]; - -// Keys used for API communications -extern const char kAutomationHasCallbackKey[]; -extern const char kAutomationErrorKey[]; // not present implies success -extern const char kAutomationNameKey[]; -extern const char kAutomationArgsKey[]; -extern const char kAutomationResponseKey[]; -// All external API requests have this target. -extern const char kAutomationRequestTarget[]; -// All API responses should have this target. -extern const char kAutomationResponseTarget[]; - -// Keys used for port communications -extern const char kAutomationConnectionIdKey[]; -extern const char kAutomationMessageDataKey[]; -extern const char kAutomationExtensionIdKey[]; -extern const char kAutomationPortIdKey[]; -extern const char kAutomationChannelNameKey[]; -extern const char kAutomationTabJsonKey[]; - -// All external port message requests should have this target. -extern const char kAutomationPortRequestTarget[]; -// All external port message responses have this target. -extern const char kAutomationPortResponseTarget[]; - -// All external browser events have this target. -extern const char kAutomationBrowserEventRequestTarget[]; - -// The command codes for our private port protocol. -enum PrivatePortCommand { - OPEN_CHANNEL = 0, - CHANNEL_OPENED = 1, - POST_MESSAGE = 2, - CHANNEL_CLOSED = 3, -}; - -}; // namespace automation_extension_constants - -#endif // CHROME_BROWSER_AUTOMATION_EXTENSION_AUTOMATION_CONSTANTS_H_ diff --git a/chrome/browser/automation/extension_port_container.cc b/chrome/browser/automation/extension_port_container.cc deleted file mode 100644 index bdcbb7e..0000000 --- a/chrome/browser/automation/extension_port_container.cc +++ /dev/null @@ -1,258 +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. - -#include "chrome/browser/automation/extension_port_container.h" - -#include "base/logging.h" -#include "base/json/json_reader.h" -#include "base/json/json_writer.h" -#include "base/values.h" -#include "chrome/browser/automation/automation_provider.h" -#include "chrome/browser/automation/extension_automation_constants.h" -#include "chrome/browser/extensions/extension_message_service.h" -#include "chrome/browser/profiles/profile.h" -#include "chrome/common/automation_messages.h" -#include "chrome/common/extensions/extension_messages.h" -#include "content/browser/renderer_host/render_process_host.h" -#include "content/browser/renderer_host/render_view_host.h" - -// TODO(siggi): Find a more structured way to read and write JSON messages. - -namespace ext = extension_automation_constants; - -ExtensionPortContainer::ExtensionPortContainer(AutomationProvider* automation, - int tab_handle) : - automation_(automation), service_(NULL), port_id_(-1), - tab_handle_(tab_handle) { - service_ = automation_->profile()->GetExtensionMessageService(); - DCHECK(service_); -} - -ExtensionPortContainer::~ExtensionPortContainer() { - DCHECK_EQ(MessageLoop::current()->type(), MessageLoop::TYPE_UI); - - if (port_id_ != -1) - service_->CloseChannel(port_id_); -} - -bool ExtensionPortContainer::PostResponseToExternalPort( - const std::string& message) { - return automation_->Send( - new AutomationMsg_ForwardMessageToExternalHost( - tab_handle_, message, ext::kAutomationOrigin, - ext::kAutomationPortResponseTarget)); -} - -bool ExtensionPortContainer::PostMessageToExternalPort( - const std::string& message) { - return automation_->Send( - new AutomationMsg_ForwardMessageToExternalHost( - tab_handle_, message, - ext::kAutomationOrigin, - ext::kAutomationPortRequestTarget)); -} - -void ExtensionPortContainer::PostMessageFromExternalPort( - const std::string &message) { - service_->PostMessageFromRenderer(port_id_, message); -} - -bool ExtensionPortContainer::Connect(const std::string &extension_id, - int process_id, - int routing_id, - int connection_id, - const std::string& channel_name, - const std::string& tab_json) { - DCHECK_EQ(MessageLoop::current()->type(), MessageLoop::TYPE_UI); - - port_id_ = service_->OpenSpecialChannelToExtension( - extension_id, channel_name, tab_json, this); - if (port_id_ == -1) { - // In this case a disconnect message has been dispatched. - return false; - } - - SendConnectionResponse(connection_id, port_id_); - return true; -} - -void ExtensionPortContainer::SendConnectionResponse(int connection_id, - int port_id) { - // Compose the reply message. - scoped_ptr<DictionaryValue> msg_dict(new DictionaryValue()); - msg_dict->SetInteger(ext::kAutomationRequestIdKey, ext::CHANNEL_OPENED); - msg_dict->SetInteger(ext::kAutomationConnectionIdKey, connection_id); - msg_dict->SetInteger(ext::kAutomationPortIdKey, port_id); - - std::string msg_json; - base::JSONWriter::Write(msg_dict.get(), false, &msg_json); - - PostResponseToExternalPort(msg_json); -} - -bool ExtensionPortContainer::Send(IPC::Message *message) { - DCHECK_EQ(MessageLoop::current()->type(), MessageLoop::TYPE_UI); - - IPC_BEGIN_MESSAGE_MAP(ExtensionPortContainer, *message) - IPC_MESSAGE_HANDLER(ExtensionMsg_MessageInvoke, OnExtensionMessageInvoke) - IPC_MESSAGE_UNHANDLED_ERROR() - IPC_END_MESSAGE_MAP() - - delete message; - return true; -} - -void ExtensionPortContainer::OnExtensionMessageInvoke( - const std::string& extension_id, - const std::string& function_name, - const ListValue& args, - const GURL& event_url) { - if (function_name == ExtensionMessageService::kDispatchOnMessage) { - DCHECK_EQ(args.GetSize(), 2u); - - std::string message; - int source_port_id; - if (args.GetString(0, &message) && args.GetInteger(1, &source_port_id)) - OnExtensionHandleMessage(message, source_port_id); - } else if (function_name == ExtensionMessageService::kDispatchOnDisconnect) { - DCHECK_EQ(args.GetSize(), 2u); - int port_id; - if (args.GetInteger(0, &port_id)) - OnExtensionPortDisconnected(port_id); - } else if (function_name == ExtensionMessageService::kDispatchOnConnect) { - // Do nothing. - // TODO(siggi): implement - } else { - NOTREACHED() << function_name << " shouldn't be called."; - } -} - -void ExtensionPortContainer::OnExtensionHandleMessage( - const std::string& message, int source_port_id) { - // Compose the reply message and fire it away. - DictionaryValue msg_dict; - msg_dict.SetInteger(ext::kAutomationRequestIdKey, ext::POST_MESSAGE); - msg_dict.SetInteger(ext::kAutomationPortIdKey, port_id_); - msg_dict.SetString(ext::kAutomationMessageDataKey, message); - - std::string msg_json; - base::JSONWriter::Write(&msg_dict, false, &msg_json); - - PostMessageToExternalPort(msg_json); -} - -void ExtensionPortContainer::OnExtensionPortDisconnected(int source_port_id) { - // Compose the disconnect message and fire it away. - DictionaryValue msg_dict; - msg_dict.SetInteger(ext::kAutomationRequestIdKey, ext::CHANNEL_CLOSED); - msg_dict.SetInteger(ext::kAutomationPortIdKey, port_id_); - - std::string msg_json; - base::JSONWriter::Write(&msg_dict, false, &msg_json); - - PostMessageToExternalPort(msg_json); -} - -bool ExtensionPortContainer::InterceptMessageFromExternalHost( - const std::string& message, const std::string& origin, - const std::string& target, AutomationProvider* automation, - RenderViewHost *view_host, int tab_handle) { - if (target != ext::kAutomationPortRequestTarget) - return false; - - if (origin != ext::kAutomationOrigin) { - // TODO(siggi): Should we block the message on wrong origin? - LOG(WARNING) << "Wrong origin on automation port message " << origin; - } - - scoped_ptr<Value> message_value(base::JSONReader::Read(message, false)); - DCHECK(message_value->IsType(Value::TYPE_DICTIONARY)); - if (!message_value->IsType(Value::TYPE_DICTIONARY)) - return true; - - DictionaryValue* message_dict = - reinterpret_cast<DictionaryValue*>(message_value.get()); - - int command = -1; - bool got_value = message_dict->GetInteger(ext::kAutomationRequestIdKey, - &command); - DCHECK(got_value); - if (!got_value) - return true; - - if (command == ext::OPEN_CHANNEL) { - // Extract the "extension_id" and "connection_id" parameters. - std::string extension_id; - got_value = message_dict->GetString(ext::kAutomationExtensionIdKey, - &extension_id); - DCHECK(got_value); - if (!got_value) - return true; - - int connection_id; - got_value = message_dict->GetInteger(ext::kAutomationConnectionIdKey, - &connection_id); - DCHECK(got_value); - if (!got_value) - return true; - - std::string channel_name; - // Channel name is optional. - message_dict->GetString(ext::kAutomationChannelNameKey, &channel_name); - - // Tab information is optional, try to retrieve it - // and re-flatten it to a string. - std::string tab_json("null"); - DictionaryValue* tab = NULL; - if (message_dict->GetDictionary(ext::kAutomationTabJsonKey, &tab)) - base::JSONWriter::Write(tab, false, &tab_json); - - int routing_id = view_host->routing_id(); - // Create the extension port and connect it. - scoped_ptr<ExtensionPortContainer> port( - new ExtensionPortContainer(automation, tab_handle)); - - int process_id = view_host->process()->id(); - if (port->Connect(extension_id, process_id, routing_id, connection_id, - channel_name, tab_json)) { - // We have a successful connection. - automation->AddPortContainer(port.release()); - } - } else if (command == ext::POST_MESSAGE) { - int port_id = -1; - got_value = message_dict->GetInteger(ext::kAutomationPortIdKey, &port_id); - DCHECK(got_value); - if (!got_value) - return true; - - std::string data; - got_value = message_dict->GetString(ext::kAutomationMessageDataKey, &data); - DCHECK(got_value); - if (!got_value) - return true; - - ExtensionPortContainer* port = automation->GetPortContainer(port_id); - DCHECK(port); - if (port) - port->PostMessageFromExternalPort(data); - } else if (command == ext::CHANNEL_CLOSED) { - int port_id = -1; - got_value = message_dict->GetInteger(ext::kAutomationPortIdKey, &port_id); - DCHECK(got_value); - if (!got_value) - return true; - - ExtensionPortContainer* port = automation->GetPortContainer(port_id); - DCHECK(port); - if (port) { - // This will delete the port and notify the other end of the disconnect. - automation->RemovePortContainer(port); - } - } else { - // We don't expect other messages here. - NOTREACHED(); - } - - return true; -} diff --git a/chrome/browser/automation/extension_port_container.h b/chrome/browser/automation/extension_port_container.h deleted file mode 100644 index d409fee..0000000 --- a/chrome/browser/automation/extension_port_container.h +++ /dev/null @@ -1,87 +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_AUTOMATION_EXTENSION_PORT_CONTAINER_H_ -#define CHROME_BROWSER_AUTOMATION_EXTENSION_PORT_CONTAINER_H_ -#pragma once - -#include <string> - -#include "base/basictypes.h" -#include "base/memory/ref_counted.h" -#include "ipc/ipc_message.h" - -class AutomationProvider; -class ExtensionMessageService; -class GURL; -class ListValue; -class RenderViewHost; - -// This class represents an external port to an extension, opened -// through the automation interface. -class ExtensionPortContainer : public IPC::Message::Sender { - public: - - // Intercepts and processes a message posted through the automation interface. - // Returns true if the message was intercepted. - static bool InterceptMessageFromExternalHost(const std::string& message, - const std::string& origin, - const std::string& target, - AutomationProvider* automation, - RenderViewHost *view_host, - int tab_handle); - - ExtensionPortContainer(AutomationProvider* automation, int tab_handle); - ~ExtensionPortContainer(); - - int port_id() const { return port_id_; } - void set_port_id(int port_id) { port_id_ = port_id; } - - // IPC implementation. - virtual bool Send(IPC::Message* msg); - - private: - // Posts a message to the external host. - bool PostMessageToExternalPort(const std::string& message); - // Posts a request response message to the external host. - bool PostResponseToExternalPort(const std::string& message); - - // Forwards a message from the external port. - void PostMessageFromExternalPort(const std::string& message); - - // Attempts to connect this instance to the extension id, sends - // a response to the connecting party. - // Returns true if the connection was successful. - bool Connect(const std::string &extension_id, - int process_id, - int routing_id, - int connection_id, - const std::string& channel_name, - const std::string& tab_json); - - // Sends a connect response to the external port. - void SendConnectionResponse(int connection_id, int port_id); - - void OnExtensionMessageInvoke(const std::string& extension_id, - const std::string& function_name, - const ListValue& args, - const GURL& event_url); - void OnExtensionHandleMessage(const std::string& message, int source_port_id); - void OnExtensionPortDisconnected(int source_port_id); - - // Our automation provider. - AutomationProvider* automation_; - - // The extension message service. - scoped_refptr<ExtensionMessageService> service_; - - // Our assigned port id. - int port_id_; - // Handle to our associated tab. - int tab_handle_; - - DISALLOW_COPY_AND_ASSIGN(ExtensionPortContainer); -}; - -#endif // CHROME_BROWSER_AUTOMATION_EXTENSION_PORT_CONTAINER_H_ diff --git a/chrome/browser/extensions/extension_function_dispatcher.h b/chrome/browser/extensions/extension_function_dispatcher.h index 6674bb4..cb67988 100644 --- a/chrome/browser/extensions/extension_function_dispatcher.h +++ b/chrome/browser/extensions/extension_function_dispatcher.h @@ -135,13 +135,6 @@ class ExtensionFunctionDispatcher { std::string extension_id_; scoped_refptr<Peer> peer_; - - // AutomationExtensionFunction requires access to the RenderViewHost - // associated with us. We make it a friend rather than exposing the - // RenderViewHost as a public method as we wouldn't want everyone to - // start assuming a 1:1 relationship between us and RenderViewHost, - // whereas AutomationExtensionFunction is by necessity "tight" with us. - friend class AutomationExtensionFunction; }; #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_FUNCTION_DISPATCHER_H_ diff --git a/chrome/browser/external_tab_container_win.cc b/chrome/browser/external_tab_container_win.cc index b2f3ade..a2c9b04 100644 --- a/chrome/browser/external_tab_container_win.cc +++ b/chrome/browser/external_tab_container_win.cc @@ -13,7 +13,6 @@ #include "base/win/win_util.h" #include "chrome/app/chrome_command_ids.h" #include "chrome/app/chrome_dll_resource.h" -#include "chrome/browser/automation/automation_extension_function.h" #include "chrome/browser/automation/automation_provider.h" #include "chrome/browser/browser_window.h" #include "chrome/browser/debugger/devtools_manager.h" @@ -95,7 +94,6 @@ ExternalTabContainer::ExternalTabContainer( load_requests_via_automation_(false), handle_top_level_requests_(false), external_method_factory_(this), - enabled_extension_automation_(false), pending_(false), infobars_enabled_(true), focus_manager_(NULL), @@ -211,10 +209,6 @@ bool ExternalTabContainer::Init(Profile* profile, } void ExternalTabContainer::Uninitialize() { - if (enabled_extension_automation_) { - AutomationExtensionFunction::Disable(); - } - registrar_.RemoveAll(); if (tab_contents_.get()) { UnregisterRenderViewHost(tab_contents_->render_view_host()); @@ -922,23 +916,6 @@ scoped_refptr<ExternalTabContainer> ExternalTabContainer::RemovePendingTab( return NULL; } -void ExternalTabContainer::SetEnableExtensionAutomation( - const std::vector<std::string>& functions_enabled) { - if (!functions_enabled.empty()) { - if (!tab_contents_.get()) { - NOTREACHED() << "Being invoked via tab so should have TabContents"; - return; - } - - AutomationExtensionFunction::Enable(tab_contents_->tab_contents(), - functions_enabled); - enabled_extension_automation_ = true; - } else { - AutomationExtensionFunction::Disable(); - enabled_extension_automation_ = false; - } -} - void ExternalTabContainer::InfoBarContainerHeightChanged(bool is_animating) { if (external_tab_view_) external_tab_view_->Layout(); diff --git a/chrome/browser/external_tab_container_win.h b/chrome/browser/external_tab_container_win.h index 02f5884..4bf35b5 100644 --- a/chrome/browser/external_tab_container_win.h +++ b/chrome/browser/external_tab_container_win.h @@ -187,12 +187,6 @@ class ExternalTabContainer : public TabContentsDelegate, // Returns NULL if we fail to find the cookie in the map. static scoped_refptr<ExternalTabContainer> RemovePendingTab(uintptr_t cookie); - // Enables extension automation (for e.g. UITests), with the current tab - // used as a conduit for the extension API messages being handled by the - // automation client. - void SetEnableExtensionAutomation( - const std::vector<std::string>& functions_enabled); - // Overridden from views::WidgetWin: virtual views::Window* GetWindow(); @@ -304,9 +298,6 @@ class ExternalTabContainer : public TabContentsDelegate, // Contains ExternalTabContainers that have not been connected to as yet. static base::LazyInstance<PendingTabs> pending_tabs_; - // True if this tab is currently the conduit for extension API automation. - bool enabled_extension_automation_; - // Allows us to run tasks on the ExternalTabContainer instance which are // bound by its lifetime. ScopedRunnableMethodFactory<ExternalTabContainer> external_method_factory_; diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index 5d8a49e..7a53b6e 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -203,8 +203,6 @@ 'browser/automation/automation_browser_tracker.h', 'browser/automation/automation_util.cc', 'browser/automation/automation_util.h', - 'browser/automation/automation_extension_function.cc', - 'browser/automation/automation_extension_function.h', 'browser/automation/automation_extension_tracker.cc', 'browser/automation/automation_extension_tracker.h', 'browser/automation/automation_provider.cc', @@ -233,10 +231,6 @@ 'browser/automation/automation_window_tracker.h', 'browser/automation/chrome_frame_automation_provider.cc', 'browser/automation/chrome_frame_automation_provider.h', - 'browser/automation/extension_automation_constants.cc', - 'browser/automation/extension_automation_constants.h', - 'browser/automation/extension_port_container.cc', - 'browser/automation/extension_port_container.h', 'browser/automation/testing_automation_provider.cc', 'browser/automation/testing_automation_provider.h', 'browser/automation/testing_automation_provider_chromeos.cc', diff --git a/chrome/common/automation_messages_internal.h b/chrome/common/automation_messages_internal.h index 573b668..58d9830 100644 --- a/chrome/common/automation_messages_internal.h +++ b/chrome/common/automation_messages_internal.h @@ -887,19 +887,19 @@ IPC_SYNC_MESSAGE_CONTROL0_1(AutomationMsg_FindNormalBrowserWindow, IPC_SYNC_MESSAGE_CONTROL0_1(AutomationMsg_NormalBrowserWindowCount, int) -// Used to put the browser into "extension automation mode" for a given -// set of Chrome Extensions API functions for the current profile, or turn -// off automation mode. The specified tab is used as the conduit for all -// automated API functions. It must be an external tab (as in -// AutomationMsg_CreateExternalTab). -IPC_MESSAGE_CONTROL2(AutomationMsg_SetEnableExtensionAutomation, - // Tab handle. +// DEPRECATED MESSAGE - But we must leave this comment and message so as +// not to perturb line numbers (see comment at top of file re __LINE__). +// TODO(phajdan.jr): Remove when the reference build is updated (this and +// all others marked "DEPRECATED MESSAGE"). +// (intentionally blank line) +IPC_MESSAGE_CONTROL2(AutomationMsg_DeprecatedMessageOne, + // (intentionally blank line) int, - // Empty to disable automation, non-empty to enable - // automation of the specified API functions, single - // entry of "*" to enable automation of all API - // functions. - std::vector<std::string>) + // (intentionally blank line) + // (intentionally blank line) + // (intentionally blank line) + // (intentionally blank line) + int) // This message tells the browser to start using the new proxy configuration // represented by the given JSON string. The parameters used in the JSON @@ -1133,20 +1133,20 @@ IPC_SYNC_MESSAGE_CONTROL1_1(AutomationMsg_InstallExtension, FilePath /* full path to crx file */, AutomationMsg_ExtensionResponseValues) -// Silently load the extension in the given directory. This expects an -// extension expanded into the directory, not a crx file. -IPC_SYNC_MESSAGE_CONTROL1_1(AutomationMsg_LoadExpandedExtension, - FilePath /* root directory of extension */, - AutomationMsg_ExtensionResponseValues) +// DEPRECATED MESSAGE - But we must leave this comment and message so as +// not to perturb line numbers (see comment at top of file re __LINE__). +IPC_SYNC_MESSAGE_CONTROL1_1(AutomationMsg_DeprecatedMessageTwo, + int, + int) -// Retrieves a list of the root directories of all enabled extensions -// that have been installed into Chrome by dropping a .crx file onto -// Chrome or an equivalent action (including loaded extensions). -// Other types of extensions are not included on the list (e.g. "component", -// "app" or "external" extensions) since since CEEE does not yet support them -// (and it actually only support a single extension in its profile for now). -IPC_SYNC_MESSAGE_CONTROL0_1(AutomationMsg_GetEnabledExtensions, - std::vector<FilePath>) +// DEPRECATED MESSAGE - But we must leave this comment and message so as +// not to perturb line numbers (see comment at top of file re __LINE__). +// (intentionally blank line) +// (intentionally blank line) +// (intentionally blank line) +// (intentionally blank line) +IPC_SYNC_MESSAGE_CONTROL0_1(AutomationMsg_DeprecatedMessageThree, + int) // This message requests the type of the window with the given handle. The // return value contains the type (Browser::Type), or -1 if the request diff --git a/chrome/test/automation/automation_proxy.cc b/chrome/test/automation/automation_proxy.cc index 4d8f7a2..637dc52 100644 --- a/chrome/test/automation/automation_proxy.cc +++ b/chrome/test/automation/automation_proxy.cc @@ -255,11 +255,6 @@ void AutomationProxy::EnsureExtensionTestResult() { ASSERT_TRUE(result) << "Extension test message: " << message; } -bool AutomationProxy::GetEnabledExtensions( - std::vector<FilePath>* extension_directories) { - return Send(new AutomationMsg_GetEnabledExtensions(extension_directories)); -} - bool AutomationProxy::GetBrowserWindowCount(int* num_windows) { if (!num_windows) { NOTREACHED(); diff --git a/chrome/test/automation/automation_proxy.h b/chrome/test/automation/automation_proxy.h index c205b4a..d98a9fb 100644 --- a/chrome/test/automation/automation_proxy.h +++ b/chrome/test/automation/automation_proxy.h @@ -206,10 +206,6 @@ class AutomationProxy : public IPC::Channel::Listener, // Asserts that the next extension test result is true. void EnsureExtensionTestResult(); - // Gets a list of all enabled extensions' base directories. - // Returns true on success. - bool GetEnabledExtensions(std::vector<FilePath>* extension_directories); - // Resets to the default theme. Returns true on success. bool ResetToDefaultTheme(); diff --git a/chrome/test/automation/tab_proxy.cc b/chrome/test/automation/tab_proxy.cc index 2eb8dd2..433f353 100644 --- a/chrome/test/automation/tab_proxy.cc +++ b/chrome/test/automation/tab_proxy.cc @@ -363,15 +363,6 @@ DOMElementProxyRef TabProxy::GetDOMDocument() { return GetObjectProxy<DOMElementProxy>(element_handle); } -bool TabProxy::SetEnableExtensionAutomation( - const std::vector<std::string>& functions_enabled) { - if (!is_valid()) - return false; - - return sender_->Send(new AutomationMsg_SetEnableExtensionAutomation( - handle_, functions_enabled)); -} - bool TabProxy::GetConstrainedWindowCount(int* count) const { if (!is_valid()) return false; diff --git a/chrome/test/automation/tab_proxy.h b/chrome/test/automation/tab_proxy.h index 62852ed..3f0e6b1 100644 --- a/chrome/test/automation/tab_proxy.h +++ b/chrome/test/automation/tab_proxy.h @@ -105,30 +105,6 @@ class TabProxy : public AutomationResourceProxy, // This proxy is invalidated when the document changes. DOMElementProxyRef GetDOMDocument(); - // Configure extension automation mode. When extension automation - // mode is turned on, the automation host can overtake extension API calls - // e.g. to make UI tests for extensions easier to write. Returns true if - // the message is successfully sent. - // - // Note that API calls in _any_ extension view will be routed to the current - // tab. This is to enable UI testing of e.g. extension background pages. - // - // Enabling extension automation from more than one tab is an error. - // - // You must disable extension automation before destroying the tab. - // - // The parameter can take the following types of values: - // a) An empty list to turn off extension automation. - // b) A list with one item, "*", to turn extension automation on for all - // functions. - // c) A list with one or more items which are the names of Chrome Extension - // API functions that should be forwarded over the automation interface. - // Other functions will continue to be fulfilled as normal. This lets you - // write tests where some functionality continues to function as normal, - // and other functionality is mocked out by the test. - bool SetEnableExtensionAutomation( - const std::vector<std::string>& functions_enabled) WARN_UNUSED_RESULT; - // Navigates to a url. This method accepts the same kinds of URL input that // can be passed to Chrome on the command line. This is a synchronous call and // hence blocks until the navigation completes. diff --git a/chrome_frame/cfproxy.h b/chrome_frame/cfproxy.h index ca3aa84..a567abc 100644 --- a/chrome_frame/cfproxy.h +++ b/chrome_frame/cfproxy.h @@ -78,14 +78,6 @@ class ChromeProxy { public: // General virtual void RemoveBrowsingData(int remove_mask) = 0; // async - virtual void InstallExtension(ChromeProxyDelegate* delegate, - const FilePath& crx_path, - SyncMessageContext* ctx) = 0; - virtual void LoadExtension(ChromeProxyDelegate* delegate, - const FilePath& path, - SyncMessageContext* ctx) = 0; - virtual void GetEnabledExtensions(ChromeProxyDelegate* delegate, - SyncMessageContext* ctx) = 0; virtual void SetProxyConfig(const std::string& json_encoded_settings) = 0; // Tab management. @@ -124,8 +116,6 @@ class ChromeProxy { // Misc. virtual void Tab_OnHostMoved(int tab) = 0; virtual void Tab_RunUnloadHandlers(int tab) = 0; - virtual void Tab_SetEnableExtensionAutomation(int tab, - const std::vector<std::string>& functions_enabled) = 0; virtual void Tab_Navigate(int tab, const GURL& url, const GURL& referrer) = 0; virtual void Tab_OverrideEncoding(int tab, const char* encoding) = 0; @@ -163,12 +153,6 @@ class ChromeProxyDelegate : public IPC::Channel::Listener { HWND tab_window, int tab_handle, int session_id) = 0; virtual void Completed_Navigate(bool success, enum AutomationMsg_NavigationResponseValues res) = 0; - virtual void Completed_InstallExtension(bool success, - AutomationMsg_ExtensionResponseValues res, SyncMessageContext* ctx) = 0; - virtual void Completed_LoadExpandedExtension(bool success, - AutomationMsg_ExtensionResponseValues res, SyncMessageContext* ctx) = 0; - virtual void Completed_GetEnabledExtensions(bool success, - const std::vector<FilePath>* extensions) = 0; protected: ~ChromeProxyDelegate() {} diff --git a/chrome_frame/cfproxy_private.h b/chrome_frame/cfproxy_private.h index 3979e0eb..19ade4e 100644 --- a/chrome_frame/cfproxy_private.h +++ b/chrome_frame/cfproxy_private.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// 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. @@ -90,8 +90,6 @@ class Interface2IPCMessage : public ChromeProxy { // Misc. virtual void Tab_OnHostMoved(int tab); - virtual void Tab_SetEnableExtensionAutomation(int tab, - const std::vector<std::string>& functions_enabled); protected: ~Interface2IPCMessage() {} private: @@ -145,12 +143,6 @@ class CFProxy : public Interface2IPCMessage, ////////////////////////////////////////////////////////////////////////// // Sync messages. - virtual void InstallExtension(ChromeProxyDelegate* delegate, - const FilePath& crx_path, SyncMessageContext* ctx); - virtual void LoadExtension(ChromeProxyDelegate* delegate, - const FilePath& path, SyncMessageContext* ctx); - virtual void GetEnabledExtensions(ChromeProxyDelegate* delegate, - SyncMessageContext* ctx); virtual void Tab_Find(int tab, const string16& search_string, FindInPageDirection forward, FindInPageCase match_case, bool find_next); virtual void Tab_OverrideEncoding(int tab, const char* encoding); diff --git a/chrome_frame/cfproxy_proxy.cc b/chrome_frame/cfproxy_proxy.cc index 46ac821..bd38337 100644 --- a/chrome_frame/cfproxy_proxy.cc +++ b/chrome_frame/cfproxy_proxy.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// 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. @@ -125,28 +125,6 @@ void CFProxy::SendIpcMessageOnIoThread(IPC::Message* m) { ////////////////////////////////////////////////////////////////////////// // Sync messages. -void CFProxy::InstallExtension(ChromeProxyDelegate* delegate, - const FilePath& crx_path, - SyncMessageContext* ctx) { - IPC::SyncMessage* m = new AutomationMsg_InstallExtension(crx_path, NULL); - sync_dispatcher_.QueueSyncMessage(m, delegate, ctx); - SendIpcMessage(m); -} - -void CFProxy::LoadExtension(ChromeProxyDelegate* delegate, - const FilePath& path, SyncMessageContext* ctx) { - IPC::SyncMessage* m = new AutomationMsg_LoadExpandedExtension(path, 0); - sync_dispatcher_.QueueSyncMessage(m, delegate, ctx); - SendIpcMessage(m); -} - -void CFProxy::GetEnabledExtensions(ChromeProxyDelegate* delegate, - SyncMessageContext* ctx) { - IPC::SyncMessage* m = new AutomationMsg_GetEnabledExtensions(NULL); - sync_dispatcher_.QueueSyncMessage(m, delegate, ctx); - SendIpcMessage(m); -} - void CFProxy::Tab_Find(int tab, const string16& search_string, FindInPageDirection forward, FindInPageCase match_case, bool find_next) { diff --git a/chrome_frame/cfproxy_support.cc b/chrome_frame/cfproxy_support.cc index 9f4edc6..7fd61b7 100644 --- a/chrome_frame/cfproxy_support.cc +++ b/chrome_frame/cfproxy_support.cc @@ -26,10 +26,6 @@ void DispatchReplyFail(uint32 type, case AutomationMsg_ConnectExternalTab::ID: delegate->Completed_ConnectToTab(false, NULL, NULL, 0, 0); break; - case AutomationMsg_InstallExtension::ID: - delegate->Completed_InstallExtension(false, - AUTOMATION_MSG_EXTENSION_INSTALL_FAILED, ctx); - break; } } @@ -59,32 +55,6 @@ bool DispatchReplyOk(const IPC::Message* reply_msg, uint32 type, } return true; } - - case AutomationMsg_InstallExtension::ID: { - // Tuple1<AutomationMsg_ExtensionResponseValues> out; - TupleTypes<AutomationMsg_InstallExtension::ReplyParam>::ValueTuple out; - if (ReadParam(reply_msg, &iter, &out)) - delegate->Completed_InstallExtension(true, out.a, ctx); - return true; - } - - case AutomationMsg_LoadExpandedExtension::ID: { - // Tuple1<AutomationMsg_ExtensionResponseValues> out; - TupleTypes<AutomationMsg_LoadExpandedExtension::ReplyParam>::ValueTuple - out; - if (ReadParam(reply_msg, &iter, &out)) - delegate->Completed_LoadExpandedExtension(true, out.a, ctx); - break; - } - - case AutomationMsg_GetEnabledExtensions::ID: { - // Tuple1<std::vector<FilePath> > - TupleTypes<AutomationMsg_GetEnabledExtensions::ReplyParam>::ValueTuple - out; - if (ReadParam(reply_msg, &iter, &out)) - delegate->Completed_GetEnabledExtensions(true, &out.a); - break; - } } // switch return false; @@ -180,12 +150,6 @@ void Interface2IPCMessage::Tab_OnHostMoved(int tab) { sender_->Send(new AutomationMsg_BrowserMove(tab)); } -void Interface2IPCMessage::Tab_SetEnableExtensionAutomation(int tab, - const std::vector<std::string>& functions_enabled) { - sender_->Send(new AutomationMsg_SetEnableExtensionAutomation(tab, - functions_enabled)); -} - void DelegateHolder::AddDelegate(ChromeProxyDelegate* p) { delegate_list_.insert(p); } diff --git a/chrome_frame/cfproxy_test.cc b/chrome_frame/cfproxy_test.cc index 30ce339..6599000 100644 --- a/chrome_frame/cfproxy_test.cc +++ b/chrome_frame/cfproxy_test.cc @@ -41,12 +41,6 @@ struct MockChromeProxyDelegate : public ChromeProxyDelegate { HWND tab_window, int tab_handle, int session_id)); MOCK_METHOD2(Completed_Navigate, void(bool success, enum AutomationMsg_NavigationResponseValues res)); - MOCK_METHOD3(Completed_InstallExtension, void(bool success, - enum AutomationMsg_ExtensionResponseValues res, SyncMessageContext* ctx)); - MOCK_METHOD3(Completed_LoadExpandedExtension, void(bool success, - enum AutomationMsg_ExtensionResponseValues res, SyncMessageContext* ctx)); - MOCK_METHOD2(Completed_GetEnabledExtensions, void(bool success, - const std::vector<FilePath>* v)); // Network requests from Chrome. MOCK_METHOD2(Network_Start, void(int request_id, @@ -343,28 +337,20 @@ TEST(SyncMsgSender, Deserialize) { const int kTabHandle = 6; const int kSessionId = 8; - // Create some sync messages and their replies. - AutomationMsg_InstallExtension m1(FilePath(L"c:\\awesome.x"), 0); - AutomationMsg_CreateExternalTab m2(ExternalTabSettings(), 0, 0, 0, 0); - scoped_ptr<IPC::Message> r1(CreateReply(&m1, - AUTOMATION_MSG_EXTENSION_INSTALL_SUCCEEDED)); - scoped_ptr<IPC::Message> r2(CreateReply(&m2, (HWND)1, (HWND)2, kTabHandle, - kSessionId)); + // Create a sync message and its reply. + AutomationMsg_CreateExternalTab m(ExternalTabSettings(), 0, 0, 0, 0); + scoped_ptr<IPC::Message> r(CreateReply(&m, (HWND)1, (HWND)2, kTabHandle, + kSessionId)); - queue.QueueSyncMessage(&m1, &d1, NULL); - queue.QueueSyncMessage(&m2, &d1, NULL); + queue.QueueSyncMessage(&m, &d1, NULL); testing::InSequence s; - EXPECT_CALL(d1, Completed_InstallExtension(true, - AUTOMATION_MSG_EXTENSION_INSTALL_SUCCEEDED, NULL)); EXPECT_CALL(d1, Completed_CreateTab(true, (HWND)1, (HWND)2, kTabHandle, kSessionId)); // Execute replies in a worker thread. ipc.message_loop()->PostTask(FROM_HERE, NewRunnableMethod(&queue, - &SyncMsgSender::OnReplyReceived, r1.get())); - ipc.message_loop()->PostTask(FROM_HERE, NewRunnableMethod(&queue, - &SyncMsgSender::OnReplyReceived, r2.get())); + &SyncMsgSender::OnReplyReceived, r.get())); ipc.Stop(); // Expect that tab 6 has been associated with the delegate. diff --git a/chrome_frame/chrome_frame_activex.cc b/chrome_frame/chrome_frame_activex.cc index ecdb1e5..f86eba3 100644 --- a/chrome_frame/chrome_frame_activex.cc +++ b/chrome_frame/chrome_frame_activex.cc @@ -309,33 +309,6 @@ void ChromeFrameActivex::OnAutomationServerLaunchFailed( } } -void ChromeFrameActivex::OnExtensionInstalled( - const FilePath& path, - void* user_data, - AutomationMsg_ExtensionResponseValues response) { - base::win::ScopedBstr path_str(path.value().c_str()); - Fire_onextensionready(path_str, response); -} - -void ChromeFrameActivex::OnGetEnabledExtensionsComplete( - void* user_data, - const std::vector<FilePath>& extension_directories) { - SAFEARRAY* sa = ::SafeArrayCreateVector(VT_BSTR, 0, - extension_directories.size()); - sa->fFeatures = sa->fFeatures | FADF_BSTR; - ::SafeArrayLock(sa); - - for (size_t i = 0; i < extension_directories.size(); ++i) { - LONG index = static_cast<LONG>(i); - ::SafeArrayPutElement(sa, &index, reinterpret_cast<void*>( - CComBSTR(extension_directories[i].value().c_str()).Detach())); - } - - Fire_ongetenabledextensionscomplete(sa); - ::SafeArrayUnlock(sa); - ::SafeArrayDestroy(sa); -} - void ChromeFrameActivex::OnChannelError() { Fire_onchannelerror(); } @@ -485,20 +458,6 @@ HRESULT ChromeFrameActivex::IOleObject_SetClientSite( std::wstring profile_name(GetHostProcessName(false)); if (is_privileged()) { - - base::win::ScopedBstr automated_functions_arg; - service_hr = service->GetExtensionApisToAutomate( - automated_functions_arg.Receive()); - if (S_OK == service_hr && automated_functions_arg) { - std::string automated_functions( - WideToASCII(static_cast<BSTR>(automated_functions_arg))); - functions_enabled_.clear(); - // base::SplitString writes one empty entry for blank strings, so we - // need this to allow specifying zero automation of API functions. - if (!automated_functions.empty()) - base::SplitString(automated_functions, ',', &functions_enabled_); - } - base::win::ScopedBstr profile_name_arg; service_hr = service->GetChromeProfileName(profile_name_arg.Receive()); if (S_OK == service_hr && profile_name_arg) diff --git a/chrome_frame/chrome_frame_activex.h b/chrome_frame/chrome_frame_activex.h index bbad3e8..b2d677b 100644 --- a/chrome_frame/chrome_frame_activex.h +++ b/chrome_frame/chrome_frame_activex.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// 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. @@ -97,11 +97,6 @@ END_MSG_MAP() virtual void OnLoadFailed(int error_code, const std::string& url); virtual void OnAutomationServerLaunchFailed( AutomationLaunchResult reason, const std::string& server_version); - virtual void OnExtensionInstalled(const FilePath& path, - void* user_data, AutomationMsg_ExtensionResponseValues response); - virtual void OnGetEnabledExtensionsComplete( - void* user_data, - const std::vector<FilePath>& extension_directories); virtual void OnChannelError(); // Separated to static function for unit testing this logic more easily. diff --git a/chrome_frame/chrome_frame_activex_base.h b/chrome_frame/chrome_frame_activex_base.h index 2b746eb..820d038 100644 --- a/chrome_frame/chrome_frame_activex_base.h +++ b/chrome_frame/chrome_frame_activex_base.h @@ -117,26 +117,6 @@ class ATL_NO_VTABLE ProxyDIChromeFrameEvents arraysize(args)); } - void Fire_onextensionready(BSTR path, long response) { // NOLINT - // Arguments in reverse order to the function declaration, because - // that's what DISPPARAMS requires. - VARIANT args[2] = { { VT_I4, }, { VT_BSTR, } }; - args[0].lVal = response; - args[1].bstrVal = path; - - FireMethodWithParams(CF_EVENT_DISPID_ONEXTENSIONREADY, - args, - arraysize(args)); - } - - void Fire_ongetenabledextensionscomplete(SAFEARRAY* extension_dirs) { - VARIANT args[1] = { { VT_ARRAY | VT_BSTR } }; - args[0].parray = extension_dirs; - - FireMethodWithParams(CF_EVENT_DISPID_ONGETENABLEDEXTENSIONSCOMPLETE, - args, arraysize(args)); - } - void Fire_onchannelerror() { // NOLINT FireMethodWithParams(CF_EVENT_DISPID_ONCHANNELERROR, NULL, 0); } @@ -174,7 +154,6 @@ class ATL_NO_VTABLE ChromeFrameActivexBase : // NOLINT public com_util::IProvideClassInfo2Impl<class_id, DIID_DIChromeFrameEvents>, public com_util::IDispatchImpl<IChromeFrame>, - public IChromeFrameInternal, public IConnectionPointContainerImpl<T>, public ProxyDIChromeFrameEvents<T>, public IPropertyNotifySinkCP<T>, @@ -208,7 +187,6 @@ DECLARE_NOT_AGGREGATABLE(T) BEGIN_COM_MAP(ChromeFrameActivexBase) COM_INTERFACE_ENTRY(IChromeFrame) COM_INTERFACE_ENTRY(IDispatch) - COM_INTERFACE_ENTRY(IChromeFrameInternal) COM_INTERFACE_ENTRY(IViewObjectEx) COM_INTERFACE_ENTRY(IViewObject2) COM_INTERFACE_ENTRY(IViewObject) @@ -826,68 +804,18 @@ END_MSG_MAP() } STDMETHOD(installExtension)(BSTR crx_path) { - DCHECK(automation_client_.get()); - - if (NULL == crx_path) { - NOTREACHED(); - return E_INVALIDARG; - } - - if (!is_privileged()) { - DLOG(ERROR) << "Attempt to installExtension in non-privileged mode"; - return E_ACCESSDENIED; - } - - FilePath::StringType crx_path_str(crx_path); - FilePath crx_file_path(crx_path_str); - - automation_client_->InstallExtension(crx_file_path, NULL); - return S_OK; + NOTREACHED(); // Deprecated. + return E_NOTIMPL; } STDMETHOD(loadExtension)(BSTR path) { - DCHECK(automation_client_.get()); - - if (NULL == path) { - NOTREACHED(); - return E_INVALIDARG; - } - - if (!is_privileged()) { - DLOG(ERROR) << "Attempt to loadExtension in non-privileged mode"; - return E_ACCESSDENIED; - } - - FilePath::StringType path_str(path); - FilePath file_path(path_str); - - automation_client_->LoadExpandedExtension(file_path, NULL); - return S_OK; + NOTREACHED(); // Deprecated. + return E_NOTIMPL; } STDMETHOD(getEnabledExtensions)() { - DCHECK(automation_client_.get()); - - if (!is_privileged()) { - DLOG(ERROR) << "Attempt to getEnabledExtensions in non-privileged mode"; - return E_ACCESSDENIED; - } - - automation_client_->GetEnabledExtensions(NULL); - return S_OK; - } - - STDMETHOD(getSessionId)(int* session_id) { - DCHECK(automation_client_.get()); - DCHECK(session_id); - - if (!is_privileged()) { - DLOG(ERROR) << "Attempt to getSessionId in non-privileged mode"; - return E_ACCESSDENIED; - } - - *session_id = automation_client_->GetSessionId(); - return (*session_id) == -1 ? S_FALSE : S_OK; + NOTREACHED(); // Deprecated. + return E_NOTIMPL; } STDMETHOD(registerBhoIfNeeded)() { diff --git a/chrome_frame/chrome_frame_automation.cc b/chrome_frame/chrome_frame_automation.cc index c3e101b..d3626eb 100644 --- a/chrome_frame/chrome_frame_automation.cc +++ b/chrome_frame/chrome_frame_automation.cc @@ -120,15 +120,6 @@ class ChromeFrameAutomationProxyImpl::CFMsgDispatcher case AutomationMsg_NavigateInExternalTab::ID: InvokeCallback<BeginNavigateContext>(msg, context); break; - case AutomationMsg_InstallExtension::ID: - InvokeCallback<InstallExtensionContext>(msg, context); - break; - case AutomationMsg_LoadExpandedExtension::ID: - InvokeCallback<InstallExtensionContext>(msg, context); - break; - case AutomationMsg_GetEnabledExtensions::ID: - InvokeCallback<GetEnabledExtensionsContext>(msg, context); - break; case AutomationMsg_RunUnloadHandlers::ID: InvokeCallback<UnloadContext>(msg, context); break; @@ -849,69 +840,6 @@ void ChromeFrameAutomationClient::FindInPage(const std::wstring& search_string, automation_server_->SendAsAsync(msg, NULL, this); } -void ChromeFrameAutomationClient::InstallExtension( - const FilePath& crx_path, - void* user_data) { - if (automation_server_ == NULL) { - InstallExtensionComplete(crx_path, - user_data, - AUTOMATION_MSG_EXTENSION_INSTALL_FAILED); - return; - } - - InstallExtensionContext* ctx = new InstallExtensionContext( - this, crx_path, user_data); - - IPC::SyncMessage* msg = new AutomationMsg_InstallExtension(crx_path, NULL); - - // The context will delete itself after it is called. - automation_server_->SendAsAsync(msg, ctx, this); -} - -void ChromeFrameAutomationClient::InstallExtensionComplete( - const FilePath& crx_path, - void* user_data, - AutomationMsg_ExtensionResponseValues res) { - DCHECK_EQ(base::PlatformThread::CurrentId(), ui_thread_id_); - - if (chrome_frame_delegate_) { - chrome_frame_delegate_->OnExtensionInstalled(crx_path, user_data, res); - } -} - -void ChromeFrameAutomationClient::GetEnabledExtensions(void* user_data) { - if (automation_server_ == NULL) { - GetEnabledExtensionsComplete(user_data, &std::vector<FilePath>()); - return; - } - - GetEnabledExtensionsContext* ctx = new GetEnabledExtensionsContext( - this, user_data); - - IPC::SyncMessage* msg = new AutomationMsg_GetEnabledExtensions( - ctx->extension_directories()); - - // The context will delete itself after it is called. - automation_server_->SendAsAsync(msg, ctx, this); -} - -void ChromeFrameAutomationClient::GetEnabledExtensionsComplete( - void* user_data, - std::vector<FilePath>* extension_directories) { - DCHECK_EQ(base::PlatformThread::CurrentId(), ui_thread_id_); - - if (chrome_frame_delegate_) { - chrome_frame_delegate_->OnGetEnabledExtensionsComplete( - user_data, *extension_directories); - } - - delete extension_directories; -} - -int ChromeFrameAutomationClient::GetSessionId() const { - return session_id_; -} - void ChromeFrameAutomationClient::OnChromeFrameHostMoved() { // Use a local var to avoid the small possibility of getting the tab_ // member be cleared while we try to use it. @@ -923,25 +851,6 @@ void ChromeFrameAutomationClient::OnChromeFrameHostMoved() { tab->OnHostMoved(); } -void ChromeFrameAutomationClient::LoadExpandedExtension( - const FilePath& path, - void* user_data) { - if (automation_server_ == NULL) { - InstallExtensionComplete(path, - user_data, - AUTOMATION_MSG_EXTENSION_INSTALL_FAILED); - return; - } - - InstallExtensionContext* ctx = new InstallExtensionContext( - this, path, user_data); - - IPC::SyncMessage* msg = new AutomationMsg_LoadExpandedExtension(path, NULL); - - // The context will delete itself after it is called. - automation_server_->SendAsAsync(msg, ctx, this); -} - void ChromeFrameAutomationClient::CreateExternalTab() { AutomationLaunchResult launch_result = AUTOMATION_SUCCESS; DCHECK(IsWindow()); @@ -1000,19 +909,6 @@ AutomationLaunchResult ChromeFrameAutomationClient::CreateExternalTabComplete( return launch_result; } -void ChromeFrameAutomationClient::SetEnableExtensionAutomation( - const std::vector<std::string>& functions_enabled) { - if (!is_initialized()) - return; - - // We are doing initialization, so there is no need to reset extension - // automation, only to set it. Also, we want to avoid resetting extension - // automation that some other automation client has set up. Therefore only - // send the message if we are going to enable automation of some functions. - if (!functions_enabled.empty()) - tab_->SetEnableExtensionAutomation(functions_enabled); -} - // Invoked in launch background thread. void ChromeFrameAutomationClient::LaunchComplete( ChromeFrameAutomationProxy* proxy, diff --git a/chrome_frame/chrome_frame_automation.h b/chrome_frame/chrome_frame_automation.h index 31b08d1..18494c3 100644 --- a/chrome_frame/chrome_frame_automation.h +++ b/chrome_frame/chrome_frame_automation.h @@ -343,34 +343,11 @@ class ChromeFrameAutomationClient const std::string& target); bool SetProxySettings(const std::string& json_encoded_proxy_settings); - virtual void SetEnableExtensionAutomation( - const std::vector<std::string>& functions_enabled); - void FindInPage(const std::wstring& search_string, FindInPageDirection forward, FindInPageCase match_case, bool find_next); - virtual void InstallExtension(const FilePath& crx_path, void* user_data); - - virtual void LoadExpandedExtension(const FilePath& path, void* user_data); - - // Starts a request to get the list of enabled extensions' base directories. - // Response comes back as ChromeFrameDelegate::OnEnabledExtensions(). - virtual void GetEnabledExtensions(void* user_data); - - virtual void InstallExtensionComplete( - const FilePath& path, - void* user_data, - AutomationMsg_ExtensionResponseValues res); - - virtual void GetEnabledExtensionsComplete( - void* user_data, - std::vector<FilePath>* extension_directories); - - // Returns the session ID used to identify a Tab in Chrome. - virtual int GetSessionId() const; - virtual void OnChromeFrameHostMoved(); TabProxy* tab() const { return tab_.get(); } diff --git a/chrome_frame/chrome_frame_delegate.h b/chrome_frame/chrome_frame_delegate.h index 0952d27..3af3bd4 100644 --- a/chrome_frame/chrome_frame_delegate.h +++ b/chrome_frame/chrome_frame_delegate.h @@ -44,13 +44,6 @@ class ChromeFrameDelegate { virtual void OnAutomationServerReady() = 0; virtual void OnAutomationServerLaunchFailed( AutomationLaunchResult reason, const std::string& server_version) = 0; - virtual void OnExtensionInstalled( - const FilePath& path, - void* user_data, - AutomationMsg_ExtensionResponseValues response) = 0; - virtual void OnGetEnabledExtensionsComplete( - void* user_data, - const std::vector<FilePath>& extension_directories) = 0; virtual bool OnMessageReceived(const IPC::Message& msg) = 0; virtual void OnChannelError() = 0; @@ -84,13 +77,6 @@ class ChromeFrameDelegateImpl : public ChromeFrameDelegate { virtual void OnAutomationServerReady() {} virtual void OnAutomationServerLaunchFailed( AutomationLaunchResult reason, const std::string& server_version) {} - virtual void OnExtensionInstalled( - const FilePath& path, - void* user_data, - AutomationMsg_ExtensionResponseValues response) {} - virtual void OnGetEnabledExtensionsComplete( - void* user_data, - const std::vector<FilePath>& extension_directories) {} virtual void OnLoadFailed(int error_code, const std::string& url) {} virtual bool OnMessageReceived(const IPC::Message& msg); virtual void OnChannelError() {} diff --git a/chrome_frame/chrome_frame_npapi.cc b/chrome_frame/chrome_frame_npapi.cc index b503e35..1dff49b 100644 --- a/chrome_frame/chrome_frame_npapi.cc +++ b/chrome_frame/chrome_frame_npapi.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// 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. @@ -55,25 +55,16 @@ const NPUTF8* ChromeFrameNPAPI::plugin_property_identifier_names_[] = { "onprivatemessage", "usechromenetwork", "onclose", - "sessionid", }; const NPUTF8* ChromeFrameNPAPI::plugin_method_identifier_names_[] = { "postMessage", "postPrivateMessage", - "installExtension", - "loadExtension", - "enableExtensionAutomation", - "getEnabledExtensions" }; ChromeFrameNPAPI::PluginMethod ChromeFrameNPAPI::plugin_methods_[] = { &ChromeFrameNPAPI::postMessage, &ChromeFrameNPAPI::postPrivateMessage, - &ChromeFrameNPAPI::installExtension, - &ChromeFrameNPAPI::loadExtension, - &ChromeFrameNPAPI::enableExtensionAutomation, - &ChromeFrameNPAPI::getEnabledExtensions, }; NPIdentifier @@ -112,10 +103,6 @@ static const char kPluginChromeExtraArguments[] = "chrome_extra_arguments"; // If privileged mode is enabled, the string value of this argument will // be used as the profile name for our chrome.exe instance. static const char kPluginChromeProfileName[] = "chrome_profile_name"; -// If privileged mode is enabled, this argument will be taken as a -// comma-separated list of API function calls to automate. -static const char kPluginChromeFunctionsAutomatedAttribute[] = - "chrome_functions_automated"; // If chrome network stack is to be used static const char kPluginUseChromeNetwork[] = "usechromenetwork"; @@ -215,13 +202,6 @@ bool ChromeFrameNPAPI::Initialize(NPMIMEType mime_type, NPP instance, chrome_extra_arguments_arg = argv[i]; } else if (LowerCaseEqualsASCII(argn[i], kPluginChromeProfileName)) { chrome_profile_name_arg = argv[i]; - } else if (LowerCaseEqualsASCII(argn[i], - kPluginChromeFunctionsAutomatedAttribute)) { - functions_enabled_.clear(); - // base::SplitString writes one empty entry for blank strings, so we need - // this to allow specifying zero automation of API functions. - if (argv[i][0] != '\0') - base::SplitString(argv[i], ',', &functions_enabled_); } else if (LowerCaseEqualsASCII(argn[i], kPluginUseChromeNetwork)) { chrome_network_arg_set = true; chrome_network_arg = atoi(argv[i]) ? true : false; @@ -666,14 +646,6 @@ bool ChromeFrameNPAPI::GetProperty(NPIdentifier name, plugin_property_identifiers_[PLUGIN_PROPERTY_USECHROMENETWORK]) { BOOLEAN_TO_NPVARIANT(automation_client_->use_chrome_network(), *variant); return true; - } else if (name == plugin_property_identifiers_[PLUGIN_PROPERTY_SESSIONID]) { - if (!is_privileged()) { - DLOG(WARNING) << "Attempt to read sessionid property while not " - "privileged"; - } else { - INT32_TO_NPVARIANT(automation_client_->GetSessionId(), *variant); - return true; - } } return false; @@ -1238,184 +1210,6 @@ bool ChromeFrameNPAPI::postPrivateMessage(NPObject* npobject, return true; } -bool ChromeFrameNPAPI::installExtension(NPObject* npobject, - const NPVariant* args, - uint32_t arg_count, - NPVariant* result) { - if (arg_count > 2 || !NPVARIANT_IS_STRING(args[0]) || - (arg_count == 2 && !NPVARIANT_IS_OBJECT(args[1]))) { - NOTREACHED(); - return false; - } - - if (!is_privileged()) { - DLOG(WARNING) << "installExtension invoked in non-privileged mode"; - return false; - } - - if (!automation_client_.get()) { - DLOG(WARNING) << "installExtension invoked with no automaton client"; - NOTREACHED(); - return false; - } - - const NPString& crx_path_str = args[0].value.stringValue; - std::string crx_path_a(crx_path_str.UTF8Characters, crx_path_str.UTF8Length); - FilePath::StringType crx_path_u(UTF8ToWide(crx_path_a)); - FilePath crx_path(crx_path_u); - NPObject* retained_function = npapi::RetainObject(args[1].value.objectValue); - - automation_client_->InstallExtension(crx_path, retained_function); - // The response to this command will be returned in the OnExtensionInstalled - // delegate callback function. - - return true; -} - -void ChromeFrameNPAPI::OnExtensionInstalled( - const FilePath& path, - void* user_data, - AutomationMsg_ExtensionResponseValues res) { - ScopedNpVariant result; - NPVariant param; - INT32_TO_NPVARIANT(res, param); - NPObject* func = reinterpret_cast<NPObject*>(user_data); - - InvokeDefault(func, param, &result); - npapi::ReleaseObject(func); -} - -bool ChromeFrameNPAPI::loadExtension(NPObject* npobject, - const NPVariant* args, - uint32_t arg_count, - NPVariant* result) { - if (arg_count > 2 || !NPVARIANT_IS_STRING(args[0]) || - (arg_count == 2 && !NPVARIANT_IS_OBJECT(args[1]))) { - NOTREACHED(); - return false; - } - - if (!is_privileged()) { - DLOG(WARNING) << "loadExtension invoked in non-privileged mode"; - return false; - } - - if (!automation_client_.get()) { - DLOG(WARNING) << "loadExtension invoked with no automaton client"; - NOTREACHED(); - return false; - } - - const NPString& path_str = args[0].value.stringValue; - std::string path_a(path_str.UTF8Characters, path_str.UTF8Length); - FilePath::StringType path_u(UTF8ToWide(path_a)); - FilePath path(path_u); - NPObject* retained_function = npapi::RetainObject(args[1].value.objectValue); - - automation_client_->LoadExpandedExtension(path, retained_function); - // The response to this command will be returned in the OnExtensionInstalled - // delegate callback function. - - return true; -} - -bool ChromeFrameNPAPI::enableExtensionAutomation(NPObject* npobject, - const NPVariant* args, - uint32_t arg_count, - NPVariant* result) { - if (arg_count > 1 || (arg_count == 1 && !NPVARIANT_IS_STRING(args[0]))) { - NOTREACHED(); - return false; - } - - if (!is_privileged()) { - DLOG(WARNING) << - "enableExtensionAutomation invoked in non-privileged mode"; - return false; - } - - if (!automation_client_.get()) { - DLOG(WARNING) << - "enableExtensionAutomation invoked with no automaton client"; - NOTREACHED(); - return false; - } - - if (!automation_client_->tab()) { - DLOG(WARNING) << "enableExtensionAutomation invoked with no hosted tab"; - NOTREACHED(); - return false; - } - - // Empty by default e.g. if no arguments passed. - std::vector<std::string> functions; - - if (arg_count == 1) { - const NPString& functions_str = args[0].value.stringValue; - std::string functions_a(functions_str.UTF8Characters, - functions_str.UTF8Length); - - // base::SplitString writes one empty entry for blank strings, so we need - // this to allow specifying zero automation of API functions. - if (functions_a[0] != '\0') - base::SplitString(functions_a, ',', &functions); - } - - automation_client_->tab()->SetEnableExtensionAutomation(functions); - // This function returns no result. - - return true; -} - -bool ChromeFrameNPAPI::getEnabledExtensions(NPObject* npobject, - const NPVariant* args, - uint32_t arg_count, - NPVariant* result) { - if (arg_count > 1 || !NPVARIANT_IS_OBJECT(args[0])) { - NOTREACHED(); - return false; - } - - if (!is_privileged()) { - DLOG(WARNING) << "getEnabledExtensions invoked in non-privileged mode"; - return false; - } - - if (!automation_client_.get()) { - DLOG(WARNING) << "getEnabledExtensions invoked with no automaton client"; - NOTREACHED(); - return false; - } - - NPObject* retained_function = npapi::RetainObject(args[0].value.objectValue); - - automation_client_->GetEnabledExtensions(retained_function); - // The response to this command will be returned in the - // OnGetEnabledExtensionsCompleted delegate callback function. - - return true; -} - -void ChromeFrameNPAPI::OnGetEnabledExtensionsComplete( - void* user_data, - const std::vector<FilePath>& extension_directories) { - std::vector<std::wstring> extension_paths; - for (size_t i = 0; i < extension_directories.size(); ++i) { - extension_paths.push_back(extension_directories[i].value()); - } - std::wstring tab_delimited = JoinString(extension_paths, L'\t'); - - std::string res = WideToUTF8(tab_delimited); - - ScopedNpVariant result; - NPVariant param; - STRINGN_TO_NPVARIANT(res.c_str(), res.length(), param); - - NPObject* func = reinterpret_cast<NPObject*>(user_data); - InvokeDefault(func, param, &result); - npapi::ReleaseObject(func); -} - void ChromeFrameNPAPI::FireEvent(const std::string& event_type, const std::string& data) { NPVariant arg; @@ -1520,4 +1314,3 @@ void ChromeFrameNPAPI::URLRedirectNotify(const char* url, int status, url_fetcher_.UrlRedirectNotify(url, status, notify_data); npapi::URLRedirectResponse(instance_, notify_data, false); } - diff --git a/chrome_frame/chrome_frame_npapi.h b/chrome_frame/chrome_frame_npapi.h index ba36b99..73cbf75 100644 --- a/chrome_frame/chrome_frame_npapi.h +++ b/chrome_frame/chrome_frame_npapi.h @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// 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. @@ -47,7 +47,6 @@ class ChromeFrameNPAPI PLUGIN_PROPERTY_ONPRIVATEMESSAGE, PLUGIN_PROPERTY_USECHROMENETWORK, PLUGIN_PROPERTY_ONCLOSE, - PLUGIN_PROPERTY_SESSIONID, PLUGIN_PROPERTY_COUNT // must be last } PluginPropertyId; @@ -147,11 +146,6 @@ END_MSG_MAP() virtual void OnAutomationServerReady(); virtual void OnAutomationServerLaunchFailed( AutomationLaunchResult reason, const std::string& server_version); - virtual void OnExtensionInstalled(const FilePath& path, - void* user_data, AutomationMsg_ExtensionResponseValues response); - virtual void OnGetEnabledExtensionsComplete( - void* user_data, - const std::vector<FilePath>& extension_directories); virtual void OnCloseTab(); private: @@ -198,22 +192,6 @@ END_MSG_MAP() bool postPrivateMessage(NPObject* npobject, const NPVariant* args, uint32_t arg_count, NPVariant* result); - // This method is only available when the control is in privileged mode. - bool installExtension(NPObject* npobject, const NPVariant* args, - uint32_t arg_count, NPVariant* result); - - // This method is only available when the control is in privileged mode. - bool loadExtension(NPObject* npobject, const NPVariant* args, - uint32_t arg_count, NPVariant* result); - - // This method is only available when the control is in privileged mode. - bool enableExtensionAutomation(NPObject* npobject, const NPVariant* args, - uint32_t arg_count, NPVariant* result); - - // This method is only available when the control is in privileged mode. - bool getEnabledExtensions(NPObject* npobject, const NPVariant* args, - uint32_t arg_count, NPVariant* result); - // Pointers to method implementations. static PluginMethod plugin_methods_[]; diff --git a/chrome_frame/chrome_frame_npapi_unittest.cc b/chrome_frame/chrome_frame_npapi_unittest.cc index f209a86..d53f92e 100644 --- a/chrome_frame/chrome_frame_npapi_unittest.cc +++ b/chrome_frame/chrome_frame_npapi_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// 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. @@ -79,8 +79,6 @@ class MockAutomationClient: public ChromeFrameAutomationClient { public: MOCK_METHOD2(Initialize, bool(ChromeFrameDelegate*, ChromeFrameLaunchParams*)); - MOCK_METHOD1(SetEnableExtensionAutomation, - void(const std::vector<std::string>&)); // NOLINT }; class MockProxyService: public NpProxyService { @@ -315,10 +313,6 @@ TEST_F(TestNPAPIPrivilegedApi, PrivilegedAllowsArgsAndProfile) { L"", // No specific language override. L"-bar=far"); // Extra arguments expected - // With privileged mode we expect automation to be enabled. - EXPECT_CALL(*mock_automation, SetEnableExtensionAutomation(_)) - .Times(1); - char* argn[] = { "privileged_mode", "chrome_extra_arguments", @@ -406,11 +400,6 @@ class TestNPAPIPrivilegedProperty: public TestNPAPIPrivilegedApi { EXPECT_CALL(mock_funcs, ReleaseObject(kMockNPObject)) .WillRepeatedly(Return()); - // And we should expect SetEnableExtensionAutomation to be called - // for privileged tests. - EXPECT_CALL(*mock_automation, SetEnableExtensionAutomation(_)) - .WillRepeatedly(Return()); - // Initializes identifiers. EXPECT_CALL(mock_funcs, GetStringIdentifiers(_, _, _)) .WillRepeatedly( @@ -571,4 +560,3 @@ TEST_F(TestNPAPIPrivilegedProperty, } // TODO(siggi): test invoking postPrivateMessage. - diff --git a/chrome_frame/chrome_frame_plugin.h b/chrome_frame/chrome_frame_plugin.h index 6b5c8ea..b1a52bc 100644 --- a/chrome_frame/chrome_frame_plugin.h +++ b/chrome_frame/chrome_frame_plugin.h @@ -104,10 +104,6 @@ END_MSG_MAP() return document_url_; } virtual void OnAutomationServerReady() { - // Issue the extension automation request if we're privileged to - // allow this control to handle extension requests from Chrome. - if (is_privileged() && IsValid()) - automation_client_->SetEnableExtensionAutomation(functions_enabled_); } virtual bool IsValid() const { @@ -267,12 +263,6 @@ END_MSG_MAP() // and notifying the host browser that we're doing so. // When the flag is not set, we transfer the focus to chrome. bool ignore_setfocus_; - - // List of functions to enable for automation, or a single entry "*" to - // enable all functions for automation. Ignored unless is_privileged_ is - // true. Defaults to the empty list, meaning automation will not be - // turned on. - std::vector<std::string> functions_enabled_; }; #endif // CHROME_FRAME_CHROME_FRAME_PLUGIN_H_ diff --git a/chrome_frame/chrome_tab.idl b/chrome_frame/chrome_tab.idl index 3ec0236..4d11ea4 100644 --- a/chrome_frame/chrome_tab.idl +++ b/chrome_frame/chrome_tab.idl @@ -67,15 +67,15 @@ interface IChromeFrame : IDispatch { HRESULT useChromeNetwork([in] VARIANT_BOOL newVal); [id(12), hidden] - // This method is available only when the control is in privileged mode. + // Deprecated. Returns E_NOTIMPL. HRESULT installExtension([in] BSTR crx_path); [id(13), hidden] - // This method is available only when the control is in privileged mode. + // Deprecated. Returns E_NOTIMPL. HRESULT loadExtension([in] BSTR extension_path); [id(14), hidden] - // This method is available only when the control is in privileged mode. + // Deprecated. Returns E_NOTIMPL. HRESULT getEnabledExtensions(); [id(15)] @@ -85,20 +85,7 @@ interface IChromeFrame : IDispatch { [ object, - uuid(851bedec-4b2c-4959-abc0-a53403117257), - local, // This interface should never be marshaled. - hidden, -] -// Internal implementation interface. Not intended as an API. May change -// frequently, don't treat this as frozen. -interface IChromeFrameInternal : IUnknown { - // This method is available only when the control is in privileged mode. - HRESULT getSessionId([out, retval] int* session_id); -}; - -[ - object, - uuid(B1B52A4D-B22E-489f-8CCD-1CF9166FA90E), + uuid(E98FDFD9-312B-444a-A640-8E88F3CC08B8), oleautomation, nonextensible, hidden, @@ -111,10 +98,6 @@ interface IChromeFramePrivileged : IUnknown { HRESULT GetWantsPrivileged([out] boolean *wants_privileged); // The profile name we want to use. HRESULT GetChromeProfileName([out] BSTR *profile_name); - // The comma-separated list of extension API functions you wish to automate. - // Return S_FALSE to leave the default, which is to not automate any - // functions. - HRESULT GetExtensionApisToAutomate([out] BSTR *extension_apis); // Called when an automation version mismatch occurs. Returns S_OK if // a dialog should be showed to the user by this CF instance, S_FALSE if // not. @@ -131,8 +114,6 @@ typedef enum { CF_EVENT_DISPID_ONLOADERROR, CF_EVENT_DISPID_ONMESSAGE, CF_EVENT_DISPID_ONPRIVATEMESSAGE, - CF_EVENT_DISPID_ONEXTENSIONREADY, - CF_EVENT_DISPID_ONGETENABLEDEXTENSIONSCOMPLETE, CF_EVENT_DISPID_ONCHANNELERROR, CF_EVENT_DISPID_ONCLOSE, CF_EVENT_DISPID_ONREADYSTATECHANGED = DISPID_READYSTATECHANGE, @@ -168,17 +149,6 @@ library ChromeTabLib { // This event is only fired when the control is in privileged mode. void onprivatemessage([in] IDispatch* event, [in] BSTR target); - [id(CF_EVENT_DISPID_ONEXTENSIONREADY)] - // This event is only fired when the control is in privileged mode. - // response is one of AutomationMsg_ExtensionResponseValues. - void onextensionready([in] BSTR path, [in] long response); - - [id(CF_EVENT_DISPID_ONGETENABLEDEXTENSIONSCOMPLETE)] - // This event is only fired when the control is in privileged mode. - // extension_paths is an array of BSTRs of the base directories of - // enabled extensions. - void ongetenabledextensionscomplete([in] SAFEARRAY(BSTR) extension_paths); - [id(CF_EVENT_DISPID_ONCHANNELERROR)] // This event is fired when there is an error in communication channel with // Chrome and Automation must be reconnected to continue. diff --git a/chrome_frame/custom_sync_call_context.h b/chrome_frame/custom_sync_call_context.h index 0167fe5..87eb075 100644 --- a/chrome_frame/custom_sync_call_context.h +++ b/chrome_frame/custom_sync_call_context.h @@ -15,72 +15,6 @@ // TODO(ananta) // Move the implementations of these classes to the source file. -// Class that maintains context during the async load/install extension -// operation. When done, InstallExtensionComplete is posted back to the UI -// thread so that the users of ChromeFrameAutomationClient can be notified. -class InstallExtensionContext - : public SyncMessageReplyDispatcher::SyncMessageCallContext { - public: - typedef Tuple1<AutomationMsg_ExtensionResponseValues> output_type; - - InstallExtensionContext(ChromeFrameAutomationClient* client, - const FilePath& crx_path, void* user_data) : client_(client), - crx_path_(crx_path), user_data_(user_data) { - } - - ~InstallExtensionContext() { - } - - void Completed(AutomationMsg_ExtensionResponseValues res) { - client_->PostTask(FROM_HERE, NewRunnableMethod(client_.get(), - &ChromeFrameAutomationClient::InstallExtensionComplete, crx_path_, - user_data_, res)); - } - - private: - scoped_refptr<ChromeFrameAutomationClient> client_; - FilePath crx_path_; - void* user_data_; -}; - -// Class that maintains context during the async retrieval of fetching the -// list of enabled extensions. When done, GetEnabledExtensionsComplete is -// posted back to the UI thread so that the users of -// ChromeFrameAutomationClient can be notified. -class GetEnabledExtensionsContext - : public SyncMessageReplyDispatcher::SyncMessageCallContext { - public: - typedef Tuple1<std::vector<FilePath> > output_type; - - GetEnabledExtensionsContext( - ChromeFrameAutomationClient* client, void* user_data) : client_(client), - user_data_(user_data) { - extension_directories_ = new std::vector<FilePath>(); - } - - ~GetEnabledExtensionsContext() { - // ChromeFrameAutomationClient::GetEnabledExtensionsComplete takes - // ownership of extension_directories_. - } - - std::vector<FilePath>* extension_directories() { - return extension_directories_; - } - - void Completed( - std::vector<FilePath> result) { - (*extension_directories_) = result; - client_->PostTask(FROM_HERE, NewRunnableMethod(client_.get(), - &ChromeFrameAutomationClient::GetEnabledExtensionsComplete, - user_data_, extension_directories_)); - } - - private: - scoped_refptr<ChromeFrameAutomationClient> client_; - std::vector<FilePath>* extension_directories_; - void* user_data_; -}; - // Class that maintains contextual information for the create and connect // external tab operations. class CreateExternalTabContext diff --git a/chrome_frame/external_tab.cc b/chrome_frame/external_tab.cc index 291104e..c9eb204 100644 --- a/chrome_frame/external_tab.cc +++ b/chrome_frame/external_tab.cc @@ -205,25 +205,6 @@ void ExternalTabProxy::ForwardMessageFromExternalHost( proxy_->Tab_PostMessage(tab_, message, origin, target); } -void ExternalTabProxy::SetEnableExtensionAutomation( - const std::vector<std::string>& functions_enabled) { - proxy_->Tab_SetEnableExtensionAutomation(tab_, functions_enabled); -} - -void ExternalTabProxy::InstallExtension(const FilePath& crx_path, - void* user_data) { - proxy_->InstallExtension(this, crx_path, new UserDataHolder(user_data)); -} - -void ExternalTabProxy::LoadExpandedExtension(const FilePath& path, - void* user_data) { - proxy_->LoadExtension(this, path, new UserDataHolder(user_data)); -} - -void ExternalTabProxy::GetEnabledExtensions(void* user_data) { - proxy_->GetEnabledExtensions(this, new UserDataHolder(user_data)); -} - void ExternalTabProxy::ChromeFrameHostMoved() { proxy_->Tab_OnHostMoved(tab_); } @@ -267,23 +248,6 @@ void ExternalTabProxy::Completed_Navigate( CHECK(0); } -void ExternalTabProxy::Completed_InstallExtension( - bool success, enum AutomationMsg_ExtensionResponseValues res, - SyncMessageContext* ctx) { - CHECK(0); -} - -void ExternalTabProxy::Completed_LoadExpandedExtension( - bool success, enum AutomationMsg_ExtensionResponseValues res, - SyncMessageContext* ctx) { - CHECK(0); -} - -void ExternalTabProxy::Completed_GetEnabledExtensions( - bool success, const std::vector<FilePath>* extensions) { - CHECK(0); -} - void ExternalTabProxy::OnNavigationStateChanged( int flags, const NavigationInfo& nav_info) { ui_.PostTask(FROM_HERE, NewRunnableMethod(ui_delegate_, diff --git a/chrome_frame/external_tab.h b/chrome_frame/external_tab.h index 027f17f..36b3e3d 100644 --- a/chrome_frame/external_tab.h +++ b/chrome_frame/external_tab.h @@ -45,8 +45,6 @@ class UIDelegate { virtual void OnNavigationStateChanged( int flags, const NavigationInfo& nav_info) = 0; virtual void OnUpdateTargetUrl(const std::wstring& new_target_url) = 0; - virtual void OnExtensionInstalled(const FilePath& path, void* user_data, - AutomationMsg_ExtensionResponseValues response) = 0; virtual void OnLoad(const GURL& url) = 0; virtual void OnMoveWindow(const gfx::Rect& pos) = 0; @@ -114,12 +112,6 @@ class ExternalTabProxy : public CWindowImpl<ExternalTabProxy>, const std::string& origin, const std::string& target); virtual void ChromeFrameHostMoved(); - virtual void SetEnableExtensionAutomation( - const std::vector<std::string>& functions_enabled); - virtual void InstallExtension(const FilePath& crx_path, void* user_data); - virtual void LoadExpandedExtension(const FilePath& path, void* user_data); - virtual void GetEnabledExtensions(void* user_data); - // Attaches an existing external tab to this automation client instance. virtual void ConnectToExternalTab(uint64 external_tab_cookie); virtual void BlockExternalTab(uint64 cookie); @@ -147,12 +139,6 @@ class ExternalTabProxy : public CWindowImpl<ExternalTabProxy>, HWND tab_window, int tab_handle, int session_id); virtual void Completed_Navigate(bool success, enum AutomationMsg_NavigationResponseValues res); - virtual void Completed_InstallExtension(bool success, - enum AutomationMsg_ExtensionResponseValues res, SyncMessageContext* ctx); - virtual void Completed_LoadExpandedExtension(bool success, - enum AutomationMsg_ExtensionResponseValues res, SyncMessageContext* ctx); - virtual void Completed_GetEnabledExtensions(bool success, - const std::vector<FilePath>* extensions); // Network requests from Chrome. virtual void OnNetwork_Start( diff --git a/chrome_frame/external_tab_test.cc b/chrome_frame/external_tab_test.cc index ee14672..46da607 100644 --- a/chrome_frame/external_tab_test.cc +++ b/chrome_frame/external_tab_test.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// 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. @@ -36,8 +36,6 @@ struct MockUIDelegate : public UIDelegate { MOCK_METHOD2(OnNavigationStateChanged, void(int flags, const NavigationInfo& nav_info)); MOCK_METHOD1(OnUpdateTargetUrl, void(const std::wstring& new_target_url)); - MOCK_METHOD3(OnExtensionInstalled, void(const FilePath& path, void* user_data, - AutomationMsg_ExtensionResponseValues response)); MOCK_METHOD1(OnLoad, void(const GURL& url)); MOCK_METHOD1(OnMoveWindow, void(const gfx::Rect& pos)); MOCK_METHOD3(OnMessageFromChromeFrame, void(const std::string& message, @@ -53,12 +51,6 @@ struct MockUIDelegate : public UIDelegate { struct MockProxy : public ChromeProxy { MOCK_METHOD1(RemoveBrowsingData, void(int remove_mask)); - MOCK_METHOD3(InstallExtension, void(ChromeProxyDelegate* delegate, - const FilePath& crx_path, SyncMessageContext* ctx)); - MOCK_METHOD3(LoadExtension, void(ChromeProxyDelegate* delegate, - const FilePath& path, SyncMessageContext* ctx)); - MOCK_METHOD2(GetEnabledExtensions, void(ChromeProxyDelegate* delegate, - SyncMessageContext* ctx)); MOCK_METHOD1(SetProxyConfig, void(const std::string& json_encoded_settings)); MOCK_METHOD2(CreateTab, void(ChromeProxyDelegate* delegate, @@ -92,8 +84,6 @@ struct MockProxy : public ChromeProxy { // Misc. MOCK_METHOD1(Tab_OnHostMoved, void(int tab)); MOCK_METHOD1(Tab_RunUnloadHandlers, void(int tab)); - MOCK_METHOD2(Tab_SetEnableExtensionAutomation, void(int tab, - const std::vector<std::string>& functions_enabled)); MOCK_METHOD3(Tab_Navigate, void(int tab, const GURL& url, const GURL& referrer)); MOCK_METHOD2(Tab_OverrideEncoding, void(int tab, const char* encoding)); diff --git a/chrome_frame/test/automation_client_mock.h b/chrome_frame/test/automation_client_mock.h index 52a1ce63..6f736a0 100644 --- a/chrome_frame/test/automation_client_mock.h +++ b/chrome_frame/test/automation_client_mock.h @@ -96,7 +96,6 @@ class MockAutomationProxy : public ChromeFrameAutomationProxy { MOCK_METHOD1(ReleaseTabProxy, void(AutomationHandle handle)); MOCK_METHOD0(server_version, std::string(void)); MOCK_METHOD1(SendProxyConfig, void(const std::string&)); - MOCK_METHOD1(SetEnableExtensionAutomation, void(bool enable)); ~MockAutomationProxy() {} }; diff --git a/chrome_frame/test/data/privileged_apis_host.html b/chrome_frame/test/data/privileged_apis_host.html index fde39e1..052b276 100644 --- a/chrome_frame/test/data/privileged_apis_host.html +++ b/chrome_frame/test/data/privileged_apis_host.html @@ -47,40 +47,8 @@ appendStatus('After postPrivateMessage') } - function tryInstallExtension() { - var cf = GetChromeFrame(); - - try { - // Any message received by this listener is a failure. - // This succeeds in FF, but throws an exception in IE. - cf.installExtension('foo'); - onFailure(testName, 1, 'installExtension should throw'); - } catch(e) { - appendStatus('installExtension threw exception') - } - - appendStatus('After installExtension') - } - - function tryLoadExtension() { - var cf = GetChromeFrame(); - - try { - // Any message received by this listener is a failure. - // This succeeds in FF, but throws an exception in IE. - cf.loadExtension('foo'); - onFailure(testName, 1, 'loadExtension should throw'); - } catch(e) { - appendStatus('loadExtension threw exception') - } - - appendStatus('After loadExtension') - } - function OnChromeFrameLoaded(url) { tryPrivateMessage(); - tryInstallExtension(); - tryLoadExtension(); // The frame reflects this twice, first to a bogus target // and again to the default target '*'. We succeed if we |