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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
126 #include "chrome/browser/ui/singleton_tabs.h" | 126 #include "chrome/browser/ui/singleton_tabs.h" |
127 #include "chrome/browser/ui/status_bubble.h" | 127 #include "chrome/browser/ui/status_bubble.h" |
128 #include "chrome/browser/ui/sync/browser_synced_window_delegate.h" | 128 #include "chrome/browser/ui/sync/browser_synced_window_delegate.h" |
129 #include "chrome/browser/ui/tab_contents/core_tab_helper.h" | 129 #include "chrome/browser/ui/tab_contents/core_tab_helper.h" |
130 #include "chrome/browser/ui/tab_modal_confirm_dialog.h" | 130 #include "chrome/browser/ui/tab_modal_confirm_dialog.h" |
131 #include "chrome/browser/ui/tabs/dock_info.h" | 131 #include "chrome/browser/ui/tabs/dock_info.h" |
132 #include "chrome/browser/ui/tabs/tab_menu_model.h" | 132 #include "chrome/browser/ui/tabs/tab_menu_model.h" |
133 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 133 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
134 #include "chrome/browser/ui/toolbar/toolbar_model_impl.h" | 134 #include "chrome/browser/ui/toolbar/toolbar_model_impl.h" |
135 #include "chrome/browser/ui/unload_controller.h" | 135 #include "chrome/browser/ui/unload_controller.h" |
136 #include "chrome/browser/ui/web_applications/hosted_app_tab_helper.h" | |
136 #include "chrome/browser/ui/web_applications/web_app_ui.h" | 137 #include "chrome/browser/ui/web_applications/web_app_ui.h" |
137 #include "chrome/browser/ui/webui/signin/login_ui_service.h" | 138 #include "chrome/browser/ui/webui/signin/login_ui_service.h" |
138 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" | 139 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" |
139 #include "chrome/browser/ui/window_sizer/window_sizer.h" | 140 #include "chrome/browser/ui/window_sizer/window_sizer.h" |
140 #include "chrome/browser/ui/zoom/zoom_controller.h" | 141 #include "chrome/browser/ui/zoom/zoom_controller.h" |
141 #include "chrome/browser/upgrade_detector.h" | 142 #include "chrome/browser/upgrade_detector.h" |
142 #include "chrome/browser/web_applications/web_app.h" | 143 #include "chrome/browser/web_applications/web_app.h" |
143 #include "chrome/common/chrome_constants.h" | 144 #include "chrome/common/chrome_constants.h" |
144 #include "chrome/common/chrome_switches.h" | 145 #include "chrome/common/chrome_switches.h" |
145 #include "chrome/common/custom_handlers/protocol_handler.h" | 146 #include "chrome/common/custom_handlers/protocol_handler.h" |
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
516 return !app_name_.empty(); | 517 return !app_name_.empty(); |
517 } | 518 } |
518 | 519 |
519 bool Browser::is_devtools() const { | 520 bool Browser::is_devtools() const { |
520 return app_name_ == DevToolsWindow::kDevToolsApp; | 521 return app_name_ == DevToolsWindow::kDevToolsApp; |
521 } | 522 } |
522 | 523 |
523 /////////////////////////////////////////////////////////////////////////////// | 524 /////////////////////////////////////////////////////////////////////////////// |
524 // Browser, State Storage and Retrieval for UI: | 525 // Browser, State Storage and Retrieval for UI: |
525 | 526 |
526 gfx::Image Browser::GetCurrentPageIcon() const { | 527 const gfx::Image* Browser::GetCurrentPageIcon(int dimension) const { |
benwells
2013/11/13 21:55:17
Maybe this function can move off browser? It just
calamity
2013/11/15 04:25:50
Done.
| |
527 WebContents* web_contents = tab_strip_model_->GetActiveWebContents(); | 528 WebContents* web_contents = tab_strip_model_->GetActiveWebContents(); |
528 // |web_contents| can be NULL since GetCurrentPageIcon() is called by the | 529 // |web_contents| can be NULL since GetCurrentPageIcon() is called by the |
529 // window during the window's creation (before tabs have been added). | 530 // window during the window's creation (before tabs have been added). |
530 FaviconTabHelper* favicon_tab_helper = | 531 HostedAppTabHelper* hosted_app_tab_helper = |
531 web_contents ? FaviconTabHelper::FromWebContents(web_contents) : NULL; | 532 web_contents ? HostedAppTabHelper::FromWebContents(web_contents) |
532 return favicon_tab_helper ? favicon_tab_helper->GetFavicon() : gfx::Image(); | 533 : NULL; |
534 return hosted_app_tab_helper | |
535 ? hosted_app_tab_helper->image_family().GetBest(dimension, dimension) | |
536 : NULL; | |
533 } | 537 } |
534 | 538 |
535 string16 Browser::GetWindowTitleForCurrentTab() const { | 539 string16 Browser::GetWindowTitleForCurrentTab() const { |
536 WebContents* contents = tab_strip_model_->GetActiveWebContents(); | 540 WebContents* contents = tab_strip_model_->GetActiveWebContents(); |
537 string16 title; | 541 string16 title; |
538 | 542 |
539 // |contents| can be NULL because GetWindowTitleForCurrentTab is called by the | 543 // |contents| can be NULL because GetWindowTitleForCurrentTab is called by the |
540 // window during the window's creation (before tabs have been added). | 544 // window during the window's creation (before tabs have been added). |
541 if (contents) { | 545 if (contents) { |
542 title = contents->GetTitle(); | 546 title = contents->GetTitle(); |
(...skipping 1191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1734 /////////////////////////////////////////////////////////////////////////////// | 1738 /////////////////////////////////////////////////////////////////////////////// |
1735 // Browser, BookmarkTabHelperDelegate implementation: | 1739 // Browser, BookmarkTabHelperDelegate implementation: |
1736 | 1740 |
1737 void Browser::URLStarredChanged(content::WebContents* web_contents, | 1741 void Browser::URLStarredChanged(content::WebContents* web_contents, |
1738 bool starred) { | 1742 bool starred) { |
1739 if (web_contents == tab_strip_model_->GetActiveWebContents()) | 1743 if (web_contents == tab_strip_model_->GetActiveWebContents()) |
1740 window_->SetStarredState(starred); | 1744 window_->SetStarredState(starred); |
1741 } | 1745 } |
1742 | 1746 |
1743 /////////////////////////////////////////////////////////////////////////////// | 1747 /////////////////////////////////////////////////////////////////////////////// |
1748 // Browser, HostedAppTabHelperDelegate implementation: | |
1749 | |
1750 void Browser::OnWindowIconLoaded(content::WebContents* source) { | |
1751 window_->UpdateLoadingAnimations(tab_strip_model_->TabsAreLoading()); | |
1752 window_->UpdateTitleBar(); | |
1753 } | |
1754 | |
1755 /////////////////////////////////////////////////////////////////////////////// | |
1744 // Browser, ZoomObserver implementation: | 1756 // Browser, ZoomObserver implementation: |
1745 | 1757 |
1746 void Browser::OnZoomChanged(content::WebContents* source, | 1758 void Browser::OnZoomChanged(content::WebContents* source, |
1747 bool can_show_bubble) { | 1759 bool can_show_bubble) { |
1748 if (source == tab_strip_model_->GetActiveWebContents()) { | 1760 if (source == tab_strip_model_->GetActiveWebContents()) { |
1749 // Only show the zoom bubble for zoom changes in the active window. | 1761 // Only show the zoom bubble for zoom changes in the active window. |
1750 window_->ZoomChangedForActiveTab(can_show_bubble && window_->IsActive()); | 1762 window_->ZoomChangedForActiveTab(can_show_bubble && window_->IsActive()); |
1751 } | 1763 } |
1752 } | 1764 } |
1753 | 1765 |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2072 BookmarkTabHelper::FromWebContents(web_contents)->set_delegate(delegate); | 2084 BookmarkTabHelper::FromWebContents(web_contents)->set_delegate(delegate); |
2073 WebContentsModalDialogManager::FromWebContents(web_contents)-> | 2085 WebContentsModalDialogManager::FromWebContents(web_contents)-> |
2074 SetDelegate(delegate); | 2086 SetDelegate(delegate); |
2075 CoreTabHelper::FromWebContents(web_contents)->set_delegate(delegate); | 2087 CoreTabHelper::FromWebContents(web_contents)->set_delegate(delegate); |
2076 SearchEngineTabHelper::FromWebContents(web_contents)->set_delegate(delegate); | 2088 SearchEngineTabHelper::FromWebContents(web_contents)->set_delegate(delegate); |
2077 ZoomController::FromWebContents(web_contents)->set_observer(delegate); | 2089 ZoomController::FromWebContents(web_contents)->set_observer(delegate); |
2078 TranslateTabHelper* translate_tab_helper = | 2090 TranslateTabHelper* translate_tab_helper = |
2079 TranslateTabHelper::FromWebContents(web_contents); | 2091 TranslateTabHelper::FromWebContents(web_contents); |
2080 translate_tab_helper->language_state().set_observer( | 2092 translate_tab_helper->language_state().set_observer( |
2081 delegate ? delegate->language_state_observer_.get() : NULL); | 2093 delegate ? delegate->language_state_observer_.get() : NULL); |
2094 #if defined(OS_WIN) | |
tapted
2013/11/13 07:44:53
If it's still needed, maybe move this #ifdef to Ho
benwells
2013/11/13 21:55:17
Yeah no ifdefs in here please. There is browser_wi
calamity
2013/11/15 04:25:50
Moved the #ifdef into HostedAppTabHelper::SetDeleg
| |
2095 if (is_app()) { | |
2096 // We need the window icon for hosted apps running as a window on Windows. | |
2097 HostedAppTabHelper::FromWebContents(web_contents)-> | |
2098 SetDelegate(delegate, true /* fetch_icons_immediately*/); | |
benwells
2013/11/13 21:55:17
Is it ever called with fetch_icons_immediately fal
calamity
2013/11/15 04:25:50
Nope. Moved the setting of this into HostedAppTabH
| |
2099 } | |
2100 #endif | |
2101 | |
2082 } | 2102 } |
2083 | 2103 |
2084 void Browser::CloseFrame() { | 2104 void Browser::CloseFrame() { |
2085 window_->Close(); | 2105 window_->Close(); |
2086 } | 2106 } |
2087 | 2107 |
2088 void Browser::TabDetachedAtImpl(content::WebContents* contents, | 2108 void Browser::TabDetachedAtImpl(content::WebContents* contents, |
2089 int index, | 2109 int index, |
2090 DetachType type) { | 2110 DetachType type) { |
2091 if (type == DETACH_TYPE_DETACH) { | 2111 if (type == DETACH_TYPE_DETACH) { |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2271 if (contents && !allow_js_access) { | 2291 if (contents && !allow_js_access) { |
2272 contents->web_contents()->GetController().LoadURL( | 2292 contents->web_contents()->GetController().LoadURL( |
2273 target_url, | 2293 target_url, |
2274 content::Referrer(), | 2294 content::Referrer(), |
2275 content::PAGE_TRANSITION_LINK, | 2295 content::PAGE_TRANSITION_LINK, |
2276 std::string()); // No extra headers. | 2296 std::string()); // No extra headers. |
2277 } | 2297 } |
2278 | 2298 |
2279 return contents != NULL; | 2299 return contents != NULL; |
2280 } | 2300 } |
OLD | NEW |