Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(789)

Side by Side Diff: chrome/browser/ui/browser.cc

Issue 8865004: Create CoreTabHelper, move remaining core TCW functionality into it. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/browser.h" 5 #include "chrome/browser/ui/browser.h"
6 6
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <windows.h> 8 #include <windows.h>
9 #include <shellapi.h> 9 #include <shellapi.h>
10 #endif // OS_WIN 10 #endif // OS_WIN
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 #include "chrome/browser/ui/global_error.h" 107 #include "chrome/browser/ui/global_error.h"
108 #include "chrome/browser/ui/global_error_service.h" 108 #include "chrome/browser/ui/global_error_service.h"
109 #include "chrome/browser/ui/global_error_service_factory.h" 109 #include "chrome/browser/ui/global_error_service_factory.h"
110 #include "chrome/browser/ui/intents/web_intent_picker_controller.h" 110 #include "chrome/browser/ui/intents/web_intent_picker_controller.h"
111 #include "chrome/browser/ui/omnibox/location_bar.h" 111 #include "chrome/browser/ui/omnibox/location_bar.h"
112 #include "chrome/browser/ui/panels/panel.h" 112 #include "chrome/browser/ui/panels/panel.h"
113 #include "chrome/browser/ui/panels/panel_manager.h" 113 #include "chrome/browser/ui/panels/panel_manager.h"
114 #include "chrome/browser/ui/search_engines/search_engine_tab_helper.h" 114 #include "chrome/browser/ui/search_engines/search_engine_tab_helper.h"
115 #include "chrome/browser/ui/status_bubble.h" 115 #include "chrome/browser/ui/status_bubble.h"
116 #include "chrome/browser/ui/sync/browser_synced_window_delegate.h" 116 #include "chrome/browser/ui/sync/browser_synced_window_delegate.h"
117 #include "chrome/browser/ui/tab_contents/core_tab_helper.h"
117 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 118 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
118 #include "chrome/browser/ui/tabs/dock_info.h" 119 #include "chrome/browser/ui/tabs/dock_info.h"
119 #include "chrome/browser/ui/tabs/tab_menu_model.h" 120 #include "chrome/browser/ui/tabs/tab_menu_model.h"
120 #include "chrome/browser/ui/web_applications/web_app_ui.h" 121 #include "chrome/browser/ui/web_applications/web_app_ui.h"
121 #include "chrome/browser/ui/webui/bug_report_ui.h" 122 #include "chrome/browser/ui/webui/bug_report_ui.h"
122 #include "chrome/browser/ui/webui/chrome_web_ui.h" 123 #include "chrome/browser/ui/webui/chrome_web_ui.h"
123 #include "chrome/browser/ui/webui/ntp/new_tab_page_handler.h" 124 #include "chrome/browser/ui/webui/ntp/new_tab_page_handler.h"
124 #include "chrome/browser/ui/webui/options/content_settings_handler.h" 125 #include "chrome/browser/ui/webui/options/content_settings_handler.h"
125 #include "chrome/browser/ui/window_sizer.h" 126 #include "chrome/browser/ui/window_sizer.h"
126 #include "chrome/browser/upgrade_detector.h" 127 #include "chrome/browser/upgrade_detector.h"
(...skipping 824 matching lines...) Expand 10 before | Expand all | Expand 10 after
951 TabContents* contents = GetSelectedTabContents(); 952 TabContents* contents = GetSelectedTabContents();
952 string16 title; 953 string16 title;
953 954
954 // |contents| can be NULL because GetWindowTitleForCurrentTab is called by the 955 // |contents| can be NULL because GetWindowTitleForCurrentTab is called by the
955 // window during the window's creation (before tabs have been added). 956 // window during the window's creation (before tabs have been added).
956 if (contents) { 957 if (contents) {
957 title = contents->GetTitle(); 958 title = contents->GetTitle();
958 FormatTitleForDisplay(&title); 959 FormatTitleForDisplay(&title);
959 } 960 }
960 if (title.empty()) 961 if (title.empty())
961 title = TabContentsWrapper::GetDefaultTitle(); 962 title = CoreTabHelper::GetDefaultTitle();
962 963
963 #if defined(OS_MACOSX) || defined(OS_CHROMEOS) 964 #if defined(OS_MACOSX) || defined(OS_CHROMEOS)
964 // On Mac or ChromeOS, we don't want to suffix the page title with 965 // On Mac or ChromeOS, we don't want to suffix the page title with
965 // the application name. 966 // the application name.
966 return title; 967 return title;
967 #else 968 #else
968 int string_id = IDS_BROWSER_WINDOW_TITLE_FORMAT; 969 int string_id = IDS_BROWSER_WINDOW_TITLE_FORMAT;
969 // Don't append the app name to window titles on app frames and app popups 970 // Don't append the app name to window titles on app frames and app popups
970 if (is_app()) 971 if (is_app())
971 string_id = IDS_BROWSER_WINDOW_TITLE_FORMAT_NO_LOGO; 972 string_id = IDS_BROWSER_WINDOW_TITLE_FORMAT_NO_LOGO;
(...skipping 2316 matching lines...) Expand 10 before | Expand all | Expand 10 after
3288 3289
3289 // Update commands to reflect current state. 3290 // Update commands to reflect current state.
3290 UpdateCommandsForTabState(); 3291 UpdateCommandsForTabState();
3291 3292
3292 // Reset the status bubble. 3293 // Reset the status bubble.
3293 StatusBubble* status_bubble = GetStatusBubble(); 3294 StatusBubble* status_bubble = GetStatusBubble();
3294 if (status_bubble) { 3295 if (status_bubble) {
3295 status_bubble->Hide(); 3296 status_bubble->Hide();
3296 3297
3297 // Show the loading state (if any). 3298 // Show the loading state (if any).
3298 status_bubble->SetStatus(GetSelectedTabContentsWrapper()->GetStatusText()); 3299 status_bubble->SetStatus(
3300 GetSelectedTabContentsWrapper()->core_tab_helper()->GetStatusText());
3299 } 3301 }
3300 3302
3301 if (HasFindBarController()) { 3303 if (HasFindBarController()) {
3302 find_bar_controller_->ChangeTabContents(new_contents); 3304 find_bar_controller_->ChangeTabContents(new_contents);
3303 find_bar_controller_->find_bar()->MoveWindowIfNecessary(gfx::Rect(), true); 3305 find_bar_controller_->find_bar()->MoveWindowIfNecessary(gfx::Rect(), true);
3304 } 3306 }
3305 3307
3306 // Update sessions. Don't force creation of sessions. If sessions doesn't 3308 // Update sessions. Don't force creation of sessions. If sessions doesn't
3307 // exist, the change will be picked up by sessions when created. 3309 // exist, the change will be picked up by sessions when created.
3308 SessionService* session_service = 3310 SessionService* session_service =
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
3487 window_->UpdateLoadingAnimations( 3489 window_->UpdateLoadingAnimations(
3488 tab_handler_->GetTabStripModel()->TabsAreLoading()); 3490 tab_handler_->GetTabStripModel()->TabsAreLoading());
3489 window_->UpdateTitleBar(); 3491 window_->UpdateTitleBar();
3490 3492
3491 TabContents* selected_contents = GetSelectedTabContents(); 3493 TabContents* selected_contents = GetSelectedTabContents();
3492 if (source == selected_contents) { 3494 if (source == selected_contents) {
3493 bool is_loading = source->IsLoading(); 3495 bool is_loading = source->IsLoading();
3494 UpdateReloadStopState(is_loading, false); 3496 UpdateReloadStopState(is_loading, false);
3495 if (GetStatusBubble()) { 3497 if (GetStatusBubble()) {
3496 GetStatusBubble()->SetStatus( 3498 GetStatusBubble()->SetStatus(
3497 GetSelectedTabContentsWrapper()->GetStatusText()); 3499 GetSelectedTabContentsWrapper()->core_tab_helper()->GetStatusText());
3498 } 3500 }
3499 3501
3500 if (!is_loading && pending_web_app_action_ == UPDATE_SHORTCUT) { 3502 if (!is_loading && pending_web_app_action_ == UPDATE_SHORTCUT) {
3501 // Schedule a shortcut update when web application info is available if 3503 // Schedule a shortcut update when web application info is available if
3502 // last committed entry is not NULL. Last committed entry could be NULL 3504 // last committed entry is not NULL. Last committed entry could be NULL
3503 // when an interstitial page is injected (e.g. bad https certificate, 3505 // when an interstitial page is injected (e.g. bad https certificate,
3504 // malware site etc). When this happens, we abort the shortcut update. 3506 // malware site etc). When this happens, we abort the shortcut update.
3505 NavigationEntry* entry = source->controller().GetLastCommittedEntry(); 3507 NavigationEntry* entry = source->controller().GetLastCommittedEntry();
3506 if (entry) { 3508 if (entry) {
3507 TabContentsWrapper::GetCurrentWrapperForContents(source)-> 3509 TabContentsWrapper::GetCurrentWrapperForContents(source)->
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after
3935 FullscreenExitBubbleType bubble_type) { 3937 FullscreenExitBubbleType bubble_type) {
3936 fullscreen_controller_->OnAcceptFullscreenPermission(url, bubble_type); 3938 fullscreen_controller_->OnAcceptFullscreenPermission(url, bubble_type);
3937 } 3939 }
3938 3940
3939 void Browser::OnDenyFullscreenPermission(FullscreenExitBubbleType bubble_type) { 3941 void Browser::OnDenyFullscreenPermission(FullscreenExitBubbleType bubble_type) {
3940 fullscreen_controller_->OnDenyFullscreenPermission(bubble_type); 3942 fullscreen_controller_->OnDenyFullscreenPermission(bubble_type);
3941 } 3943 }
3942 3944
3943 3945
3944 /////////////////////////////////////////////////////////////////////////////// 3946 ///////////////////////////////////////////////////////////////////////////////
3945 // Browser, TabContentsWrapperDelegate implementation: 3947 // Browser, CoreTabHelperDelegate implementation:
3946 3948
3947 void Browser::OnDidGetApplicationInfo(TabContentsWrapper* source, 3949 void Browser::OnDidGetApplicationInfo(TabContentsWrapper* source,
3948 int32 page_id) { 3950 int32 page_id) {
3949 if (GetSelectedTabContentsWrapper() != source) 3951 if (GetSelectedTabContentsWrapper() != source)
3950 return; 3952 return;
3951 3953
3952 NavigationEntry* entry = source->controller().GetLastCommittedEntry(); 3954 NavigationEntry* entry = source->controller().GetLastCommittedEntry();
3953 if (!entry || (entry->page_id() != page_id)) 3955 if (!entry || (entry->page_id() != page_id))
3954 return; 3956 return;
3955 3957
(...skipping 820 matching lines...) Expand 10 before | Expand all | Expand 10 after
4776 // Updates that only matter when the tab is selected go here. 4778 // Updates that only matter when the tab is selected go here.
4777 4779
4778 if (flags & TabContents::INVALIDATE_PAGE_ACTIONS) { 4780 if (flags & TabContents::INVALIDATE_PAGE_ACTIONS) {
4779 LocationBar* location_bar = window()->GetLocationBar(); 4781 LocationBar* location_bar = window()->GetLocationBar();
4780 if (location_bar) 4782 if (location_bar)
4781 location_bar->UpdatePageActions(); 4783 location_bar->UpdatePageActions();
4782 } 4784 }
4783 // Updating the URL happens synchronously in ScheduleUIUpdate. 4785 // Updating the URL happens synchronously in ScheduleUIUpdate.
4784 if (flags & TabContents::INVALIDATE_LOAD && GetStatusBubble()) { 4786 if (flags & TabContents::INVALIDATE_LOAD && GetStatusBubble()) {
4785 GetStatusBubble()->SetStatus( 4787 GetStatusBubble()->SetStatus(
4786 GetSelectedTabContentsWrapper()->GetStatusText()); 4788 GetSelectedTabContentsWrapper()->
4789 core_tab_helper()->GetStatusText());
4787 } 4790 }
4788 4791
4789 if (flags & (TabContents::INVALIDATE_TAB | 4792 if (flags & (TabContents::INVALIDATE_TAB |
4790 TabContents::INVALIDATE_TITLE)) { 4793 TabContents::INVALIDATE_TITLE)) {
4791 // TODO(pinkerton): Disable app-mode in the model until we implement it 4794 // TODO(pinkerton): Disable app-mode in the model until we implement it
4792 // on the Mac. Be sure to remove both ifdefs. http://crbug.com/13148 4795 // on the Mac. Be sure to remove both ifdefs. http://crbug.com/13148
4793 #if !defined(OS_MACOSX) 4796 #if !defined(OS_MACOSX)
4794 command_updater_.UpdateCommandEnabled(IDC_CREATE_SHORTCUTS, 4797 command_updater_.UpdateCommandEnabled(IDC_CREATE_SHORTCUTS,
4795 web_app::IsValidUrl(contents->GetURL())); 4798 web_app::IsValidUrl(contents->GetURL()));
4796 #endif 4799 #endif
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
4991 Browser* Browser::GetOrCreateTabbedBrowser(Profile* profile) { 4994 Browser* Browser::GetOrCreateTabbedBrowser(Profile* profile) {
4992 Browser* browser = GetTabbedBrowser(profile, false); 4995 Browser* browser = GetTabbedBrowser(profile, false);
4993 if (!browser) 4996 if (!browser)
4994 browser = Browser::Create(profile); 4997 browser = Browser::Create(profile);
4995 return browser; 4998 return browser;
4996 } 4999 }
4997 5000
4998 void Browser::SetAsDelegate(TabContentsWrapper* tab, Browser* delegate) { 5001 void Browser::SetAsDelegate(TabContentsWrapper* tab, Browser* delegate) {
4999 // TabContents... 5002 // TabContents...
5000 tab->tab_contents()->set_delegate(delegate); 5003 tab->tab_contents()->set_delegate(delegate);
5001 tab->set_delegate(delegate);
5002 5004
5003 // ...and all the helpers. 5005 // ...and all the helpers.
5004 tab->blocked_content_tab_helper()->set_delegate(delegate); 5006 tab->blocked_content_tab_helper()->set_delegate(delegate);
5005 tab->bookmark_tab_helper()->set_delegate(delegate); 5007 tab->bookmark_tab_helper()->set_delegate(delegate);
5006 tab->constrained_window_tab_helper()->set_delegate(delegate); 5008 tab->constrained_window_tab_helper()->set_delegate(delegate);
5009 tab->core_tab_helper()->set_delegate(delegate);
5007 tab->extension_tab_helper()->set_delegate(delegate); 5010 tab->extension_tab_helper()->set_delegate(delegate);
5008 tab->search_engine_tab_helper()->set_delegate(delegate); 5011 tab->search_engine_tab_helper()->set_delegate(delegate);
5009 } 5012 }
5010 5013
5011 void Browser::FindInPage(bool find_next, bool forward_direction) { 5014 void Browser::FindInPage(bool find_next, bool forward_direction) {
5012 ShowFindBar(); 5015 ShowFindBar();
5013 if (find_next) { 5016 if (find_next) {
5014 string16 find_text; 5017 string16 find_text;
5015 #if defined(OS_MACOSX) 5018 #if defined(OS_MACOSX)
5016 // We always want to search for the contents of the find pasteboard on OS X. 5019 // We always want to search for the contents of the find pasteboard on OS X.
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
5323 window_->GetLocationBar()->ShowFirstRunBubble(bubble_type); 5326 window_->GetLocationBar()->ShowFirstRunBubble(bubble_type);
5324 } else { 5327 } else {
5325 GlobalErrorService* service = 5328 GlobalErrorService* service =
5326 GlobalErrorServiceFactory::GetForProfile(profile()); 5329 GlobalErrorServiceFactory::GetForProfile(profile());
5327 GlobalError* error = service->GetFirstGlobalErrorWithBubbleView(); 5330 GlobalError* error = service->GetFirstGlobalErrorWithBubbleView();
5328 if (error) { 5331 if (error) {
5329 error->ShowBubbleView(this); 5332 error->ShowBubbleView(this);
5330 } 5333 }
5331 } 5334 }
5332 } 5335 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698