| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 // defined(OS_WIN) | 10 #endif // defined(OS_WIN) |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 #include "chrome/browser/devtools/devtools_window.h" | 48 #include "chrome/browser/devtools/devtools_window.h" |
| 49 #include "chrome/browser/download/download_item_model.h" | 49 #include "chrome/browser/download/download_item_model.h" |
| 50 #include "chrome/browser/download/download_service.h" | 50 #include "chrome/browser/download/download_service.h" |
| 51 #include "chrome/browser/download/download_service_factory.h" | 51 #include "chrome/browser/download/download_service_factory.h" |
| 52 #include "chrome/browser/download/download_shelf.h" | 52 #include "chrome/browser/download/download_shelf.h" |
| 53 #include "chrome/browser/extensions/browser_extension_window_controller.h" | 53 #include "chrome/browser/extensions/browser_extension_window_controller.h" |
| 54 #include "chrome/browser/extensions/extension_prefs.h" | 54 #include "chrome/browser/extensions/extension_prefs.h" |
| 55 #include "chrome/browser/extensions/extension_service.h" | 55 #include "chrome/browser/extensions/extension_service.h" |
| 56 #include "chrome/browser/extensions/extension_system.h" | 56 #include "chrome/browser/extensions/extension_system.h" |
| 57 #include "chrome/browser/extensions/tab_helper.h" | 57 #include "chrome/browser/extensions/tab_helper.h" |
| 58 #include "chrome/browser/favicon/favicon_tab_helper.h" | |
| 59 #include "chrome/browser/file_select_helper.h" | 58 #include "chrome/browser/file_select_helper.h" |
| 60 #include "chrome/browser/first_run/first_run.h" | 59 #include "chrome/browser/first_run/first_run.h" |
| 61 #include "chrome/browser/google/google_url_tracker.h" | 60 #include "chrome/browser/google/google_url_tracker.h" |
| 62 #include "chrome/browser/infobars/infobar_service.h" | 61 #include "chrome/browser/infobars/infobar_service.h" |
| 63 #include "chrome/browser/infobars/simple_alert_infobar_delegate.h" | 62 #include "chrome/browser/infobars/simple_alert_infobar_delegate.h" |
| 64 #include "chrome/browser/lifetime/application_lifetime.h" | 63 #include "chrome/browser/lifetime/application_lifetime.h" |
| 65 #include "chrome/browser/notifications/notification_ui_manager.h" | 64 #include "chrome/browser/notifications/notification_ui_manager.h" |
| 66 #include "chrome/browser/pepper_broker_infobar_delegate.h" | 65 #include "chrome/browser/pepper_broker_infobar_delegate.h" |
| 67 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 66 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
| 68 #include "chrome/browser/profiles/profile.h" | 67 #include "chrome/browser/profiles/profile.h" |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 #include "chrome/browser/ui/singleton_tabs.h" | 125 #include "chrome/browser/ui/singleton_tabs.h" |
| 127 #include "chrome/browser/ui/status_bubble.h" | 126 #include "chrome/browser/ui/status_bubble.h" |
| 128 #include "chrome/browser/ui/sync/browser_synced_window_delegate.h" | 127 #include "chrome/browser/ui/sync/browser_synced_window_delegate.h" |
| 129 #include "chrome/browser/ui/tab_contents/core_tab_helper.h" | 128 #include "chrome/browser/ui/tab_contents/core_tab_helper.h" |
| 130 #include "chrome/browser/ui/tab_modal_confirm_dialog.h" | 129 #include "chrome/browser/ui/tab_modal_confirm_dialog.h" |
| 131 #include "chrome/browser/ui/tabs/dock_info.h" | 130 #include "chrome/browser/ui/tabs/dock_info.h" |
| 132 #include "chrome/browser/ui/tabs/tab_menu_model.h" | 131 #include "chrome/browser/ui/tabs/tab_menu_model.h" |
| 133 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 132 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 134 #include "chrome/browser/ui/toolbar/toolbar_model_impl.h" | 133 #include "chrome/browser/ui/toolbar/toolbar_model_impl.h" |
| 135 #include "chrome/browser/ui/unload_controller.h" | 134 #include "chrome/browser/ui/unload_controller.h" |
| 135 #include "chrome/browser/ui/web_applications/hosted_app_tab_helper.h" |
| 136 #include "chrome/browser/ui/web_applications/web_app_ui.h" | 136 #include "chrome/browser/ui/web_applications/web_app_ui.h" |
| 137 #include "chrome/browser/ui/webui/signin/login_ui_service.h" | 137 #include "chrome/browser/ui/webui/signin/login_ui_service.h" |
| 138 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" | 138 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" |
| 139 #include "chrome/browser/ui/window_sizer/window_sizer.h" | 139 #include "chrome/browser/ui/window_sizer/window_sizer.h" |
| 140 #include "chrome/browser/ui/zoom/zoom_controller.h" | 140 #include "chrome/browser/ui/zoom/zoom_controller.h" |
| 141 #include "chrome/browser/upgrade_detector.h" | 141 #include "chrome/browser/upgrade_detector.h" |
| 142 #include "chrome/browser/web_applications/web_app.h" | 142 #include "chrome/browser/web_applications/web_app.h" |
| 143 #include "chrome/common/chrome_constants.h" | 143 #include "chrome/common/chrome_constants.h" |
| 144 #include "chrome/common/chrome_switches.h" | 144 #include "chrome/common/chrome_switches.h" |
| 145 #include "chrome/common/custom_handlers/protocol_handler.h" | 145 #include "chrome/common/custom_handlers/protocol_handler.h" |
| (...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 521 return !app_name_.empty(); | 521 return !app_name_.empty(); |
| 522 } | 522 } |
| 523 | 523 |
| 524 bool Browser::is_devtools() const { | 524 bool Browser::is_devtools() const { |
| 525 return app_name_ == DevToolsWindow::kDevToolsApp; | 525 return app_name_ == DevToolsWindow::kDevToolsApp; |
| 526 } | 526 } |
| 527 | 527 |
| 528 /////////////////////////////////////////////////////////////////////////////// | 528 /////////////////////////////////////////////////////////////////////////////// |
| 529 // Browser, State Storage and Retrieval for UI: | 529 // Browser, State Storage and Retrieval for UI: |
| 530 | 530 |
| 531 gfx::Image Browser::GetCurrentPageIcon() const { | |
| 532 WebContents* web_contents = tab_strip_model_->GetActiveWebContents(); | |
| 533 // |web_contents| can be NULL since GetCurrentPageIcon() is called by the | |
| 534 // window during the window's creation (before tabs have been added). | |
| 535 FaviconTabHelper* favicon_tab_helper = | |
| 536 web_contents ? FaviconTabHelper::FromWebContents(web_contents) : NULL; | |
| 537 return favicon_tab_helper ? favicon_tab_helper->GetFavicon() : gfx::Image(); | |
| 538 } | |
| 539 | |
| 540 string16 Browser::GetWindowTitleForCurrentTab() const { | 531 string16 Browser::GetWindowTitleForCurrentTab() const { |
| 541 WebContents* contents = tab_strip_model_->GetActiveWebContents(); | 532 WebContents* contents = tab_strip_model_->GetActiveWebContents(); |
| 542 string16 title; | 533 string16 title; |
| 543 | 534 |
| 544 // |contents| can be NULL because GetWindowTitleForCurrentTab is called by the | 535 // |contents| can be NULL because GetWindowTitleForCurrentTab is called by the |
| 545 // window during the window's creation (before tabs have been added). | 536 // window during the window's creation (before tabs have been added). |
| 546 if (contents) { | 537 if (contents) { |
| 547 title = contents->GetTitle(); | 538 title = contents->GetTitle(); |
| 548 FormatTitleForDisplay(&title); | 539 FormatTitleForDisplay(&title); |
| 549 } | 540 } |
| (...skipping 1189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1739 /////////////////////////////////////////////////////////////////////////////// | 1730 /////////////////////////////////////////////////////////////////////////////// |
| 1740 // Browser, BookmarkTabHelperDelegate implementation: | 1731 // Browser, BookmarkTabHelperDelegate implementation: |
| 1741 | 1732 |
| 1742 void Browser::URLStarredChanged(content::WebContents* web_contents, | 1733 void Browser::URLStarredChanged(content::WebContents* web_contents, |
| 1743 bool starred) { | 1734 bool starred) { |
| 1744 if (web_contents == tab_strip_model_->GetActiveWebContents()) | 1735 if (web_contents == tab_strip_model_->GetActiveWebContents()) |
| 1745 window_->SetStarredState(starred); | 1736 window_->SetStarredState(starred); |
| 1746 } | 1737 } |
| 1747 | 1738 |
| 1748 /////////////////////////////////////////////////////////////////////////////// | 1739 /////////////////////////////////////////////////////////////////////////////// |
| 1740 // Browser, HostedAppTabHelperDelegate implementation: |
| 1741 |
| 1742 void Browser::OnWindowIconLoaded(content::WebContents* source) { |
| 1743 window_->UpdateLoadingAnimations(tab_strip_model_->TabsAreLoading()); |
| 1744 window_->UpdateTitleBar(); |
| 1745 } |
| 1746 |
| 1747 /////////////////////////////////////////////////////////////////////////////// |
| 1749 // Browser, ZoomObserver implementation: | 1748 // Browser, ZoomObserver implementation: |
| 1750 | 1749 |
| 1751 void Browser::OnZoomChanged(content::WebContents* source, | 1750 void Browser::OnZoomChanged(content::WebContents* source, |
| 1752 bool can_show_bubble) { | 1751 bool can_show_bubble) { |
| 1753 if (source == tab_strip_model_->GetActiveWebContents()) { | 1752 if (source == tab_strip_model_->GetActiveWebContents()) { |
| 1754 // Only show the zoom bubble for zoom changes in the active window. | 1753 // Only show the zoom bubble for zoom changes in the active window. |
| 1755 window_->ZoomChangedForActiveTab(can_show_bubble && window_->IsActive()); | 1754 window_->ZoomChangedForActiveTab(can_show_bubble && window_->IsActive()); |
| 1756 } | 1755 } |
| 1757 } | 1756 } |
| 1758 | 1757 |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2077 BookmarkTabHelper::FromWebContents(web_contents)->set_delegate(delegate); | 2076 BookmarkTabHelper::FromWebContents(web_contents)->set_delegate(delegate); |
| 2078 WebContentsModalDialogManager::FromWebContents(web_contents)-> | 2077 WebContentsModalDialogManager::FromWebContents(web_contents)-> |
| 2079 SetDelegate(delegate); | 2078 SetDelegate(delegate); |
| 2080 CoreTabHelper::FromWebContents(web_contents)->set_delegate(delegate); | 2079 CoreTabHelper::FromWebContents(web_contents)->set_delegate(delegate); |
| 2081 SearchEngineTabHelper::FromWebContents(web_contents)->set_delegate(delegate); | 2080 SearchEngineTabHelper::FromWebContents(web_contents)->set_delegate(delegate); |
| 2082 ZoomController::FromWebContents(web_contents)->set_observer(delegate); | 2081 ZoomController::FromWebContents(web_contents)->set_observer(delegate); |
| 2083 TranslateTabHelper* translate_tab_helper = | 2082 TranslateTabHelper* translate_tab_helper = |
| 2084 TranslateTabHelper::FromWebContents(web_contents); | 2083 TranslateTabHelper::FromWebContents(web_contents); |
| 2085 translate_tab_helper->language_state().set_observer( | 2084 translate_tab_helper->language_state().set_observer( |
| 2086 delegate ? delegate->language_state_observer_.get() : NULL); | 2085 delegate ? delegate->language_state_observer_.get() : NULL); |
| 2086 if (is_app()) |
| 2087 HostedAppTabHelper::FromWebContents(web_contents)->SetDelegate(delegate); |
| 2087 } | 2088 } |
| 2088 | 2089 |
| 2089 void Browser::CloseFrame() { | 2090 void Browser::CloseFrame() { |
| 2090 window_->Close(); | 2091 window_->Close(); |
| 2091 } | 2092 } |
| 2092 | 2093 |
| 2093 void Browser::TabDetachedAtImpl(content::WebContents* contents, | 2094 void Browser::TabDetachedAtImpl(content::WebContents* contents, |
| 2094 int index, | 2095 int index, |
| 2095 DetachType type) { | 2096 DetachType type) { |
| 2096 if (type == DETACH_TYPE_DETACH) { | 2097 if (type == DETACH_TYPE_DETACH) { |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2276 if (contents && !allow_js_access) { | 2277 if (contents && !allow_js_access) { |
| 2277 contents->web_contents()->GetController().LoadURL( | 2278 contents->web_contents()->GetController().LoadURL( |
| 2278 target_url, | 2279 target_url, |
| 2279 content::Referrer(), | 2280 content::Referrer(), |
| 2280 content::PAGE_TRANSITION_LINK, | 2281 content::PAGE_TRANSITION_LINK, |
| 2281 std::string()); // No extra headers. | 2282 std::string()); // No extra headers. |
| 2282 } | 2283 } |
| 2283 | 2284 |
| 2284 return contents != NULL; | 2285 return contents != NULL; |
| 2285 } | 2286 } |
| OLD | NEW |