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 icon_size) const { |
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 if (hosted_app_tab_helper) { | |
535 const gfx::Image* icon = | |
536 hosted_app_tab_helper->icon_family().GetBest(icon_size, icon_size); | |
537 if (icon) | |
538 return *icon; | |
539 } | |
540 return gfx::Image(); | |
533 } | 541 } |
534 | 542 |
535 string16 Browser::GetWindowTitleForCurrentTab() const { | 543 string16 Browser::GetWindowTitleForCurrentTab() const { |
536 WebContents* contents = tab_strip_model_->GetActiveWebContents(); | 544 WebContents* contents = tab_strip_model_->GetActiveWebContents(); |
537 string16 title; | 545 string16 title; |
538 | 546 |
539 // |contents| can be NULL because GetWindowTitleForCurrentTab is called by the | 547 // |contents| can be NULL because GetWindowTitleForCurrentTab is called by the |
540 // window during the window's creation (before tabs have been added). | 548 // window during the window's creation (before tabs have been added). |
541 if (contents) { | 549 if (contents) { |
542 title = contents->GetTitle(); | 550 title = contents->GetTitle(); |
(...skipping 1191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1734 /////////////////////////////////////////////////////////////////////////////// | 1742 /////////////////////////////////////////////////////////////////////////////// |
1735 // Browser, BookmarkTabHelperDelegate implementation: | 1743 // Browser, BookmarkTabHelperDelegate implementation: |
1736 | 1744 |
1737 void Browser::URLStarredChanged(content::WebContents* web_contents, | 1745 void Browser::URLStarredChanged(content::WebContents* web_contents, |
1738 bool starred) { | 1746 bool starred) { |
1739 if (web_contents == tab_strip_model_->GetActiveWebContents()) | 1747 if (web_contents == tab_strip_model_->GetActiveWebContents()) |
1740 window_->SetStarredState(starred); | 1748 window_->SetStarredState(starred); |
1741 } | 1749 } |
1742 | 1750 |
1743 /////////////////////////////////////////////////////////////////////////////// | 1751 /////////////////////////////////////////////////////////////////////////////// |
1752 // Browser, HostedAppTabHelperDelegate implementation: | |
1753 | |
1754 void Browser::OnWindowIconLoaded(content::WebContents* source) { | |
1755 LoadingStateChanged(source); | |
tapted
2013/11/11 08:52:57
This doesn't feel right. WebContentsImpl only call
calamity
2013/11/13 06:37:14
Yes, updating the loading animation and title bar
| |
1756 } | |
1757 | |
1758 /////////////////////////////////////////////////////////////////////////////// | |
1744 // Browser, ZoomObserver implementation: | 1759 // Browser, ZoomObserver implementation: |
1745 | 1760 |
1746 void Browser::OnZoomChanged(content::WebContents* source, | 1761 void Browser::OnZoomChanged(content::WebContents* source, |
1747 bool can_show_bubble) { | 1762 bool can_show_bubble) { |
1748 if (source == tab_strip_model_->GetActiveWebContents()) { | 1763 if (source == tab_strip_model_->GetActiveWebContents()) { |
1749 // Only show the zoom bubble for zoom changes in the active window. | 1764 // Only show the zoom bubble for zoom changes in the active window. |
1750 window_->ZoomChangedForActiveTab(can_show_bubble && window_->IsActive()); | 1765 window_->ZoomChangedForActiveTab(can_show_bubble && window_->IsActive()); |
1751 } | 1766 } |
1752 } | 1767 } |
1753 | 1768 |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2072 BookmarkTabHelper::FromWebContents(web_contents)->set_delegate(delegate); | 2087 BookmarkTabHelper::FromWebContents(web_contents)->set_delegate(delegate); |
2073 WebContentsModalDialogManager::FromWebContents(web_contents)-> | 2088 WebContentsModalDialogManager::FromWebContents(web_contents)-> |
2074 SetDelegate(delegate); | 2089 SetDelegate(delegate); |
2075 CoreTabHelper::FromWebContents(web_contents)->set_delegate(delegate); | 2090 CoreTabHelper::FromWebContents(web_contents)->set_delegate(delegate); |
2076 SearchEngineTabHelper::FromWebContents(web_contents)->set_delegate(delegate); | 2091 SearchEngineTabHelper::FromWebContents(web_contents)->set_delegate(delegate); |
2077 ZoomController::FromWebContents(web_contents)->set_observer(delegate); | 2092 ZoomController::FromWebContents(web_contents)->set_observer(delegate); |
2078 TranslateTabHelper* translate_tab_helper = | 2093 TranslateTabHelper* translate_tab_helper = |
2079 TranslateTabHelper::FromWebContents(web_contents); | 2094 TranslateTabHelper::FromWebContents(web_contents); |
2080 translate_tab_helper->language_state().set_observer( | 2095 translate_tab_helper->language_state().set_observer( |
2081 delegate ? delegate->language_state_observer_.get() : NULL); | 2096 delegate ? delegate->language_state_observer_.get() : NULL); |
2097 HostedAppTabHelper* hosted_app_tab_helper = | |
tapted
2013/11/11 08:52:57
Is there an overhead to consider for this?
E.g. w
calamity
2013/11/13 06:37:14
I don't think so. Any overhead would be in creatin
tapted
2013/11/13 07:44:53
Yeah - that's what I meant (sorry - should have co
| |
2098 HostedAppTabHelper::FromWebContents(web_contents); | |
2099 hosted_app_tab_helper->set_delegate(delegate); | |
tapted
2013/11/11 08:52:57
What about SetDelegate(delegate, is_app()) - that
benwells
2013/11/11 23:15:55
Why is this limited OS_WIN? This flag should work
calamity
2013/11/13 06:37:14
Done.
calamity
2013/11/13 06:37:14
This is for Window Icons which are only used on Wi
| |
2100 #if defined(OS_WIN) | |
2101 // We need the window icon for hosted apps running as a window on Windows. | |
2102 hosted_app_tab_helper->set_fetch_icons_immediately(is_app()); | |
2103 #endif | |
2082 } | 2104 } |
2083 | 2105 |
2084 void Browser::CloseFrame() { | 2106 void Browser::CloseFrame() { |
2085 window_->Close(); | 2107 window_->Close(); |
2086 } | 2108 } |
2087 | 2109 |
2088 void Browser::TabDetachedAtImpl(content::WebContents* contents, | 2110 void Browser::TabDetachedAtImpl(content::WebContents* contents, |
2089 int index, | 2111 int index, |
2090 DetachType type) { | 2112 DetachType type) { |
2091 if (type == DETACH_TYPE_DETACH) { | 2113 if (type == DETACH_TYPE_DETACH) { |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2271 if (contents && !allow_js_access) { | 2293 if (contents && !allow_js_access) { |
2272 contents->web_contents()->GetController().LoadURL( | 2294 contents->web_contents()->GetController().LoadURL( |
2273 target_url, | 2295 target_url, |
2274 content::Referrer(), | 2296 content::Referrer(), |
2275 content::PAGE_TRANSITION_LINK, | 2297 content::PAGE_TRANSITION_LINK, |
2276 std::string()); // No extra headers. | 2298 std::string()); // No extra headers. |
2277 } | 2299 } |
2278 | 2300 |
2279 return contents != NULL; | 2301 return contents != NULL; |
2280 } | 2302 } |
OLD | NEW |