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 <shellapi.h> | 8 #include <shellapi.h> |
9 #include <windows.h> | 9 #include <windows.h> |
10 #endif // OS_WIN | 10 #endif // OS_WIN |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 #include "chrome/common/chrome_switches.h" | 95 #include "chrome/common/chrome_switches.h" |
96 #include "chrome/common/content_restriction.h" | 96 #include "chrome/common/content_restriction.h" |
97 #include "chrome/common/extensions/extension.h" | 97 #include "chrome/common/extensions/extension.h" |
98 #include "chrome/common/extensions/extension_constants.h" | 98 #include "chrome/common/extensions/extension_constants.h" |
99 #include "chrome/common/notification_service.h" | 99 #include "chrome/common/notification_service.h" |
100 #include "chrome/common/page_transition_types.h" | 100 #include "chrome/common/page_transition_types.h" |
101 #include "chrome/common/pref_names.h" | 101 #include "chrome/common/pref_names.h" |
102 #include "chrome/common/profiling.h" | 102 #include "chrome/common/profiling.h" |
103 #include "chrome/common/url_constants.h" | 103 #include "chrome/common/url_constants.h" |
104 #include "chrome/common/web_apps.h" | 104 #include "chrome/common/web_apps.h" |
| 105 #include "content/browser/tab_contents/infobar_delegate.h" |
105 #include "grit/chromium_strings.h" | 106 #include "grit/chromium_strings.h" |
106 #include "grit/generated_resources.h" | 107 #include "grit/generated_resources.h" |
107 #include "grit/locale_settings.h" | 108 #include "grit/locale_settings.h" |
108 #include "net/base/cookie_monster.h" | 109 #include "net/base/cookie_monster.h" |
109 #include "net/base/net_util.h" | 110 #include "net/base/net_util.h" |
110 #include "net/base/registry_controlled_domain.h" | 111 #include "net/base/registry_controlled_domain.h" |
111 #include "net/base/static_cookie_policy.h" | 112 #include "net/base/static_cookie_policy.h" |
112 #include "net/url_request/url_request_context.h" | 113 #include "net/url_request/url_request_context.h" |
113 #include "ui/base/animation/animation.h" | 114 #include "ui/base/animation/animation.h" |
114 #include "ui/base/l10n/l10n_util.h" | 115 #include "ui/base/l10n/l10n_util.h" |
(...skipping 703 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
818 TabContents* contents = GetSelectedTabContents(); | 819 TabContents* contents = GetSelectedTabContents(); |
819 string16 title; | 820 string16 title; |
820 | 821 |
821 // |contents| can be NULL because GetWindowTitleForCurrentTab is called by the | 822 // |contents| can be NULL because GetWindowTitleForCurrentTab is called by the |
822 // window during the window's creation (before tabs have been added). | 823 // window during the window's creation (before tabs have been added). |
823 if (contents) { | 824 if (contents) { |
824 title = contents->GetTitle(); | 825 title = contents->GetTitle(); |
825 FormatTitleForDisplay(&title); | 826 FormatTitleForDisplay(&title); |
826 } | 827 } |
827 if (title.empty()) | 828 if (title.empty()) |
828 title = TabContents::GetDefaultTitle(); | 829 title = TabContentsWrapper::GetDefaultTitle(); |
829 | 830 |
830 #if defined(OS_MACOSX) || defined(OS_CHROMEOS) | 831 #if defined(OS_MACOSX) || defined(OS_CHROMEOS) |
831 // On Mac or ChromeOS, we don't want to suffix the page title with | 832 // On Mac or ChromeOS, we don't want to suffix the page title with |
832 // the application name. | 833 // the application name. |
833 return title; | 834 return title; |
834 #elif defined(OS_WIN) || defined(OS_LINUX) | 835 #elif defined(OS_WIN) || defined(OS_LINUX) |
835 int string_id = IDS_BROWSER_WINDOW_TITLE_FORMAT; | 836 int string_id = IDS_BROWSER_WINDOW_TITLE_FORMAT; |
836 // Don't append the app name to window titles on app frames and app popups | 837 // Don't append the app name to window titles on app frames and app popups |
837 if (type_ & TYPE_APP) | 838 if (type_ & TYPE_APP) |
838 string_id = IDS_BROWSER_WINDOW_TITLE_FORMAT_NO_LOGO; | 839 string_id = IDS_BROWSER_WINDOW_TITLE_FORMAT_NO_LOGO; |
(...skipping 1900 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2739 | 2740 |
2740 // Update commands to reflect current state. | 2741 // Update commands to reflect current state. |
2741 UpdateCommandsForTabState(); | 2742 UpdateCommandsForTabState(); |
2742 | 2743 |
2743 // Reset the status bubble. | 2744 // Reset the status bubble. |
2744 StatusBubble* status_bubble = GetStatusBubble(); | 2745 StatusBubble* status_bubble = GetStatusBubble(); |
2745 if (status_bubble) { | 2746 if (status_bubble) { |
2746 status_bubble->Hide(); | 2747 status_bubble->Hide(); |
2747 | 2748 |
2748 // Show the loading state (if any). | 2749 // Show the loading state (if any). |
2749 status_bubble->SetStatus(GetSelectedTabContents()->GetStatusText()); | 2750 status_bubble->SetStatus(GetSelectedTabContentsWrapper()->GetStatusText()); |
2750 } | 2751 } |
2751 | 2752 |
2752 if (HasFindBarController()) { | 2753 if (HasFindBarController()) { |
2753 find_bar_controller_->ChangeTabContents(new_contents); | 2754 find_bar_controller_->ChangeTabContents(new_contents); |
2754 find_bar_controller_->find_bar()->MoveWindowIfNecessary(gfx::Rect(), true); | 2755 find_bar_controller_->find_bar()->MoveWindowIfNecessary(gfx::Rect(), true); |
2755 } | 2756 } |
2756 | 2757 |
2757 // Update sessions. Don't force creation of sessions. If sessions doesn't | 2758 // Update sessions. Don't force creation of sessions. If sessions doesn't |
2758 // exist, the change will be picked up by sessions when created. | 2759 // exist, the change will be picked up by sessions when created. |
2759 if (profile_->HasSessionService()) { | 2760 if (profile_->HasSessionService()) { |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2910 | 2911 |
2911 void Browser::LoadingStateChanged(TabContents* source) { | 2912 void Browser::LoadingStateChanged(TabContents* source) { |
2912 window_->UpdateLoadingAnimations( | 2913 window_->UpdateLoadingAnimations( |
2913 tab_handler_->GetTabStripModel()->TabsAreLoading()); | 2914 tab_handler_->GetTabStripModel()->TabsAreLoading()); |
2914 window_->UpdateTitleBar(); | 2915 window_->UpdateTitleBar(); |
2915 | 2916 |
2916 TabContents* selected_contents = GetSelectedTabContents(); | 2917 TabContents* selected_contents = GetSelectedTabContents(); |
2917 if (source == selected_contents) { | 2918 if (source == selected_contents) { |
2918 UpdateReloadStopState(source->is_loading(), false); | 2919 UpdateReloadStopState(source->is_loading(), false); |
2919 if (GetStatusBubble()) { | 2920 if (GetStatusBubble()) { |
2920 GetStatusBubble()->SetStatus(GetSelectedTabContents()->GetStatusText()); | 2921 GetStatusBubble()->SetStatus( |
| 2922 GetSelectedTabContentsWrapper()->GetStatusText()); |
2921 } | 2923 } |
2922 | 2924 |
2923 if (!source->is_loading() && | 2925 if (!source->is_loading() && |
2924 pending_web_app_action_ == UPDATE_SHORTCUT) { | 2926 pending_web_app_action_ == UPDATE_SHORTCUT) { |
2925 // Schedule a shortcut update when web application info is available if | 2927 // Schedule a shortcut update when web application info is available if |
2926 // last committed entry is not NULL. Last committed entry could be NULL | 2928 // last committed entry is not NULL. Last committed entry could be NULL |
2927 // when an interstitial page is injected (e.g. bad https certificate, | 2929 // when an interstitial page is injected (e.g. bad https certificate, |
2928 // malware site etc). When this happens, we abort the shortcut update. | 2930 // malware site etc). When this happens, we abort the shortcut update. |
2929 NavigationEntry* entry = source->controller().GetLastCommittedEntry(); | 2931 NavigationEntry* entry = source->controller().GetLastCommittedEntry(); |
2930 if (entry) { | 2932 if (entry) { |
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3260 new CrxInstaller(extensions_service, | 3262 new CrxInstaller(extensions_service, |
3261 extensions_service->show_extensions_prompts() ? | 3263 extensions_service->show_extensions_prompts() ? |
3262 new ExtensionInstallUI(profile()) : NULL)); | 3264 new ExtensionInstallUI(profile()) : NULL)); |
3263 installer->InstallWebApp(web_app); | 3265 installer->InstallWebApp(web_app); |
3264 } | 3266 } |
3265 | 3267 |
3266 void Browser::ContentRestrictionsChanged(TabContents* source) { | 3268 void Browser::ContentRestrictionsChanged(TabContents* source) { |
3267 UpdateCommandsForContentRestrictionState(); | 3269 UpdateCommandsForContentRestrictionState(); |
3268 } | 3270 } |
3269 | 3271 |
| 3272 void Browser::WorkerCrashed() { |
| 3273 TabContents* tab_contents = GetSelectedTabContents(); |
| 3274 if (!tab_contents) |
| 3275 return; |
| 3276 tab_contents->AddInfoBar(new SimpleAlertInfoBarDelegate(tab_contents, NULL, |
| 3277 l10n_util::GetStringUTF16(IDS_WEBWORKER_CRASHED_PROMPT), true)); |
| 3278 } |
| 3279 |
3270 /////////////////////////////////////////////////////////////////////////////// | 3280 /////////////////////////////////////////////////////////////////////////////// |
3271 // Browser, TabContentsWrapperDelegate implementation: | 3281 // Browser, TabContentsWrapperDelegate implementation: |
3272 | 3282 |
3273 void Browser::URLStarredChanged(TabContentsWrapper* source, bool starred) { | 3283 void Browser::URLStarredChanged(TabContentsWrapper* source, bool starred) { |
3274 if (source == GetSelectedTabContentsWrapper()) | 3284 if (source == GetSelectedTabContentsWrapper()) |
3275 window_->SetStarredState(starred); | 3285 window_->SetStarredState(starred); |
3276 } | 3286 } |
3277 | 3287 |
3278 /////////////////////////////////////////////////////////////////////////////// | 3288 /////////////////////////////////////////////////////////////////////////////// |
3279 // Browser, SearchEngineTabHelperDelegate implementation: | 3289 // Browser, SearchEngineTabHelperDelegate implementation: |
(...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3877 const TabContents* contents = i->first; | 3887 const TabContents* contents = i->first; |
3878 unsigned flags = i->second; | 3888 unsigned flags = i->second; |
3879 | 3889 |
3880 if (contents == GetSelectedTabContents()) { | 3890 if (contents == GetSelectedTabContents()) { |
3881 // Updates that only matter when the tab is selected go here. | 3891 // Updates that only matter when the tab is selected go here. |
3882 | 3892 |
3883 if (flags & TabContents::INVALIDATE_PAGE_ACTIONS) | 3893 if (flags & TabContents::INVALIDATE_PAGE_ACTIONS) |
3884 window()->GetLocationBar()->UpdatePageActions(); | 3894 window()->GetLocationBar()->UpdatePageActions(); |
3885 | 3895 |
3886 // Updating the URL happens synchronously in ScheduleUIUpdate. | 3896 // Updating the URL happens synchronously in ScheduleUIUpdate. |
3887 if (flags & TabContents::INVALIDATE_LOAD && GetStatusBubble()) | 3897 if (flags & TabContents::INVALIDATE_LOAD && GetStatusBubble()) { |
3888 GetStatusBubble()->SetStatus(contents->GetStatusText()); | 3898 GetStatusBubble()->SetStatus( |
| 3899 GetSelectedTabContentsWrapper()->GetStatusText()); |
| 3900 } |
3889 | 3901 |
3890 if (flags & (TabContents::INVALIDATE_TAB | | 3902 if (flags & (TabContents::INVALIDATE_TAB | |
3891 TabContents::INVALIDATE_TITLE)) { | 3903 TabContents::INVALIDATE_TITLE)) { |
3892 // TODO(pinkerton): Disable app-mode in the model until we implement it | 3904 // TODO(pinkerton): Disable app-mode in the model until we implement it |
3893 // on the Mac. Be sure to remove both ifdefs. http://crbug.com/13148 | 3905 // on the Mac. Be sure to remove both ifdefs. http://crbug.com/13148 |
3894 #if !defined(OS_MACOSX) | 3906 #if !defined(OS_MACOSX) |
3895 command_updater_.UpdateCommandEnabled(IDC_CREATE_SHORTCUTS, | 3907 command_updater_.UpdateCommandEnabled(IDC_CREATE_SHORTCUTS, |
3896 web_app::IsValidUrl(contents->GetURL())); | 3908 web_app::IsValidUrl(contents->GetURL())); |
3897 #endif | 3909 #endif |
3898 window_->UpdateTitleBar(); | 3910 window_->UpdateTitleBar(); |
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4376 // The page transition below is only for the purpose of inserting the tab. | 4388 // The page transition below is only for the purpose of inserting the tab. |
4377 browser->AddTab(view_source_contents, PageTransition::LINK); | 4389 browser->AddTab(view_source_contents, PageTransition::LINK); |
4378 } | 4390 } |
4379 | 4391 |
4380 if (profile_->HasSessionService()) { | 4392 if (profile_->HasSessionService()) { |
4381 SessionService* session_service = profile_->GetSessionService(); | 4393 SessionService* session_service = profile_->GetSessionService(); |
4382 if (session_service) | 4394 if (session_service) |
4383 session_service->TabRestored(&view_source_contents->controller(), false); | 4395 session_service->TabRestored(&view_source_contents->controller(), false); |
4384 } | 4396 } |
4385 } | 4397 } |
OLD | NEW |