summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions
diff options
context:
space:
mode:
authorben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-18 16:17:49 +0000
committerben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-18 16:17:49 +0000
commit3c9e187bd8ec34ebf2a91a37c868584c465647e8 (patch)
tree84c9540d220fa155cf2af8c944638c0719dee670 /chrome/browser/extensions
parent3e35b224fd0c36f17f432f23e2eb3729667210b1 (diff)
downloadchromium_src-3c9e187bd8ec34ebf2a91a37c868584c465647e8.zip
chromium_src-3c9e187bd8ec34ebf2a91a37c868584c465647e8.tar.gz
chromium_src-3c9e187bd8ec34ebf2a91a37c868584c465647e8.tar.bz2
Make pink's TabContentsWrapper change compile on Windows.
Code by pinkerton@, with modifications by evanm and myself to get it to build on windows/linux/chromeos. BUG=none TEST=none Review URL: http://codereview.chromium.org/4694008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@66626 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions')
-rw-r--r--chrome/browser/extensions/execute_code_in_tab_function.cc11
-rw-r--r--chrome/browser/extensions/extension_browser_event_router.cc85
-rw-r--r--chrome/browser/extensions/extension_browser_event_router.h22
-rw-r--r--chrome/browser/extensions/extension_browsertests_misc.cc3
-rw-r--r--chrome/browser/extensions/extension_clipboard_api.cc3
-rw-r--r--chrome/browser/extensions/extension_cookies_helpers.cc4
-rw-r--r--chrome/browser/extensions/extension_devtools_bridge.cc3
-rw-r--r--chrome/browser/extensions/extension_devtools_browsertests.cc4
-rw-r--r--chrome/browser/extensions/extension_infobar_module.cc8
-rw-r--r--chrome/browser/extensions/extension_message_service.cc3
-rw-r--r--chrome/browser/extensions/extension_page_actions_module.cc11
-rw-r--r--chrome/browser/extensions/extension_processes_api.cc6
-rw-r--r--chrome/browser/extensions/extension_sidebar_api.cc7
-rw-r--r--chrome/browser/extensions/extension_tabs_module.cc68
-rw-r--r--chrome/browser/extensions/extension_tabs_module.h54
15 files changed, 160 insertions, 132 deletions
diff --git a/chrome/browser/extensions/execute_code_in_tab_function.cc b/chrome/browser/extensions/execute_code_in_tab_function.cc
index 52bf74f..1659af3 100644
--- a/chrome/browser/extensions/execute_code_in_tab_function.cc
+++ b/chrome/browser/extensions/execute_code_in_tab_function.cc
@@ -13,6 +13,7 @@
#include "chrome/browser/extensions/file_reader.h"
#include "chrome/browser/profile.h"
#include "chrome/browser/tab_contents/tab_contents.h"
+#include "chrome/browser/tab_contents_wrapper.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/extension_constants.h"
@@ -50,7 +51,7 @@ bool ExecuteCodeInTabFunction::RunImpl() {
execute_tab_id_ = -1;
Browser* browser = NULL;
- TabContents* contents = NULL;
+ TabContentsWrapper* contents = NULL;
// If |tab_id| is specified, look for it. Otherwise default to selected tab
// in the current window.
@@ -82,7 +83,7 @@ bool ExecuteCodeInTabFunction::RunImpl() {
const std::vector<URLPattern> host_permissions =
extension->host_permissions();
if (!Extension::CanExecuteScriptOnPage(
- contents->GetURL(),
+ contents->tab_contents()->GetURL(),
extension->CanExecuteScriptEverywhere(),
&host_permissions,
NULL,
@@ -146,7 +147,7 @@ void ExecuteCodeInTabFunction::DidLoadFile(bool success,
}
bool ExecuteCodeInTabFunction::Execute(const std::string& code_string) {
- TabContents* contents = NULL;
+ TabContentsWrapper* contents = NULL;
Browser* browser = NULL;
bool success = ExtensionTabUtil::GetTabById(
@@ -171,8 +172,8 @@ bool ExecuteCodeInTabFunction::Execute(const std::string& code_string) {
} else if (function_name != TabsExecuteScriptFunction::function_name()) {
DCHECK(false);
}
- if (!contents->ExecuteCode(request_id(), extension->id(),
- is_js_code, code_string, all_frames_)) {
+ if (!contents->tab_contents()->ExecuteCode(request_id(), extension->id(),
+ is_js_code, code_string, all_frames_)) {
SendResponse(false);
return false;
}
diff --git a/chrome/browser/extensions/extension_browser_event_router.cc b/chrome/browser/extensions/extension_browser_event_router.cc
index ce0d673..b49c1a9 100644
--- a/chrome/browser/extensions/extension_browser_event_router.cc
+++ b/chrome/browser/extensions/extension_browser_event_router.cc
@@ -13,6 +13,8 @@
#include "chrome/browser/profile.h"
#include "chrome/browser/tab_contents/navigation_entry.h"
#include "chrome/browser/tab_contents/tab_contents.h"
+#include "chrome/browser/tab_contents_wrapper.h"
+#include "chrome/browser/tab_contents_wrapper.h"
#include "chrome/browser/tabs/tab_strip_model.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/common/extensions/extension_constants.h"
@@ -137,7 +139,7 @@ void ExtensionBrowserEventRouter::Init(Profile* profile) {
Browser* browser = *iter;
if (browser->tabstrip_model()) {
for (int i = 0; i < browser->tabstrip_model()->count(); ++i) {
- TabContents* contents = browser->tabstrip_model()->GetTabContentsAt(i);
+ TabContents* contents = browser->GetTabContentsAt(i);
int tab_id = ExtensionTabUtil::GetTabId(contents);
tab_entries_[tab_id] = TabEntry();
}
@@ -171,8 +173,7 @@ void ExtensionBrowserEventRouter::RegisterForBrowserNotifications(
if (browser->tabstrip_model()) {
for (int i = 0; i < browser->tabstrip_model()->count(); ++i)
- RegisterForTabNotifications(
- browser->tabstrip_model()->GetTabContentsAt(i));
+ RegisterForTabNotifications(browser->GetTabContentsAt(i));
}
}
@@ -265,15 +266,15 @@ void ExtensionBrowserEventRouter::TabCreatedAt(TabContents* contents,
RegisterForTabNotifications(contents);
}
-void ExtensionBrowserEventRouter::TabInsertedAt(TabContents* contents,
+void ExtensionBrowserEventRouter::TabInsertedAt(TabContentsWrapper* contents,
int index,
bool foreground) {
// If tab is new, send created event.
- int tab_id = ExtensionTabUtil::GetTabId(contents);
- if (!GetTabEntry(contents)) {
+ int tab_id = ExtensionTabUtil::GetTabId(contents->tab_contents());
+ if (!GetTabEntry(contents->tab_contents())) {
tab_entries_[tab_id] = TabEntry();
- TabCreatedAt(contents, index, foreground);
+ TabCreatedAt(contents->tab_contents(), index, foreground);
return;
}
@@ -282,7 +283,7 @@ void ExtensionBrowserEventRouter::TabInsertedAt(TabContents* contents,
DictionaryValue* object_args = new DictionaryValue();
object_args->Set(tab_keys::kNewWindowIdKey, Value::CreateIntegerValue(
- ExtensionTabUtil::GetWindowIdOfTab(contents)));
+ ExtensionTabUtil::GetWindowIdOfTab(contents->tab_contents())));
object_args->Set(tab_keys::kNewPositionKey, Value::CreateIntegerValue(
index));
args.Append(object_args);
@@ -293,19 +294,20 @@ void ExtensionBrowserEventRouter::TabInsertedAt(TabContents* contents,
DispatchEvent(contents->profile(), events::kOnTabAttached, json_args);
}
-void ExtensionBrowserEventRouter::TabDetachedAt(TabContents* contents,
+void ExtensionBrowserEventRouter::TabDetachedAt(TabContentsWrapper* contents,
int index) {
- if (!GetTabEntry(contents)) {
+ if (!GetTabEntry(contents->tab_contents())) {
// The tab was removed. Don't send detach event.
return;
}
ListValue args;
- args.Append(Value::CreateIntegerValue(ExtensionTabUtil::GetTabId(contents)));
+ args.Append(Value::CreateIntegerValue(
+ ExtensionTabUtil::GetTabId(contents->tab_contents())));
DictionaryValue* object_args = new DictionaryValue();
object_args->Set(tab_keys::kOldWindowIdKey, Value::CreateIntegerValue(
- ExtensionTabUtil::GetWindowIdOfTab(contents)));
+ ExtensionTabUtil::GetWindowIdOfTab(contents->tab_contents())));
object_args->Set(tab_keys::kOldPositionKey, Value::CreateIntegerValue(
index));
args.Append(object_args);
@@ -317,9 +319,9 @@ void ExtensionBrowserEventRouter::TabDetachedAt(TabContents* contents,
}
void ExtensionBrowserEventRouter::TabClosingAt(TabStripModel* tab_strip_model,
- TabContents* contents,
+ TabContentsWrapper* contents,
int index) {
- int tab_id = ExtensionTabUtil::GetTabId(contents);
+ int tab_id = ExtensionTabUtil::GetTabId(contents->tab_contents());
ListValue args;
args.Append(Value::CreateIntegerValue(tab_id));
@@ -337,20 +339,21 @@ void ExtensionBrowserEventRouter::TabClosingAt(TabStripModel* tab_strip_model,
int removed_count = tab_entries_.erase(tab_id);
DCHECK_GT(removed_count, 0);
- UnregisterForTabNotifications(contents);
+ UnregisterForTabNotifications(contents->tab_contents());
}
-void ExtensionBrowserEventRouter::TabSelectedAt(TabContents* old_contents,
- TabContents* new_contents,
- int index,
- bool user_gesture) {
+void ExtensionBrowserEventRouter::TabSelectedAt(
+ TabContentsWrapper* old_contents,
+ TabContentsWrapper* new_contents,
+ int index,
+ bool user_gesture) {
ListValue args;
args.Append(Value::CreateIntegerValue(
- ExtensionTabUtil::GetTabId(new_contents)));
+ ExtensionTabUtil::GetTabId(new_contents->tab_contents())));
DictionaryValue* object_args = new DictionaryValue();
object_args->Set(tab_keys::kWindowIdKey, Value::CreateIntegerValue(
- ExtensionTabUtil::GetWindowIdOfTab(new_contents)));
+ ExtensionTabUtil::GetWindowIdOfTab(new_contents->tab_contents())));
args.Append(object_args);
std::string json_args;
@@ -360,15 +363,16 @@ void ExtensionBrowserEventRouter::TabSelectedAt(TabContents* old_contents,
json_args);
}
-void ExtensionBrowserEventRouter::TabMoved(TabContents* contents,
+void ExtensionBrowserEventRouter::TabMoved(TabContentsWrapper* contents,
int from_index,
int to_index) {
ListValue args;
- args.Append(Value::CreateIntegerValue(ExtensionTabUtil::GetTabId(contents)));
+ args.Append(Value::CreateIntegerValue(
+ ExtensionTabUtil::GetTabId(contents->tab_contents())));
DictionaryValue* object_args = new DictionaryValue();
object_args->Set(tab_keys::kWindowIdKey, Value::CreateIntegerValue(
- ExtensionTabUtil::GetWindowIdOfTab(contents)));
+ ExtensionTabUtil::GetWindowIdOfTab(contents->tab_contents())));
object_args->Set(tab_keys::kFromIndexKey, Value::CreateIntegerValue(
from_index));
object_args->Set(tab_keys::kToIndexKey, Value::CreateIntegerValue(
@@ -456,29 +460,32 @@ void ExtensionBrowserEventRouter::Observe(NotificationType type,
}
}
-void ExtensionBrowserEventRouter::TabChangedAt(TabContents* contents,
+void ExtensionBrowserEventRouter::TabChangedAt(TabContentsWrapper* contents,
int index,
TabChangeType change_type) {
- TabUpdated(contents, false);
+ TabUpdated(contents->tab_contents(), false);
}
-void ExtensionBrowserEventRouter::TabReplacedAt(TabContents* old_contents,
- TabContents* new_contents,
- int index) {
- UnregisterForTabNotifications(old_contents);
- RegisterForTabNotifications(new_contents);
+void ExtensionBrowserEventRouter::TabReplacedAt(
+ TabContentsWrapper* old_contents,
+ TabContentsWrapper* new_contents,
+ int index) {
+ UnregisterForTabNotifications(old_contents->tab_contents());
+ RegisterForTabNotifications(new_contents->tab_contents());
}
-void ExtensionBrowserEventRouter::TabPinnedStateChanged(TabContents* contents,
- int index) {
+void ExtensionBrowserEventRouter::TabPinnedStateChanged(
+ TabContentsWrapper* contents,
+ int index) {
TabStripModel* tab_strip = NULL;
int tab_index;
- if (ExtensionTabUtil::GetTabStripModel(contents, &tab_strip, &tab_index)) {
+ if (ExtensionTabUtil::GetTabStripModel(
+ contents->tab_contents(), &tab_strip, &tab_index)) {
DictionaryValue* changed_properties = new DictionaryValue();
changed_properties->SetBoolean(tab_keys::kPinnedKey,
tab_strip->IsTabPinned(tab_index));
- DispatchTabUpdatedEvent(contents, changed_properties);
+ DispatchTabUpdatedEvent(contents->tab_contents(), changed_properties);
}
}
@@ -515,21 +522,21 @@ void ExtensionBrowserEventRouter::PageActionExecuted(
int button) {
DispatchOldPageActionEvent(profile, extension_id, page_action_id, tab_id, url,
button);
- TabContents* tab_contents = NULL;
+ TabContentsWrapper* tab_contents = NULL;
if (!ExtensionTabUtil::GetTabById(tab_id, profile, profile->IsOffTheRecord(),
NULL, NULL, &tab_contents, NULL)) {
return;
}
DispatchEventWithTab(profile, extension_id, "pageAction.onClicked",
- tab_contents);
+ tab_contents->tab_contents());
}
void ExtensionBrowserEventRouter::BrowserActionExecuted(
Profile* profile, const std::string& extension_id, Browser* browser) {
- TabContents* tab_contents = NULL;
+ TabContentsWrapper* tab_contents = NULL;
int tab_id = 0;
if (!ExtensionTabUtil::GetDefaultTab(browser, &tab_contents, &tab_id))
return;
DispatchEventWithTab(profile, extension_id, "browserAction.onClicked",
- tab_contents);
+ tab_contents->tab_contents());
}
diff --git a/chrome/browser/extensions/extension_browser_event_router.h b/chrome/browser/extensions/extension_browser_event_router.h
index a84749d..e951290 100644
--- a/chrome/browser/extensions/extension_browser_event_router.h
+++ b/chrome/browser/extensions/extension_browser_event_router.h
@@ -59,22 +59,24 @@ class ExtensionBrowserEventRouter : public TabStripModelObserver,
void OnBrowserWindowReady(const Browser* browser);
// TabStripModelObserver
- virtual void TabInsertedAt(TabContents* contents, int index, bool foreground);
+ virtual void TabInsertedAt(TabContentsWrapper* contents, int index,
+ bool foreground);
virtual void TabClosingAt(TabStripModel* tab_strip_model,
- TabContents* contents,
+ TabContentsWrapper* contents,
int index);
- virtual void TabDetachedAt(TabContents* contents, int index);
- virtual void TabSelectedAt(TabContents* old_contents,
- TabContents* new_contents,
+ virtual void TabDetachedAt(TabContentsWrapper* contents, int index);
+ virtual void TabSelectedAt(TabContentsWrapper* old_contents,
+ TabContentsWrapper* new_contents,
int index,
bool user_gesture);
- virtual void TabMoved(TabContents* contents, int from_index, int to_index);
- virtual void TabChangedAt(TabContents* contents, int index,
+ virtual void TabMoved(TabContentsWrapper* contents, int from_index,
+ int to_index);
+ virtual void TabChangedAt(TabContentsWrapper* contents, int index,
TabChangeType change_type);
- virtual void TabReplacedAt(TabContents* old_contents,
- TabContents* new_contents,
+ virtual void TabReplacedAt(TabContentsWrapper* old_contents,
+ TabContentsWrapper* new_contents,
int index);
- virtual void TabPinnedStateChanged(TabContents* contents, int index);
+ virtual void TabPinnedStateChanged(TabContentsWrapper* contents, int index);
virtual void TabStripEmpty();
// Page Action execute event.
diff --git a/chrome/browser/extensions/extension_browsertests_misc.cc b/chrome/browser/extensions/extension_browsertests_misc.cc
index 224c1f8..fa034fc 100644
--- a/chrome/browser/extensions/extension_browsertests_misc.cc
+++ b/chrome/browser/extensions/extension_browsertests_misc.cc
@@ -19,6 +19,7 @@
#include "chrome/browser/renderer_host/render_view_host.h"
#include "chrome/browser/renderer_host/site_instance.h"
#include "chrome/browser/tab_contents/tab_contents.h"
+#include "chrome/browser/tab_contents_wrapper.h"
#include "chrome/browser/tabs/tab_strip_model.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/common/chrome_paths.h"
@@ -794,7 +795,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, DISABLED_OptionsPage) {
ASSERT_EQ(2, tab_strip->count());
EXPECT_EQ(extension->GetResourceURL("options.html"),
- tab_strip->GetTabContentsAt(1)->GetURL());
+ tab_strip->GetTabContentsAt(1)->tab_contents()->GetURL());
}
// Test window.chrome.app.isInstalled .
diff --git a/chrome/browser/extensions/extension_clipboard_api.cc b/chrome/browser/extensions/extension_clipboard_api.cc
index af1deae..f80be6b 100644
--- a/chrome/browser/extensions/extension_clipboard_api.cc
+++ b/chrome/browser/extensions/extension_clipboard_api.cc
@@ -9,6 +9,7 @@
#include "chrome/browser/extensions/extension_tabs_module.h"
#include "chrome/browser/renderer_host/render_view_host.h"
#include "chrome/browser/tab_contents/tab_contents.h"
+#include "chrome/browser/tab_contents_wrapper.h"
#include "chrome/common/extensions/extension_error_utils.h"
namespace {
@@ -20,7 +21,7 @@ bool ClipboardFunction::RunImpl() {
int tab_id;
EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &tab_id));
- TabContents* contents = NULL;
+ TabContentsWrapper* contents = NULL;
if (!ExtensionTabUtil::GetTabById(tab_id, profile(), include_incognito(),
NULL, NULL, &contents, NULL)) {
error_ = ExtensionErrorUtils::FormatErrorMessage(
diff --git a/chrome/browser/extensions/extension_cookies_helpers.cc b/chrome/browser/extensions/extension_cookies_helpers.cc
index cef1d1e..a140c8e 100644
--- a/chrome/browser/extensions/extension_cookies_helpers.cc
+++ b/chrome/browser/extensions/extension_cookies_helpers.cc
@@ -12,6 +12,7 @@
#include "chrome/browser/extensions/extension_tabs_module.h"
#include "chrome/browser/profile.h"
#include "chrome/browser/tabs/tab_strip_model.h"
+#include "chrome/browser/tab_contents_wrapper.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/common/url_constants.h"
@@ -121,7 +122,8 @@ void AppendToTabIdList(Browser* browser, ListValue* tab_ids) {
TabStripModel* tab_strip = browser->tabstrip_model();
for (int i = 0; i < tab_strip->count(); ++i) {
tab_ids->Append(Value::CreateIntegerValue(
- ExtensionTabUtil::GetTabId(tab_strip->GetTabContentsAt(i))));
+ ExtensionTabUtil::GetTabId(
+ tab_strip->GetTabContentsAt(i)->tab_contents())));
}
}
diff --git a/chrome/browser/extensions/extension_devtools_bridge.cc b/chrome/browser/extensions/extension_devtools_bridge.cc
index d1731ce..3a8f525 100644
--- a/chrome/browser/extensions/extension_devtools_bridge.cc
+++ b/chrome/browser/extensions/extension_devtools_bridge.cc
@@ -14,6 +14,7 @@
#include "chrome/browser/extensions/extension_tabs_module.h"
#include "chrome/browser/profile.h"
#include "chrome/browser/tab_contents/tab_contents.h"
+#include "chrome/browser/tab_contents_wrapper.h"
#include "chrome/common/devtools_messages.h"
ExtensionDevToolsBridge::ExtensionDevToolsBridge(int tab_id,
@@ -36,7 +37,7 @@ bool ExtensionDevToolsBridge::RegisterAsDevToolsClientHost() {
Browser* browser;
TabStripModel* tab_strip;
- TabContents* contents;
+ TabContentsWrapper* contents;
int tab_index;
if (ExtensionTabUtil::GetTabById(tab_id_, profile_, true,
&browser, &tab_strip,
diff --git a/chrome/browser/extensions/extension_devtools_browsertests.cc b/chrome/browser/extensions/extension_devtools_browsertests.cc
index 3bfd134e..cc61b3d 100644
--- a/chrome/browser/extensions/extension_devtools_browsertests.cc
+++ b/chrome/browser/extensions/extension_devtools_browsertests.cc
@@ -61,7 +61,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionDevToolsBrowserTest, FLAKY_TimelineApi) {
DevToolsManager* devtools_manager = DevToolsManager::GetInstance();
// Grab the tab_id of whatever tab happens to be first.
- TabContents* tab_contents = browser()->tabstrip_model()->GetTabContentsAt(0);
+ TabContents* tab_contents = browser()->GetTabContentsAt(0);
ASSERT_TRUE(tab_contents);
int tab_id = ExtensionTabUtil::GetTabId(tab_contents);
@@ -117,7 +117,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionDevToolsBrowserTest, ProcessRefCounting) {
DevToolsManager* devtools_manager = DevToolsManager::GetInstance();
// Grab the tab_id of whatever tab happens to be first.
- TabContents* tab_contents = browser()->tabstrip_model()->GetTabContentsAt(0);
+ TabContents* tab_contents = browser()->GetTabContentsAt(0);
ASSERT_TRUE(tab_contents);
int tab_id = ExtensionTabUtil::GetTabId(tab_contents);
diff --git a/chrome/browser/extensions/extension_infobar_module.cc b/chrome/browser/extensions/extension_infobar_module.cc
index f86abd2..21d94ae 100644
--- a/chrome/browser/extensions/extension_infobar_module.cc
+++ b/chrome/browser/extensions/extension_infobar_module.cc
@@ -14,6 +14,7 @@
#include "chrome/browser/extensions/extension_tabs_module_constants.h"
#include "chrome/browser/tab_contents/infobar_delegate.h"
#include "chrome/browser/tab_contents/tab_contents.h"
+#include "chrome/browser/tab_contents_wrapper.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/extension_error_utils.h"
@@ -36,7 +37,7 @@ bool ShowInfoBarFunction::RunImpl() {
GURL url = extension->GetResourceURL(extension->url(), html_path);
Browser* browser = NULL;
- TabContents* tab_contents = NULL;
+ TabContentsWrapper* tab_contents = NULL;
if (!ExtensionTabUtil::GetTabById(
tab_id,
profile(),
@@ -51,8 +52,9 @@ bool ShowInfoBarFunction::RunImpl() {
return false;
}
- tab_contents->AddInfoBar(
- new ExtensionInfoBarDelegate(browser, tab_contents, GetExtension(), url));
+ tab_contents->tab_contents()->AddInfoBar(
+ new ExtensionInfoBarDelegate(browser, tab_contents->tab_contents(),
+ GetExtension(), url));
// TODO(finnur): Return the actual DOMWindow object. Bug 26463.
result_.reset(ExtensionTabUtil::CreateWindowValue(browser, false));
diff --git a/chrome/browser/extensions/extension_message_service.cc b/chrome/browser/extensions/extension_message_service.cc
index 01faa1d..67c6e71 100644
--- a/chrome/browser/extensions/extension_message_service.cc
+++ b/chrome/browser/extensions/extension_message_service.cc
@@ -16,6 +16,7 @@
#include "chrome/browser/renderer_host/render_view_host.h"
#include "chrome/browser/tab_contents/tab_contents.h"
#include "chrome/browser/tab_contents/tab_util.h"
+#include "chrome/browser/tab_contents_wrapper.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/common/notification_service.h"
#include "chrome/common/render_messages.h"
@@ -173,7 +174,7 @@ void ExtensionMessageService::OpenChannelToTab(
if (!source)
return;
- TabContents* contents = NULL;
+ TabContentsWrapper* contents = NULL;
MessagePort receiver;
if (ExtensionTabUtil::GetTabById(tab_id, source->profile(), true,
NULL, NULL, &contents, NULL)) {
diff --git a/chrome/browser/extensions/extension_page_actions_module.cc b/chrome/browser/extensions/extension_page_actions_module.cc
index 84b20de..c9dc2a3 100644
--- a/chrome/browser/extensions/extension_page_actions_module.cc
+++ b/chrome/browser/extensions/extension_page_actions_module.cc
@@ -12,6 +12,7 @@
#include "chrome/browser/profile.h"
#include "chrome/browser/tab_contents/navigation_entry.h"
#include "chrome/browser/tab_contents/tab_contents.h"
+#include "chrome/browser/tab_contents_wrapper.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/extension_action.h"
@@ -67,7 +68,7 @@ bool PageActionFunction::SetPageActionEnabled(bool enable) {
}
// Find the TabContents that contains this tab id.
- TabContents* contents = NULL;
+ TabContentsWrapper* contents = NULL;
bool result = ExtensionTabUtil::GetTabById(
tab_id, profile(), include_incognito(), NULL, NULL, &contents, NULL);
if (!result || !contents) {
@@ -87,7 +88,7 @@ bool PageActionFunction::SetPageActionEnabled(bool enable) {
page_action->SetIsVisible(tab_id, enable);
page_action->SetTitle(tab_id, title);
page_action->SetIconIndex(tab_id, icon_id);
- contents->PageActionStateChanged();
+ contents->tab_contents()->PageActionStateChanged();
return true;
}
@@ -101,13 +102,15 @@ bool PageActionFunction::InitCommon(int tab_id) {
// Find the TabContents that contains this tab id.
contents_ = NULL;
+ TabContentsWrapper* wrapper = NULL;
bool result = ExtensionTabUtil::GetTabById(
- tab_id, profile(), include_incognito(), NULL, NULL, &contents_, NULL);
- if (!result || !contents_) {
+ tab_id, profile(), include_incognito(), NULL, NULL, &wrapper, NULL);
+ if (!result || !wrapper) {
error_ = ExtensionErrorUtils::FormatErrorMessage(
kNoTabError, base::IntToString(tab_id));
return false;
}
+ contents_ = wrapper->tab_contents();
return true;
}
diff --git a/chrome/browser/extensions/extension_processes_api.cc b/chrome/browser/extensions/extension_processes_api.cc
index 2246965..99b72e8 100644
--- a/chrome/browser/extensions/extension_processes_api.cc
+++ b/chrome/browser/extensions/extension_processes_api.cc
@@ -19,6 +19,7 @@
#include "chrome/browser/profile.h"
#include "chrome/browser/renderer_host/render_process_host.h"
#include "chrome/browser/tab_contents/tab_contents.h"
+#include "chrome/browser/tab_contents_wrapper.h"
#include "chrome/browser/task_manager/task_manager.h"
#include "chrome/common/extensions/extension_error_utils.h"
#include "chrome/common/notification_service.h"
@@ -160,7 +161,7 @@ bool GetProcessIdForTabFunction::RunImpl() {
int tab_id;
EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &tab_id));
- TabContents* contents = NULL;
+ TabContentsWrapper* contents = NULL;
int tab_index = -1;
if (!ExtensionTabUtil::GetTabById(tab_id, profile(), include_incognito(),
NULL, NULL, &contents, &tab_index)) {
@@ -171,7 +172,8 @@ bool GetProcessIdForTabFunction::RunImpl() {
}
// Return the process ID of the tab as an integer.
- int id = base::GetProcId(contents->GetRenderProcessHost()->GetHandle());
+ int id = base::GetProcId(contents->tab_contents()->
+ GetRenderProcessHost()->GetHandle());
result_.reset(Value::CreateIntegerValue(id));
return true;
}
diff --git a/chrome/browser/extensions/extension_sidebar_api.cc b/chrome/browser/extensions/extension_sidebar_api.cc
index 7dbb6fd..5495a8e 100644
--- a/chrome/browser/extensions/extension_sidebar_api.cc
+++ b/chrome/browser/extensions/extension_sidebar_api.cc
@@ -16,6 +16,7 @@
#include "chrome/browser/sidebar/sidebar_container.h"
#include "chrome/browser/sidebar/sidebar_manager.h"
#include "chrome/browser/tab_contents/tab_contents.h"
+#include "chrome/browser/tab_contents_wrapper.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/extension_constants.h"
#include "chrome/common/extensions/extension_error_utils.h"
@@ -122,7 +123,7 @@ bool SidebarFunction::RunImpl() {
}
int tab_id;
- TabContents* tab_contents = NULL;
+ TabContentsWrapper* tab_contents = NULL;
if (details->HasKey(kTabIdKey)) {
EXTENSION_FUNCTION_VALIDATE(details->GetInteger(kTabIdKey, &tab_id));
if (!ExtensionTabUtil::GetTabById(tab_id, profile(), include_incognito(),
@@ -146,7 +147,7 @@ bool SidebarFunction::RunImpl() {
return false;
std::string content_id(GetExtension()->id());
- return RunImpl(tab_contents, content_id, *details);
+ return RunImpl(tab_contents->tab_contents(), content_id, *details);
}
@@ -193,7 +194,7 @@ bool GetStateSidebarFunction::RunImpl(TabContents* tab,
// Check if this tab is selected.
Browser* browser = GetCurrentBrowser();
- TabContents* contents = NULL;
+ TabContentsWrapper* contents = NULL;
int default_tab_id = -1;
if (browser &&
ExtensionTabUtil::GetDefaultTab(browser, &contents,
diff --git a/chrome/browser/extensions/extension_tabs_module.cc b/chrome/browser/extensions/extension_tabs_module.cc
index 8deafb2..169cfff 100644
--- a/chrome/browser/extensions/extension_tabs_module.cc
+++ b/chrome/browser/extensions/extension_tabs_module.cc
@@ -23,6 +23,7 @@
#include "chrome/browser/tab_contents/navigation_entry.h"
#include "chrome/browser/tab_contents/tab_contents_view.h"
#include "chrome/browser/tab_contents/tab_contents.h"
+#include "chrome/browser/tab_contents_wrapper.h"
#include "chrome/browser/tabs/tab_strip_model.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_navigator.h"
@@ -55,7 +56,7 @@ static bool GetTabById(int tab_id, Profile* profile,
bool include_incognito,
Browser** browser,
TabStripModel** tab_strip,
- TabContents** contents,
+ TabContentsWrapper** contents,
int* tab_index, std::string* error_message);
// Takes |url_string| and returns a GURL which is either valid and absolute
@@ -104,7 +105,7 @@ ListValue* ExtensionTabUtil::CreateTabList(const Browser* browser) {
TabStripModel* tab_strip = browser->tabstrip_model();
for (int i = 0; i < tab_strip->count(); ++i) {
tab_list->Append(ExtensionTabUtil::CreateTabValue(
- tab_strip->GetTabContentsAt(i), tab_strip, i));
+ tab_strip->GetTabContentsAt(i)->tab_contents(), tab_strip, i));
}
return tab_list;
@@ -174,7 +175,7 @@ bool ExtensionTabUtil::GetTabStripModel(const TabContents* tab_contents,
for (BrowserList::const_iterator it = BrowserList::begin();
it != BrowserList::end(); ++it) {
TabStripModel* tab_strip = (*it)->tabstrip_model();
- int index = tab_strip->GetIndexOfTabContents(tab_contents);
+ int index = tab_strip->GetWrapperIndex(tab_contents);
if (index != -1) {
*tab_strip_model = tab_strip;
*tab_index = index;
@@ -185,16 +186,17 @@ bool ExtensionTabUtil::GetTabStripModel(const TabContents* tab_contents,
return false;
}
-bool ExtensionTabUtil::GetDefaultTab(Browser* browser, TabContents** contents,
+bool ExtensionTabUtil::GetDefaultTab(Browser* browser,
+ TabContentsWrapper** contents,
int* tab_id) {
DCHECK(browser);
DCHECK(contents);
DCHECK(tab_id);
- *contents = browser->tabstrip_model()->GetSelectedTabContents();
+ *contents = browser->GetSelectedTabContentsWrapper();
if (*contents) {
if (tab_id)
- *tab_id = ExtensionTabUtil::GetTabId(*contents);
+ *tab_id = ExtensionTabUtil::GetTabId((*contents)->tab_contents());
return true;
}
@@ -205,22 +207,20 @@ bool ExtensionTabUtil::GetTabById(int tab_id, Profile* profile,
bool include_incognito,
Browser** browser,
TabStripModel** tab_strip,
- TabContents** contents,
+ TabContentsWrapper** contents,
int* tab_index) {
- Browser* target_browser;
- TabStripModel* target_tab_strip;
- TabContents* target_contents;
Profile* incognito_profile =
include_incognito && profile->HasOffTheRecordProfile() ?
profile->GetOffTheRecordProfile() : NULL;
for (BrowserList::const_iterator iter = BrowserList::begin();
iter != BrowserList::end(); ++iter) {
- target_browser = *iter;
+ Browser* target_browser = *iter;
if (target_browser->profile() == profile ||
target_browser->profile() == incognito_profile) {
- target_tab_strip = target_browser->tabstrip_model();
+ TabStripModel* target_tab_strip = target_browser->tabstrip_model();
for (int i = 0; i < target_tab_strip->count(); ++i) {
- target_contents = target_tab_strip->GetTabContentsAt(i);
+ TabContentsWrapper* target_contents =
+ target_tab_strip->GetTabContentsAt(i);
if (target_contents->controller().session_id().id() == tab_id) {
if (browser)
*browser = target_browser;
@@ -542,12 +542,13 @@ bool GetSelectedTabFunction::RunImpl() {
return false;
TabStripModel* tab_strip = browser->tabstrip_model();
- TabContents* contents = tab_strip->GetSelectedTabContents();
+ TabContentsWrapper* contents = tab_strip->GetSelectedTabContents();
if (!contents) {
error_ = keys::kNoSelectedTabError;
return false;
}
- result_.reset(ExtensionTabUtil::CreateTabValue(contents, tab_strip,
+ result_.reset(ExtensionTabUtil::CreateTabValue(contents->tab_contents(),
+ tab_strip,
tab_strip->selected_index()));
return true;
}
@@ -664,7 +665,7 @@ bool CreateTabFunction::RunImpl() {
// Return data about the newly created tab.
if (has_callback()) {
result_.reset(ExtensionTabUtil::CreateTabValue(
- params.target_contents,
+ params.target_contents->tab_contents(),
params.browser->tabstrip_model(),
params.browser->tabstrip_model()->GetIndexOfTabContents(
params.target_contents)));
@@ -678,13 +679,14 @@ bool GetTabFunction::RunImpl() {
EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &tab_id));
TabStripModel* tab_strip = NULL;
- TabContents* contents = NULL;
+ TabContentsWrapper* contents = NULL;
int tab_index = -1;
if (!GetTabById(tab_id, profile(), include_incognito(),
NULL, &tab_strip, &contents, &tab_index, &error_))
return false;
- result_.reset(ExtensionTabUtil::CreateTabValue(contents, tab_strip,
+ result_.reset(ExtensionTabUtil::CreateTabValue(contents->tab_contents(),
+ tab_strip,
tab_index));
return true;
}
@@ -706,7 +708,7 @@ bool UpdateTabFunction::RunImpl() {
EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(1, &update_props));
TabStripModel* tab_strip = NULL;
- TabContents* contents = NULL;
+ TabContentsWrapper* contents = NULL;
int tab_index = -1;
if (!GetTabById(tab_id, profile(), include_incognito(),
NULL, &tab_strip, &contents, &tab_index, &error_))
@@ -738,7 +740,7 @@ bool UpdateTabFunction::RunImpl() {
const std::vector<URLPattern> host_permissions =
extension->host_permissions();
if (!Extension::CanExecuteScriptOnPage(
- contents->GetURL(),
+ contents->tab_contents()->GetURL(),
extension->CanExecuteScriptEverywhere(),
&host_permissions,
NULL,
@@ -756,7 +758,7 @@ bool UpdateTabFunction::RunImpl() {
// 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(), contents->GetURL().spec());
+ DCHECK_EQ(url.spec(), contents->tab_contents()->GetURL().spec());
}
bool selected = false;
@@ -771,7 +773,7 @@ bool UpdateTabFunction::RunImpl() {
tab_strip->SelectTabContentsAt(tab_index, false);
DCHECK_EQ(contents, tab_strip->GetSelectedTabContents());
}
- contents->Focus();
+ contents->tab_contents()->Focus();
}
}
@@ -786,7 +788,8 @@ bool UpdateTabFunction::RunImpl() {
}
if (has_callback())
- result_.reset(ExtensionTabUtil::CreateTabValue(contents, tab_strip,
+ result_.reset(ExtensionTabUtil::CreateTabValue(contents->tab_contents(),
+ tab_strip,
tab_index));
return true;
@@ -805,7 +808,7 @@ bool MoveTabFunction::RunImpl() {
Browser* source_browser = NULL;
TabStripModel* source_tab_strip = NULL;
- TabContents* contents = NULL;
+ TabContentsWrapper* contents = NULL;
int tab_index = -1;
if (!GetTabById(tab_id, profile(), include_incognito(),
&source_browser, &source_tab_strip, &contents,
@@ -852,7 +855,7 @@ bool MoveTabFunction::RunImpl() {
TabStripModel::ADD_NONE);
if (has_callback())
- result_.reset(ExtensionTabUtil::CreateTabValue(contents,
+ result_.reset(ExtensionTabUtil::CreateTabValue(contents->tab_contents(),
target_tab_strip, new_index));
return true;
@@ -869,7 +872,8 @@ bool MoveTabFunction::RunImpl() {
source_tab_strip->MoveTabContentsAt(tab_index, new_index, false);
if (has_callback())
- result_.reset(ExtensionTabUtil::CreateTabValue(contents, source_tab_strip,
+ result_.reset(ExtensionTabUtil::CreateTabValue(contents->tab_contents(),
+ source_tab_strip,
new_index));
return true;
}
@@ -880,7 +884,7 @@ bool RemoveTabFunction::RunImpl() {
EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &tab_id));
Browser* browser = NULL;
- TabContents* contents = NULL;
+ TabContentsWrapper* contents = NULL;
if (!GetTabById(tab_id, profile(), include_incognito(),
&browser, NULL, &contents, NULL, &error_))
return false;
@@ -1059,7 +1063,7 @@ void CaptureVisibleTabFunction::SendResultFromBitmap(
bool DetectTabLanguageFunction::RunImpl() {
int tab_id = 0;
Browser* browser = NULL;
- TabContents* contents = NULL;
+ TabContentsWrapper* contents = NULL;
// If |tab_id| is specified, look for it. Otherwise default to selected tab
// in the current window.
@@ -1088,18 +1092,18 @@ bool DetectTabLanguageFunction::RunImpl() {
AddRef(); // Balanced in GotLanguage()
- if (!contents->language_state().original_language().empty()) {
+ if (!contents->tab_contents()->language_state().original_language().empty()) {
// Delay the callback invocation until after the current JS call has
// returned.
MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod(
this, &DetectTabLanguageFunction::GotLanguage,
- contents->language_state().original_language()));
+ contents->tab_contents()->language_state().original_language()));
return true;
}
// The tab contents does not know its language yet. Let's wait until it
// receives it, or until the tab is closed/navigates to some other page.
registrar_.Add(this, NotificationType::TAB_LANGUAGE_DETERMINED,
- Source<TabContents>(contents));
+ Source<TabContents>(contents->tab_contents()));
registrar_.Add(this, NotificationType::TAB_CLOSING,
Source<NavigationController>(&(contents->controller())));
registrar_.Add(this, NotificationType::NAV_ENTRY_COMMITTED,
@@ -1156,7 +1160,7 @@ static bool GetTabById(int tab_id, Profile* profile,
bool include_incognito,
Browser** browser,
TabStripModel** tab_strip,
- TabContents** contents,
+ TabContentsWrapper** contents,
int* tab_index,
std::string* error_message) {
if (ExtensionTabUtil::GetTabById(tab_id, profile, include_incognito,
diff --git a/chrome/browser/extensions/extension_tabs_module.h b/chrome/browser/extensions/extension_tabs_module.h
index 9bf36cb..4307c90 100644
--- a/chrome/browser/extensions/extension_tabs_module.h
+++ b/chrome/browser/extensions/extension_tabs_module.h
@@ -19,35 +19,35 @@ class DictionaryValue;
class ListValue;
class SkBitmap;
class TabContents;
+class TabContentsWrapper;
class TabStripModel;
-class ExtensionTabUtil {
- public:
- static int GetWindowId(const Browser* browser);
- static int GetTabId(const TabContents* tab_contents);
- static std::string GetTabStatusText(bool is_loading);
- static int GetWindowIdOfTab(const TabContents* tab_contents);
- static ListValue* CreateTabList(const Browser* browser);
- static DictionaryValue* CreateTabValue(const TabContents* tab_contents);
- static DictionaryValue* CreateTabValue(const TabContents* tab_contents,
- TabStripModel* tab_strip,
- int tab_index);
- static DictionaryValue* CreateWindowValue(const Browser* browser,
- bool populate_tabs);
- // Gets the |tab_strip_model| and |tab_index| for the given |tab_contents|.
- static bool GetTabStripModel(const TabContents* tab_contents,
- TabStripModel** tab_strip_model,
- int* tab_index);
- static bool GetDefaultTab(Browser* browser, TabContents** contents,
- int* tab_id);
- // Any out parameter (|browser|, |tab_strip|, |contents|, & |tab_index|) may
- // be NULL and will not be set within the function.
- static bool GetTabById(int tab_id, Profile* profile, bool incognito_enabled,
- Browser** browser,
- TabStripModel** tab_strip,
- TabContents** contents,
- int* tab_index);
-};
+namespace ExtensionTabUtil {
+int GetWindowId(const Browser* browser);
+int GetTabId(const TabContents* tab_contents);
+std::string GetTabStatusText(bool is_loading);
+int GetWindowIdOfTab(const TabContents* tab_contents);
+ListValue* CreateTabList(const Browser* browser);
+DictionaryValue* CreateTabValue(const TabContents* tab_contents);
+DictionaryValue* CreateTabValue(const TabContents* tab_contents,
+ TabStripModel* tab_strip,
+ int tab_index);
+DictionaryValue* CreateWindowValue(const Browser* browser,
+ bool populate_tabs);
+// Gets the |tab_strip_model| and |tab_index| for the given |tab_contents|.
+bool GetTabStripModel(const TabContents* tab_contents,
+ TabStripModel** tab_strip_model,
+ int* tab_index);
+bool GetDefaultTab(Browser* browser, TabContentsWrapper** contents,
+ int* tab_id);
+// Any out parameter (|browser|, |tab_strip|, |contents|, & |tab_index|) may
+// be NULL and will not be set within the function.
+bool GetTabById(int tab_id, Profile* profile, bool incognito_enabled,
+ Browser** browser,
+ TabStripModel** tab_strip,
+ TabContentsWrapper** contents,
+ int* tab_index);
+}
// Windows
class GetWindowFunction : public SyncExtensionFunction {