| Index: chrome/browser/extensions/extension_tabs_module.cc
|
| diff --git a/chrome/browser/extensions/extension_tabs_module.cc b/chrome/browser/extensions/extension_tabs_module.cc
|
| index b72ecc55c07c6b32e41dd59ddd5f6699d07b7e0b..4c8e954e1c2de54922bb5385b1f9402b07a8bba9 100644
|
| --- a/chrome/browser/extensions/extension_tabs_module.cc
|
| +++ b/chrome/browser/extensions/extension_tabs_module.cc
|
| @@ -20,6 +20,7 @@
|
| #include "base/utf_string_conversions.h"
|
| #include "chrome/browser/extensions/extension_function_dispatcher.h"
|
| #include "chrome/browser/extensions/extension_host.h"
|
| +#include "chrome/browser/extensions/script_executor.h"
|
| #include "chrome/browser/extensions/extension_service.h"
|
| #include "chrome/browser/extensions/extension_tab_helper.h"
|
| #include "chrome/browser/extensions/extension_tab_util.h"
|
| @@ -1176,7 +1177,7 @@ bool HighlightTabsFunction::RunImpl() {
|
| return true;
|
| }
|
|
|
| -UpdateTabFunction::UpdateTabFunction() : web_contents_(NULL) {
|
| +UpdateTabFunction::UpdateTabFunction() : tab_contents_(NULL) {
|
| }
|
|
|
| bool UpdateTabFunction::RunImpl() {
|
| @@ -1213,7 +1214,7 @@ bool UpdateTabFunction::RunImpl() {
|
| return false;
|
| }
|
|
|
| - web_contents_ = contents->web_contents();
|
| + tab_contents_ = contents;
|
|
|
| // TODO(rafaelw): handle setting remaining tab properties:
|
| // -title
|
| @@ -1241,7 +1242,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)) {
|
| @@ -1311,37 +1312,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(),
|
| + true,
|
| + url.path(),
|
| + false,
|
| + UserScript::DOCUMENT_IDLE,
|
| + true,
|
| + 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;
|
| }
|
| @@ -1350,42 +1344,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);
|
| @@ -1395,9 +1362,6 @@ void UpdateTabFunction::OnExecuteCodeFinished(int request_id,
|
| if (success)
|
| PopulateResult();
|
| SendResponse(success);
|
| -
|
| - Observe(NULL);
|
| - Release(); // Balanced in UpdateURLIfPresent().
|
| }
|
|
|
| bool MoveTabsFunction::RunImpl() {
|
|
|