| OLD | NEW |
| 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 Loading... |
| 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 826 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 953 TabContents* contents = GetSelectedTabContents(); | 954 TabContents* contents = GetSelectedTabContents(); |
| 954 string16 title; | 955 string16 title; |
| 955 | 956 |
| 956 // |contents| can be NULL because GetWindowTitleForCurrentTab is called by the | 957 // |contents| can be NULL because GetWindowTitleForCurrentTab is called by the |
| 957 // window during the window's creation (before tabs have been added). | 958 // window during the window's creation (before tabs have been added). |
| 958 if (contents) { | 959 if (contents) { |
| 959 title = contents->GetTitle(); | 960 title = contents->GetTitle(); |
| 960 FormatTitleForDisplay(&title); | 961 FormatTitleForDisplay(&title); |
| 961 } | 962 } |
| 962 if (title.empty()) | 963 if (title.empty()) |
| 963 title = TabContentsWrapper::GetDefaultTitle(); | 964 title = CoreTabHelper::GetDefaultTitle(); |
| 964 | 965 |
| 965 #if defined(OS_MACOSX) || defined(OS_CHROMEOS) | 966 #if defined(OS_MACOSX) || defined(OS_CHROMEOS) |
| 966 // On Mac or ChromeOS, we don't want to suffix the page title with | 967 // On Mac or ChromeOS, we don't want to suffix the page title with |
| 967 // the application name. | 968 // the application name. |
| 968 return title; | 969 return title; |
| 969 #else | 970 #else |
| 970 int string_id = IDS_BROWSER_WINDOW_TITLE_FORMAT; | 971 int string_id = IDS_BROWSER_WINDOW_TITLE_FORMAT; |
| 971 // Don't append the app name to window titles on app frames and app popups | 972 // Don't append the app name to window titles on app frames and app popups |
| 972 if (is_app()) | 973 if (is_app()) |
| 973 string_id = IDS_BROWSER_WINDOW_TITLE_FORMAT_NO_LOGO; | 974 string_id = IDS_BROWSER_WINDOW_TITLE_FORMAT_NO_LOGO; |
| (...skipping 2323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3297 | 3298 |
| 3298 // Update commands to reflect current state. | 3299 // Update commands to reflect current state. |
| 3299 UpdateCommandsForTabState(); | 3300 UpdateCommandsForTabState(); |
| 3300 | 3301 |
| 3301 // Reset the status bubble. | 3302 // Reset the status bubble. |
| 3302 StatusBubble* status_bubble = GetStatusBubble(); | 3303 StatusBubble* status_bubble = GetStatusBubble(); |
| 3303 if (status_bubble) { | 3304 if (status_bubble) { |
| 3304 status_bubble->Hide(); | 3305 status_bubble->Hide(); |
| 3305 | 3306 |
| 3306 // Show the loading state (if any). | 3307 // Show the loading state (if any). |
| 3307 status_bubble->SetStatus(GetSelectedTabContentsWrapper()->GetStatusText()); | 3308 status_bubble->SetStatus( |
| 3309 GetSelectedTabContentsWrapper()->core_tab_helper()->GetStatusText()); |
| 3308 } | 3310 } |
| 3309 | 3311 |
| 3310 if (HasFindBarController()) { | 3312 if (HasFindBarController()) { |
| 3311 find_bar_controller_->ChangeTabContents(new_contents); | 3313 find_bar_controller_->ChangeTabContents(new_contents); |
| 3312 find_bar_controller_->find_bar()->MoveWindowIfNecessary(gfx::Rect(), true); | 3314 find_bar_controller_->find_bar()->MoveWindowIfNecessary(gfx::Rect(), true); |
| 3313 } | 3315 } |
| 3314 | 3316 |
| 3315 // Update sessions. Don't force creation of sessions. If sessions doesn't | 3317 // Update sessions. Don't force creation of sessions. If sessions doesn't |
| 3316 // exist, the change will be picked up by sessions when created. | 3318 // exist, the change will be picked up by sessions when created. |
| 3317 SessionService* session_service = | 3319 SessionService* session_service = |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3496 window_->UpdateLoadingAnimations( | 3498 window_->UpdateLoadingAnimations( |
| 3497 tab_handler_->GetTabStripModel()->TabsAreLoading()); | 3499 tab_handler_->GetTabStripModel()->TabsAreLoading()); |
| 3498 window_->UpdateTitleBar(); | 3500 window_->UpdateTitleBar(); |
| 3499 | 3501 |
| 3500 TabContents* selected_contents = GetSelectedTabContents(); | 3502 TabContents* selected_contents = GetSelectedTabContents(); |
| 3501 if (source == selected_contents) { | 3503 if (source == selected_contents) { |
| 3502 bool is_loading = source->IsLoading(); | 3504 bool is_loading = source->IsLoading(); |
| 3503 UpdateReloadStopState(is_loading, false); | 3505 UpdateReloadStopState(is_loading, false); |
| 3504 if (GetStatusBubble()) { | 3506 if (GetStatusBubble()) { |
| 3505 GetStatusBubble()->SetStatus( | 3507 GetStatusBubble()->SetStatus( |
| 3506 GetSelectedTabContentsWrapper()->GetStatusText()); | 3508 GetSelectedTabContentsWrapper()->core_tab_helper()->GetStatusText()); |
| 3507 } | 3509 } |
| 3508 | 3510 |
| 3509 if (!is_loading && pending_web_app_action_ == UPDATE_SHORTCUT) { | 3511 if (!is_loading && pending_web_app_action_ == UPDATE_SHORTCUT) { |
| 3510 // Schedule a shortcut update when web application info is available if | 3512 // Schedule a shortcut update when web application info is available if |
| 3511 // last committed entry is not NULL. Last committed entry could be NULL | 3513 // last committed entry is not NULL. Last committed entry could be NULL |
| 3512 // when an interstitial page is injected (e.g. bad https certificate, | 3514 // when an interstitial page is injected (e.g. bad https certificate, |
| 3513 // malware site etc). When this happens, we abort the shortcut update. | 3515 // malware site etc). When this happens, we abort the shortcut update. |
| 3514 NavigationEntry* entry = source->controller().GetLastCommittedEntry(); | 3516 NavigationEntry* entry = source->controller().GetLastCommittedEntry(); |
| 3515 if (entry) { | 3517 if (entry) { |
| 3516 TabContentsWrapper::GetCurrentWrapperForContents(source)-> | 3518 TabContentsWrapper::GetCurrentWrapperForContents(source)-> |
| (...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3944 FullscreenExitBubbleType bubble_type) { | 3946 FullscreenExitBubbleType bubble_type) { |
| 3945 fullscreen_controller_->OnAcceptFullscreenPermission(url, bubble_type); | 3947 fullscreen_controller_->OnAcceptFullscreenPermission(url, bubble_type); |
| 3946 } | 3948 } |
| 3947 | 3949 |
| 3948 void Browser::OnDenyFullscreenPermission(FullscreenExitBubbleType bubble_type) { | 3950 void Browser::OnDenyFullscreenPermission(FullscreenExitBubbleType bubble_type) { |
| 3949 fullscreen_controller_->OnDenyFullscreenPermission(bubble_type); | 3951 fullscreen_controller_->OnDenyFullscreenPermission(bubble_type); |
| 3950 } | 3952 } |
| 3951 | 3953 |
| 3952 | 3954 |
| 3953 /////////////////////////////////////////////////////////////////////////////// | 3955 /////////////////////////////////////////////////////////////////////////////// |
| 3954 // Browser, TabContentsWrapperDelegate implementation: | 3956 // Browser, CoreTabHelperDelegate implementation: |
| 3955 | 3957 |
| 3956 void Browser::OnDidGetApplicationInfo(TabContentsWrapper* source, | 3958 void Browser::OnDidGetApplicationInfo(TabContentsWrapper* source, |
| 3957 int32 page_id) { | 3959 int32 page_id) { |
| 3958 if (GetSelectedTabContentsWrapper() != source) | 3960 if (GetSelectedTabContentsWrapper() != source) |
| 3959 return; | 3961 return; |
| 3960 | 3962 |
| 3961 NavigationEntry* entry = source->controller().GetLastCommittedEntry(); | 3963 NavigationEntry* entry = source->controller().GetLastCommittedEntry(); |
| 3962 if (!entry || (entry->page_id() != page_id)) | 3964 if (!entry || (entry->page_id() != page_id)) |
| 3963 return; | 3965 return; |
| 3964 | 3966 |
| (...skipping 821 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4786 // Updates that only matter when the tab is selected go here. | 4788 // Updates that only matter when the tab is selected go here. |
| 4787 | 4789 |
| 4788 if (flags & TabContents::INVALIDATE_PAGE_ACTIONS) { | 4790 if (flags & TabContents::INVALIDATE_PAGE_ACTIONS) { |
| 4789 LocationBar* location_bar = window()->GetLocationBar(); | 4791 LocationBar* location_bar = window()->GetLocationBar(); |
| 4790 if (location_bar) | 4792 if (location_bar) |
| 4791 location_bar->UpdatePageActions(); | 4793 location_bar->UpdatePageActions(); |
| 4792 } | 4794 } |
| 4793 // Updating the URL happens synchronously in ScheduleUIUpdate. | 4795 // Updating the URL happens synchronously in ScheduleUIUpdate. |
| 4794 if (flags & TabContents::INVALIDATE_LOAD && GetStatusBubble()) { | 4796 if (flags & TabContents::INVALIDATE_LOAD && GetStatusBubble()) { |
| 4795 GetStatusBubble()->SetStatus( | 4797 GetStatusBubble()->SetStatus( |
| 4796 GetSelectedTabContentsWrapper()->GetStatusText()); | 4798 GetSelectedTabContentsWrapper()-> |
| 4799 core_tab_helper()->GetStatusText()); |
| 4797 } | 4800 } |
| 4798 | 4801 |
| 4799 if (flags & (TabContents::INVALIDATE_TAB | | 4802 if (flags & (TabContents::INVALIDATE_TAB | |
| 4800 TabContents::INVALIDATE_TITLE)) { | 4803 TabContents::INVALIDATE_TITLE)) { |
| 4801 // TODO(pinkerton): Disable app-mode in the model until we implement it | 4804 // TODO(pinkerton): Disable app-mode in the model until we implement it |
| 4802 // on the Mac. Be sure to remove both ifdefs. http://crbug.com/13148 | 4805 // on the Mac. Be sure to remove both ifdefs. http://crbug.com/13148 |
| 4803 #if !defined(OS_MACOSX) | 4806 #if !defined(OS_MACOSX) |
| 4804 command_updater_.UpdateCommandEnabled(IDC_CREATE_SHORTCUTS, | 4807 command_updater_.UpdateCommandEnabled(IDC_CREATE_SHORTCUTS, |
| 4805 web_app::IsValidUrl(contents->GetURL())); | 4808 web_app::IsValidUrl(contents->GetURL())); |
| 4806 #endif | 4809 #endif |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5001 Browser* Browser::GetOrCreateTabbedBrowser(Profile* profile) { | 5004 Browser* Browser::GetOrCreateTabbedBrowser(Profile* profile) { |
| 5002 Browser* browser = GetTabbedBrowser(profile, false); | 5005 Browser* browser = GetTabbedBrowser(profile, false); |
| 5003 if (!browser) | 5006 if (!browser) |
| 5004 browser = Browser::Create(profile); | 5007 browser = Browser::Create(profile); |
| 5005 return browser; | 5008 return browser; |
| 5006 } | 5009 } |
| 5007 | 5010 |
| 5008 void Browser::SetAsDelegate(TabContentsWrapper* tab, Browser* delegate) { | 5011 void Browser::SetAsDelegate(TabContentsWrapper* tab, Browser* delegate) { |
| 5009 // TabContents... | 5012 // TabContents... |
| 5010 tab->tab_contents()->set_delegate(delegate); | 5013 tab->tab_contents()->set_delegate(delegate); |
| 5011 tab->set_delegate(delegate); | |
| 5012 | 5014 |
| 5013 // ...and all the helpers. | 5015 // ...and all the helpers. |
| 5014 tab->blocked_content_tab_helper()->set_delegate(delegate); | 5016 tab->blocked_content_tab_helper()->set_delegate(delegate); |
| 5015 tab->bookmark_tab_helper()->set_delegate(delegate); | 5017 tab->bookmark_tab_helper()->set_delegate(delegate); |
| 5016 tab->constrained_window_tab_helper()->set_delegate(delegate); | 5018 tab->constrained_window_tab_helper()->set_delegate(delegate); |
| 5019 tab->core_tab_helper()->set_delegate(delegate); |
| 5017 tab->extension_tab_helper()->set_delegate(delegate); | 5020 tab->extension_tab_helper()->set_delegate(delegate); |
| 5018 tab->search_engine_tab_helper()->set_delegate(delegate); | 5021 tab->search_engine_tab_helper()->set_delegate(delegate); |
| 5019 } | 5022 } |
| 5020 | 5023 |
| 5021 void Browser::FindInPage(bool find_next, bool forward_direction) { | 5024 void Browser::FindInPage(bool find_next, bool forward_direction) { |
| 5022 ShowFindBar(); | 5025 ShowFindBar(); |
| 5023 if (find_next) { | 5026 if (find_next) { |
| 5024 string16 find_text; | 5027 string16 find_text; |
| 5025 #if defined(OS_MACOSX) | 5028 #if defined(OS_MACOSX) |
| 5026 // We always want to search for the contents of the find pasteboard on OS X. | 5029 // 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 Loading... |
| 5333 window_->GetLocationBar()->ShowFirstRunBubble(bubble_type); | 5336 window_->GetLocationBar()->ShowFirstRunBubble(bubble_type); |
| 5334 } else { | 5337 } else { |
| 5335 GlobalErrorService* service = | 5338 GlobalErrorService* service = |
| 5336 GlobalErrorServiceFactory::GetForProfile(profile()); | 5339 GlobalErrorServiceFactory::GetForProfile(profile()); |
| 5337 GlobalError* error = service->GetFirstGlobalErrorWithBubbleView(); | 5340 GlobalError* error = service->GetFirstGlobalErrorWithBubbleView(); |
| 5338 if (error) { | 5341 if (error) { |
| 5339 error->ShowBubbleView(this); | 5342 error->ShowBubbleView(this); |
| 5340 } | 5343 } |
| 5341 } | 5344 } |
| 5342 } | 5345 } |
| OLD | NEW |