diff options
author | kalman@chromium.org <kalman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-14 05:51:56 +0000 |
---|---|---|
committer | kalman@chromium.org <kalman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-14 05:51:56 +0000 |
commit | 3fd3cf7d3474d5bd2df4f8bd8585bba36f975120 (patch) | |
tree | 7fdc1acf3517af5b148a95c767fffaece4bd36a8 | |
parent | 2b4f7e7be99649ad667ec6658448dcebc75ec124 (diff) | |
download | chromium_src-3fd3cf7d3474d5bd2df4f8bd8585bba36f975120.zip chromium_src-3fd3cf7d3474d5bd2df4f8bd8585bba36f975120.tar.gz chromium_src-3fd3cf7d3474d5bd2df4f8bd8585bba36f975120.tar.bz2 |
Extract executeScript-like functionality into a single ExtensionScriptExecutorImpl class,
and convert all but one* existing uses of ExtensionMsg_ExecuteCode_Params to use it.
This is so that we can extend the implementation of ExtensionScriptExecutor to notify
the UI when extensions have executed scripts, and potentially have control over whether
scripts are actually executed.
* the file not converted is chrome/browser/chromeos/accessibility/accessibility_util.cc
since it has its own script loading logic and I don't feel the need to change that.
Plus, we probably don't want any special script execution logic applying to the loading
of chromevox.
BUG=127988
Review URL: https://chromiumcodereview.appspot.com/10383104
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@136831 0039d316-1c4b-4281-b951-d872f2087c98
11 files changed, 270 insertions, 120 deletions
diff --git a/chrome/browser/extensions/api/offscreen_tabs/offscreen_tabs_api.cc b/chrome/browser/extensions/api/offscreen_tabs/offscreen_tabs_api.cc index e50fdfa..52e9da9 100644 --- a/chrome/browser/extensions/api/offscreen_tabs/offscreen_tabs_api.cc +++ b/chrome/browser/extensions/api/offscreen_tabs/offscreen_tabs_api.cc @@ -799,7 +799,7 @@ bool UpdateOffscreenTabFunction::RunImpl() { DictionaryValue* update_props; EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(1, &update_props)); - web_contents_ = offscreen_tab->web_contents(); + tab_contents_ = offscreen_tab->tab_contents(); bool is_async = false; if (!UpdateURLIfPresent(update_props, &is_async)) return false; @@ -807,19 +807,22 @@ bool UpdateOffscreenTabFunction::RunImpl() { // Update the width and height, if specified. if (update_props->HasKey(tabs_keys::kWidthKey) || update_props->HasKey(tabs_keys::kHeightKey)) { + const gfx::Size& size = + tab_contents_->web_contents()->GetView()->GetContainerSize(); + int width; if (update_props->HasKey(tabs_keys::kWidthKey)) EXTENSION_FUNCTION_VALIDATE( update_props->GetInteger(tabs_keys::kWidthKey, &width)); else - web_contents_->GetView()->GetContainerSize().width(); + width = size.width(); int height; if (update_props->HasKey(tabs_keys::kHeightKey)) EXTENSION_FUNCTION_VALIDATE( update_props->GetInteger(tabs_keys::kHeightKey, &height)); else - web_contents_->GetView()->GetContainerSize().height(); + height = size.height(); offscreen_tab->SetSize(width, height); } diff --git a/chrome/browser/extensions/execute_code_in_tab_function.cc b/chrome/browser/extensions/execute_code_in_tab_function.cc index 44d03f2..b2c4e7a 100644 --- a/chrome/browser/extensions/execute_code_in_tab_function.cc +++ b/chrome/browser/extensions/execute_code_in_tab_function.cc @@ -12,6 +12,7 @@ #include "chrome/browser/extensions/extension_tabs_module.h" #include "chrome/browser/extensions/extension_tabs_module_constants.h" #include "chrome/browser/extensions/file_reader.h" +#include "chrome/browser/extensions/script_executor.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" @@ -27,6 +28,7 @@ #include "content/public/browser/web_contents.h" using content::BrowserThread; +using extensions::ScriptExecutor; namespace keys = extension_tabs_module_constants; @@ -141,29 +143,7 @@ bool ExecuteCodeInTabFunction::RunImpl() { return true; } -bool ExecuteCodeInTabFunction::OnMessageReceived(const IPC::Message& message) { - if (message.type() != ExtensionHostMsg_ExecuteCodeFinished::ID) - return false; - - int message_request_id; - PickleIterator iter(message); - if (!message.ReadInt(&iter, &message_request_id)) { - NOTREACHED() << "malformed extension message"; - return true; - } - - if (message_request_id != request_id()) - return false; - - IPC_BEGIN_MESSAGE_MAP(ExecuteCodeInTabFunction, message) - IPC_MESSAGE_HANDLER(ExtensionHostMsg_ExecuteCodeFinished, - OnExecuteCodeFinished) - IPC_END_MESSAGE_MAP() - return true; -} - -void ExecuteCodeInTabFunction::OnExecuteCodeFinished(int request_id, - bool success, +void ExecuteCodeInTabFunction::OnExecuteCodeFinished(bool success, const std::string& error) { if (!error.empty()) { CHECK(!success); @@ -171,9 +151,6 @@ void ExecuteCodeInTabFunction::OnExecuteCodeFinished(int request_id, } SendResponse(success); - - Observe(NULL); - Release(); // balanced in Execute() } void ExecuteCodeInTabFunction::DidLoadFile(bool success, @@ -259,28 +236,21 @@ bool ExecuteCodeInTabFunction::Execute(const std::string& code_string) { return false; } - bool is_js_code = true; + ScriptExecutor::ScriptType script_type = ScriptExecutor::JAVASCRIPT; std::string function_name = name(); if (function_name == TabsInsertCSSFunction::function_name()) { - is_js_code = false; + script_type = ScriptExecutor::CSS; } else if (function_name != TabsExecuteScriptFunction::function_name()) { - DCHECK(false); + NOTREACHED(); } - ExtensionMsg_ExecuteCode_Params params; - params.request_id = request_id(); - params.extension_id = extension->id(); - params.is_javascript = is_js_code; - params.code = code_string; - params.all_frames = all_frames_; - params.run_at = run_at_; - params.in_main_world = false; - contents->web_contents()->GetRenderViewHost()->Send( - new ExtensionMsg_ExecuteCode( - contents->web_contents()->GetRenderViewHost()->GetRoutingID(), - params)); - - Observe(contents->web_contents()); - AddRef(); // balanced in OnExecuteCodeFinished() + contents->extension_script_executor()->ExecuteScript( + extension->id(), + script_type, + code_string, + all_frames_ ? ScriptExecutor::ALL_FRAMES : ScriptExecutor::TOP_FRAME, + run_at_, + ScriptExecutor::ISOLATED_WORLD, + base::Bind(&ExecuteCodeInTabFunction::OnExecuteCodeFinished, this)); return true; } diff --git a/chrome/browser/extensions/execute_code_in_tab_function.h b/chrome/browser/extensions/execute_code_in_tab_function.h index 81cee16..21ef63b 100644 --- a/chrome/browser/extensions/execute_code_in_tab_function.h +++ b/chrome/browser/extensions/execute_code_in_tab_function.h @@ -11,11 +11,9 @@ #include "chrome/browser/extensions/extension_function.h" #include "chrome/common/extensions/extension_resource.h" #include "chrome/common/extensions/user_script.h" -#include "content/public/browser/web_contents_observer.h" // Implement API call tabs.executeScript and tabs.insertCSS. -class ExecuteCodeInTabFunction : public AsyncExtensionFunction, - public content::WebContentsObserver { +class ExecuteCodeInTabFunction : public AsyncExtensionFunction { public: ExecuteCodeInTabFunction(); @@ -26,12 +24,8 @@ class ExecuteCodeInTabFunction : public AsyncExtensionFunction, virtual bool RunImpl() OVERRIDE; private: - // content::WebContentsObserver overrides. - virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; - // Message handler. - void OnExecuteCodeFinished(int request_id, bool success, - const std::string& error); + void OnExecuteCodeFinished(bool success, const std::string& error); // Called when contents from the file whose path is specified in JSON // arguments has been loaded. diff --git a/chrome/browser/extensions/extension_tabs_module.cc b/chrome/browser/extensions/extension_tabs_module.cc index 66846fd..dc228a8 100644 --- a/chrome/browser/extensions/extension_tabs_module.cc +++ b/chrome/browser/extensions/extension_tabs_module.cc @@ -27,6 +27,7 @@ #include "chrome/browser/extensions/extension_tabs_module_constants.h" #include "chrome/browser/extensions/extension_window_controller.h" #include "chrome/browser/extensions/extension_window_list.h" +#include "chrome/browser/extensions/script_executor.h" #include "chrome/browser/prefs/incognito_mode_prefs.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/sessions/restore_tab_helper.h" @@ -88,6 +89,7 @@ using content::OpenURLParams; using content::Referrer; using content::RenderViewHost; using content::WebContents; +using extensions::ScriptExecutor; const int CaptureVisibleTabFunction::kDefaultQuality = 90; @@ -1178,7 +1180,7 @@ bool HighlightTabsFunction::RunImpl() { return true; } -UpdateTabFunction::UpdateTabFunction() : web_contents_(NULL) { +UpdateTabFunction::UpdateTabFunction() : tab_contents_(NULL) { } bool UpdateTabFunction::RunImpl() { @@ -1215,7 +1217,7 @@ bool UpdateTabFunction::RunImpl() { return false; } - web_contents_ = contents->web_contents(); + tab_contents_ = contents; // TODO(rafaelw): handle setting remaining tab properties: // -title @@ -1243,7 +1245,7 @@ bool UpdateTabFunction::RunImpl() { tab_strip->ActivateTabAt(tab_index, false); DCHECK_EQ(contents, tab_strip->GetActiveTabContents()); } - web_contents_->Focus(); + tab_contents_->web_contents()->Focus(); } if (update_props->HasKey(keys::kHighlightedKey)) { @@ -1313,37 +1315,30 @@ bool UpdateTabFunction::UpdateURLIfPresent(DictionaryValue* update_props, // we need to check host permissions before allowing them. if (url.SchemeIs(chrome::kJavaScriptScheme)) { if (!GetExtension()->CanExecuteScriptOnPage( - web_contents_->GetURL(), NULL, &error_)) { + tab_contents_->web_contents()->GetURL(), NULL, &error_)) { return false; } - ExtensionMsg_ExecuteCode_Params params; - params.request_id = request_id(); - params.extension_id = extension_id(); - params.is_javascript = true; - params.code = url.path(); - params.run_at = UserScript::DOCUMENT_IDLE; - params.all_frames = false; - params.in_main_world = true; - - RenderViewHost* render_view_host = web_contents_->GetRenderViewHost(); - render_view_host->Send( - new ExtensionMsg_ExecuteCode(render_view_host->GetRoutingID(), params)); - - Observe(web_contents_); - AddRef(); // Balanced in OnExecuteCodeFinished(). + tab_contents_->extension_script_executor()->ExecuteScript( + extension_id(), + ScriptExecutor::JAVASCRIPT, + url.path(), + ScriptExecutor::TOP_FRAME, + UserScript::DOCUMENT_IDLE, + ScriptExecutor::MAIN_WORLD, + base::Bind(&UpdateTabFunction::OnExecuteCodeFinished, this)); *is_async = true; return true; } - web_contents_->GetController().LoadURL( + tab_contents_->web_contents()->GetController().LoadURL( url, content::Referrer(), content::PAGE_TRANSITION_LINK, std::string()); // The URL of a tab contents never actually changes to a JavaScript URL, so // this check only makes sense in other cases. if (!url.SchemeIs(chrome::kJavaScriptScheme)) - DCHECK_EQ(url.spec(), web_contents_->GetURL().spec()); + DCHECK_EQ(url.spec(), tab_contents_->web_contents()->GetURL().spec()); return true; } @@ -1352,42 +1347,15 @@ void UpdateTabFunction::PopulateResult() { if (!has_callback()) return; - if (GetExtension()->HasAPIPermission(ExtensionAPIPermission::kTab) && - web_contents_ != NULL) { - result_.reset(ExtensionTabUtil::CreateTabValue(web_contents_)); + if (GetExtension()->HasAPIPermission(ExtensionAPIPermission::kTab)) { + result_.reset( + ExtensionTabUtil::CreateTabValue(tab_contents_->web_contents())); } else { result_.reset(Value::CreateNullValue()); } } -void UpdateTabFunction::WebContentsDestroyed(WebContents* tab) { - CHECK_EQ(tab, web_contents_); - web_contents_ = NULL; -} - -bool UpdateTabFunction::OnMessageReceived(const IPC::Message& message) { - if (message.type() != ExtensionHostMsg_ExecuteCodeFinished::ID) - return false; - - int message_request_id = -1; - PickleIterator iter(message); - if (!message.ReadInt(&iter, &message_request_id)) { - NOTREACHED() << "malformed extension message"; - return true; - } - - if (message_request_id != request_id()) - return false; - - IPC_BEGIN_MESSAGE_MAP(UpdateTabFunction, message) - IPC_MESSAGE_HANDLER(ExtensionHostMsg_ExecuteCodeFinished, - OnExecuteCodeFinished) - IPC_END_MESSAGE_MAP() - return true; -} - -void UpdateTabFunction::OnExecuteCodeFinished(int request_id, - bool success, +void UpdateTabFunction::OnExecuteCodeFinished(bool success, const std::string& error) { if (!error.empty()) { CHECK(!success); @@ -1397,9 +1365,6 @@ void UpdateTabFunction::OnExecuteCodeFinished(int request_id, if (success) PopulateResult(); SendResponse(success); - - Observe(NULL); - Release(); // Balanced in UpdateURLIfPresent(). } bool MoveTabsFunction::RunImpl() { diff --git a/chrome/browser/extensions/extension_tabs_module.h b/chrome/browser/extensions/extension_tabs_module.h index 085b743..7d9d81d 100644 --- a/chrome/browser/extensions/extension_tabs_module.h +++ b/chrome/browser/extensions/extension_tabs_module.h @@ -13,7 +13,6 @@ #include "chrome/browser/extensions/extension_function.h" #include "content/public/browser/notification_observer.h" #include "content/public/browser/notification_registrar.h" -#include "content/public/browser/web_contents_observer.h" #include "googleurl/src/gurl.h" class BackingStore; @@ -113,8 +112,7 @@ class HighlightTabsFunction : public SyncExtensionFunction { virtual bool RunImpl() OVERRIDE; DECLARE_EXTENSION_FUNCTION_NAME("tabs.highlight") }; -class UpdateTabFunction : public AsyncExtensionFunction, - public content::WebContentsObserver { +class UpdateTabFunction : public AsyncExtensionFunction { public: UpdateTabFunction(); @@ -124,15 +122,11 @@ class UpdateTabFunction : public AsyncExtensionFunction, bool* is_async); virtual void PopulateResult(); - content::WebContents* web_contents_; + TabContentsWrapper* tab_contents_; private: virtual bool RunImpl() OVERRIDE; - virtual void WebContentsDestroyed(content::WebContents* tab) OVERRIDE; - virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; - void OnExecuteCodeFinished(int request_id, - bool success, - const std::string& error); + void OnExecuteCodeFinished(bool success, const std::string& error); DECLARE_EXTENSION_FUNCTION_NAME("tabs.update") }; diff --git a/chrome/browser/extensions/script_executor.h b/chrome/browser/extensions/script_executor.h new file mode 100644 index 0000000..20b203f --- /dev/null +++ b/chrome/browser/extensions/script_executor.h @@ -0,0 +1,65 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_EXTENSIONS_SCRIPT_EXECUTOR_H_ +#define CHROME_BROWSER_EXTENSIONS_SCRIPT_EXECUTOR_H_ +#pragma once + +#include <string> + +#include "base/callback_forward.h" +#include "chrome/common/extensions/user_script.h" + +namespace content { +class WebContents; +} + +namespace extensions { + +// Interface for executing extension content scripts (e.g. executeScript) as +// described by the ExtensionMsg_ExecuteCode_Params IPC, and notifying the +// caller when responded with ExtensionHostMsg_ExecuteCodeFinished. +class ScriptExecutor { + public: + virtual ~ScriptExecutor() {} + + // The type of script being injected. + enum ScriptType { + JAVASCRIPT, + CSS, + }; + + // The scope of the script injection across the frames. + enum FrameScope { + TOP_FRAME, + ALL_FRAMES, + }; + + // The type of world to inject into (main world, or its own isolated world). + enum WorldType { + MAIN_WORLD, + ISOLATED_WORLD, + }; + + // Callback from ExecuteScript. The arguments are (success, error). + typedef base::Callback<void(bool, const std::string&)> ExecuteScriptCallback; + + // Executes a script. The arguments match ExtensionMsg_ExecuteCode_Params in + // extension_messages.h (request_id is populated automatically). + // + // |callback| will always be called even if the IPC'd renderer is destroyed + // before a response is received (in this case the callback will be with a + // failure and appropriate error message). + virtual void ExecuteScript(const std::string& extension_id, + ScriptType script_type, + const std::string& code, + FrameScope frame_scope, + UserScript::RunLocation run_at, + WorldType world_type, + const ExecuteScriptCallback& callback) = 0; +}; + +} // namespace extensions + +#endif // CHROME_BROWSER_EXTENSIONS_SCRIPT_EXECUTOR_H_ diff --git a/chrome/browser/extensions/script_executor_impl.cc b/chrome/browser/extensions/script_executor_impl.cc new file mode 100644 index 0000000..7b3d737 --- /dev/null +++ b/chrome/browser/extensions/script_executor_impl.cc @@ -0,0 +1,107 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/extensions/script_executor_impl.h" + +#include "base/callback.h" +#include "base/logging.h" +#include "base/pickle.h" +#include "chrome/common/extensions/extension_messages.h" +#include "content/public/browser/render_view_host.h" +#include "content/public/browser/web_contents.h" +#include "content/public/browser/web_contents_observer.h" +#include "ipc/ipc_message.h" +#include "ipc/ipc_message_macros.h" + +namespace extensions { + +namespace { + +const char* kRendererDestroyed = "The tab was closed."; + +// A handler for a single injection request. On creation this will send the +// injection request to the renderer, and it will be destroyed after either the +// corresponding response comes from the renderer, or the renderer is destroyed. +class Handler : public content::WebContentsObserver { + public: + Handler(content::WebContents* web_contents, + const ExtensionMsg_ExecuteCode_Params params, + const ScriptExecutor::ExecuteScriptCallback& callback) + : content::WebContentsObserver(web_contents), + request_id_(params.request_id), + callback_(callback) { + content::RenderViewHost* rvh = web_contents->GetRenderViewHost(); + rvh->Send(new ExtensionMsg_ExecuteCode(rvh->GetRoutingID(), params)); + } + + virtual ~Handler() {} + + virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE { + // Unpack by hand to check the request_id, since there may be multiple + // requests in flight but only one is for this. + if (message.type() != ExtensionHostMsg_ExecuteCodeFinished::ID) + return false; + + int message_request_id; + PickleIterator iter(message); + CHECK(message.ReadInt(&iter, &message_request_id)); + + if (message_request_id != request_id_) + return false; + + IPC_BEGIN_MESSAGE_MAP(Handler, message) + IPC_MESSAGE_HANDLER(ExtensionHostMsg_ExecuteCodeFinished, + OnExecuteCodeFinished) + IPC_END_MESSAGE_MAP() + return true; + } + + virtual void WebContentsDestroyed(content::WebContents* tab) OVERRIDE { + callback_.Run(false, kRendererDestroyed); + delete this; + } + + private: + void OnExecuteCodeFinished(int request_id, + bool success, + const std::string& error) { + callback_.Run(success, error); + delete this; + } + + int request_id_; + ScriptExecutor::ExecuteScriptCallback callback_; +}; + +} // namespace + +ScriptExecutorImpl::ScriptExecutorImpl( + content::WebContents* web_contents) + : next_request_id_(0), + web_contents_(web_contents) {} + +ScriptExecutorImpl::~ScriptExecutorImpl() {} + +void ScriptExecutorImpl::ExecuteScript( + const std::string& extension_id, + ScriptExecutor::ScriptType script_type, + const std::string& code, + ScriptExecutor::FrameScope frame_scope, + UserScript::RunLocation run_at, + ScriptExecutor::WorldType world_type, + const ExecuteScriptCallback& callback) { + ExtensionMsg_ExecuteCode_Params params; + params.request_id = next_request_id_++; + params.extension_id = extension_id; + params.is_javascript = (script_type == JAVASCRIPT); + params.code = code; + params.all_frames = (frame_scope == ALL_FRAMES); + params.run_at = (int) run_at; + params.in_main_world = (world_type == MAIN_WORLD); + + // Handler handles IPCs and deletes itself on completion. + new Handler(web_contents_, params, callback); +} + +} // namespace extensions diff --git a/chrome/browser/extensions/script_executor_impl.h b/chrome/browser/extensions/script_executor_impl.h new file mode 100644 index 0000000..bf66cd4 --- /dev/null +++ b/chrome/browser/extensions/script_executor_impl.h @@ -0,0 +1,40 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_EXTENSIONS_SCRIPT_EXECUTOR_IMPL_H_ +#define CHROME_BROWSER_EXTENSIONS_SCRIPT_EXECUTOR_IMPL_H_ +#pragma once + +#include "chrome/browser/extensions/script_executor.h" + +#include "base/compiler_specific.h" + +namespace extensions { + +// Standard implementation of ScriptExecutor which just sends an IPC to +// |web_contents_| to execute the script. +class ScriptExecutorImpl : public ScriptExecutor { + public: + explicit ScriptExecutorImpl(content::WebContents* web_contents); + + virtual ~ScriptExecutorImpl(); + + virtual void ExecuteScript(const std::string& extension_id, + ScriptType script_type, + const std::string& code, + FrameScope frame_scope, + UserScript::RunLocation run_at, + WorldType world_type, + const ExecuteScriptCallback& callback) OVERRIDE; + private: + // The next value to use for request_id inExtensionMsg_ExecuteCode_Params. + int next_request_id_; + + // The WebContents this is bound to. + content::WebContents* web_contents_; +}; + +} // namespace extensions + +#endif // CHROME_BROWSER_EXTENSIONS_SCRIPT_EXECUTOR_IMPL_H_ diff --git a/chrome/browser/ui/tab_contents/tab_contents_wrapper.cc b/chrome/browser/ui/tab_contents/tab_contents_wrapper.cc index 5e457ea..c2003a8 100644 --- a/chrome/browser/ui/tab_contents/tab_contents_wrapper.cc +++ b/chrome/browser/ui/tab_contents/tab_contents_wrapper.cc @@ -12,8 +12,9 @@ #include "chrome/browser/automation/automation_tab_helper.h" #include "chrome/browser/content_settings/tab_specific_content_settings.h" #include "chrome/browser/download/download_request_limiter_observer.h" -#include "chrome/browser/extensions/extension_tab_helper.h" #include "chrome/browser/extensions/api/web_navigation/web_navigation_api.h" +#include "chrome/browser/extensions/extension_tab_helper.h" +#include "chrome/browser/extensions/script_executor_impl.h" #include "chrome/browser/external_protocol/external_protocol_observer.h" #include "chrome/browser/favicon/favicon_tab_helper.h" #include "chrome/browser/history/history_tab_helper.h" @@ -90,6 +91,8 @@ TabContentsWrapper::TabContentsWrapper(WebContents* contents) constrained_window_tab_helper_.reset(new ConstrainedWindowTabHelper(this)); core_tab_helper_.reset(new CoreTabHelper(contents)); extension_tab_helper_.reset(new ExtensionTabHelper(this)); + extension_script_executor_.reset( + new extensions::ScriptExecutorImpl(web_contents())); favicon_tab_helper_.reset(new FaviconTabHelper(contents)); find_tab_helper_.reset(new FindTabHelper(contents)); history_tab_helper_.reset(new HistoryTabHelper(contents)); diff --git a/chrome/browser/ui/tab_contents/tab_contents_wrapper.h b/chrome/browser/ui/tab_contents/tab_contents_wrapper.h index 3fc5e14..e128c85 100644 --- a/chrome/browser/ui/tab_contents/tab_contents_wrapper.h +++ b/chrome/browser/ui/tab_contents/tab_contents_wrapper.h @@ -56,6 +56,7 @@ class SyncedTabDelegate; } namespace extensions { +class ScriptExecutor; class WebNavigationTabObserver; } @@ -132,6 +133,10 @@ class TabContentsWrapper : public content::WebContentsObserver { CoreTabHelper* core_tab_helper() { return core_tab_helper_.get(); } + extensions::ScriptExecutor* extension_script_executor() { + return extension_script_executor_.get(); + } + ExtensionTabHelper* extension_tab_helper() { return extension_tab_helper_.get(); } @@ -228,6 +233,7 @@ class TabContentsWrapper : public content::WebContentsObserver { scoped_ptr<BookmarkTabHelper> bookmark_tab_helper_; scoped_ptr<ConstrainedWindowTabHelper> constrained_window_tab_helper_; scoped_ptr<CoreTabHelper> core_tab_helper_; + scoped_ptr<extensions::ScriptExecutor> extension_script_executor_; scoped_ptr<ExtensionTabHelper> extension_tab_helper_; scoped_ptr<FaviconTabHelper> favicon_tab_helper_; scoped_ptr<FindTabHelper> find_tab_helper_; diff --git a/chrome/chrome_browser_extensions.gypi b/chrome/chrome_browser_extensions.gypi index a483080..abd66a9 100644 --- a/chrome/chrome_browser_extensions.gypi +++ b/chrome/chrome_browser_extensions.gypi @@ -389,6 +389,9 @@ 'browser/extensions/process_map.h', 'browser/extensions/sandboxed_extension_unpacker.cc', 'browser/extensions/sandboxed_extension_unpacker.h', + 'browser/extensions/script_executor.h', + 'browser/extensions/script_executor_impl.cc', + 'browser/extensions/script_executor_impl.h', 'browser/extensions/settings/failing_settings_storage.cc', 'browser/extensions/settings/failing_settings_storage.h', 'browser/extensions/settings/setting_change.cc', |