Remove some TabContentses from extensions.

This is a removal from ExtensionTabUtil and then following dependencies.

BUG=107201
TEST=no visible change


Review URL: https://chromiumcodereview.appspot.com/11308012

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@164963 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/browser/accessibility/accessibility_extension_api.cc b/chrome/browser/accessibility/accessibility_extension_api.cc
index eac0ea7..ed8368b1 100644
--- a/chrome/browser/accessibility/accessibility_extension_api.cc
+++ b/chrome/browser/accessibility/accessibility_extension_api.cc
@@ -16,7 +16,6 @@
 #include "chrome/browser/extensions/extension_tab_util.h"
 #include "chrome/browser/infobars/infobar_tab_helper.h"
 #include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/ui/tab_contents/tab_contents.h"
 #include "chrome/common/chrome_notification_types.h"
 #include "chrome/common/extensions/extension_error_utils.h"
 #include "content/public/browser/notification_service.h"
@@ -200,7 +199,7 @@
   EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &tab_id));
 
   TabStripModel* tab_strip = NULL;
-  TabContents* contents = NULL;
+  content::WebContents* contents = NULL;
   int tab_index = -1;
   if (!ExtensionTabUtil::GetTabById(tab_id, profile(), include_incognito(),
                                     NULL, &tab_strip, &contents, &tab_index)) {
@@ -213,7 +212,7 @@
   ListValue* alerts_value = new ListValue;
 
   InfoBarTabHelper* infobar_helper =
-      InfoBarTabHelper::FromWebContents(contents->web_contents());
+      InfoBarTabHelper::FromWebContents(contents);
   for (size_t i = 0; i < infobar_helper->GetInfoBarCount(); ++i) {
     // TODO(hashimoto): Make other kind of alerts available.  crosbug.com/24281
     InfoBarDelegate* infobar_delegate = infobar_helper->GetInfoBarDelegateAt(i);
diff --git a/chrome/browser/extensions/api/debugger/debugger_api.cc b/chrome/browser/extensions/api/debugger/debugger_api.cc
index c987e9f..bd5b98f 100644
--- a/chrome/browser/extensions/api/debugger/debugger_api.cc
+++ b/chrome/browser/extensions/api/debugger/debugger_api.cc
@@ -24,7 +24,6 @@
 #include "chrome/browser/infobars/infobar.h"
 #include "chrome/browser/infobars/infobar_tab_helper.h"
 #include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/ui/tab_contents/tab_contents.h"
 #include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h"
 #include "chrome/common/chrome_notification_types.h"
 #include "chrome/common/extensions/api/debugger.h"
@@ -412,19 +411,19 @@
       client_host_(0) {
 }
 
-bool DebuggerFunction::InitTabContents() {
-  // Find the TabContents that contains this tab id.
+bool DebuggerFunction::InitWebContents() {
+  // Find the WebContents that contains this tab id.
   contents_ = NULL;
-  TabContents* tab_contents = NULL;
+  WebContents* web_contents = NULL;
   bool result = ExtensionTabUtil::GetTabById(
-      tab_id_, profile(), include_incognito(), NULL, NULL, &tab_contents, NULL);
-  if (!result || !tab_contents) {
+      tab_id_, profile(), include_incognito(), NULL, NULL, &web_contents, NULL);
+  if (!result || !web_contents) {
     error_ = ExtensionErrorUtils::FormatErrorMessage(
         keys::kNoTabError,
         base::IntToString(tab_id_));
     return false;
   }
-  contents_ = tab_contents->web_contents();
+  contents_ = web_contents;
 
   if (content::GetContentClient()->HasWebUIScheme(
           contents_->GetURL())) {
@@ -438,7 +437,7 @@
 }
 
 bool DebuggerFunction::InitClientHost() {
-  if (!InitTabContents())
+  if (!InitWebContents())
     return false;
 
   // Don't fetch rvh from the contents since it'll be wrong upon navigation.
@@ -464,7 +463,7 @@
   EXTENSION_FUNCTION_VALIDATE(params.get());
 
   tab_id_ = params->target.tab_id;
-  if (!InitTabContents())
+  if (!InitWebContents())
     return false;
 
   if (!webkit_glue::IsInspectorProtocolVersionSupported(
diff --git a/chrome/browser/extensions/api/debugger/debugger_api.h b/chrome/browser/extensions/api/debugger/debugger_api.h
index 603b02b5..a4fa965 100644
--- a/chrome/browser/extensions/api/debugger/debugger_api.h
+++ b/chrome/browser/extensions/api/debugger/debugger_api.h
@@ -30,7 +30,7 @@
   DebuggerFunction();
   virtual ~DebuggerFunction() {}
 
-  bool InitTabContents();
+  bool InitWebContents();
   bool InitClientHost();
 
   content::WebContents* contents_;
diff --git a/chrome/browser/extensions/api/extension_action/extension_actions_api.cc b/chrome/browser/extensions/api/extension_action/extension_actions_api.cc
index 3b7a2b49..b741308 100644
--- a/chrome/browser/extensions/api/extension_action/extension_actions_api.cc
+++ b/chrome/browser/extensions/api/extension_action/extension_actions_api.cc
@@ -20,7 +20,6 @@
 #include "chrome/browser/extensions/state_store.h"
 #include "chrome/browser/extensions/tab_helper.h"
 #include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/ui/tab_contents/tab_contents.h"
 #include "chrome/common/chrome_notification_types.h"
 #include "chrome/common/extensions/extension.h"
 #include "chrome/common/extensions/extension_error_utils.h"
@@ -343,7 +342,7 @@
     }
   }
 
-  // Find the TabContents that contains this tab id if one is required.
+  // Find the WebContents that contains this tab id if one is required.
   if (tab_id_ == ExtensionAction::kDefaultTabId) {
     EXTENSION_FUNCTION_VALIDATE(
         extensions::ExtensionActionManager::Get(profile_)->
@@ -388,7 +387,7 @@
 }
 
 void ExtensionActionFunction::NotifyLocationBarChange() {
-  extensions::TabHelper::FromWebContents(contents_->web_contents())->
+  extensions::TabHelper::FromWebContents(contents_)->
       location_bar_controller()->NotifyChange();
 }
 
@@ -438,7 +437,7 @@
 
 extensions::TabHelper& ExtensionActionFunction::tab_helper() const {
   CHECK(contents_);
-  return *extensions::TabHelper::FromWebContents(contents_->web_contents());
+  return *extensions::TabHelper::FromWebContents(contents_);
 }
 
 bool ExtensionActionShowFunction::RunExtensionAction() {
diff --git a/chrome/browser/extensions/api/extension_action/extension_actions_api.h b/chrome/browser/extensions/api/extension_action/extension_actions_api.h
index 167170e3..ff023617 100644
--- a/chrome/browser/extensions/api/extension_action/extension_actions_api.h
+++ b/chrome/browser/extensions/api/extension_action/extension_actions_api.h
@@ -14,10 +14,14 @@
 namespace base {
 class DictionaryValue;
 }
+
+namespace content {
+class WebContents;
+}
+
 namespace extensions {
 class TabHelper;
 }
-class TabContents;
 
 namespace extensions {
 
@@ -80,8 +84,8 @@
   // kDefaultTabId if none was specified.
   int tab_id_;
 
-  // Tab content for |tab_id_| if one exists.
-  TabContents* contents_;
+  // WebContents for |tab_id_| if one exists.
+  content::WebContents* contents_;
 
   // The extension action for the current extension.
   ExtensionAction* extension_action_;
diff --git a/chrome/browser/extensions/api/extension_action/extension_page_actions_api.cc b/chrome/browser/extensions/api/extension_action/extension_page_actions_api.cc
index c2cb5b1..f6bb47e 100644
--- a/chrome/browser/extensions/api/extension_action/extension_page_actions_api.cc
+++ b/chrome/browser/extensions/api/extension_action/extension_page_actions_api.cc
@@ -16,7 +16,6 @@
 #include "chrome/browser/extensions/tab_helper.h"
 #include "chrome/browser/profiles/profile.h"
 #include "chrome/browser/ui/browser_list.h"
-#include "chrome/browser/ui/tab_contents/tab_contents.h"
 #include "chrome/common/extensions/extension.h"
 #include "chrome/common/extensions/extension_error_utils.h"
 #include "content/public/browser/navigation_entry.h"
@@ -65,8 +64,8 @@
     return false;
   }
 
-  // Find the TabContents that contains this tab id.
-  TabContents* contents = NULL;
+  // Find the WebContents that contains this tab id.
+  content::WebContents* contents = NULL;
   bool result = ExtensionTabUtil::GetTabById(
       tab_id, profile(), include_incognito(), NULL, NULL, &contents, NULL);
   if (!result || !contents) {
@@ -76,8 +75,7 @@
   }
 
   // Make sure the URL hasn't changed.
-  NavigationEntry* entry =
-      contents->web_contents()->GetController().GetActiveEntry();
+  NavigationEntry* entry = contents->GetController().GetActiveEntry();
   if (!entry || url != entry->GetURL().spec()) {
     error_ = ExtensionErrorUtils::FormatErrorMessage(kUrlNotActiveError, url);
     return false;
@@ -87,7 +85,7 @@
   page_action->SetAppearance(
       tab_id, enable ? ExtensionAction::ACTIVE : ExtensionAction::INVISIBLE);
   page_action->SetTitle(tab_id, title);
-  extensions::TabHelper::FromWebContents(contents->web_contents())->
+  extensions::TabHelper::FromWebContents(contents)->
       location_bar_controller()->NotifyChange();
 
   return true;
diff --git a/chrome/browser/extensions/api/messaging/message_service.cc b/chrome/browser/extensions/api/messaging/message_service.cc
index 4f328bd..afc9407a 100644
--- a/chrome/browser/extensions/api/messaging/message_service.cc
+++ b/chrome/browser/extensions/api/messaging/message_service.cc
@@ -21,7 +21,6 @@
 #include "chrome/browser/extensions/process_map.h"
 #include "chrome/browser/profiles/profile.h"
 #include "chrome/browser/tab_contents/tab_util.h"
-#include "chrome/browser/ui/tab_contents/tab_contents.h"
 #include "chrome/common/chrome_notification_types.h"
 #include "chrome/common/extensions/extension.h"
 #include "chrome/common/extensions/extension_messages.h"
@@ -263,17 +262,17 @@
     return;
   Profile* profile = Profile::FromBrowserContext(source->GetBrowserContext());
 
-  TabContents* contents = NULL;
+  WebContents* contents = NULL;
   scoped_ptr<MessagePort> receiver;
   if (ExtensionTabUtil::GetTabById(tab_id, profile, true,
                                    NULL, NULL, &contents, NULL)) {
     receiver.reset(new ExtensionMessagePort(
-        contents->web_contents()->GetRenderProcessHost(),
-        contents->web_contents()->GetRenderViewHost()->GetRoutingID(),
+        contents->GetRenderProcessHost(),
+        contents->GetRenderViewHost()->GetRoutingID(),
         extension_id));
   }
 
-  if (contents && contents->web_contents()->GetController().NeedsReload()) {
+  if (contents && contents->GetController().NeedsReload()) {
     // The tab isn't loaded yet. Don't attempt to connect. Treat this as a
     // disconnect.
     ExtensionMessagePort port(source, MSG_ROUTING_CONTROL, extension_id);
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 aaa8cb0..817a91c 100644
--- a/chrome/browser/extensions/api/offscreen_tabs/offscreen_tabs_api.cc
+++ b/chrome/browser/extensions/api/offscreen_tabs/offscreen_tabs_api.cc
@@ -809,7 +809,7 @@
   DictionaryValue* update_props;
   EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(1, &update_props));
 
-  tab_contents_ = offscreen_tab->tab_contents();
+  web_contents_ = offscreen_tab->tab_contents()->web_contents();
   bool is_async = false;
   if (!UpdateURLIfPresent(update_props, offscreen_tab_id, &is_async))
     return false;
@@ -817,8 +817,7 @@
   // 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();
+    const gfx::Size& size = web_contents_->GetView()->GetContainerSize();
 
     int width;
     if (update_props->HasKey(tabs_keys::kWidthKey))
diff --git a/chrome/browser/extensions/api/offscreen_tabs/offscreen_tabs_api.h b/chrome/browser/extensions/api/offscreen_tabs/offscreen_tabs_api.h
index aa4f099..9650ad8 100644
--- a/chrome/browser/extensions/api/offscreen_tabs/offscreen_tabs_api.h
+++ b/chrome/browser/extensions/api/offscreen_tabs/offscreen_tabs_api.h
@@ -27,10 +27,10 @@
 
 class BackingStore;
 class SkBitmap;
-class TabContents;
+
 namespace content {
 class WebContents;
-}  // namespace content
+}
 
 // Creates an offscreen tab.
 class CreateOffscreenTabFunction : public SyncExtensionFunction {
diff --git a/chrome/browser/extensions/api/page_capture/page_capture_api.cc b/chrome/browser/extensions/api/page_capture/page_capture_api.cc
index 6da38cc..a12cdbf 100644
--- a/chrome/browser/extensions/api/page_capture/page_capture_api.cc
+++ b/chrome/browser/extensions/api/page_capture/page_capture_api.cc
@@ -8,7 +8,6 @@
 #include "base/file_util.h"
 #include "chrome/browser/browser_process.h"
 #include "chrome/browser/extensions/extension_tab_util.h"
-#include "chrome/browser/ui/tab_contents/tab_contents.h"
 #include "chrome/common/extensions/extension_messages.h"
 #include "content/public/browser/child_process_security_policy.h"
 #include "content/public/browser/notification_details.h"
@@ -188,12 +187,12 @@
 
 WebContents* PageCaptureSaveAsMHTMLFunction::GetWebContents() {
   Browser* browser = NULL;
-  TabContents* tab_contents = NULL;
+  content::WebContents* web_contents = NULL;
 
   if (!ExtensionTabUtil::GetTabById(params_->details.tab_id, profile(),
                                     include_incognito(), &browser, NULL,
-                                    &tab_contents, NULL)) {
+                                    &web_contents, NULL)) {
     return NULL;
   }
-  return tab_contents->web_contents();
+  return web_contents;
 }
diff --git a/chrome/browser/extensions/api/processes/processes_api.cc b/chrome/browser/extensions/api/processes/processes_api.cc
index 5a500e3..6c10f6e 100644
--- a/chrome/browser/extensions/api/processes/processes_api.cc
+++ b/chrome/browser/extensions/api/processes/processes_api.cc
@@ -21,7 +21,6 @@
 #include "chrome/browser/extensions/extension_tab_util.h"
 #include "chrome/browser/profiles/profile.h"
 #include "chrome/browser/task_manager/task_manager.h"
-#include "chrome/browser/ui/tab_contents/tab_contents.h"
 #include "chrome/common/chrome_notification_types.h"
 #include "chrome/common/extensions/extension_error_utils.h"
 #include "content/public/browser/browser_thread.h"
@@ -554,7 +553,7 @@
 }
 
 void GetProcessIdForTabFunction::GetProcessIdForTab() {
-  TabContents* contents = NULL;
+  content::WebContents* contents = NULL;
   int tab_index = -1;
   if (!ExtensionTabUtil::GetTabById(tab_id_, profile(), include_incognito(),
                                     NULL, NULL, &contents, &tab_index)) {
@@ -564,7 +563,7 @@
     SetResult(Value::CreateIntegerValue(-1));
     SendResponse(false);
   } else {
-    int process_id = contents->web_contents()->GetRenderProcessHost()->GetID();
+    int process_id = contents->GetRenderProcessHost()->GetID();
     SetResult(Value::CreateIntegerValue(process_id));
     SendResponse(true);
   }
diff --git a/chrome/browser/extensions/api/tabs/execute_code_in_tab_function.cc b/chrome/browser/extensions/api/tabs/execute_code_in_tab_function.cc
index 5b76613..9a3c0e4 100644
--- a/chrome/browser/extensions/api/tabs/execute_code_in_tab_function.cc
+++ b/chrome/browser/extensions/api/tabs/execute_code_in_tab_function.cc
@@ -16,7 +16,6 @@
 #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.h"
 #include "chrome/common/extensions/api/tabs.h"
 #include "chrome/common/extensions/extension.h"
 #include "chrome/common/extensions/extension_constants.h"
@@ -63,7 +62,7 @@
     return false;
   }
 
-  TabContents* contents = NULL;
+  content::WebContents* contents = NULL;
 
   // If |tab_id| is specified, look for the tab. Otherwise default to selected
   // tab in the current window.
@@ -77,12 +76,11 @@
   // NOTE: This can give the wrong answer due to race conditions, but it is OK,
   // we check again in the renderer.
   CHECK(contents);
-  if (!GetExtension()->CanExecuteScriptOnPage(
-          contents->web_contents()->GetURL(),
-          contents->web_contents()->GetURL(),
-          execute_tab_id_,
-          NULL,
-          &error_)) {
+  if (!GetExtension()->CanExecuteScriptOnPage(contents->GetURL(),
+                                              contents->GetURL(),
+                                              execute_tab_id_,
+                                              NULL,
+                                              &error_)) {
     return false;
   }
 
@@ -146,8 +144,8 @@
     Browser* browser = GetCurrentBrowser();
     if (!browser)
       return false;
-    TabContents* tab_contents = NULL;
-    if (!ExtensionTabUtil::GetDefaultTab(browser, &tab_contents, &tab_id))
+    content::WebContents* web_contents = NULL;
+    if (!ExtensionTabUtil::GetDefaultTab(browser, &web_contents, &tab_id))
       return false;
   }
 
@@ -223,7 +221,7 @@
 }
 
 bool ExecuteCodeInTabFunction::Execute(const std::string& code_string) {
-  TabContents* contents = NULL;
+  content::WebContents* contents = NULL;
   Browser* browser = NULL;
 
   bool success = ExtensionTabUtil::GetTabById(
@@ -265,7 +263,7 @@
   }
   CHECK_NE(UserScript::UNDEFINED, run_at);
 
-  extensions::TabHelper::FromWebContents(contents->web_contents())->
+  extensions::TabHelper::FromWebContents(contents)->
       script_executor()->ExecuteScript(
           extension->id(),
           script_type,
diff --git a/chrome/browser/extensions/api/tabs/tabs.cc b/chrome/browser/extensions/api/tabs/tabs.cc
index 68bc8d73aa..ad9d913 100644
--- a/chrome/browser/extensions/api/tabs/tabs.cc
+++ b/chrome/browser/extensions/api/tabs/tabs.cc
@@ -173,6 +173,7 @@
   }
   return true;
 }
+
 // |error_message| can optionally be passed in and will be set with an
 // appropriate message if the tab cannot be found by id.
 bool GetTabById(int tab_id,
@@ -180,7 +181,7 @@
                 bool include_incognito,
                 Browser** browser,
                 TabStripModel** tab_strip,
-                TabContents** contents,
+                content::WebContents** contents,
                 int* tab_index,
                 std::string* error_message) {
   if (ExtensionTabUtil::GetTabById(tab_id, profile, include_incognito,
@@ -442,12 +443,11 @@
       EXTENSION_FUNCTION_VALIDATE(args->GetInteger(keys::kTabIdKey, &tab_id));
 
       // Find the tab and detach it from the original window.
-      Browser* source_browser = NULL;
       TabStripModel* source_tab_strip = NULL;
       int tab_index = -1;
       if (!GetTabById(tab_id, profile(), include_incognito(),
-                      &source_browser, &source_tab_strip, &contents,
-                      &tab_index, &error_))
+                      NULL, &source_tab_strip,
+                      NULL, &tab_index, &error_))
         return false;
       contents = source_tab_strip->DetachTabContentsAt(tab_index);
       if (!contents) {
@@ -1006,13 +1006,10 @@
     EXTENSION_FUNCTION_VALIDATE(args->GetInteger(
         keys::kOpenerTabIdKey, &opener_id));
 
-    TabContents* opener_contents = NULL;
     if (!ExtensionTabUtil::GetTabById(
             opener_id, profile(), include_incognito(),
-            NULL, NULL, &opener_contents, NULL))
+            NULL, NULL, &opener, NULL))
       return false;
-
-    opener = opener_contents->web_contents();
   }
 
   // TODO(rafaelw): handle setting remaining tab properties:
@@ -1116,10 +1113,9 @@
 
   Browser* browser = NULL;
   TabStripModel* tab_strip = NULL;
-  TabContents* contents = NULL;
   int tab_index = -1;
   if (!GetTabById(tab_id, profile(), include_incognito(),
-                  &browser, &tab_strip, &contents, &tab_index, &error_)) {
+                  &browser, &tab_strip, NULL, &tab_index, &error_)) {
     return false;
   }
 
@@ -1142,13 +1138,13 @@
   EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &tab_id));
 
   TabStripModel* tab_strip = NULL;
-  TabContents* contents = NULL;
+  WebContents* contents = NULL;
   int tab_index = -1;
   if (!GetTabById(tab_id, profile(), include_incognito(),
                   NULL, &tab_strip, &contents, &tab_index, &error_))
     return false;
 
-  SetResult(ExtensionTabUtil::CreateTabValue(contents->web_contents(),
+  SetResult(ExtensionTabUtil::CreateTabValue(contents,
                                              tab_strip,
                                              tab_index,
                                              GetExtension()));
@@ -1222,7 +1218,7 @@
   return true;
 }
 
-UpdateTabFunction::UpdateTabFunction() : tab_contents_(NULL) {
+UpdateTabFunction::UpdateTabFunction() : web_contents_(NULL) {
 }
 
 bool UpdateTabFunction::RunImpl() {
@@ -1235,19 +1231,19 @@
   }
 
   int tab_id = -1;
-  TabContents* contents = NULL;
+  WebContents* contents = NULL;
   if (tab_value == NULL || tab_value->IsType(Value::TYPE_NULL)) {
     Browser* browser = GetCurrentBrowser();
     if (!browser) {
       error_ = keys::kNoCurrentWindowError;
       return false;
     }
-    contents = browser->tab_strip_model()->GetActiveTabContents();
+    contents = browser->tab_strip_model()->GetActiveWebContents();
     if (!contents) {
       error_ = keys::kNoSelectedTabError;
       return false;
     }
-    tab_id = SessionID::IdForTab(contents->web_contents());
+    tab_id = SessionID::IdForTab(contents);
   } else {
     EXTENSION_FUNCTION_VALIDATE(tab_value->GetAsInteger(&tab_id));
   }
@@ -1259,7 +1255,7 @@
     return false;
   }
 
-  tab_contents_ = contents;
+  web_contents_ = contents;
 
   // TODO(rafaelw): handle setting remaining tab properties:
   // -title
@@ -1285,9 +1281,9 @@
   if (active) {
     if (tab_strip->active_index() != tab_index) {
       tab_strip->ActivateTabAt(tab_index, false);
-      DCHECK_EQ(contents, tab_strip->GetActiveTabContents());
+      DCHECK_EQ(contents, tab_strip->GetActiveWebContents());
     }
-    tab_contents_->web_contents()->Focus();
+    web_contents_->Focus();
   }
 
   if (update_props->HasKey(keys::kHighlightedKey)) {
@@ -1305,7 +1301,7 @@
     tab_strip->SetTabPinned(tab_index, pinned);
 
     // Update the tab index because it may move when being pinned.
-    tab_index = tab_strip->GetIndexOfTabContents(contents);
+    tab_index = tab_strip->GetIndexOfWebContents(contents);
   }
 
   if (update_props->HasKey(keys::kOpenerTabIdKey)) {
@@ -1313,14 +1309,13 @@
     EXTENSION_FUNCTION_VALIDATE(update_props->GetInteger(
         keys::kOpenerTabIdKey, &opener_id));
 
-    TabContents* opener_contents = NULL;
+    WebContents* opener_contents = NULL;
     if (!ExtensionTabUtil::GetTabById(
             opener_id, profile(), include_incognito(),
             NULL, NULL, &opener_contents, NULL))
       return false;
 
-    tab_strip->SetOpenerOfWebContentsAt(
-        tab_index, opener_contents->web_contents());
+    tab_strip->SetOpenerOfWebContentsAt(tab_index, opener_contents);
   }
 
   if (!is_async) {
@@ -1358,15 +1353,15 @@
   // we need to check host permissions before allowing them.
   if (url.SchemeIs(chrome::kJavaScriptScheme)) {
     if (!GetExtension()->CanExecuteScriptOnPage(
-            tab_contents_->web_contents()->GetURL(),
-            tab_contents_->web_contents()->GetURL(),
+            web_contents_->GetURL(),
+            web_contents_->GetURL(),
             tab_id,
             NULL,
             &error_)) {
       return false;
     }
 
-    extensions::TabHelper::FromWebContents(tab_contents_->web_contents())->
+    extensions::TabHelper::FromWebContents(web_contents_)->
         script_executor()->ExecuteScript(
             extension_id(),
             ScriptExecutor::JAVASCRIPT,
@@ -1380,13 +1375,13 @@
     return true;
   }
 
-  tab_contents_->web_contents()->GetController().LoadURL(
+  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(), tab_contents_->web_contents()->GetURL().spec());
+    DCHECK_EQ(url.spec(), web_contents_->GetURL().spec());
 
   return true;
 }
@@ -1395,8 +1390,7 @@
   if (!has_callback())
     return;
 
-  SetResult(ExtensionTabUtil::CreateTabValue(tab_contents_->web_contents(),
-                                             GetExtension()));
+  SetResult(ExtensionTabUtil::CreateTabValue(web_contents_, GetExtension()));
 }
 
 void UpdateTabFunction::OnExecuteCodeFinished(const std::string& error,
@@ -1428,7 +1422,7 @@
   for (size_t i = 0; i < tab_ids.size(); ++i) {
     Browser* source_browser = NULL;
     TabStripModel* source_tab_strip = NULL;
-    TabContents* contents = NULL;
+    WebContents* contents = NULL;
     int tab_index = -1;
     if (!GetTabById(tab_ids[i], profile(), include_incognito(),
                     &source_browser, &source_tab_strip, &contents,
@@ -1472,8 +1466,9 @@
       if (ExtensionTabUtil::GetWindowId(target_browser) !=
           ExtensionTabUtil::GetWindowId(source_browser)) {
         TabStripModel* target_tab_strip = target_browser->tab_strip_model();
-        contents = source_tab_strip->DetachTabContentsAt(tab_index);
-        if (!contents) {
+        TabContents* tab_contents =
+            source_tab_strip->DetachTabContentsAt(tab_index);
+        if (!tab_contents) {
           error_ = ExtensionErrorUtils::FormatErrorMessage(
               keys::kTabNotFoundError, base::IntToString(tab_ids[i]));
           return false;
@@ -1486,11 +1481,11 @@
           new_index = target_tab_strip->count();
 
         target_tab_strip->InsertTabContentsAt(
-            new_index, contents, TabStripModel::ADD_NONE);
+            new_index, tab_contents, TabStripModel::ADD_NONE);
 
         if (has_callback()) {
           tab_values.Append(ExtensionTabUtil::CreateTabValue(
-              contents->web_contents(),
+              tab_contents->web_contents(),
               target_tab_strip,
               new_index,
               GetExtension()));
@@ -1512,8 +1507,7 @@
 
     if (has_callback()) {
       tab_values.Append(ExtensionTabUtil::CreateTabValue(
-          contents->web_contents(), source_tab_strip, new_index,
-          GetExtension()));
+          contents, source_tab_strip, new_index, GetExtension()));
     }
   }
 
@@ -1544,7 +1538,7 @@
       }
   }
 
-  TabContents* contents = NULL;
+  content::WebContents* web_contents = NULL;
 
   // If |tab_id| is specified, look for it. Otherwise default to selected tab
   // in the current window.
@@ -1559,7 +1553,7 @@
       return false;
     }
 
-    if (!ExtensionTabUtil::GetDefaultTab(browser, &contents, NULL))
+    if (!ExtensionTabUtil::GetDefaultTab(browser, &web_contents, NULL))
       return false;
   } else {
     int tab_id = -1;
@@ -1567,11 +1561,10 @@
 
     Browser* browser = NULL;
     if (!GetTabById(tab_id, profile(), include_incognito(),
-                    &browser, NULL, &contents, NULL, &error_))
+                    &browser, NULL, &web_contents, NULL, &error_))
     return false;
   }
 
-  WebContents* web_contents = contents->web_contents();
   if (web_contents->ShowingInterstitialPage()) {
     // This does as same as Browser::ReloadInternal.
     NavigationEntry* entry = web_contents->GetController().GetActiveEntry();
@@ -1597,7 +1590,7 @@
 
   for (size_t i = 0; i < tab_ids.size(); ++i) {
     Browser* browser = NULL;
-    TabContents* contents = NULL;
+    WebContents* contents = NULL;
     if (!GetTabById(tab_ids[i], profile(), include_incognito(),
                     &browser, NULL, &contents, NULL, &error_))
       return false;
@@ -1611,7 +1604,7 @@
     // There's a chance that the tab is being dragged, or we're in some other
     // nested event loop. This code path ensures that the tab is safely closed
     // under such circumstances, whereas |chrome::CloseWebContents()| does not.
-    contents->web_contents()->Close();
+    contents->Close();
   }
   return true;
 }
@@ -1806,7 +1799,7 @@
 bool DetectTabLanguageFunction::RunImpl() {
   int tab_id = 0;
   Browser* browser = NULL;
-  TabContents* contents = NULL;
+  WebContents* contents = NULL;
 
   // If |tab_id| is specified, look for it. Otherwise default to selected tab
   // in the current window.
@@ -1822,21 +1815,21 @@
     browser = GetCurrentBrowser();
     if (!browser)
       return false;
-    contents = browser->tab_strip_model()->GetActiveTabContents();
+    contents = browser->tab_strip_model()->GetActiveWebContents();
     if (!contents)
       return false;
   }
 
-  if (contents->web_contents()->GetController().NeedsReload()) {
+  if (contents->GetController().NeedsReload()) {
     // If the tab hasn't been loaded, don't wait for the tab to load.
     error_ = keys::kCannotDetermineLanguageOfUnloadedTab;
     return false;
   }
 
-  AddRef();  // Balanced in GotLanguage()
+  AddRef();  // Balanced in GotLanguage().
 
   TranslateTabHelper* translate_tab_helper =
-      TranslateTabHelper::FromWebContents(contents->web_contents());
+      TranslateTabHelper::FromWebContents(contents);
   if (!translate_tab_helper->language_state().original_language().empty()) {
     // Delay the callback invocation until after the current JS call has
     // returned.
@@ -1848,15 +1841,13 @@
   // 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, chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED,
-                 content::Source<WebContents>(contents->web_contents()));
+                 content::Source<WebContents>(contents));
   registrar_.Add(
       this, chrome::NOTIFICATION_TAB_CLOSING,
-      content::Source<NavigationController>(
-          &(contents->web_contents()->GetController())));
+      content::Source<NavigationController>(&(contents->GetController())));
   registrar_.Add(
       this, content::NOTIFICATION_NAV_ENTRY_COMMITTED,
-      content::Source<NavigationController>(
-          &(contents->web_contents()->GetController())));
+      content::Source<NavigationController>(&(contents->GetController())));
   return true;
 }
 
diff --git a/chrome/browser/extensions/api/tabs/tabs.h b/chrome/browser/extensions/api/tabs/tabs.h
index c0e02125..e5780c3 100644
--- a/chrome/browser/extensions/api/tabs/tabs.h
+++ b/chrome/browser/extensions/api/tabs/tabs.h
@@ -18,7 +18,6 @@
 class GURL;
 class PrefService;
 class SkBitmap;
-class TabContents;
 
 namespace base {
 class DictionaryValue;
@@ -130,7 +129,7 @@
                                   bool* is_async);
   virtual void PopulateResult();
 
-  TabContents* tab_contents_;
+  content::WebContents* web_contents_;
 
  private:
   virtual bool RunImpl() OVERRIDE;
diff --git a/chrome/browser/extensions/api/web_navigation/web_navigation_api.cc b/chrome/browser/extensions/api/web_navigation/web_navigation_api.cc
index 00e66d1..5e3f1adc 100644
--- a/chrome/browser/extensions/api/web_navigation/web_navigation_api.cc
+++ b/chrome/browser/extensions/api/web_navigation/web_navigation_api.cc
@@ -648,18 +648,17 @@
 
   SetResult(Value::CreateNullValue());
 
-  TabContents* tab_contents;
+  content::WebContents* web_contents;
   if (!ExtensionTabUtil::GetTabById(tab_id,
                                     profile(),
                                     include_incognito(),
                                     NULL, NULL,
-                                    &tab_contents,
+                                    &web_contents,
                                     NULL) ||
-      !tab_contents) {
+      !web_contents) {
     return true;
   }
 
-  content::WebContents* web_contents = tab_contents->web_contents();
   WebNavigationTabObserver* observer =
       WebNavigationTabObserver::Get(web_contents);
   DCHECK(observer);
@@ -703,18 +702,17 @@
 
   SetResult(Value::CreateNullValue());
 
-  TabContents* tab_contents;
+  content::WebContents* web_contents;
   if (!ExtensionTabUtil::GetTabById(tab_id,
                                     profile(),
                                     include_incognito(),
                                     NULL, NULL,
-                                    &tab_contents,
+                                    &web_contents,
                                     NULL) ||
-      !tab_contents) {
+      !web_contents) {
     return true;
   }
 
-  content::WebContents* web_contents = tab_contents->web_contents();
   WebNavigationTabObserver* observer =
       WebNavigationTabObserver::Get(web_contents);
   DCHECK(observer);
diff --git a/chrome/browser/extensions/browser_event_router.cc b/chrome/browser/extensions/browser_event_router.cc
index 996a54d..a47d6fb 100644
--- a/chrome/browser/extensions/browser_event_router.cc
+++ b/chrome/browser/extensions/browser_event_router.cc
@@ -89,8 +89,7 @@
     Browser* browser = *iter;
     if (browser->tab_strip_model()) {
       for (int i = 0; i < browser->tab_strip_model()->count(); ++i) {
-        WebContents* contents =
-            chrome::GetTabContentsAt(browser, i)->web_contents();
+        WebContents* contents = chrome::GetWebContentsAt(browser, i);
         int tab_id = ExtensionTabUtil::GetTabId(contents);
         tab_entries_[tab_id] = TabEntry();
       }
@@ -121,8 +120,7 @@
   browser->tab_strip_model()->AddObserver(this);
 
   for (int i = 0; i < browser->tab_strip_model()->count(); ++i) {
-    RegisterForTabNotifications(
-        chrome::GetTabContentsAt(browser, i)->web_contents());
+    RegisterForTabNotifications(chrome::GetWebContentsAt(browser, i));
   }
 }
 
@@ -295,10 +293,10 @@
 
   for (size_t i = 0; i < new_selection.size(); ++i) {
     int index = new_selection[i];
-    TabContents* contents = tab_strip_model->GetTabContentsAt(index);
+    WebContents* contents = tab_strip_model->GetWebContentsAt(index);
     if (!contents)
       break;
-    int tab_id = ExtensionTabUtil::GetTabId(contents->web_contents());
+    int tab_id = ExtensionTabUtil::GetTabId(contents);
     all->Append(Value::CreateIntegerValue(tab_id));
   }
 
@@ -528,11 +526,11 @@
     const ExtensionAction& browser_action,
     Browser* browser) {
   Profile* profile = browser->profile();
-  TabContents* tab_contents = NULL;
+  WebContents* web_contents = NULL;
   int tab_id = 0;
-  if (!ExtensionTabUtil::GetDefaultTab(browser, &tab_contents, &tab_id))
+  if (!ExtensionTabUtil::GetDefaultTab(browser, &web_contents, &tab_id))
     return;
-  ExtensionActionExecuted(profile, browser_action, tab_contents);
+  ExtensionActionExecuted(profile, browser_action, web_contents);
 }
 
 void BrowserEventRouter::PageActionExecuted(Profile* profile,
@@ -542,24 +540,24 @@
                                             int button) {
   DispatchOldPageActionEvent(profile, page_action.extension_id(),
                              page_action.id(), tab_id, url, button);
-  TabContents* tab_contents = NULL;
+  WebContents* web_contents = NULL;
   if (!ExtensionTabUtil::GetTabById(tab_id, profile, profile->IsOffTheRecord(),
-                                    NULL, NULL, &tab_contents, NULL)) {
+                                    NULL, NULL, &web_contents, NULL)) {
     return;
   }
-  ExtensionActionExecuted(profile, page_action, tab_contents);
+  ExtensionActionExecuted(profile, page_action, web_contents);
 }
 
 void BrowserEventRouter::ScriptBadgeExecuted(
     Profile* profile,
     const ExtensionAction& script_badge,
     int tab_id) {
-  TabContents* tab_contents = NULL;
+  WebContents* web_contents = NULL;
   if (!ExtensionTabUtil::GetTabById(tab_id, profile, profile->IsOffTheRecord(),
-                                    NULL, NULL, &tab_contents, NULL)) {
+                                    NULL, NULL, &web_contents, NULL)) {
     return;
   }
-  ExtensionActionExecuted(profile, script_badge, tab_contents);
+  ExtensionActionExecuted(profile, script_badge, web_contents);
 }
 
 void BrowserEventRouter::CommandExecuted(Profile* profile,
@@ -578,7 +576,7 @@
 void BrowserEventRouter::ExtensionActionExecuted(
     Profile* profile,
     const ExtensionAction& extension_action,
-    TabContents* tab_contents) {
+    WebContents* web_contents) {
   const char* event_name = NULL;
   switch (extension_action.action_type()) {
     case Extension::ActionInfo::TYPE_BROWSER:
@@ -595,7 +593,7 @@
   if (event_name) {
     scoped_ptr<ListValue> args(new ListValue());
     DictionaryValue* tab_value = ExtensionTabUtil::CreateTabValue(
-        tab_contents->web_contents(),
+        web_contents,
         ExtensionTabUtil::INCLUDE_PRIVACY_SENSITIVE_FIELDS);
     args->Append(tab_value);
 
diff --git a/chrome/browser/extensions/browser_event_router.h b/chrome/browser/extensions/browser_event_router.h
index 0ea37b3..1a7e156 100644
--- a/chrome/browser/extensions/browser_event_router.h
+++ b/chrome/browser/extensions/browser_event_router.h
@@ -199,7 +199,7 @@
   // event to send based on what the extension wants.
   void ExtensionActionExecuted(Profile* profile,
                                const ExtensionAction& extension_action,
-                               TabContents* tab_contents);
+                               content::WebContents* web_contents);
 
   std::map<int, TabEntry> tab_entries_;
 
diff --git a/chrome/browser/extensions/extension_devtools_bridge.cc b/chrome/browser/extensions/extension_devtools_bridge.cc
index ab1499e..633c527f 100644
--- a/chrome/browser/extensions/extension_devtools_bridge.cc
+++ b/chrome/browser/extensions/extension_devtools_bridge.cc
@@ -58,14 +58,14 @@
 
   Browser* browser;
   TabStripModel* tab_strip;
-  TabContents* contents;
+  WebContents* contents;
   int tab_index;
   if (ExtensionTabUtil::GetTabById(tab_id_, profile_, true,
                                    &browser, &tab_strip,
                                    &contents, &tab_index)) {
     DevToolsManager* devtools_manager = DevToolsManager::GetInstance();
     DevToolsAgentHost* agent = DevToolsAgentHostRegistry::GetDevToolsAgentHost(
-        contents->web_contents()->GetRenderViewHost());
+        contents->GetRenderViewHost());
     if (devtools_manager->GetDevToolsClientHostFor(agent))
       return false;
 
diff --git a/chrome/browser/extensions/extension_tab_util.cc b/chrome/browser/extensions/extension_tab_util.cc
index c836b1b..4603a30 100644
--- a/chrome/browser/extensions/extension_tab_util.cc
+++ b/chrome/browser/extensions/extension_tab_util.cc
@@ -81,11 +81,10 @@
   ListValue* tab_list = new ListValue();
   TabStripModel* tab_strip = browser->tab_strip_model();
   for (int i = 0; i < tab_strip->count(); ++i) {
-    tab_list->Append(CreateTabValue(
-        tab_strip->GetTabContentsAt(i)->web_contents(),
-        tab_strip,
-        i,
-        extension));
+    tab_list->Append(CreateTabValue(tab_strip->GetWebContentsAt(i),
+                                    tab_strip,
+                                    i,
+                                    extension));
   }
 
   return tab_list;
@@ -157,15 +156,15 @@
 }
 
 bool ExtensionTabUtil::GetDefaultTab(Browser* browser,
-                                     TabContents** contents,
+                                     WebContents** contents,
                                      int* tab_id) {
   DCHECK(browser);
   DCHECK(contents);
 
-  *contents = chrome::GetActiveTabContents(browser);
+  *contents = chrome::GetActiveWebContents(browser);
   if (*contents) {
     if (tab_id)
-      *tab_id = GetTabId((*contents)->web_contents());
+      *tab_id = GetTabId(*contents);
     return true;
   }
 
@@ -177,7 +176,7 @@
                                   bool include_incognito,
                                   Browser** browser,
                                   TabStripModel** tab_strip,
-                                  TabContents** contents,
+                                  WebContents** contents,
                                   int* tab_index) {
   Profile* incognito_profile =
       include_incognito && profile->HasOffTheRecordProfile() ?
@@ -189,8 +188,8 @@
         target_browser->profile() == incognito_profile) {
       TabStripModel* target_tab_strip = target_browser->tab_strip_model();
       for (int i = 0; i < target_tab_strip->count(); ++i) {
-        TabContents* target_contents = target_tab_strip->GetTabContentsAt(i);
-        if (SessionID::IdForTab(target_contents->web_contents()) == tab_id) {
+        WebContents* target_contents = target_tab_strip->GetWebContentsAt(i);
+        if (SessionID::IdForTab(target_contents) == tab_id) {
           if (browser)
             *browser = target_browser;
           if (tab_strip)
diff --git a/chrome/browser/extensions/extension_tab_util.h b/chrome/browser/extensions/extension_tab_util.h
index de81e8b..4e8e5c6 100644
--- a/chrome/browser/extensions/extension_tab_util.h
+++ b/chrome/browser/extensions/extension_tab_util.h
@@ -13,7 +13,6 @@
 class Browser;
 class GURL;
 class Profile;
-class TabContents;
 class TabStripModel;
 
 namespace base {
@@ -78,14 +77,14 @@
                                TabStripModel** tab_strip_model,
                                int* tab_index);
   static bool GetDefaultTab(Browser* browser,
-                            TabContents** contents,
+                            content::WebContents** 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,
+                         content::WebContents** contents,
                          int* tab_index);
 
   // Takes |url_string| and returns a GURL which is either valid and absolute
diff --git a/chrome/browser/extensions/extension_tab_util_android.cc b/chrome/browser/extensions/extension_tab_util_android.cc
index d863180..6210724 100644
--- a/chrome/browser/extensions/extension_tab_util_android.cc
+++ b/chrome/browser/extensions/extension_tab_util_android.cc
@@ -65,7 +65,7 @@
 }
 
 bool ExtensionTabUtil::GetDefaultTab(Browser* browser,
-                                     TabContents** contents,
+                                     content::WebContents** contents,
                                      int* tab_id) {
   NOTIMPLEMENTED();
   return false;
@@ -76,7 +76,7 @@
                                   bool include_incognito,
                                   Browser** browser,
                                   TabStripModel** tab_strip,
-                                  TabContents** contents,
+                                  content::WebContents** contents,
                                   int* tab_index) {
   NOTIMPLEMENTED();
   return false;
diff --git a/chrome/browser/infobars/infobar_extension_api.cc b/chrome/browser/infobars/infobar_extension_api.cc
index 797cdb3..fe6d578 100644
--- a/chrome/browser/infobars/infobar_extension_api.cc
+++ b/chrome/browser/infobars/infobar_extension_api.cc
@@ -15,7 +15,6 @@
 #include "chrome/browser/extensions/window_controller.h"
 #include "chrome/browser/infobars/infobar_tab_helper.h"
 #include "chrome/browser/ui/browser.h"
-#include "chrome/browser/ui/tab_contents/tab_contents.h"
 #include "chrome/common/extensions/extension.h"
 #include "chrome/common/extensions/extension_error_utils.h"
 #include "chrome/common/url_constants.h"
@@ -53,14 +52,14 @@
   GURL url = extension->GetResourceURL(extension->url(), html_path);
 
   Browser* browser = NULL;
-  TabContents* tab_contents = NULL;
+  content::WebContents* web_contents = NULL;
   if (!ExtensionTabUtil::GetTabById(
       tab_id,
       profile(),
       include_incognito(),
       &browser,
       NULL,
-      &tab_contents,
+      &web_contents,
       NULL)) {
     error_ = ExtensionErrorUtils::FormatErrorMessage(
         extensions::tabs_constants::kTabNotFoundError,
@@ -69,7 +68,7 @@
   }
 
   InfoBarTabHelper* infobar_tab_helper =
-      InfoBarTabHelper::FromWebContents(tab_contents->web_contents());
+      InfoBarTabHelper::FromWebContents(web_contents);
   infobar_tab_helper->AddInfoBar(
       new ExtensionInfoBarDelegate(browser, infobar_tab_helper,
                                    GetExtension(), url, height));