diff options
author | avi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-12 02:59:13 +0000 |
---|---|---|
committer | avi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-12 02:59:13 +0000 |
commit | 1d3e917629c873ec30133f7023e35c5218a97725 (patch) | |
tree | 7ed63df857ef342dd30926313904e9318b0a2c7f | |
parent | f2ea1fc3579f75e010cc6e8ff4fa95ad9e2a1453 (diff) | |
download | chromium_src-1d3e917629c873ec30133f7023e35c5218a97725.zip chromium_src-1d3e917629c873ec30133f7023e35c5218a97725.tar.gz chromium_src-1d3e917629c873ec30133f7023e35c5218a97725.tar.bz2 |
TabContentsWrapper -> TabContents, part 43.
GetOwningTabContentsForWebContents
BUG=131026
TEST=no change
Review URL: https://chromiumcodereview.appspot.com/10535120
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@141602 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/automation/automation_provider.cc | 3 | ||||
-rw-r--r-- | chrome/browser/automation/automation_provider_observers.cc | 18 | ||||
-rw-r--r-- | chrome/browser/automation/automation_provider_win.cc | 3 | ||||
-rw-r--r-- | chrome/browser/automation/testing_automation_provider.cc | 21 | ||||
-rw-r--r-- | chrome/browser/debugger/devtools_window.cc | 5 | ||||
-rw-r--r-- | chrome/browser/download/download_request_limiter.cc | 12 | ||||
-rw-r--r-- | chrome/browser/download/download_request_limiter_unittest.cc | 3 | ||||
-rw-r--r-- | chrome/browser/external_tab/external_tab_container_win.cc | 2 | ||||
-rw-r--r-- | chrome/browser/ui/browser.cc | 150 | ||||
-rw-r--r-- | chrome/browser/ui/browser.h | 48 | ||||
-rw-r--r-- | chrome/browser/ui/gtk/location_bar_view_gtk.cc | 4 | ||||
-rw-r--r-- | chrome/browser/ui/tab_contents/tab_contents.cc | 14 | ||||
-rw-r--r-- | chrome/browser/ui/tab_contents/tab_contents.h | 4 | ||||
-rw-r--r-- | chrome/browser/ui/views/location_bar/content_setting_image_view.cc | 4 |
14 files changed, 131 insertions, 160 deletions
diff --git a/chrome/browser/automation/automation_provider.cc b/chrome/browser/automation/automation_provider.cc index 8553aa7..af86a9d 100644 --- a/chrome/browser/automation/automation_provider.cc +++ b/chrome/browser/automation/automation_provider.cc @@ -519,8 +519,7 @@ void AutomationProvider::SendFindRequest( if (!with_json) { find_in_page_observer_.reset(observer); } - TabContents* tab_contents = - TabContents::GetOwningTabContentsForWebContents(web_contents); + TabContents* tab_contents = TabContents::FromWebContents(web_contents); if (tab_contents) tab_contents->find_tab_helper()->set_current_find_request_id(request_id); diff --git a/chrome/browser/automation/automation_provider_observers.cc b/chrome/browser/automation/automation_provider_observers.cc index e2e790f..aaca274 100644 --- a/chrome/browser/automation/automation_provider_observers.cc +++ b/chrome/browser/automation/automation_provider_observers.cc @@ -801,8 +801,8 @@ void BrowserOpenedNotificationObserver::Observe( // Only send the result if the loaded tab is in the new window. NavigationController* controller = content::Source<NavigationController>(source).ptr(); - TabContents* tab = TabContents::GetOwningTabContentsForWebContents( - controller->GetWebContents()); + TabContents* tab = + TabContents::FromWebContents(controller->GetWebContents()); int window_id = tab ? tab->restore_tab_helper()->window_id().id() : -1; if (window_id == new_window_id_) { if (for_browser_command_) { @@ -1118,8 +1118,7 @@ void DomOperationObserver::Observe( } else if (type == chrome::NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED) { WebContents* web_contents = content::Source<WebContents>(source).ptr(); if (web_contents) { - TabContents* tab_contents = - TabContents::GetOwningTabContentsForWebContents(web_contents); + TabContents* tab_contents = TabContents::FromWebContents(web_contents); if (tab_contents && tab_contents->content_settings() && tab_contents->content_settings()->IsContentBlocked( @@ -1259,8 +1258,8 @@ void TabLanguageDeterminedObserver::Observe( return; } - TranslateTabHelper* helper = TabContents::GetOwningTabContentsForWebContents( - web_contents_)->translate_tab_helper(); + TranslateTabHelper* helper = + TabContents::FromWebContents(web_contents_)->translate_tab_helper(); scoped_ptr<DictionaryValue> return_value(new DictionaryValue); return_value->SetBoolean("page_translated", helper->language_state().IsPageTranslated()); @@ -2151,8 +2150,7 @@ void AppLaunchObserver::Observe(int type, NavigationController* controller = content::Source<NavigationController>(source).ptr(); TabContents* tab = - TabContents::GetOwningTabContentsForWebContents( - controller->GetWebContents()); + TabContents::FromWebContents(controller->GetWebContents()); int window_id = tab ? tab->restore_tab_helper()->window_id().id() : -1; if (window_id == new_window_id_) { if (automation_) { @@ -2978,8 +2976,8 @@ void BrowserOpenedWithNewProfileNotificationObserver::Observe( // Only send the result if the loaded tab is in the new window. NavigationController* controller = content::Source<NavigationController>(source).ptr(); - TabContents* tab = TabContents::GetOwningTabContentsForWebContents( - controller->GetWebContents()); + TabContents* tab = + TabContents::FromWebContents(controller->GetWebContents()); int window_id = tab ? tab->restore_tab_helper()->window_id().id() : -1; if (window_id == new_window_id_) { if (automation_) { diff --git a/chrome/browser/automation/automation_provider_win.cc b/chrome/browser/automation/automation_provider_win.cc index 3447b06..8c1c11b 100644 --- a/chrome/browser/automation/automation_provider_win.cc +++ b/chrome/browser/automation/automation_provider_win.cc @@ -241,8 +241,7 @@ void AutomationProvider::PrintAsync(int tab_handle) { if (!web_contents) return; - TabContents* tab_contents = - TabContents::GetOwningTabContentsForWebContents(web_contents); + TabContents* tab_contents = TabContents::FromWebContents(web_contents); tab_contents->print_view_manager()->PrintNow(); } diff --git a/chrome/browser/automation/testing_automation_provider.cc b/chrome/browser/automation/testing_automation_provider.cc index c86a5de..307b1b0 100644 --- a/chrome/browser/automation/testing_automation_provider.cc +++ b/chrome/browser/automation/testing_automation_provider.cc @@ -2094,8 +2094,7 @@ ListValue* TestingAutomationProvider::GetInfobarsInfo(WebContents* wc) { // Each infobar may have different properties depending on the type. ListValue* infobars = new ListValue; InfoBarTabHelper* infobar_helper = - TabContents::GetOwningTabContentsForWebContents(wc)-> - infobar_tab_helper(); + TabContents::FromWebContents(wc)->infobar_tab_helper(); for (size_t i = 0; i < infobar_helper->infobar_count(); ++i) { DictionaryValue* infobar_item = new DictionaryValue; InfoBarDelegate* infobar = infobar_helper->GetInfoBarDelegateAt(i); @@ -3648,8 +3647,7 @@ TabContents* GetTabContentsFromDict(const Browser* browser, TranslateInfoBarDelegate* GetTranslateInfoBarDelegate( WebContents* web_contents) { InfoBarTabHelper* infobar_helper = - TabContents::GetOwningTabContentsForWebContents(web_contents)-> - infobar_tab_helper(); + TabContents::FromWebContents(web_contents)->infobar_tab_helper(); for (size_t i = 0; i < infobar_helper->infobar_count(); i++) { InfoBarDelegate* infobar = infobar_helper->GetInfoBarDelegateAt(i); if (infobar->AsTranslateInfoBarDelegate()) @@ -3729,8 +3727,8 @@ void TestingAutomationProvider::GetTranslateInfo( this, reply_message, web_contents, translate_bar); // If the language for the page hasn't been loaded yet, then just make // the observer, otherwise call observe directly. - TranslateTabHelper* helper = TabContents::GetOwningTabContentsForWebContents( - web_contents)->translate_tab_helper(); + TranslateTabHelper* helper = + TabContents::FromWebContents(web_contents)->translate_tab_helper(); std::string language = helper->language_state().original_language(); if (!language.empty()) { observer->Observe(chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED, @@ -4396,8 +4394,7 @@ void TestingAutomationProvider::HeapProfilerDump( return; } - TabContents* tab_contents = - TabContents::GetOwningTabContentsForWebContents(web_contents); + TabContents* tab_contents = TabContents::FromWebContents(web_contents); tab_contents->automation_tab_helper()->HeapProfilerDump(reason_string); reply.SendSuccess(NULL); return; @@ -6013,7 +6010,7 @@ void TestingAutomationProvider::GetIndicesFromTab( } int id = id_or_handle; if (has_handle) { - TabContents* tab = TabContents::GetOwningTabContentsForWebContents( + TabContents* tab = TabContents::FromWebContents( tab_tracker_->GetResource(id_or_handle)->GetWebContents()); id = tab->restore_tab_helper()->session_id().id(); } @@ -6338,8 +6335,7 @@ void TestingAutomationProvider::CaptureEntirePageJSON( FilePath path(path_str); // This will delete itself when finished. PageSnapshotTaker* snapshot_taker = new PageSnapshotTaker( - this, reply_message, - TabContents::GetOwningTabContentsForWebContents(web_contents), path); + this, reply_message, TabContents::FromWebContents(web_contents), path); snapshot_taker->Start(); } else { AutomationJSONReply(this, reply_message) @@ -6648,8 +6644,7 @@ void TestingAutomationProvider::WaitForInfoBarCount( // The delegate will delete itself. new InfoBarCountObserver(this, reply_message, - TabContents::GetOwningTabContentsForWebContents( - controller->GetWebContents()), target_count); + TabContents::FromWebContents(controller->GetWebContents()), target_count); } void TestingAutomationProvider::ResetToDefaultTheme() { diff --git a/chrome/browser/debugger/devtools_window.cc b/chrome/browser/debugger/devtools_window.cc index 1f36652..82f5e30 100644 --- a/chrome/browser/debugger/devtools_window.cc +++ b/chrome/browser/debugger/devtools_window.cc @@ -227,7 +227,7 @@ DevToolsWindow::DevToolsWindow(TabContents* tab_contents, if (inspected_rvh) { WebContents* tab = WebContents::FromRenderViewHost(inspected_rvh); if (tab) - inspected_tab_ = TabContents::GetOwningTabContentsForWebContents(tab); + inspected_tab_ = TabContents::FromWebContents(tab); } } @@ -262,8 +262,7 @@ void DevToolsWindow::InspectedContentsClosing() { } void DevToolsWindow::ContentsReplaced(WebContents* new_contents) { - TabContents* new_tab_contents = - TabContents::GetOwningTabContentsForWebContents(new_contents); + TabContents* new_tab_contents = TabContents::FromWebContents(new_contents); DCHECK(new_tab_contents); if (!new_tab_contents) return; diff --git a/chrome/browser/download/download_request_limiter.cc b/chrome/browser/download/download_request_limiter.cc index 901071a..155d633 100644 --- a/chrome/browser/download/download_request_limiter.cc +++ b/chrome/browser/download/download_request_limiter.cc @@ -65,10 +65,9 @@ void DownloadRequestLimiter::TabDownloadState::DidGetUserGesture() { return; } - TabContents* tab_contents = - TabContents::GetOwningTabContentsForWebContents(web_contents()); - // See PromptUserForDownload(): if there's no TCW, then DOWNLOADS_NOT_ALLOWED - // is functionally equivalent to PROMPT_BEFORE_DOWNLOAD. + TabContents* tab_contents = TabContents::FromWebContents(web_contents()); + // See PromptUserForDownload(): if there's no TabContents, then + // DOWNLOADS_NOT_ALLOWED is functionally equivalent to PROMPT_BEFORE_DOWNLOAD. if ((tab_contents && status_ != DownloadRequestLimiter::ALLOW_ALL_DOWNLOADS && status_ != DownloadRequestLimiter::DOWNLOADS_NOT_ALLOWED) || @@ -92,8 +91,7 @@ void DownloadRequestLimiter::TabDownloadState::PromptUserForDownload( NotifyCallbacks(DownloadRequestLimiter::delegate_->ShouldAllowDownload()); return; } - TabContents* tab_contents = - TabContents::GetOwningTabContentsForWebContents(web_contents); + TabContents* tab_contents = TabContents::FromWebContents(web_contents); if (!tab_contents) { // If |web_contents| doesn't have a TabContents, then it isn't what a user // thinks of as a tab, it's actually a "raw" WebContents like those used @@ -319,7 +317,7 @@ void DownloadRequestLimiter::CanDownloadImpl(WebContents* originating_contents, // shown, treat the request as if it came from the parent. WebContents* effective_contents = originating_contents; TabContents* originating_tab_contents = - TabContents::GetOwningTabContentsForWebContents(originating_contents); + TabContents::FromWebContents(originating_contents); if (originating_tab_contents && originating_tab_contents->blocked_content_tab_helper()->delegate()) { effective_contents = diff --git a/chrome/browser/download/download_request_limiter_unittest.cc b/chrome/browser/download/download_request_limiter_unittest.cc index 3dd2724..c59b2e1 100644 --- a/chrome/browser/download/download_request_limiter_unittest.cc +++ b/chrome/browser/download/download_request_limiter_unittest.cc @@ -238,8 +238,7 @@ TEST_F(DownloadRequestLimiterTest, // RenderViewHostTestHarness::CreateTestWebContents() directly so that there // will be no TabContents for web_contents. scoped_ptr<WebContents> web_contents(CreateTestWebContents()); - TabContents* tab_contents = - TabContents::GetOwningTabContentsForWebContents(web_contents.get()); + TabContents* tab_contents = TabContents::FromWebContents(web_contents.get()); ASSERT_TRUE(tab_contents == NULL); // DRL won't try to make an infobar if it doesn't have a TCW, and we want to // test that it will Cancel() instead of prompting when it doesn't have a TCW, diff --git a/chrome/browser/external_tab/external_tab_container_win.cc b/chrome/browser/external_tab/external_tab_container_win.cc index dbd2a28..c8805c0 100644 --- a/chrome/browser/external_tab/external_tab_container_win.cc +++ b/chrome/browser/external_tab/external_tab_container_win.cc @@ -717,7 +717,7 @@ void ExternalTabContainer::ShowRepostFormWarningDialog( WebContents* source) { browser::ShowTabModalConfirmDialog( new RepostFormWarningController(source), - TabContents::GetOwningTabContentsForWebContents(source)); + TabContents::FromWebContents(source)); } void ExternalTabContainer::RunFileChooser( diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc index 65bda1e..4911154 100644 --- a/chrome/browser/ui/browser.cc +++ b/chrome/browser/ui/browser.cc @@ -1579,8 +1579,7 @@ void Browser::ShowPageInfo(content::WebContents* web_contents, bool show_history) { Profile* profile = Profile::FromBrowserContext( web_contents->GetBrowserContext()); - TabContents* tab_contents = - TabContents::GetOwningTabContentsForWebContents(web_contents); + TabContents* tab_contents = TabContents::FromWebContents(web_contents); if (CommandLine::ForCurrentProcess()->HasSwitch( switches::kEnableWebsiteSettings)) { @@ -2236,9 +2235,8 @@ bool Browser::RunUnloadEventsHelper(WebContents* contents) { } // static -void Browser::JSOutOfMemoryHelper(WebContents* tab) { - TabContents* tab_contents = TabContents::GetOwningTabContentsForWebContents( - tab); +void Browser::JSOutOfMemoryHelper(WebContents* web_contents) { + TabContents* tab_contents = TabContents::FromWebContents(web_contents); if (!tab_contents) return; @@ -2251,13 +2249,12 @@ void Browser::JSOutOfMemoryHelper(WebContents* tab) { } // static -void Browser::RegisterProtocolHandlerHelper(WebContents* tab, +void Browser::RegisterProtocolHandlerHelper(WebContents* web_contents, const std::string& protocol, const GURL& url, const string16& title, bool user_gesture) { - TabContents* tab_contents = TabContents::GetOwningTabContentsForWebContents( - tab); + TabContents* tab_contents = TabContents::FromWebContents(web_contents); if (!tab_contents || tab_contents->profile()->IsOffTheRecord()) return; @@ -2294,14 +2291,13 @@ void Browser::RegisterProtocolHandlerHelper(WebContents* tab, } // static -void Browser::FindReplyHelper(WebContents* tab, +void Browser::FindReplyHelper(WebContents* web_contents, int request_id, int number_of_matches, const gfx::Rect& selection_rect, int active_match_ordinal, bool final_update) { - TabContents* tab_contents = TabContents::GetOwningTabContentsForWebContents( - tab); + TabContents* tab_contents = TabContents::FromWebContents(web_contents); if (!tab_contents || !tab_contents->find_tab_helper()) return; @@ -3173,14 +3169,12 @@ void Browser::AddNewContents(WebContents* source, TabContents* source_tab_contents = NULL; BlockedContentTabHelper* source_blocked_content = NULL; - TabContents* new_tab_contents = - TabContents::GetOwningTabContentsForWebContents(new_contents); + TabContents* new_tab_contents = TabContents::FromWebContents(new_contents); if (!new_tab_contents) { new_tab_contents = new TabContents(new_contents); } if (source) { - source_tab_contents = - TabContents::GetOwningTabContentsForWebContents(source); + source_tab_contents = TabContents::FromWebContents(source); source_blocked_content = source_tab_contents->blocked_content_tab_helper(); } @@ -3248,7 +3242,7 @@ void Browser::LoadingStateChanged(WebContents* source) { // malware site etc). When this happens, we abort the shortcut update. NavigationEntry* entry = source->GetController().GetLastCommittedEntry(); if (entry) { - TabContents::GetOwningTabContentsForWebContents(source)-> + TabContents::FromWebContents(source)-> extension_tab_helper()->GetApplicationInfo(entry->GetPageID()); } else { pending_web_app_action_ = NONE; @@ -3350,8 +3344,7 @@ void Browser::ConvertContentsToApplication(WebContents* contents) { Browser* app_browser = Browser::CreateWithParams( Browser::CreateParams::CreateForApp( TYPE_POPUP, app_name, gfx::Rect(), profile_)); - TabContents* tab_contents = - TabContents::GetOwningTabContentsForWebContents(contents); + TabContents* tab_contents = TabContents::FromWebContents(contents); if (!tab_contents) tab_contents = new TabContents(contents); app_browser->tab_strip_model()->AppendTabContents(tab_contents, true); @@ -3365,27 +3358,27 @@ gfx::Rect Browser::GetRootWindowResizerRect() const { return window_->GetRootWindowResizerRect(); } -void Browser::BeforeUnloadFired(WebContents* tab, +void Browser::BeforeUnloadFired(WebContents* web_contents, bool proceed, bool* proceed_to_fire_unload) { if (!is_attempting_to_close_browser_) { *proceed_to_fire_unload = proceed; if (!proceed) - tab->SetClosedByUserGesture(false); + web_contents->SetClosedByUserGesture(false); return; } if (!proceed) { CancelWindowClose(); *proceed_to_fire_unload = false; - tab->SetClosedByUserGesture(false); + web_contents->SetClosedByUserGesture(false); return; } - if (RemoveFromSet(&tabs_needing_before_unload_fired_, tab)) { + if (RemoveFromSet(&tabs_needing_before_unload_fired_, web_contents)) { // Now that beforeunload has fired, put the tab on the queue to fire // unload. - tabs_needing_unload_fired_.insert(tab); + tabs_needing_unload_fired_.insert(web_contents); ProcessPendingTabs(); // We want to handle firing the unload event ourselves since we want to // fire all the beforeunload events before attempting to fire the unload @@ -3418,8 +3411,7 @@ int Browser::GetExtraRenderViewHeight() const { void Browser::OnStartDownload(WebContents* source, content::DownloadItem* download) { - TabContents* tab_contents = - TabContents::GetOwningTabContentsForWebContents(source); + TabContents* tab_contents = TabContents::FromWebContents(source); TabContents* constrained = GetConstrainingTabContents(tab_contents); if (constrained != tab_contents) { // Download in a constrained popup is shown in the tab that opened it. @@ -3475,7 +3467,7 @@ void Browser::ViewSourceForFrame(WebContents* source, void Browser::ShowRepostFormWarningDialog(WebContents* source) { browser::ShowTabModalConfirmDialog( new RepostFormWarningController(source), - TabContents::GetOwningTabContentsForWebContents(source)); + TabContents::FromWebContents(source)); } bool Browser::ShouldAddNavigationToHistory( @@ -3530,8 +3522,7 @@ void Browser::ContentRestrictionsChanged(WebContents* source) { void Browser::RendererUnresponsive(WebContents* source) { // Ignore hangs if print preview is open. - TabContents* tab_contents = - TabContents::GetOwningTabContentsForWebContents(source); + TabContents* tab_contents = TabContents::FromWebContents(source); if (tab_contents) { printing::PrintPreviewTabController* controller = printing::PrintPreviewTabController::GetInstance(); @@ -3552,8 +3543,7 @@ void Browser::RendererResponsive(WebContents* source) { } void Browser::WorkerCrashed(WebContents* source) { - TabContents* tab_contents = - TabContents::GetOwningTabContentsForWebContents(source); + TabContents* tab_contents = TabContents::FromWebContents(source); InfoBarTabHelper* infobar_helper = tab_contents->infobar_tab_helper(); infobar_helper->AddInfoBar(new SimpleAlertInfoBarDelegate( infobar_helper, @@ -3562,13 +3552,13 @@ void Browser::WorkerCrashed(WebContents* source) { true)); } -void Browser::DidNavigateMainFramePostCommit(WebContents* tab) { - if (tab == GetActiveWebContents()) +void Browser::DidNavigateMainFramePostCommit(WebContents* web_contents) { + if (web_contents == GetActiveWebContents()) UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TAB_STATE); } -void Browser::DidNavigateToPendingEntry(WebContents* tab) { - if (tab == GetActiveWebContents()) +void Browser::DidNavigateToPendingEntry(WebContents* web_contents) { + if (web_contents == GetActiveWebContents()) UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TAB_STATE); } @@ -3576,19 +3566,21 @@ content::JavaScriptDialogCreator* Browser::GetJavaScriptDialogCreator() { return GetJavaScriptDialogCreatorInstance(); } -content::ColorChooser* Browser::OpenColorChooser(WebContents* tab, +content::ColorChooser* Browser::OpenColorChooser(WebContents* web_contents, int color_chooser_id, SkColor color) { #if defined(OS_WIN) // On Windows, only create a color chooser if one doesn't exist, because we // can't close the old color chooser dialog. if (!color_chooser_.get()) - color_chooser_.reset(content::ColorChooser::Create(color_chooser_id, tab, + color_chooser_.reset(content::ColorChooser::Create(color_chooser_id, + web_contents, color)); #else if (color_chooser_.get()) color_chooser_->End(); - color_chooser_.reset(content::ColorChooser::Create(color_chooser_id, tab, + color_chooser_.reset(content::ColorChooser::Create(color_chooser_id, + web_contents, color)); #endif return color_chooser_.get(); @@ -3598,54 +3590,57 @@ void Browser::DidEndColorChooser() { color_chooser_.reset(); } -void Browser::RunFileChooser(WebContents* tab, +void Browser::RunFileChooser(WebContents* web_contents, const content::FileChooserParams& params) { - FileSelectHelper::RunFileChooser(tab, params); + FileSelectHelper::RunFileChooser(web_contents, params); } -void Browser::EnumerateDirectory(WebContents* tab, +void Browser::EnumerateDirectory(WebContents* web_contents, int request_id, const FilePath& path) { - FileSelectHelper::EnumerateDirectory(tab, request_id, path); + FileSelectHelper::EnumerateDirectory(web_contents, request_id, path); } -void Browser::ToggleFullscreenModeForTab(WebContents* tab, +void Browser::ToggleFullscreenModeForTab(WebContents* web_contents, bool enter_fullscreen) { - fullscreen_controller_->ToggleFullscreenModeForTab(tab, enter_fullscreen); + fullscreen_controller_->ToggleFullscreenModeForTab(web_contents, + enter_fullscreen); } -bool Browser::IsFullscreenForTabOrPending(const WebContents* tab) const { - return fullscreen_controller_->IsFullscreenForTabOrPending(tab); +bool Browser::IsFullscreenForTabOrPending( + const WebContents* web_contents) const { + return fullscreen_controller_->IsFullscreenForTabOrPending(web_contents); } -void Browser::JSOutOfMemory(WebContents* tab) { - JSOutOfMemoryHelper(tab); +void Browser::JSOutOfMemory(WebContents* web_contents) { + JSOutOfMemoryHelper(web_contents); } -void Browser::RegisterProtocolHandler(WebContents* tab, +void Browser::RegisterProtocolHandler(WebContents* web_contents, const std::string& protocol, const GURL& url, const string16& title, bool user_gesture) { - RegisterProtocolHandlerHelper(tab, protocol, url, title, user_gesture); + RegisterProtocolHandlerHelper( + web_contents, protocol, url, title, user_gesture); } void Browser::RegisterIntentHandler( - WebContents* tab, + WebContents* web_contents, const webkit_glue::WebIntentServiceData& data, bool user_gesture) { - RegisterIntentHandlerHelper(tab, data, user_gesture); + RegisterIntentHandlerHelper(web_contents, data, user_gesture); } void Browser::WebIntentDispatch( - WebContents* tab, content::WebIntentsDispatcher* intents_dispatcher) { + WebContents* web_contents, + content::WebIntentsDispatcher* intents_dispatcher) { if (!web_intents::IsWebIntentsEnabledForProfile(profile_)) return; UMA_HISTOGRAM_COUNTS("WebIntents.Dispatch", 1); - TabContents* tab_contents = - TabContents::GetOwningTabContentsForWebContents(tab); + TabContents* tab_contents = TabContents::FromWebContents(web_contents); tab_contents->web_intent_picker_controller()->SetIntentsDispatcher( intents_dispatcher); tab_contents->web_intent_picker_controller()->ShowDialog( @@ -3663,20 +3658,20 @@ void Browser::ResizeDueToAutoResize(WebContents* source, window_->ResizeDueToAutoResize(source, new_size); } -void Browser::FindReply(WebContents* tab, +void Browser::FindReply(WebContents* web_contents, int request_id, int number_of_matches, const gfx::Rect& selection_rect, int active_match_ordinal, bool final_update) { - FindReplyHelper(tab, request_id, number_of_matches, selection_rect, + FindReplyHelper(web_contents, request_id, number_of_matches, selection_rect, active_match_ordinal, final_update); } -void Browser::RequestToLockMouse(WebContents* tab, +void Browser::RequestToLockMouse(WebContents* web_contents, bool user_gesture, bool last_unlocked_by_target) { - fullscreen_controller_->RequestToLockMouse(tab, + fullscreen_controller_->RequestToLockMouse(web_contents, user_gesture, last_unlocked_by_target); } @@ -4623,13 +4618,13 @@ void Browser::ProcessPendingTabs() { // Process beforeunload tabs first. When that queue is empty, process // unload tabs. if (!tabs_needing_before_unload_fired_.empty()) { - WebContents* tab = *(tabs_needing_before_unload_fired_.begin()); + WebContents* web_contents = *(tabs_needing_before_unload_fired_.begin()); // Null check render_view_host here as this gets called on a PostTask and // the tab's render_view_host may have been nulled out. - if (tab->GetRenderViewHost()) { - tab->GetRenderViewHost()->FirePageBeforeUnload(false); + if (web_contents->GetRenderViewHost()) { + web_contents->GetRenderViewHost()->FirePageBeforeUnload(false); } else { - ClearUnloadState(tab, true); + ClearUnloadState(web_contents, true); } } else if (!tabs_needing_unload_fired_.empty()) { // We've finished firing all beforeunload events and can proceed with unload @@ -4640,13 +4635,13 @@ void Browser::ProcessPendingTabs() { // TODO(ojan): We can probably fire all the unload events in parallel and // get a perf benefit from that in the cases where the tab hangs in it's // unload handler or takes a long time to page in. - WebContents* tab = *(tabs_needing_unload_fired_.begin()); + WebContents* web_contents = *(tabs_needing_unload_fired_.begin()); // Null check render_view_host here as this gets called on a PostTask and // the tab's render_view_host may have been nulled out. - if (tab->GetRenderViewHost()) { - tab->GetRenderViewHost()->ClosePage(); + if (web_contents->GetRenderViewHost()) { + web_contents->GetRenderViewHost()->ClosePage(); } else { - ClearUnloadState(tab, true); + ClearUnloadState(web_contents, true); } } else { NOTREACHED(); @@ -4680,10 +4675,11 @@ void Browser::CancelWindowClose() { watcher->OnWindowCloseCanceled(this); } -bool Browser::RemoveFromSet(UnloadListenerSet* set, WebContents* tab) { +bool Browser::RemoveFromSet(UnloadListenerSet* set, WebContents* web_contents) { DCHECK(is_attempting_to_close_browser_); - UnloadListenerSet::iterator iter = std::find(set->begin(), set->end(), tab); + UnloadListenerSet::iterator iter = + std::find(set->begin(), set->end(), web_contents); if (iter != set->end()) { set->erase(iter); return true; @@ -4691,13 +4687,13 @@ bool Browser::RemoveFromSet(UnloadListenerSet* set, WebContents* tab) { return false; } -void Browser::ClearUnloadState(WebContents* tab, bool process_now) { +void Browser::ClearUnloadState(WebContents* web_contents, bool process_now) { // Closing of browser could be canceled (via IsClosingPermitted) between the // time when request was initiated and when this method is called, so check // for is_attempting_to_close_browser_ flag before proceeding. if (is_attempting_to_close_browser_) { - RemoveFromSet(&tabs_needing_before_unload_fired_, tab); - RemoveFromSet(&tabs_needing_unload_fired_, tab); + RemoveFromSet(&tabs_needing_before_unload_fired_, web_contents); + RemoveFromSet(&tabs_needing_unload_fired_, web_contents); if (process_now) { ProcessPendingTabs(); } else { @@ -4838,14 +4834,14 @@ void Browser::ReloadInternal(WindowOpenDisposition disposition, // // Also notify RenderViewHostDelegate of the user gesture; this is // normally done in Browser::Navigate, but a reload bypasses Navigate. - WebContents* tab = GetOrCloneTabForDisposition(disposition); - tab->UserGestureDone(); - if (!tab->FocusLocationBarByDefault()) - tab->Focus(); + WebContents* web_contents = GetOrCloneTabForDisposition(disposition); + web_contents->UserGestureDone(); + if (!web_contents->FocusLocationBarByDefault()) + web_contents->Focus(); if (ignore_cache) - tab->GetController().ReloadIgnoringCache(true); + web_contents->GetController().ReloadIgnoringCache(true); else - tab->GetController().Reload(true); + web_contents->GetController().Reload(true); } WebContents* Browser::GetOrCloneTabForDisposition( diff --git a/chrome/browser/ui/browser.h b/chrome/browser/ui/browser.h index 7cba339..1a29ee6 100644 --- a/chrome/browser/ui/browser.h +++ b/chrome/browser/ui/browser.h @@ -653,10 +653,10 @@ class Browser : public TabStripModelDelegate, static bool RunUnloadEventsHelper(content::WebContents* contents); // Helper function to handle JS out of memory notifications - static void JSOutOfMemoryHelper(content::WebContents* tab); + static void JSOutOfMemoryHelper(content::WebContents* web_contents); // Helper function to register a protocol handler. - static void RegisterProtocolHandlerHelper(content::WebContents* tab, + static void RegisterProtocolHandlerHelper(content::WebContents* web_contents, const std::string& protocol, const GURL& url, const string16& title, @@ -666,12 +666,12 @@ class Browser : public TabStripModelDelegate, // |data| is the registered handler data. |user_gesture| is true if the call // was made in the context of a user gesture. static void RegisterIntentHandlerHelper( - content::WebContents* tab, + content::WebContents* web_contents, const webkit_glue::WebIntentServiceData& data, bool user_gesture); // Helper function to handle find results. - static void FindReplyHelper(content::WebContents* tab, + static void FindReplyHelper(content::WebContents* web_contents, int request_id, int number_of_matches, const gfx::Rect& selection_rect, @@ -960,49 +960,52 @@ class Browser : public TabStripModelDelegate, virtual void RendererResponsive(content::WebContents* source) OVERRIDE; virtual void WorkerCrashed(content::WebContents* source) OVERRIDE; virtual void DidNavigateMainFramePostCommit( - content::WebContents* tab) OVERRIDE; - virtual void DidNavigateToPendingEntry(content::WebContents* tab) OVERRIDE; + content::WebContents* web_contents) OVERRIDE; + virtual void DidNavigateToPendingEntry( + content::WebContents* web_contents) OVERRIDE; virtual content::JavaScriptDialogCreator* GetJavaScriptDialogCreator() OVERRIDE; - virtual content::ColorChooser* OpenColorChooser(content::WebContents* tab, - int color_chooser_id, - SkColor color) OVERRIDE; + virtual content::ColorChooser* OpenColorChooser( + content::WebContents* web_contents, + int color_chooser_id, + SkColor color) OVERRIDE; virtual void DidEndColorChooser() OVERRIDE; virtual void RunFileChooser( - content::WebContents* tab, + content::WebContents* web_contents, const content::FileChooserParams& params) OVERRIDE; - virtual void EnumerateDirectory(content::WebContents* tab, int request_id, + virtual void EnumerateDirectory(content::WebContents* web_contents, + int request_id, const FilePath& path) OVERRIDE; - virtual void ToggleFullscreenModeForTab(content::WebContents* tab, + virtual void ToggleFullscreenModeForTab(content::WebContents* web_contents, bool enter_fullscreen) OVERRIDE; virtual bool IsFullscreenForTabOrPending( - const content::WebContents* tab) const OVERRIDE; - virtual void JSOutOfMemory(content::WebContents* tab) OVERRIDE; - virtual void RegisterProtocolHandler(content::WebContents* tab, + const content::WebContents* web_contents) const OVERRIDE; + virtual void JSOutOfMemory(content::WebContents* web_contents) OVERRIDE; + virtual void RegisterProtocolHandler(content::WebContents* web_contents, const std::string& protocol, const GURL& url, const string16& title, bool user_gesture) OVERRIDE; virtual void RegisterIntentHandler( - content::WebContents* tab, + content::WebContents* web_contents, const webkit_glue::WebIntentServiceData& data, bool user_gesture) OVERRIDE; virtual void WebIntentDispatch( - content::WebContents* tab, + content::WebContents* web_contents, content::WebIntentsDispatcher* intents_dispatcher) OVERRIDE; virtual void UpdatePreferredSize(content::WebContents* source, const gfx::Size& pref_size) OVERRIDE; virtual void ResizeDueToAutoResize(content::WebContents* source, const gfx::Size& new_size) OVERRIDE; - virtual void FindReply(content::WebContents* tab, + virtual void FindReply(content::WebContents* web_contents, int request_id, int number_of_matches, const gfx::Rect& selection_rect, int active_match_ordinal, bool final_update) OVERRIDE; - virtual void RequestToLockMouse(content::WebContents* tab, + virtual void RequestToLockMouse(content::WebContents* web_contents, bool user_gesture, bool last_unlocked_by_target) OVERRIDE; virtual void LostMouseLock() OVERRIDE; @@ -1176,10 +1179,11 @@ class Browser : public TabStripModelDelegate, // events since the user cancelled closing the window. void CancelWindowClose(); - // Removes |tab| from the passed |set|. + // Removes |web_contents| from the passed |set|. // Returns whether the tab was in the set in the first place. // TODO(beng): this method needs a better name! - bool RemoveFromSet(UnloadListenerSet* set, content::WebContents* tab); + bool RemoveFromSet(UnloadListenerSet* set, + content::WebContents* web_contents); // Cleans up state appropriately when we are trying to close the browser and // the tab has finished firing its unload handler. We also use this in the @@ -1190,7 +1194,7 @@ class Browser : public TabStripModelDelegate, // Typically you'll want to pass in true for |process_now|. Passing in true // may result in deleting |tab|. If you know that shouldn't happen (because of // the state of the stack), pass in false. - void ClearUnloadState(content::WebContents* tab, bool process_now); + void ClearUnloadState(content::WebContents* web_contents, bool process_now); // In-progress download termination handling ///////////////////////////////// diff --git a/chrome/browser/ui/gtk/location_bar_view_gtk.cc b/chrome/browser/ui/gtk/location_bar_view_gtk.cc index 46f57bd..e08e481 100644 --- a/chrome/browser/ui/gtk/location_bar_view_gtk.cc +++ b/chrome/browser/ui/gtk/location_bar_view_gtk.cc @@ -1377,8 +1377,8 @@ void LocationBarViewGtk::ContentSettingImageViewGtk::UpdateFromWebContents( TabSpecificContentSettings* content_settings = NULL; if (web_contents) { - content_settings = TabContents::GetOwningTabContentsForWebContents( - web_contents)->content_settings(); + content_settings = + TabContents::FromWebContents(web_contents)->content_settings(); } if (!content_settings || content_settings->IsBlockageIndicated( content_setting_image_model_->get_content_settings_type())) diff --git a/chrome/browser/ui/tab_contents/tab_contents.cc b/chrome/browser/ui/tab_contents/tab_contents.cc index 8f0f0db..b6dc733 100644 --- a/chrome/browser/ui/tab_contents/tab_contents.cc +++ b/chrome/browser/ui/tab_contents/tab_contents.cc @@ -73,7 +73,7 @@ TabContents::TabContents(WebContents* contents) in_destructor_(false), web_contents_(contents) { DCHECK(contents); - DCHECK(!GetOwningTabContentsForWebContents(contents)); + DCHECK(!FromWebContents(contents)); chrome::SetViewType(contents, chrome::VIEW_TYPE_TAB_CONTENTS); @@ -220,18 +220,6 @@ const TabContents* TabContents::GetCurrentWrapperForContents( return FromWebContents(contents); } -// static deprecated -TabContents* TabContents::GetOwningTabContentsForWebContents( - WebContents* contents) { - return FromWebContents(contents); -} - -// static deprecated -const TabContents* TabContents::GetOwningTabContentsForWebContents( - const WebContents* contents) { - return FromWebContents(contents); -} - // static TabContents* TabContents::FromWebContents(WebContents* contents) { TabContents** tab_contents = diff --git a/chrome/browser/ui/tab_contents/tab_contents.h b/chrome/browser/ui/tab_contents/tab_contents.h index 6479ca9..0406ae9e 100644 --- a/chrome/browser/ui/tab_contents/tab_contents.h +++ b/chrome/browser/ui/tab_contents/tab_contents.h @@ -108,10 +108,6 @@ class TabContents : public content::WebContentsObserver { content::WebContents* contents); // DEPRECATED static const TabContents* GetCurrentWrapperForContents( const content::WebContents* contents); // DEPRECATED - static TabContents* GetOwningTabContentsForWebContents( - content::WebContents* contents); // DEPRECATED - static const TabContents* GetOwningTabContentsForWebContents( - const content::WebContents* contents); // DEPRECATED static TabContents* FromWebContents(content::WebContents* contents); static const TabContents* FromWebContents( const content::WebContents* contents); diff --git a/chrome/browser/ui/views/location_bar/content_setting_image_view.cc b/chrome/browser/ui/views/location_bar/content_setting_image_view.cc index 49371f1..56f1332 100644 --- a/chrome/browser/ui/views/location_bar/content_setting_image_view.cc +++ b/chrome/browser/ui/views/location_bar/content_setting_image_view.cc @@ -80,8 +80,8 @@ void ContentSettingImageView::UpdateFromWebContents(WebContents* web_contents) { TabSpecificContentSettings* content_settings = NULL; if (web_contents) { - content_settings = TabContents::GetOwningTabContentsForWebContents( - web_contents)->content_settings(); + content_settings = + TabContents::FromWebContents(web_contents)->content_settings(); } if (!content_settings || content_settings->IsBlockageIndicated( content_setting_image_model_->get_content_settings_type())) |