diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-23 01:36:47 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-23 01:36:47 +0000 |
commit | 26b5e32067f119d2d69e83b319db7f52fdc48ede (patch) | |
tree | a213e3b49f2843f865ee950c6f980c791e38f582 /chrome/browser | |
parent | 290fb65488853449fee7c3794179ffa5855a72a0 (diff) | |
download | chromium_src-26b5e32067f119d2d69e83b319db7f52fdc48ede.zip chromium_src-26b5e32067f119d2d69e83b319db7f52fdc48ede.tar.gz chromium_src-26b5e32067f119d2d69e83b319db7f52fdc48ede.tar.bz2 |
Change most of the methods of WebContentsObserver to take a content::WebContents instead of a TabContents, and update all the dependent code.
BUG=98716
Review URL: http://codereview.chromium.org/9022023
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@115664 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
53 files changed, 239 insertions, 185 deletions
diff --git a/chrome/browser/automation/automation_provider_observers.cc b/chrome/browser/automation/automation_provider_observers.cc index ad48c70..a2f01e2 100644 --- a/chrome/browser/automation/automation_provider_observers.cc +++ b/chrome/browser/automation/automation_provider_observers.cc @@ -2683,18 +2683,18 @@ AllViewsStoppedLoadingObserver::~AllViewsStoppedLoadingObserver() { } void AllViewsStoppedLoadingObserver::OnFirstPendingLoad( - TabContents* tab_contents) { - pending_tabs_.insert(tab_contents); + content::WebContents* web_contents) { + pending_tabs_.insert(web_contents); } void AllViewsStoppedLoadingObserver::OnNoMorePendingLoads( - TabContents* tab_contents) { + content::WebContents* web_contents) { if (!automation_) { delete this; return; } - TabSet::iterator iter = pending_tabs_.find(tab_contents); + TabSet::iterator iter = pending_tabs_.find(web_contents); if (iter == pending_tabs_.end()) { LOG(ERROR) << "Received OnNoMorePendingLoads for tab without " << "OnFirstPendingLoad."; diff --git a/chrome/browser/automation/automation_provider_observers.h b/chrome/browser/automation/automation_provider_observers.h index 6dc207b..fea57b1 100644 --- a/chrome/browser/automation/automation_provider_observers.h +++ b/chrome/browser/automation/automation_provider_observers.h @@ -1658,8 +1658,9 @@ class AllViewsStoppedLoadingObserver : public TabEventObserver, virtual ~AllViewsStoppedLoadingObserver(); // TabEventObserver implementation. - virtual void OnFirstPendingLoad(TabContents* tab_contents) OVERRIDE; - virtual void OnNoMorePendingLoads(TabContents* tab_contents) OVERRIDE; + virtual void OnFirstPendingLoad(content::WebContents* web_contents) OVERRIDE; + virtual void OnNoMorePendingLoads( + content::WebContents* web_contents) OVERRIDE; // content::NotificationObserver implementation. virtual void Observe(int type, @@ -1667,7 +1668,7 @@ class AllViewsStoppedLoadingObserver : public TabEventObserver, const content::NotificationDetails& details) OVERRIDE; private: - typedef std::set<TabContents*> TabSet; + typedef std::set<content::WebContents*> TabSet; // Checks if there are no pending loads. If none, it will send an automation // relpy and delete itself. diff --git a/chrome/browser/automation/automation_tab_helper.cc b/chrome/browser/automation/automation_tab_helper.cc index f951fde..1d346ce 100644 --- a/chrome/browser/automation/automation_tab_helper.cc +++ b/chrome/browser/automation/automation_tab_helper.cc @@ -11,9 +11,10 @@ #include "chrome/common/automation_messages.h" #include "ipc/ipc_message.h" #include "ipc/ipc_message_macros.h" - #include "ui/gfx/size.h" +using content::WebContents; + TabEventObserver::TabEventObserver() { } TabEventObserver::~TabEventObserver() { @@ -91,17 +92,17 @@ void AutomationTabHelper::RenderViewGone(base::TerminationStatus status) { OnTabOrRenderViewDestroyed(tab_contents()); } -void AutomationTabHelper::TabContentsDestroyed(TabContents* tab_contents) { - OnTabOrRenderViewDestroyed(tab_contents); +void AutomationTabHelper::WebContentsDestroyed(WebContents* web_contents) { + OnTabOrRenderViewDestroyed(web_contents); } void AutomationTabHelper::OnTabOrRenderViewDestroyed( - TabContents* tab_contents) { + WebContents* web_contents) { if (has_pending_loads()) { is_loading_ = false; pending_client_redirects_.clear(); FOR_EACH_OBSERVER(TabEventObserver, observers_, - OnNoMorePendingLoads(tab_contents)); + OnNoMorePendingLoads(web_contents)); } } diff --git a/chrome/browser/automation/automation_tab_helper.h b/chrome/browser/automation/automation_tab_helper.h index 1c80792..5d17565 100644 --- a/chrome/browser/automation/automation_tab_helper.h +++ b/chrome/browser/automation/automation_tab_helper.h @@ -14,13 +14,8 @@ #include "base/memory/weak_ptr.h" #include "content/public/browser/web_contents_observer.h" -class TabContents; class AutomationTabHelper; -namespace IPC { -class Message; -} - // An observer API implemented by classes which are interested in various // tab events from AutomationTabHelper(s). class TabEventObserver { @@ -40,13 +35,13 @@ class TabEventObserver { // Called when the tab that had no pending loads now has a new pending // load. |tab_contents| will always be valid. - virtual void OnFirstPendingLoad(TabContents* tab_contents) { } + virtual void OnFirstPendingLoad(content::WebContents* web_contents) { } // Called when the tab that had one or more pending loads now has no // pending loads. |tab_contents| will always be valid. // // This method will always be called if |OnFirstPendingLoad| was called. - virtual void OnNoMorePendingLoads(TabContents* tab_contents) { } + virtual void OnNoMorePendingLoads(content::WebContents* web_contents) { } // Called as a result of a tab being snapshotted. virtual void OnSnapshotEntirePageACK( @@ -109,12 +104,13 @@ class AutomationTabHelper virtual void DidStartLoading() OVERRIDE; virtual void DidStopLoading() OVERRIDE; virtual void RenderViewGone(base::TerminationStatus status) OVERRIDE; - virtual void TabContentsDestroyed(TabContents* tab_contents) OVERRIDE; + virtual void WebContentsDestroyed( + content::WebContents* web_contents) OVERRIDE; virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; void OnWillPerformClientRedirect(int64 frame_id, double delay_seconds); void OnDidCompleteOrCancelClientRedirect(int64 frame_id); - void OnTabOrRenderViewDestroyed(TabContents* tab_contents); + void OnTabOrRenderViewDestroyed(content::WebContents* web_contents); // True if the tab is currently loading. If a navigation is scheduled but not // yet loading, this will be false. diff --git a/chrome/browser/automation/automation_tab_helper_unittest.cc b/chrome/browser/automation/automation_tab_helper_unittest.cc index 11056ea..d25abc1 100644 --- a/chrome/browser/automation/automation_tab_helper_unittest.cc +++ b/chrome/browser/automation/automation_tab_helper_unittest.cc @@ -41,7 +41,7 @@ class AutomationTabHelperTest : public TabContentsWrapperTestHarness { } void TabContentsDestroyed() { - tab_helper()->TabContentsDestroyed(contents_wrapper()->tab_contents()); + tab_helper()->WebContentsDestroyed(contents_wrapper()->tab_contents()); } void WillPerformClientRedirect(int64 frame_id) { diff --git a/chrome/browser/automation/mock_tab_event_observer.h b/chrome/browser/automation/mock_tab_event_observer.h index d0400e6..2e6a0a2 100644 --- a/chrome/browser/automation/mock_tab_event_observer.h +++ b/chrome/browser/automation/mock_tab_event_observer.h @@ -20,8 +20,8 @@ class MockTabEventObserver : public TabEventObserver { void StartObserving(AutomationTabHelper* tab_helper); void StopObserving(AutomationTabHelper* tab_helper); - MOCK_METHOD1(OnFirstPendingLoad, void(TabContents* tab_contents)); - MOCK_METHOD1(OnNoMorePendingLoads, void(TabContents* tab_contents)); + MOCK_METHOD1(OnFirstPendingLoad, void(content::WebContents* tab_contents)); + MOCK_METHOD1(OnNoMorePendingLoads, void(content::WebContents* tab_contents)); private: DISALLOW_COPY_AND_ASSIGN(MockTabEventObserver); diff --git a/chrome/browser/chrome_plugin_message_filter.cc b/chrome/browser/chrome_plugin_message_filter.cc index 9d9677b..8d68825 100644 --- a/chrome/browser/chrome_plugin_message_filter.cc +++ b/chrome/browser/chrome_plugin_message_filter.cc @@ -13,6 +13,7 @@ #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" #include "chrome/common/chrome_plugin_messages.h" #include "content/browser/plugin_process_host.h" +#include "content/browser/tab_contents/tab_contents.h" #include "content/browser/renderer_host/render_view_host.h" #include "content/browser/renderer_host/render_view_host_delegate.h" #include "content/public/browser/browser_thread.h" diff --git a/chrome/browser/chrome_quota_permission_context.cc b/chrome/browser/chrome_quota_permission_context.cc index 1317da3..0d7e818 100644 --- a/chrome/browser/chrome_quota_permission_context.cc +++ b/chrome/browser/chrome_quota_permission_context.cc @@ -15,6 +15,7 @@ #include "chrome/browser/tab_contents/tab_util.h" #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" #include "chrome/common/pref_names.h" +#include "content/browser/tab_contents/tab_contents.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/navigation_details.h" #include "googleurl/src/gurl.h" diff --git a/chrome/browser/download/download_request_limiter_observer.cc b/chrome/browser/download/download_request_limiter_observer.cc index 1242282..661b466 100644 --- a/chrome/browser/download/download_request_limiter_observer.cc +++ b/chrome/browser/download/download_request_limiter_observer.cc @@ -7,9 +7,11 @@ #include "chrome/browser/browser_process.h" #include "chrome/browser/download/download_request_limiter.h" +using content::WebContents; + DownloadRequestLimiterObserver::DownloadRequestLimiterObserver( - TabContents* tab_contents) - : content::WebContentsObserver(tab_contents) { + WebContents* web_contents) + : content::WebContentsObserver(web_contents) { } DownloadRequestLimiterObserver::~DownloadRequestLimiterObserver() { diff --git a/chrome/browser/download/download_request_limiter_observer.h b/chrome/browser/download/download_request_limiter_observer.h index 004c1c3..b0fa595 100644 --- a/chrome/browser/download/download_request_limiter_observer.h +++ b/chrome/browser/download/download_request_limiter_observer.h @@ -10,7 +10,7 @@ // Watches for user gesture notifications. class DownloadRequestLimiterObserver : public content::WebContentsObserver { public: - explicit DownloadRequestLimiterObserver(TabContents* tab_contents); + explicit DownloadRequestLimiterObserver(content::WebContents* web_contents); virtual ~DownloadRequestLimiterObserver(); // content::WebContentsObserver overrides. diff --git a/chrome/browser/extensions/extension_context_menu_model.cc b/chrome/browser/extensions/extension_context_menu_model.cc index 4bdf618..2ceb38e 100644 --- a/chrome/browser/extensions/extension_context_menu_model.cc +++ b/chrome/browser/extensions/extension_context_menu_model.cc @@ -15,6 +15,7 @@ #include "chrome/common/extensions/extension_constants.h" #include "chrome/common/pref_names.h" #include "chrome/common/url_constants.h" +#include "content/browser/tab_contents/tab_contents.h" #include "grit/chromium_strings.h" #include "grit/generated_resources.h" #include "ui/base/l10n/l10n_util.h" diff --git a/chrome/browser/extensions/extension_cookies_helpers.cc b/chrome/browser/extensions/extension_cookies_helpers.cc index ed3ac61..296ddbd 100644 --- a/chrome/browser/extensions/extension_cookies_helpers.cc +++ b/chrome/browser/extensions/extension_cookies_helpers.cc @@ -18,6 +18,7 @@ #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" #include "chrome/common/extensions/extension.h" #include "chrome/common/url_constants.h" +#include "content/browser/tab_contents/tab_contents.h" #include "googleurl/src/gurl.h" #include "net/base/cookie_util.h" diff --git a/chrome/browser/extensions/extension_tab_id_map.cc b/chrome/browser/extensions/extension_tab_id_map.cc index 1926aab..cd70e74 100644 --- a/chrome/browser/extensions/extension_tab_id_map.cc +++ b/chrome/browser/extensions/extension_tab_id_map.cc @@ -20,6 +20,7 @@ #include "content/public/browser/notification_types.h" using content::BrowserThread; +using content::WebContents; // // ExtensionTabIdMap::TabObserver @@ -98,12 +99,12 @@ void ExtensionTabIdMap::TabObserver::Observe( case chrome::NOTIFICATION_RETARGETING: { RetargetingDetails* retargeting_details = content::Details<RetargetingDetails>(details).ptr(); - TabContents* contents = retargeting_details->target_tab_contents; + WebContents* contents = retargeting_details->target_web_contents; TabContentsWrapper* tab = TabContentsWrapper::GetCurrentWrapperForContents(contents); if (!tab) break; - RenderViewHost* host = tab->tab_contents()->GetRenderViewHost(); + RenderViewHost* host = contents->GetRenderViewHost(); BrowserThread::PostTask( BrowserThread::IO, FROM_HERE, base::Bind( diff --git a/chrome/browser/extensions/extension_tab_util.cc b/chrome/browser/extensions/extension_tab_util.cc index 4c1f7cb..4ab20a64 100644 --- a/chrome/browser/extensions/extension_tab_util.cc +++ b/chrome/browser/extensions/extension_tab_util.cc @@ -16,6 +16,8 @@ namespace keys = extension_tabs_module_constants; namespace errors = extension_manifest_errors; +using content::WebContents; + int ExtensionTabUtil::GetWindowId(const Browser* browser) { return browser->session_id().id(); } @@ -31,9 +33,9 @@ int ExtensionTabUtil::GetWindowIdOfTabStripModel( } // TODO(sky): this function should really take a TabContentsWrapper. -int ExtensionTabUtil::GetTabId(const TabContents* tab_contents) { +int ExtensionTabUtil::GetTabId(const WebContents* web_contents) { const TabContentsWrapper* tab = - TabContentsWrapper::GetCurrentWrapperForContents(tab_contents); + TabContentsWrapper::GetCurrentWrapperForContents(web_contents); return tab ? tab->restore_tab_helper()->session_id().id() : -1; } diff --git a/chrome/browser/extensions/extension_tab_util.h b/chrome/browser/extensions/extension_tab_util.h index 5638cbd..385f6ad 100644 --- a/chrome/browser/extensions/extension_tab_util.h +++ b/chrome/browser/extensions/extension_tab_util.h @@ -19,12 +19,16 @@ class DictionaryValue; class ListValue; } +namespace content { +class WebContents; +} + // Provides various utility functions that help manipulate tabs. class ExtensionTabUtil { public: static int GetWindowId(const Browser* browser); static int GetWindowIdOfTabStripModel(const TabStripModel* tab_strip_model); - static int GetTabId(const TabContents* tab_contents); + static int GetTabId(const content::WebContents* web_contents); static bool GetTabIdFromArgument(const base::ListValue &args, int argument_index, int *tab_id, std::string* error_message); diff --git a/chrome/browser/extensions/extension_webnavigation_api.cc b/chrome/browser/extensions/extension_webnavigation_api.cc index 4644376..eb647e3 100644 --- a/chrome/browser/extensions/extension_webnavigation_api.cc +++ b/chrome/browser/extensions/extension_webnavigation_api.cc @@ -19,6 +19,7 @@ #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" #include "chrome/common/chrome_notification_types.h" #include "chrome/common/url_constants.h" +#include "content/browser/renderer_host/render_view_host.h" #include "content/browser/tab_contents/tab_contents.h" #include "content/public/browser/navigation_details.h" #include "content/public/browser/notification_service.h" @@ -27,9 +28,12 @@ namespace keys = extension_webnavigation_api_constants; +using content::BrowserContext; +using content::WebContents; + namespace { -typedef std::map<TabContents*, ExtensionWebNavigationTabObserver*> +typedef std::map<WebContents*, ExtensionWebNavigationTabObserver*> TabObserverMap; static base::LazyInstance<TabObserverMap> g_tab_observer = LAZY_INSTANCE_INITIALIZER; @@ -59,7 +63,7 @@ double MilliSecondsFromTime(const base::Time& time) { } // Dispatches events to the extension message service. -void DispatchEvent(content::BrowserContext* browser_context, +void DispatchEvent(BrowserContext* browser_context, const char* event_name, const std::string& json_args) { Profile* profile = Profile::FromBrowserContext(browser_context); @@ -70,14 +74,13 @@ void DispatchEvent(content::BrowserContext* browser_context, } // Constructs and dispatches an onBeforeNavigate event. -void DispatchOnBeforeNavigate(TabContents* tab_contents, +void DispatchOnBeforeNavigate(WebContents* web_contents, int64 frame_id, bool is_main_frame, const GURL& validated_url) { ListValue args; DictionaryValue* dict = new DictionaryValue(); - dict->SetInteger(keys::kTabIdKey, - ExtensionTabUtil::GetTabId(tab_contents)); + dict->SetInteger(keys::kTabIdKey, ExtensionTabUtil::GetTabId(web_contents)); dict->SetString(keys::kUrlKey, validated_url.spec()); dict->SetInteger(keys::kFrameIdKey, GetFrameId(is_main_frame, frame_id)); dict->SetDouble(keys::kTimeStampKey, MilliSecondsFromTime(base::Time::Now())); @@ -85,7 +88,7 @@ void DispatchOnBeforeNavigate(TabContents* tab_contents, std::string json_args; base::JSONWriter::Write(&args, false, &json_args); - DispatchEvent(tab_contents->GetBrowserContext(), + DispatchEvent(web_contents->GetBrowserContext(), keys::kOnBeforeNavigate, json_args); } @@ -93,15 +96,14 @@ void DispatchOnBeforeNavigate(TabContents* tab_contents, // Constructs and dispatches an onCommitted or onReferenceFragmentUpdated // event. void DispatchOnCommitted(const char* event_name, - TabContents* tab_contents, + WebContents* web_contents, int64 frame_id, bool is_main_frame, const GURL& url, content::PageTransition transition_type) { ListValue args; DictionaryValue* dict = new DictionaryValue(); - dict->SetInteger(keys::kTabIdKey, - ExtensionTabUtil::GetTabId(tab_contents)); + dict->SetInteger(keys::kTabIdKey, ExtensionTabUtil::GetTabId(web_contents)); dict->SetString(keys::kUrlKey, url.spec()); dict->SetInteger(keys::kFrameIdKey, GetFrameId(is_main_frame, frame_id)); dict->SetString( @@ -122,18 +124,18 @@ void DispatchOnCommitted(const char* event_name, std::string json_args; base::JSONWriter::Write(&args, false, &json_args); - DispatchEvent(tab_contents->GetBrowserContext(), event_name, json_args); + DispatchEvent(web_contents->GetBrowserContext(), event_name, json_args); } // Constructs and dispatches an onDOMContentLoaded event. -void DispatchOnDOMContentLoaded(TabContents* tab_contents, +void DispatchOnDOMContentLoaded(WebContents* web_contents, const GURL& url, bool is_main_frame, int64 frame_id) { ListValue args; DictionaryValue* dict = new DictionaryValue(); dict->SetInteger(keys::kTabIdKey, - ExtensionTabUtil::GetTabId(tab_contents)); + ExtensionTabUtil::GetTabId(web_contents)); dict->SetString(keys::kUrlKey, url.spec()); dict->SetInteger(keys::kFrameIdKey, GetFrameId(is_main_frame, frame_id)); dict->SetDouble(keys::kTimeStampKey, MilliSecondsFromTime(base::Time::Now())); @@ -141,20 +143,20 @@ void DispatchOnDOMContentLoaded(TabContents* tab_contents, std::string json_args; base::JSONWriter::Write(&args, false, &json_args); - DispatchEvent(tab_contents->GetBrowserContext(), + DispatchEvent(web_contents->GetBrowserContext(), keys::kOnDOMContentLoaded, json_args); } // Constructs and dispatches an onCompleted event. -void DispatchOnCompleted(TabContents* tab_contents, +void DispatchOnCompleted(WebContents* web_contents, const GURL& url, bool is_main_frame, int64 frame_id) { ListValue args; DictionaryValue* dict = new DictionaryValue(); dict->SetInteger(keys::kTabIdKey, - ExtensionTabUtil::GetTabId(tab_contents)); + ExtensionTabUtil::GetTabId(web_contents)); dict->SetString(keys::kUrlKey, url.spec()); dict->SetInteger(keys::kFrameIdKey, GetFrameId(is_main_frame, frame_id)); dict->SetDouble(keys::kTimeStampKey, MilliSecondsFromTime(base::Time::Now())); @@ -162,34 +164,34 @@ void DispatchOnCompleted(TabContents* tab_contents, std::string json_args; base::JSONWriter::Write(&args, false, &json_args); - DispatchEvent(tab_contents->GetBrowserContext(), + DispatchEvent(web_contents->GetBrowserContext(), keys::kOnCompleted, json_args); } // Constructs and dispatches an onCreatedNavigationTarget event. void DispatchOnCreatedNavigationTarget( - TabContents* tab_contents, - content::BrowserContext* browser_context, + WebContents* web_contents, + BrowserContext* browser_context, int64 source_frame_id, bool source_frame_is_main_frame, - TabContents* target_tab_contents, + WebContents* target_web_contents, const GURL& target_url) { // Check that the tab is already inserted into a tab strip model. This code // path is exercised by ExtensionApiTest.WebNavigationRequestOpenTab. DCHECK(ExtensionTabUtil::GetTabById( - ExtensionTabUtil::GetTabId(target_tab_contents), - Profile::FromBrowserContext(target_tab_contents->GetBrowserContext()), + ExtensionTabUtil::GetTabId(target_web_contents), + Profile::FromBrowserContext(target_web_contents->GetBrowserContext()), false, NULL, NULL, NULL, NULL)); ListValue args; DictionaryValue* dict = new DictionaryValue(); dict->SetInteger(keys::kSourceTabIdKey, - ExtensionTabUtil::GetTabId(tab_contents)); + ExtensionTabUtil::GetTabId(web_contents)); dict->SetInteger(keys::kSourceFrameIdKey, GetFrameId(source_frame_is_main_frame, source_frame_id)); dict->SetString(keys::kUrlKey, target_url.possibly_invalid_spec()); dict->SetInteger(keys::kTabIdKey, - ExtensionTabUtil::GetTabId(target_tab_contents)); + ExtensionTabUtil::GetTabId(target_web_contents)); dict->SetDouble(keys::kTimeStampKey, MilliSecondsFromTime(base::Time::Now())); args.Append(dict); @@ -200,15 +202,14 @@ void DispatchOnCreatedNavigationTarget( } // Constructs and dispatches an onErrorOccurred event. -void DispatchOnErrorOccurred(TabContents* tab_contents, +void DispatchOnErrorOccurred(WebContents* web_contents, const GURL& url, int64 frame_id, bool is_main_frame, int error_code) { ListValue args; DictionaryValue* dict = new DictionaryValue(); - dict->SetInteger(keys::kTabIdKey, - ExtensionTabUtil::GetTabId(tab_contents)); + dict->SetInteger(keys::kTabIdKey, ExtensionTabUtil::GetTabId(web_contents)); dict->SetString(keys::kUrlKey, url.spec()); dict->SetInteger(keys::kFrameIdKey, GetFrameId(is_main_frame, frame_id)); dict->SetString(keys::kErrorKey, net::ErrorToString(error_code)); @@ -217,7 +218,7 @@ void DispatchOnErrorOccurred(TabContents* tab_contents, std::string json_args; base::JSONWriter::Write(&args, false, &json_args); - DispatchEvent(tab_contents->GetBrowserContext(), + DispatchEvent(web_contents->GetBrowserContext(), keys::kOnErrorOccurred, json_args); } @@ -342,28 +343,28 @@ bool FrameNavigationState::GetNavigationCommitted(int64 frame_id) const { // ExtensionWebNavigtionEventRouter ------------------------------------------- -ExtensionWebNavigationEventRouter::PendingTabContents::PendingTabContents() - : source_tab_contents(NULL), +ExtensionWebNavigationEventRouter::PendingWebContents::PendingWebContents() + : source_web_contents(NULL), source_frame_id(0), source_frame_is_main_frame(false), - target_tab_contents(NULL), + target_web_contents(NULL), target_url() { } -ExtensionWebNavigationEventRouter::PendingTabContents::PendingTabContents( - TabContents* source_tab_contents, +ExtensionWebNavigationEventRouter::PendingWebContents::PendingWebContents( + WebContents* source_web_contents, int64 source_frame_id, bool source_frame_is_main_frame, - TabContents* target_tab_contents, + WebContents* target_web_contents, const GURL& target_url) - : source_tab_contents(source_tab_contents), + : source_web_contents(source_web_contents), source_frame_id(source_frame_id), source_frame_is_main_frame(source_frame_is_main_frame), - target_tab_contents(target_tab_contents), + target_web_contents(target_web_contents), target_url(target_url) { } -ExtensionWebNavigationEventRouter::PendingTabContents::~PendingTabContents() {} +ExtensionWebNavigationEventRouter::PendingWebContents::~PendingWebContents() {} ExtensionWebNavigationEventRouter::ExtensionWebNavigationEventRouter( Profile* profile) : profile_(profile) {} @@ -412,10 +413,10 @@ void ExtensionWebNavigationEventRouter::Retargeting( if (details->source_frame_id == 0) return; ExtensionWebNavigationTabObserver* tab_observer = - ExtensionWebNavigationTabObserver::Get(details->source_tab_contents); + ExtensionWebNavigationTabObserver::Get(details->source_web_contents); if (!tab_observer) { - CHECK(details->source_tab_contents->GetRenderViewType() != - content::VIEW_TYPE_TAB_CONTENTS); + CHECK(details->source_web_contents->GetRenderViewHost()->delegate()-> + GetRenderViewType() != content::VIEW_TYPE_TAB_CONTENTS); return; } const FrameNavigationState& frame_navigation_state = @@ -424,54 +425,53 @@ void ExtensionWebNavigationEventRouter::Retargeting( if (!frame_navigation_state.CanSendEvents(details->source_frame_id)) return; - // If the TabContents was created as a response to an IPC from a renderer + // If the WebContents was created as a response to an IPC from a renderer // (and therefore doesn't yet have a wrapper), or if it isn't yet inserted // into a tab strip, we need to delay the extension event until the - // TabContents is fully initialized. + // WebContents is fully initialized. if ((TabContentsWrapper::GetCurrentWrapperForContents( - details->target_tab_contents) == NULL) || + details->target_web_contents) == NULL) || details->not_yet_in_tabstrip) { - pending_tab_contents_[details->target_tab_contents] = - PendingTabContents( - details->source_tab_contents, + pending_web_contents_[details->target_web_contents] = + PendingWebContents( + details->source_web_contents, details->source_frame_id, frame_navigation_state.IsMainFrame(details->source_frame_id), - details->target_tab_contents, + details->target_web_contents, details->target_url); } else { DispatchOnCreatedNavigationTarget( - details->source_tab_contents, - details->target_tab_contents->GetBrowserContext(), + details->source_web_contents, + details->target_web_contents->GetBrowserContext(), details->source_frame_id, frame_navigation_state.IsMainFrame(details->source_frame_id), - details->target_tab_contents, + details->target_web_contents, details->target_url); } } -void ExtensionWebNavigationEventRouter::TabAdded(TabContents* tab_contents) { - std::map<TabContents*, PendingTabContents>::iterator iter = - pending_tab_contents_.find(tab_contents); - if (iter == pending_tab_contents_.end()) +void ExtensionWebNavigationEventRouter::TabAdded(WebContents* tab) { + std::map<WebContents*, PendingWebContents>::iterator iter = + pending_web_contents_.find(tab); + if (iter == pending_web_contents_.end()) return; DispatchOnCreatedNavigationTarget( - iter->second.source_tab_contents, - iter->second.target_tab_contents->GetBrowserContext(), + iter->second.source_web_contents, + iter->second.target_web_contents->GetBrowserContext(), iter->second.source_frame_id, iter->second.source_frame_is_main_frame, - iter->second.target_tab_contents, + iter->second.target_web_contents, iter->second.target_url); - pending_tab_contents_.erase(iter); + pending_web_contents_.erase(iter); } -void ExtensionWebNavigationEventRouter::TabDestroyed( - TabContents* tab_contents) { - pending_tab_contents_.erase(tab_contents); - for (std::map<TabContents*, PendingTabContents>::iterator i = - pending_tab_contents_.begin(); i != pending_tab_contents_.end(); ) { - if (i->second.source_tab_contents == tab_contents) - pending_tab_contents_.erase(i++); +void ExtensionWebNavigationEventRouter::TabDestroyed(WebContents* tab) { + pending_web_contents_.erase(tab); + for (std::map<WebContents*, PendingWebContents>::iterator i = + pending_web_contents_.begin(); i != pending_web_contents_.end(); ) { + if (i->second.source_web_contents == tab) + pending_web_contents_.erase(i++); else ++i; } @@ -480,17 +480,17 @@ void ExtensionWebNavigationEventRouter::TabDestroyed( // ExtensionWebNavigationTabObserver ------------------------------------------ ExtensionWebNavigationTabObserver::ExtensionWebNavigationTabObserver( - TabContents* tab_contents) - : content::WebContentsObserver(tab_contents) { - g_tab_observer.Get().insert(TabObserverMap::value_type(tab_contents, this)); + WebContents* web_contents) + : WebContentsObserver(web_contents) { + g_tab_observer.Get().insert(TabObserverMap::value_type(web_contents, this)); } ExtensionWebNavigationTabObserver::~ExtensionWebNavigationTabObserver() {} // static ExtensionWebNavigationTabObserver* ExtensionWebNavigationTabObserver::Get( - TabContents* tab_contents) { - TabObserverMap::iterator i = g_tab_observer.Get().find(tab_contents); + WebContents* web_contents) { + TabObserverMap::iterator i = g_tab_observer.Get().find(web_contents); return i == g_tab_observer.Get().end() ? NULL : i->second; } @@ -598,7 +598,7 @@ void ExtensionWebNavigationTabObserver::DidFinishLoad( } void ExtensionWebNavigationTabObserver::DidOpenRequestedURL( - TabContents* new_contents, + WebContents* new_contents, const GURL& url, const content::Referrer& referrer, WindowOpenDisposition disposition, @@ -626,8 +626,7 @@ void ExtensionWebNavigationTabObserver::DidOpenRequestedURL( url); } -void ExtensionWebNavigationTabObserver::TabContentsDestroyed( - TabContents* tab) { +void ExtensionWebNavigationTabObserver::WebContentsDestroyed(WebContents* tab) { g_tab_observer.Get().erase(tab); for (FrameNavigationState::const_iterator frame = navigation_state_.begin(); frame != navigation_state_.end(); ++frame) { diff --git a/chrome/browser/extensions/extension_webnavigation_api.h b/chrome/browser/extensions/extension_webnavigation_api.h index 43953c5..9d184f1 100644 --- a/chrome/browser/extensions/extension_webnavigation_api.h +++ b/chrome/browser/extensions/extension_webnavigation_api.h @@ -21,7 +21,6 @@ #include "googleurl/src/gurl.h" struct RetargetingDetails; -class TabContents; // Tracks the navigation state of all frames in a given tab currently known to // the webNavigation API. It is mainly used to track in which frames an error @@ -117,11 +116,13 @@ class FrameNavigationState { // Tab contents observer that forwards navigation events to the event router. class ExtensionWebNavigationTabObserver : public content::WebContentsObserver { public: - explicit ExtensionWebNavigationTabObserver(TabContents* tab_contents); + explicit ExtensionWebNavigationTabObserver( + content::WebContents* web_contents); virtual ~ExtensionWebNavigationTabObserver(); // Returns the object for the given |tab_contents|. - static ExtensionWebNavigationTabObserver* Get(TabContents* tab_contents); + static ExtensionWebNavigationTabObserver* Get( + content::WebContents* web_contents); const FrameNavigationState& frame_navigation_state() const { return navigation_state_; @@ -149,13 +150,13 @@ class ExtensionWebNavigationTabObserver : public content::WebContentsObserver { virtual void DidFinishLoad(int64 frame_id, const GURL& validated_url, bool is_main_frame) OVERRIDE; - virtual void DidOpenRequestedURL(TabContents* new_contents, + virtual void DidOpenRequestedURL(content::WebContents* new_contents, const GURL& url, const content::Referrer& referrer, WindowOpenDisposition disposition, content::PageTransition transition, int64 source_frame_id) OVERRIDE; - virtual void TabContentsDestroyed(TabContents* tab) OVERRIDE; + virtual void WebContentsDestroyed(content::WebContents* tab) OVERRIDE; private: // True if the transition and target url correspond to a reference fragment @@ -180,20 +181,20 @@ class ExtensionWebNavigationEventRouter : public content::NotificationObserver { void Init(); private: - // Used to cache the information about newly created TabContents objects. - struct PendingTabContents { - PendingTabContents(); - PendingTabContents(TabContents* source_tab_contents, + // Used to cache the information about newly created WebContents objects. + struct PendingWebContents{ + PendingWebContents(); + PendingWebContents(content::WebContents* source_web_contents, int64 source_frame_id, bool source_frame_is_main_frame, - TabContents* target_tab_contents, + content::WebContents* target_web_contents, const GURL& target_url); - ~PendingTabContents(); + ~PendingWebContents(); - TabContents* source_tab_contents; + content::WebContents* source_web_contents; int64 source_frame_id; bool source_frame_is_main_frame; - TabContents* target_tab_contents; + content::WebContents* target_web_contents; GURL target_url; }; @@ -209,15 +210,15 @@ class ExtensionWebNavigationEventRouter : public content::NotificationObserver { // Handler for the NOTIFICATION_TAB_ADDED event. The method takes the details // of such an event and creates a JSON formated extension event from it. - void TabAdded(TabContents* tab_contents); + void TabAdded(content::WebContents* tab); - // Handler for NOTIFICATION_TAB_CONTENTS_DESTROYED. If |tab_contents| is - // in |pending_tab_contents_|, it is removed. - void TabDestroyed(TabContents* tab_contents); + // Handler for NOTIFICATION_TAB_CONTENTS_DESTROYED. If |tab| is in + // |pending_web_contents_|, it is removed. + void TabDestroyed(content::WebContents* tab); - // Mapping pointers to TabContents objects to information about how they got + // Mapping pointers to WebContents objects to information about how they got // created. - std::map<TabContents*, PendingTabContents> pending_tab_contents_; + std::map<content::WebContents*, PendingWebContents> pending_web_contents_; // Used for tracking registrations to navigation notifications. content::NotificationRegistrar registrar_; diff --git a/chrome/browser/extensions/webstore_inline_installer.cc b/chrome/browser/extensions/webstore_inline_installer.cc index 5fdc9ab..b58a652 100644 --- a/chrome/browser/extensions/webstore_inline_installer.cc +++ b/chrome/browser/extensions/webstore_inline_installer.cc @@ -26,6 +26,7 @@ #include "net/url_request/url_request_status.h" using content::BrowserThread; +using content::WebContents; const char kManifestKey[] = "manifest"; const char kIconUrlKey[] = "icon_url"; @@ -144,12 +145,12 @@ class SafeWebstoreResponseParser : public UtilityProcessHost::Client { scoped_ptr<DictionaryValue> parsed_webstore_data_; }; -WebstoreInlineInstaller::WebstoreInlineInstaller(TabContents* tab_contents, +WebstoreInlineInstaller::WebstoreInlineInstaller(WebContents* web_contents, int install_id, std::string webstore_item_id, GURL requestor_url, Delegate* delegate) - : content::WebContentsObserver(tab_contents), + : content::WebContentsObserver(web_contents), install_id_(install_id), id_(webstore_item_id), requestor_url_(requestor_url), @@ -161,7 +162,7 @@ WebstoreInlineInstaller::~WebstoreInlineInstaller() { } void WebstoreInlineInstaller::BeginInstall() { - AddRef(); // Balanced in CompleteInstall or TabContentsDestroyed. + AddRef(); // Balanced in CompleteInstall or WebContentsDestroyed. if (!Extension::IdIsValid(id_)) { CompleteInstall(kInvalidWebstoreItemId); @@ -189,8 +190,8 @@ void WebstoreInlineInstaller::BeginInstall() { void WebstoreInlineInstaller::OnURLFetchComplete( const content::URLFetcher* source) { CHECK_EQ(webstore_data_url_fetcher_.get(), source); - // We shouldn't be getting UrlFetcher callbacks if the TabContents has gone - // away; we stop any in in-progress fetches in TabContentsDestroyed. + // We shouldn't be getting UrlFetcher callbacks if the WebContents has gone + // away; we stop any in in-progress fetches in WebContentsDestroyed. CHECK(tab_contents()); if (!webstore_data_url_fetcher_->GetStatus().is_success() || @@ -403,7 +404,7 @@ void WebstoreInlineInstaller::InstallUIAbort(bool user_initiated) { CompleteInstall(kUserCancelledError); } -void WebstoreInlineInstaller::TabContentsDestroyed(TabContents* tab_contents) { +void WebstoreInlineInstaller::WebContentsDestroyed(WebContents* web_contents) { // Abort any in-progress fetches. if (webstore_data_url_fetcher_.get()) { webstore_data_url_fetcher_.reset(); diff --git a/chrome/browser/extensions/webstore_inline_installer.h b/chrome/browser/extensions/webstore_inline_installer.h index c7c0595..96aedfb 100644 --- a/chrome/browser/extensions/webstore_inline_installer.h +++ b/chrome/browser/extensions/webstore_inline_installer.h @@ -19,14 +19,13 @@ #include "googleurl/src/gurl.h" #include "third_party/skia/include/core/SkBitmap.h" -class TabContents; class SafeWebstoreResponseParser; // Manages inline installs requested by a page (downloads and parses metadata // from the webstore, shows the install UI, starts the download once the user // confirms). Clients must implement the WebstoreInlineInstaller::Delegate // interface to be notified when the inline install completes (successfully or -// not). The client will not be notified if the TabContents that this install +// not). The client will not be notified if the WebContents that this install // request is attached to goes away. class WebstoreInlineInstaller : public base::RefCountedThreadSafe<WebstoreInlineInstaller>, @@ -43,7 +42,7 @@ class WebstoreInlineInstaller const std::string& error) = 0; }; - WebstoreInlineInstaller(TabContents* tab_contents, + WebstoreInlineInstaller(content::WebContents* web_contents, int install_id, std::string webstore_item_id, GURL requestor_url, @@ -91,7 +90,8 @@ class WebstoreInlineInstaller virtual void InstallUIAbort(bool user_initiated) OVERRIDE; // content::WebContentsObserver interface implementation. - virtual void TabContentsDestroyed(TabContents* tab_contents) OVERRIDE; + virtual void WebContentsDestroyed( + content::WebContents* web_contents) OVERRIDE; // WebstoreInstaller::Delegate interface implementation. virtual void OnExtensionInstallSuccess(const std::string& id) OVERRIDE; diff --git a/chrome/browser/geolocation/chrome_geolocation_permission_context.cc b/chrome/browser/geolocation/chrome_geolocation_permission_context.cc index e4d4eee..bac8016 100644 --- a/chrome/browser/geolocation/chrome_geolocation_permission_context.cc +++ b/chrome/browser/geolocation/chrome_geolocation_permission_context.cc @@ -576,7 +576,8 @@ void ChromeGeolocationPermissionContext::RequestGeolocationPermission( TabContents* tab_contents = tab_util::GetTabContentsByID(render_process_id, render_view_id); if (!tab_contents || - tab_contents->GetRenderViewType() != content::VIEW_TYPE_TAB_CONTENTS) { + tab_contents->GetRenderViewHost()->delegate()->GetRenderViewType() != + content::VIEW_TYPE_TAB_CONTENTS) { // The tab may have gone away, or the request may not be from a tab at all. // TODO(mpcomplete): the request could be from a background page or // extension popup (tab_contents will have a different ViewType). But why do diff --git a/chrome/browser/notifications/desktop_notification_service.cc b/chrome/browser/notifications/desktop_notification_service.cc index 1207ea8..7f3a52d 100644 --- a/chrome/browser/notifications/desktop_notification_service.cc +++ b/chrome/browser/notifications/desktop_notification_service.cc @@ -31,6 +31,7 @@ #include "content/browser/browser_child_process_host.h" #include "content/browser/renderer_host/render_view_host.h" #include "content/browser/site_instance.h" +#include "content/browser/tab_contents/tab_contents.h" #include "content/browser/worker_host/worker_process_host.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/notification_service.h" diff --git a/chrome/browser/password_manager/password_manager.cc b/chrome/browser/password_manager/password_manager.cc index 8eaf155..3964d2e 100644 --- a/chrome/browser/password_manager/password_manager.cc +++ b/chrome/browser/password_manager/password_manager.cc @@ -20,6 +20,7 @@ #include "grit/generated_resources.h" using content::UserMetricsAction; +using content::WebContents; using webkit::forms::PasswordForm; using webkit::forms::PasswordFormMap; @@ -55,9 +56,9 @@ static void ReportMetrics(bool password_manager_enabled) { content::RecordAction(UserMetricsAction("PasswordManager_Disabled")); } -PasswordManager::PasswordManager(TabContents* tab_contents, +PasswordManager::PasswordManager(WebContents* web_contents, PasswordManagerDelegate* delegate) - : content::WebContentsObserver(tab_contents), + : content::WebContentsObserver(web_contents), login_managers_deleter_(&pending_login_managers_), delegate_(delegate), observer_(NULL) { diff --git a/chrome/browser/password_manager/password_manager.h b/chrome/browser/password_manager/password_manager.h index aac2129..0552893 100644 --- a/chrome/browser/password_manager/password_manager.h +++ b/chrome/browser/password_manager/password_manager.h @@ -30,7 +30,7 @@ class PasswordManager : public LoginModel, static void RegisterUserPrefs(PrefService* prefs); // The delegate passed in is required to outlive the PasswordManager. - PasswordManager(TabContents* tab_contents, + PasswordManager(content::WebContents* web_contents, PasswordManagerDelegate* delegate); virtual ~PasswordManager(); diff --git a/chrome/browser/printing/print_preview_tab_controller_browsertest.cc b/chrome/browser/printing/print_preview_tab_controller_browsertest.cc index 6dd22cbe..7ded4fa 100644 --- a/chrome/browser/printing/print_preview_tab_controller_browsertest.cc +++ b/chrome/browser/printing/print_preview_tab_controller_browsertest.cc @@ -18,6 +18,8 @@ #include "content/public/browser/web_contents_observer.h" #include "googleurl/src/gurl.h" +using content::WebContents; + namespace { class PrintPreviewTabControllerBrowserTest : public InProcessBrowserTest { @@ -41,7 +43,7 @@ class TabDestroyedObserver : public content::WebContentsObserver { bool tab_destroyed() { return tab_destroyed_; } private: - virtual void TabContentsDestroyed(TabContents* tab) { + virtual void WebContentsDestroyed(WebContents* tab) OVERRIDE { tab_destroyed_ = true; } diff --git a/chrome/browser/safe_browsing/client_side_detection_host.cc b/chrome/browser/safe_browsing/client_side_detection_host.cc index d4a7721..c8e8289 100644 --- a/chrome/browser/safe_browsing/client_side_detection_host.cc +++ b/chrome/browser/safe_browsing/client_side_detection_host.cc @@ -36,6 +36,7 @@ #include "googleurl/src/gurl.h" using content::BrowserThread; +using content::WebContents; namespace safe_browsing { @@ -357,7 +358,7 @@ void ClientSideDetectionHost::OnSafeBrowsingHit( } } -void ClientSideDetectionHost::TabContentsDestroyed(TabContents* tab) { +void ClientSideDetectionHost::WebContentsDestroyed(WebContents* tab) { DCHECK(tab); // Tell any pending classification request that it is being canceled. if (classification_request_.get()) { diff --git a/chrome/browser/safe_browsing/client_side_detection_host.h b/chrome/browser/safe_browsing/client_side_detection_host.h index ad769b7..6943732 100644 --- a/chrome/browser/safe_browsing/client_side_detection_host.h +++ b/chrome/browser/safe_browsing/client_side_detection_host.h @@ -55,7 +55,7 @@ class ClientSideDetectionHost : public content::WebContentsObserver, protected: // From content::WebContentsObserver. - virtual void TabContentsDestroyed(TabContents* tab) OVERRIDE; + virtual void WebContentsDestroyed(content::WebContents* tab) OVERRIDE; private: friend class ClientSideDetectionHostTest; diff --git a/chrome/browser/ssl/ssl_add_cert_handler.cc b/chrome/browser/ssl/ssl_add_cert_handler.cc index 36bcf31..6bdfbaf 100644 --- a/chrome/browser/ssl/ssl_add_cert_handler.cc +++ b/chrome/browser/ssl/ssl_add_cert_handler.cc @@ -10,6 +10,7 @@ #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" #include "content/browser/renderer_host/resource_dispatcher_host.h" #include "content/browser/renderer_host/resource_dispatcher_host_request_info.h" +#include "content/browser/tab_contents/tab_contents.h" #include "content/public/browser/browser_thread.h" #include "net/base/cert_database.h" #include "net/base/net_errors.h" diff --git a/chrome/browser/tab_contents/render_view_context_menu.cc b/chrome/browser/tab_contents/render_view_context_menu.cc index ff50e33..f8ce218 100644 --- a/chrome/browser/tab_contents/render_view_context_menu.cc +++ b/chrome/browser/tab_contents/render_view_context_menu.cc @@ -1834,10 +1834,10 @@ void RenderViewContextMenu::OpenURL( if (new_contents) { RetargetingDetails details; - details.source_tab_contents = source_tab_contents_; + details.source_web_contents = source_tab_contents_; details.source_frame_id = frame_id; details.target_url = url; - details.target_tab_contents = new_contents; + details.target_web_contents = new_contents; details.not_yet_in_tabstrip = false; content::NotificationService::current()->Notify( chrome::NOTIFICATION_RETARGETING, diff --git a/chrome/browser/tab_contents/render_view_host_delegate_helper.cc b/chrome/browser/tab_contents/render_view_host_delegate_helper.cc index 375c0ff..925120d 100644 --- a/chrome/browser/tab_contents/render_view_host_delegate_helper.cc +++ b/chrome/browser/tab_contents/render_view_host_delegate_helper.cc @@ -273,10 +273,10 @@ TabContents* RenderViewHostDelegateViewHelper::CreateNewWindowFromTabContents( tab_contents->GetDelegate()->TabContentsCreated(new_contents); RetargetingDetails details; - details.source_tab_contents = tab_contents; + details.source_web_contents = tab_contents; details.source_frame_id = params.opener_frame_id; details.target_url = params.target_url; - details.target_tab_contents = new_contents; + details.target_web_contents = new_contents; details.not_yet_in_tabstrip = true; content::NotificationService::current()->Notify( chrome::NOTIFICATION_RETARGETING, diff --git a/chrome/browser/tab_contents/retargeting_details.h b/chrome/browser/tab_contents/retargeting_details.h index 988e8ee..f978e0e 100644 --- a/chrome/browser/tab_contents/retargeting_details.h +++ b/chrome/browser/tab_contents/retargeting_details.h @@ -8,12 +8,14 @@ #include "googleurl/src/gurl.h" -class TabContents; +namespace content { +class WebContents; +} // Details sent for NOTIFICATION_RETARGETING. struct RetargetingDetails { // The source tab contents. - TabContents* source_tab_contents; + content::WebContents* source_web_contents; // The frame ID of the source tab from which the retargeting was triggered. int64 source_frame_id; @@ -22,7 +24,7 @@ struct RetargetingDetails { GURL target_url; // The target tab contents. - TabContents* target_tab_contents; + content::WebContents* target_web_contents; // True if the target_tab_contents is not yet inserted into a tab strip. bool not_yet_in_tabstrip; diff --git a/chrome/browser/tabs/tab_finder.cc b/chrome/browser/tabs/tab_finder.cc index f923178..bf09a8d 100644 --- a/chrome/browser/tabs/tab_finder.cc +++ b/chrome/browser/tabs/tab_finder.cc @@ -24,6 +24,8 @@ #include "content/public/common/frame_navigate_params.h" #include "content/public/common/page_transition_types.h" +using content::WebContents; + class TabFinder::WebContentsObserverImpl : public content::WebContentsObserver { public: WebContentsObserverImpl(TabContents* tab, TabFinder* finder); @@ -37,7 +39,7 @@ class TabFinder::WebContentsObserverImpl : public content::WebContentsObserver { virtual void DidNavigateAnyFrame( const content::LoadCommittedDetails& details, const content::FrameNavigateParams& params) OVERRIDE; - virtual void TabContentsDestroyed(TabContents* tab) OVERRIDE; + virtual void WebContentsDestroyed(WebContents* tab) OVERRIDE; private: TabFinder* finder_; @@ -61,8 +63,8 @@ void TabFinder::WebContentsObserverImpl::DidNavigateAnyFrame( finder_->DidNavigateAnyFrame(tab_contents(), details, params); } -void TabFinder::WebContentsObserverImpl::TabContentsDestroyed( - TabContents* tab) { +void TabFinder::WebContentsObserverImpl::WebContentsDestroyed( + WebContents* tab) { finder_->TabDestroyed(this); delete this; } diff --git a/chrome/browser/ui/cocoa/extensions/extension_action_context_menu.mm b/chrome/browser/ui/cocoa/extensions/extension_action_context_menu.mm index e9f9b8b..702da38 100644 --- a/chrome/browser/ui/cocoa/extensions/extension_action_context_menu.mm +++ b/chrome/browser/ui/cocoa/extensions/extension_action_context_menu.mm @@ -26,6 +26,7 @@ #include "chrome/common/extensions/extension_constants.h" #include "chrome/common/pref_names.h" #include "chrome/common/url_constants.h" +#include "content/browser/tab_contents/tab_contents.h" #include "content/public/browser/notification_observer.h" #include "content/public/browser/notification_details.h" #include "content/public/browser/notification_source.h" diff --git a/chrome/browser/ui/cocoa/hung_renderer_controller.mm b/chrome/browser/ui/cocoa/hung_renderer_controller.mm index 681cf09c..7d63db5 100644 --- a/chrome/browser/ui/cocoa/hung_renderer_controller.mm +++ b/chrome/browser/ui/cocoa/hung_renderer_controller.mm @@ -31,6 +31,8 @@ #include "ui/base/resource/resource_bundle.h" #include "ui/gfx/image/image.h" +using content::WebContents; + namespace { // We only support showing one of these at a time per app. The // controller owns itself and is released when its window is closed. @@ -50,7 +52,7 @@ class WebContentsObserverBridge : public content::WebContentsObserver { virtual void RenderViewGone(base::TerminationStatus status) OVERRIDE { [controller_ renderViewGone]; } - virtual void TabContentsDestroyed(TabContents* tab) OVERRIDE { + virtual void WebContentsDestroyed(WebContents* tab) OVERRIDE { [controller_ renderViewGone]; } diff --git a/chrome/browser/ui/constrained_window_tab_helper.cc b/chrome/browser/ui/constrained_window_tab_helper.cc index bab46d5..e384b67 100644 --- a/chrome/browser/ui/constrained_window_tab_helper.cc +++ b/chrome/browser/ui/constrained_window_tab_helper.cc @@ -14,6 +14,8 @@ #include "content/public/browser/navigation_details.h" #include "net/base/registry_controlled_domain.h" +using content::WebContents; + ConstrainedWindowTabHelper::ConstrainedWindowTabHelper( TabContentsWrapper* wrapper) : content::WebContentsObserver(wrapper->tab_contents()), @@ -101,7 +103,7 @@ void ConstrainedWindowTabHelper::DidGetIgnoredUIEvent() { } } -void ConstrainedWindowTabHelper::TabContentsDestroyed(TabContents* tab) { +void ConstrainedWindowTabHelper::WebContentsDestroyed(WebContents* tab) { // First cleanly close all child windows. // TODO(mpcomplete): handle case if MaybeCloseChildWindows() already asked // some of these to close. CloseWindows is async, so it might get called diff --git a/chrome/browser/ui/constrained_window_tab_helper.h b/chrome/browser/ui/constrained_window_tab_helper.h index d5682fd..d2622de 100644 --- a/chrome/browser/ui/constrained_window_tab_helper.h +++ b/chrome/browser/ui/constrained_window_tab_helper.h @@ -57,7 +57,7 @@ class ConstrainedWindowTabHelper : public content::WebContentsObserver { const content::LoadCommittedDetails& details, const content::FrameNavigateParams& params) OVERRIDE; virtual void DidGetIgnoredUIEvent() OVERRIDE; - virtual void TabContentsDestroyed(TabContents* tab) OVERRIDE; + virtual void WebContentsDestroyed(content::WebContents* tab) OVERRIDE; // Our owning TabContentsWrapper. TabContentsWrapper* wrapper_; diff --git a/chrome/browser/ui/gtk/hung_renderer_dialog_gtk.cc b/chrome/browser/ui/gtk/hung_renderer_dialog_gtk.cc index 1a09a7a..3651103 100644 --- a/chrome/browser/ui/gtk/hung_renderer_dialog_gtk.cc +++ b/chrome/browser/ui/gtk/hung_renderer_dialog_gtk.cc @@ -28,6 +28,8 @@ #include "ui/gfx/gtk_util.h" #include "ui/gfx/image/image.h" +using content::WebContents; + namespace { // A wrapper class that represents the Gtk dialog. @@ -53,7 +55,7 @@ class HungRendererDialogGtk { virtual void RenderViewGone(base::TerminationStatus status) OVERRIDE { dialog_->Hide(); } - virtual void TabContentsDestroyed(TabContents* tab) OVERRIDE { + virtual void WebContentsDestroyed(WebContents* tab) OVERRIDE { dialog_->Hide(); } diff --git a/chrome/browser/ui/pdf/pdf_browsertest.cc b/chrome/browser/ui/pdf/pdf_browsertest.cc index 1d9d768..509de30 100644 --- a/chrome/browser/ui/pdf/pdf_browsertest.cc +++ b/chrome/browser/ui/pdf/pdf_browsertest.cc @@ -23,6 +23,8 @@ #include "ui/gfx/codec/png_codec.h" #include "ui/gfx/screen.h" +using content::WebContents; + namespace { // Include things like browser frame and scrollbar and make sure we're bigger @@ -82,7 +84,7 @@ class PDFBrowserTest : public InProcessBrowserTest, ui_test_utils::RegisterAndWait( this, chrome::NOTIFICATION_TAB_SNAPSHOT_TAKEN, - content::Source<TabContentsWrapper>(wrapper)); + content::Source<WebContents>(wrapper->tab_contents())); ASSERT_FALSE(snapshot_different_) << "Rendering didn't match, see result " "at " << snapshot_filename_.value().c_str(); } diff --git a/chrome/browser/ui/pdf/pdf_tab_observer.cc b/chrome/browser/ui/pdf/pdf_tab_observer.cc index 60ff1b4..fa91143 100644 --- a/chrome/browser/ui/pdf/pdf_tab_observer.cc +++ b/chrome/browser/ui/pdf/pdf_tab_observer.cc @@ -7,6 +7,7 @@ #include "chrome/browser/ui/pdf/pdf_unsupported_feature.h" #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" #include "chrome/common/render_messages.h" +#include "content/browser/tab_contents/tab_contents.h" PDFTabObserver::PDFTabObserver(TabContentsWrapper* wrapper) : content::WebContentsObserver(wrapper->tab_contents()), diff --git a/chrome/browser/ui/prefs/prefs_tab_helper.cc b/chrome/browser/ui/prefs/prefs_tab_helper.cc index e4020b9..c0f2b41 100644 --- a/chrome/browser/ui/prefs/prefs_tab_helper.cc +++ b/chrome/browser/ui/prefs/prefs_tab_helper.cc @@ -23,6 +23,8 @@ #include "grit/platform_locale_settings.h" #include "webkit/glue/webpreferences.h" +using content::WebContents; + namespace { const char* kPerTabPrefsToObserve[] = { @@ -385,7 +387,7 @@ void PrefsTabHelper::RenderViewCreated(RenderViewHost* render_view_host) { UpdateWebPreferences(); } -void PrefsTabHelper::TabContentsDestroyed(TabContents* tab) { +void PrefsTabHelper::WebContentsDestroyed(WebContents* tab) { per_tab_pref_change_registrar_.RemoveAll(); } diff --git a/chrome/browser/ui/prefs/prefs_tab_helper.h b/chrome/browser/ui/prefs/prefs_tab_helper.h index 7888149..f5c5d35 100644 --- a/chrome/browser/ui/prefs/prefs_tab_helper.h +++ b/chrome/browser/ui/prefs/prefs_tab_helper.h @@ -34,7 +34,7 @@ class PrefsTabHelper : public content::WebContentsObserver, private: // content::WebContentsObserver overrides: - virtual void TabContentsDestroyed(TabContents* tab) OVERRIDE; + virtual void WebContentsDestroyed(content::WebContents* tab) OVERRIDE; // content::NotificationObserver overrides: virtual void Observe(int type, diff --git a/chrome/browser/ui/select_file_dialog.cc b/chrome/browser/ui/select_file_dialog.cc index b7b6aa0..ddca99c 100644 --- a/chrome/browser/ui/select_file_dialog.cc +++ b/chrome/browser/ui/select_file_dialog.cc @@ -13,6 +13,7 @@ #include "chrome/browser/tab_contents/simple_alert_infobar_delegate.h" #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" #include "chrome/common/pref_names.h" +#include "content/browser/tab_contents/tab_contents.h" #include "grit/generated_resources.h" #include "ui/base/l10n/l10n_util.h" diff --git a/chrome/browser/ui/snapshot_tab_helper.cc b/chrome/browser/ui/snapshot_tab_helper.cc index 7f9e1b0..998a3546 100644 --- a/chrome/browser/ui/snapshot_tab_helper.cc +++ b/chrome/browser/ui/snapshot_tab_helper.cc @@ -7,11 +7,13 @@ #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" #include "chrome/common/chrome_notification_types.h" #include "chrome/common/render_messages.h" +#include "content/browser/tab_contents/tab_contents.h" #include "content/public/browser/notification_service.h" -SnapshotTabHelper::SnapshotTabHelper(TabContentsWrapper* wrapper) - : content::WebContentsObserver(wrapper->tab_contents()), - wrapper_(wrapper) { +using content::WebContents; + +SnapshotTabHelper::SnapshotTabHelper(WebContents* tab) + : content::WebContentsObserver(tab) { } SnapshotTabHelper::~SnapshotTabHelper() { @@ -39,6 +41,6 @@ bool SnapshotTabHelper::OnMessageReceived(const IPC::Message& message) { void SnapshotTabHelper::OnSnapshot(const SkBitmap& bitmap) { content::NotificationService::current()->Notify( chrome::NOTIFICATION_TAB_SNAPSHOT_TAKEN, - content::Source<TabContentsWrapper>(wrapper_), + content::Source<WebContents>(tab_contents()), content::Details<const SkBitmap>(&bitmap)); } diff --git a/chrome/browser/ui/snapshot_tab_helper.h b/chrome/browser/ui/snapshot_tab_helper.h index dca4ebb..3870ffd 100644 --- a/chrome/browser/ui/snapshot_tab_helper.h +++ b/chrome/browser/ui/snapshot_tab_helper.h @@ -14,7 +14,7 @@ class TabContentsWrapper; // Per-tab class to handle snapshot functionality. class SnapshotTabHelper : public content::WebContentsObserver { public: - explicit SnapshotTabHelper(TabContentsWrapper* wrapper); + explicit SnapshotTabHelper(content::WebContents* tab); virtual ~SnapshotTabHelper(); // Captures a snapshot of the page. @@ -29,9 +29,6 @@ class SnapshotTabHelper : public content::WebContentsObserver { // Message handler. void OnSnapshot(const SkBitmap& bitmap); - // Our owning TabContentsWrapper. - TabContentsWrapper* wrapper_; - DISALLOW_COPY_AND_ASSIGN(SnapshotTabHelper); }; diff --git a/chrome/browser/ui/tab_contents/tab_contents_wrapper.cc b/chrome/browser/ui/tab_contents/tab_contents_wrapper.cc index 0135aa4..d72c9ea 100644 --- a/chrome/browser/ui/tab_contents/tab_contents_wrapper.cc +++ b/chrome/browser/ui/tab_contents/tab_contents_wrapper.cc @@ -47,6 +47,8 @@ #include "chrome/common/chrome_switches.h" #include "content/browser/tab_contents/tab_contents.h" +using content::WebContents; + namespace { static base::LazyInstance<base::PropertyAccessor<TabContentsWrapper*> > @@ -97,7 +99,7 @@ TabContentsWrapper::TabContentsWrapper(TabContents* contents) print_view_manager_.reset(new printing::PrintViewManager(this)); restore_tab_helper_.reset(new RestoreTabHelper(contents)); search_engine_tab_helper_.reset(new SearchEngineTabHelper(contents)); - snapshot_tab_helper_.reset(new SnapshotTabHelper(this)); + snapshot_tab_helper_.reset(new SnapshotTabHelper(contents)); ssl_helper_.reset(new TabContentsSSLHelper(this)); synced_tab_delegate_.reset(new TabContentsWrapperSyncedTabDelegate(this)); content_settings_.reset(new TabSpecificContentSettings(contents)); @@ -155,7 +157,7 @@ TabContentsWrapper* TabContentsWrapper::Clone() { // static TabContentsWrapper* TabContentsWrapper::GetCurrentWrapperForContents( - TabContents* contents) { + WebContents* contents) { TabContentsWrapper** wrapper = property_accessor()->GetProperty(contents->GetPropertyBag()); @@ -164,7 +166,7 @@ TabContentsWrapper* TabContentsWrapper::GetCurrentWrapperForContents( // static const TabContentsWrapper* TabContentsWrapper::GetCurrentWrapperForContents( - const TabContents* contents) { + const WebContents* contents) { TabContentsWrapper* const* wrapper = property_accessor()->GetProperty(contents->GetPropertyBag()); @@ -178,8 +180,8 @@ Profile* TabContentsWrapper::profile() const { //////////////////////////////////////////////////////////////////////////////// // WebContentsObserver overrides -void TabContentsWrapper::TabContentsDestroyed(TabContents* tab) { - // Destruction of the TabContents should only be done by us from our +void TabContentsWrapper::WebContentsDestroyed(WebContents* tab) { + // Destruction of the WebContents should only be done by us from our // destructor. Otherwise it's very likely we (or one of the helpers we own) // will attempt to access the TabContents and we'll crash. DCHECK(in_destructor_); diff --git a/chrome/browser/ui/tab_contents/tab_contents_wrapper.h b/chrome/browser/ui/tab_contents/tab_contents_wrapper.h index 0f9813c..40c3b31 100644 --- a/chrome/browser/ui/tab_contents/tab_contents_wrapper.h +++ b/chrome/browser/ui/tab_contents/tab_contents_wrapper.h @@ -90,9 +90,9 @@ class TabContentsWrapper : public content::WebContentsObserver { // general case, please do NOT use this; plumb TabContentsWrapper through the // chrome/ code instead of TabContents. static TabContentsWrapper* GetCurrentWrapperForContents( - TabContents* contents); + content::WebContents* contents); static const TabContentsWrapper* GetCurrentWrapperForContents( - const TabContents* contents); + const content::WebContents* contents); // Returns the TabContents that this wraps. TabContents* tab_contents() const { return tab_contents_.get(); } @@ -187,7 +187,7 @@ class TabContentsWrapper : public content::WebContentsObserver { // Overrides ----------------------------------------------------------------- // content::WebContentsObserver overrides: - virtual void TabContentsDestroyed(TabContents* tab) OVERRIDE; + virtual void WebContentsDestroyed(content::WebContents* tab) OVERRIDE; private: FRIEND_TEST_ALL_PREFIXES( diff --git a/chrome/browser/ui/views/hung_renderer_view.cc b/chrome/browser/ui/views/hung_renderer_view.cc index bc78c3d..791d02f 100644 --- a/chrome/browser/ui/views/hung_renderer_view.cc +++ b/chrome/browser/ui/views/hung_renderer_view.cc @@ -35,6 +35,8 @@ class HungRendererDialogView; +using content::WebContents; + namespace { // We only support showing one of these at a time per app. HungRendererDialogView* g_instance = NULL; @@ -92,7 +94,7 @@ class HungPagesTableModel : public views::GroupTableModel { // WebContentsObserver overrides: virtual void RenderViewGone(base::TerminationStatus status) OVERRIDE; - virtual void TabContentsDestroyed(TabContents* tab) OVERRIDE; + virtual void WebContentsDestroyed(WebContents* tab) OVERRIDE; private: HungPagesTableModel* model_; @@ -218,8 +220,8 @@ void HungPagesTableModel::WebContentsObserverImpl::RenderViewGone( model_->TabDestroyed(this); } -void HungPagesTableModel::WebContentsObserverImpl::TabContentsDestroyed( - TabContents* tab) { +void HungPagesTableModel::WebContentsObserverImpl::WebContentsDestroyed( + WebContents* tab) { model_->TabDestroyed(this); } diff --git a/chrome/browser/ui/views/location_bar/page_action_image_view.cc b/chrome/browser/ui/views/location_bar/page_action_image_view.cc index 219b658..a260b80 100644 --- a/chrome/browser/ui/views/location_bar/page_action_image_view.cc +++ b/chrome/browser/ui/views/location_bar/page_action_image_view.cc @@ -24,6 +24,8 @@ #include "ui/views/controls/menu/menu_model_adapter.h" #include "ui/views/controls/menu/menu_runner.h" +using content::WebContents; + PageActionImageView::PageActionImageView(LocationBarView* owner, ExtensionAction* page_action) : owner_(owner), @@ -183,7 +185,7 @@ void PageActionImageView::OnImageLoaded( owner_->UpdatePageActions(); } -void PageActionImageView::UpdateVisibility(TabContents* contents, +void PageActionImageView::UpdateVisibility(WebContents* contents, const GURL& url) { // Save this off so we can pass it back to the extension when the action gets // executed. See PageActionImageView::OnMousePressed. diff --git a/chrome/browser/ui/views/location_bar/page_action_image_view.h b/chrome/browser/ui/views/location_bar/page_action_image_view.h index ab81007..01ca8ed 100644 --- a/chrome/browser/ui/views/location_bar/page_action_image_view.h +++ b/chrome/browser/ui/views/location_bar/page_action_image_view.h @@ -16,6 +16,10 @@ #include "ui/views/controls/image_view.h" class LocationBarView; + +namespace content { +class WebContents; +} namespace views { class MenuRunner; } @@ -67,7 +71,7 @@ class PageActionImageView : public views::ImageView, // Called to notify the PageAction that it should determine whether to be // visible or hidden. |contents| is the TabContents that is active, |url| is // the current page URL. - void UpdateVisibility(TabContents* contents, const GURL& url); + void UpdateVisibility(content::WebContents* contents, const GURL& url); // Either notify listeners or show a popup depending on the page action. void ExecuteAction(int button, bool inspect_with_devtools); diff --git a/chrome/browser/ui/views/location_bar/page_action_with_badge_view.cc b/chrome/browser/ui/views/location_bar/page_action_with_badge_view.cc index 1144239..569ea44 100644 --- a/chrome/browser/ui/views/location_bar/page_action_with_badge_view.cc +++ b/chrome/browser/ui/views/location_bar/page_action_with_badge_view.cc @@ -8,6 +8,8 @@ #include "chrome/common/extensions/extension.h" #include "ui/base/accessibility/accessible_view_state.h" +using content::WebContents; + PageActionWithBadgeView::PageActionWithBadgeView( PageActionImageView* image_view) { image_view_ = image_view; @@ -34,7 +36,7 @@ void PageActionWithBadgeView::Layout() { image_view_->SetBounds(0, y, width(), height()); } -void PageActionWithBadgeView::UpdateVisibility(TabContents* contents, +void PageActionWithBadgeView::UpdateVisibility(WebContents* contents, const GURL& url) { image_view_->UpdateVisibility(contents, url); SetVisible(image_view_->visible()); diff --git a/chrome/browser/ui/views/location_bar/page_action_with_badge_view.h b/chrome/browser/ui/views/location_bar/page_action_with_badge_view.h index 84931dc..f56c4a2 100644 --- a/chrome/browser/ui/views/location_bar/page_action_with_badge_view.h +++ b/chrome/browser/ui/views/location_bar/page_action_with_badge_view.h @@ -12,7 +12,10 @@ class GURL; class PageActionImageView; -class TabContents; + +namespace content { +class WebContents; +} // A container for the PageActionImageView plus its badge. class PageActionWithBadgeView : public views::View { @@ -25,7 +28,7 @@ class PageActionWithBadgeView : public views::View { virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; virtual gfx::Size GetPreferredSize() OVERRIDE; - void UpdateVisibility(TabContents* contents, const GURL& url); + void UpdateVisibility(content::WebContents* contents, const GURL& url); private: virtual void Layout() OVERRIDE; diff --git a/chrome/browser/ui/webui/constrained_html_ui_browsertest.cc b/chrome/browser/ui/webui/constrained_html_ui_browsertest.cc index 20f1dad..6e07100 100644 --- a/chrome/browser/ui/webui/constrained_html_ui_browsertest.cc +++ b/chrome/browser/ui/webui/constrained_html_ui_browsertest.cc @@ -16,6 +16,8 @@ #include "content/browser/tab_contents/tab_contents.h" #include "content/public/browser/web_contents_observer.h" +using content::WebContents; + namespace { class ConstrainedHtmlDialogBrowserTestObserver @@ -30,7 +32,7 @@ class ConstrainedHtmlDialogBrowserTestObserver bool tab_destroyed() { return tab_destroyed_; } private: - virtual void TabContentsDestroyed(TabContents* tab) { + virtual void WebContentsDestroyed(WebContents* tab) OVERRIDE { tab_destroyed_ = true; } diff --git a/chrome/browser/ui/webui/hung_renderer_dialog.cc b/chrome/browser/ui/webui/hung_renderer_dialog.cc index cfcbe1d..fe35ef6 100644 --- a/chrome/browser/ui/webui/hung_renderer_dialog.cc +++ b/chrome/browser/ui/webui/hung_renderer_dialog.cc @@ -27,6 +27,8 @@ #include "grit/generated_resources.h" #include "ui/base/l10n/l10n_util.h" +using content::WebContents; + namespace { HungRendererDialog* g_instance = NULL; const int kHungRendererDialogWidth = 425; @@ -89,8 +91,8 @@ void HungRendererDialog::WebContentsObserverImpl::RenderViewGone( dialog_->HideDialog(contents_); } -void HungRendererDialog::WebContentsObserverImpl::TabContentsDestroyed( - TabContents* tab) { +void HungRendererDialog::WebContentsObserverImpl::WebContentsDestroyed( + WebContents* tab) { dialog_->HideDialog(contents_); } diff --git a/chrome/browser/ui/webui/hung_renderer_dialog.h b/chrome/browser/ui/webui/hung_renderer_dialog.h index f42b31c..f12096a 100644 --- a/chrome/browser/ui/webui/hung_renderer_dialog.h +++ b/chrome/browser/ui/webui/hung_renderer_dialog.h @@ -34,7 +34,7 @@ class HungRendererDialog : private HtmlDialogUIDelegate { // content::WebContentsObserver overrides: virtual void RenderViewGone(base::TerminationStatus status) OVERRIDE; - virtual void TabContentsDestroyed(TabContents* tab) OVERRIDE; + virtual void WebContentsDestroyed(content::WebContents* tab) OVERRIDE; private: TabContents* contents_; // weak |