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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
52 #include "chrome/browser/download/download_service.h" | 52 #include "chrome/browser/download/download_service.h" |
53 #include "chrome/browser/download/download_service_factory.h" | 53 #include "chrome/browser/download/download_service_factory.h" |
54 #include "chrome/browser/download/download_shelf.h" | 54 #include "chrome/browser/download/download_shelf.h" |
55 #include "chrome/browser/extensions/browser_extension_window_controller.h" | 55 #include "chrome/browser/extensions/browser_extension_window_controller.h" |
56 #include "chrome/browser/extensions/extension_service.h" | 56 #include "chrome/browser/extensions/extension_service.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" | 58 #include "chrome/browser/favicon/favicon_tab_helper.h" |
59 #include "chrome/browser/file_select_helper.h" | 59 #include "chrome/browser/file_select_helper.h" |
60 #include "chrome/browser/first_run/first_run.h" | 60 #include "chrome/browser/first_run/first_run.h" |
61 #include "chrome/browser/google/google_url_tracker.h" | 61 #include "chrome/browser/google/google_url_tracker.h" |
62 #include "chrome/browser/history/top_sites.h" | |
62 #include "chrome/browser/infobars/infobar_service.h" | 63 #include "chrome/browser/infobars/infobar_service.h" |
63 #include "chrome/browser/infobars/simple_alert_infobar_delegate.h" | 64 #include "chrome/browser/infobars/simple_alert_infobar_delegate.h" |
64 #include "chrome/browser/lifetime/application_lifetime.h" | 65 #include "chrome/browser/lifetime/application_lifetime.h" |
65 #include "chrome/browser/notifications/notification_ui_manager.h" | 66 #include "chrome/browser/notifications/notification_ui_manager.h" |
66 #include "chrome/browser/pepper_broker_infobar_delegate.h" | 67 #include "chrome/browser/pepper_broker_infobar_delegate.h" |
67 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 68 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
68 #include "chrome/browser/profiles/profile.h" | 69 #include "chrome/browser/profiles/profile.h" |
69 #include "chrome/browser/profiles/profile_destroyer.h" | 70 #include "chrome/browser/profiles/profile_destroyer.h" |
70 #include "chrome/browser/profiles/profile_manager.h" | 71 #include "chrome/browser/profiles/profile_manager.h" |
71 #include "chrome/browser/profiles/profile_metrics.h" | 72 #include "chrome/browser/profiles/profile_metrics.h" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
124 #include "chrome/browser/ui/search/search_tab_helper.h" | 125 #include "chrome/browser/ui/search/search_tab_helper.h" |
125 #include "chrome/browser/ui/search_engines/search_engine_tab_helper.h" | 126 #include "chrome/browser/ui/search_engines/search_engine_tab_helper.h" |
126 #include "chrome/browser/ui/singleton_tabs.h" | 127 #include "chrome/browser/ui/singleton_tabs.h" |
127 #include "chrome/browser/ui/status_bubble.h" | 128 #include "chrome/browser/ui/status_bubble.h" |
128 #include "chrome/browser/ui/sync/browser_synced_window_delegate.h" | 129 #include "chrome/browser/ui/sync/browser_synced_window_delegate.h" |
129 #include "chrome/browser/ui/tab_contents/core_tab_helper.h" | 130 #include "chrome/browser/ui/tab_contents/core_tab_helper.h" |
130 #include "chrome/browser/ui/tab_helpers.h" | 131 #include "chrome/browser/ui/tab_helpers.h" |
131 #include "chrome/browser/ui/tab_modal_confirm_dialog.h" | 132 #include "chrome/browser/ui/tab_modal_confirm_dialog.h" |
132 #include "chrome/browser/ui/tabs/tab_menu_model.h" | 133 #include "chrome/browser/ui/tabs/tab_menu_model.h" |
133 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 134 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
135 #include "chrome/browser/ui/tabs/tab_strip_model_utils.h" | |
134 #include "chrome/browser/ui/toolbar/toolbar_model_impl.h" | 136 #include "chrome/browser/ui/toolbar/toolbar_model_impl.h" |
135 #include "chrome/browser/ui/unload_controller.h" | 137 #include "chrome/browser/ui/unload_controller.h" |
136 #include "chrome/browser/ui/validation_message_bubble.h" | 138 #include "chrome/browser/ui/validation_message_bubble.h" |
137 #include "chrome/browser/ui/website_settings/permission_bubble_manager.h" | 139 #include "chrome/browser/ui/website_settings/permission_bubble_manager.h" |
138 #include "chrome/browser/ui/webui/signin/login_ui_service.h" | 140 #include "chrome/browser/ui/webui/signin/login_ui_service.h" |
139 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" | 141 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" |
140 #include "chrome/browser/ui/window_sizer/window_sizer.h" | 142 #include "chrome/browser/ui/window_sizer/window_sizer.h" |
141 #include "chrome/browser/ui/zoom/zoom_controller.h" | 143 #include "chrome/browser/ui/zoom/zoom_controller.h" |
142 #include "chrome/browser/upgrade_detector.h" | 144 #include "chrome/browser/upgrade_detector.h" |
143 #include "chrome/browser/web_applications/web_app.h" | 145 #include "chrome/browser/web_applications/web_app.h" |
(...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
766 } | 768 } |
767 | 769 |
768 void Browser::VisibleSSLStateChanged(content::WebContents* web_contents) { | 770 void Browser::VisibleSSLStateChanged(content::WebContents* web_contents) { |
769 // When the current tab's SSL state changes, we need to update the URL | 771 // When the current tab's SSL state changes, we need to update the URL |
770 // bar to reflect the new state. | 772 // bar to reflect the new state. |
771 DCHECK(web_contents); | 773 DCHECK(web_contents); |
772 if (tab_strip_model_->GetActiveWebContents() == web_contents) | 774 if (tab_strip_model_->GetActiveWebContents() == web_contents) |
773 UpdateToolbar(false); | 775 UpdateToolbar(false); |
774 } | 776 } |
775 | 777 |
776 void Browser::OnWebContentsInstantSupportDisabled( | |
777 const content::WebContents* web_contents) { | |
778 DCHECK(web_contents); | |
779 if (tab_strip_model_->GetActiveWebContents() == web_contents) | |
780 UpdateToolbar(false); | |
781 } | |
782 | 778 |
783 /////////////////////////////////////////////////////////////////////////////// | 779 /////////////////////////////////////////////////////////////////////////////// |
784 // Browser, Assorted browser commands: | 780 // Browser, Assorted browser commands: |
785 | 781 |
786 void Browser::ToggleFullscreenModeWithExtension(const GURL& extension_url) { | 782 void Browser::ToggleFullscreenModeWithExtension(const GURL& extension_url) { |
787 fullscreen_controller_-> | 783 fullscreen_controller_-> |
788 ToggleBrowserFullscreenModeWithExtension(extension_url); | 784 ToggleBrowserFullscreenModeWithExtension(extension_url); |
789 } | 785 } |
790 | 786 |
791 bool Browser::SupportsWindowFeature(WindowFeature feature) const { | 787 bool Browser::SupportsWindowFeature(WindowFeature feature) const { |
(...skipping 955 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1747 | 1743 |
1748 /////////////////////////////////////////////////////////////////////////////// | 1744 /////////////////////////////////////////////////////////////////////////////// |
1749 // Browser, SearchEngineTabHelperDelegate implementation: | 1745 // Browser, SearchEngineTabHelperDelegate implementation: |
1750 | 1746 |
1751 void Browser::ConfirmAddSearchProvider(TemplateURL* template_url, | 1747 void Browser::ConfirmAddSearchProvider(TemplateURL* template_url, |
1752 Profile* profile) { | 1748 Profile* profile) { |
1753 window()->ConfirmAddSearchProvider(template_url, profile); | 1749 window()->ConfirmAddSearchProvider(template_url, profile); |
1754 } | 1750 } |
1755 | 1751 |
1756 /////////////////////////////////////////////////////////////////////////////// | 1752 /////////////////////////////////////////////////////////////////////////////// |
1753 // Browser, SearchTabHelperDelegate implementation: | |
1754 | |
1755 void Browser::NavigateToURL(const GURL& url, | |
1756 WindowOpenDisposition disposition, | |
1757 content::WebContents* source_contents) { | |
1758 DCHECK(source_contents); | |
1759 chrome::NavigateParams params(this, url, | |
1760 content::PAGE_TRANSITION_AUTO_BOOKMARK); | |
Peter Kasting
2014/04/08 20:47:52
What kinds of navigations are these? I want to be
kmadhusu
2014/04/08 21:11:36
When an user clicks on a most visited thumbnail, w
Peter Kasting
2014/04/08 21:45:46
You may want to encode that in the function name,
kmadhusu
2014/04/09 00:00:42
Renamed "NavigateToURL" to "NavigateOnClick" and a
Peter Kasting
2014/04/09 00:03:24
I don't think that's a great function name -- link
kmadhusu
2014/04/09 01:31:04
Renamed "NavigateOnClick" to "NavigateOnThumbnailC
| |
1761 params.referrer = content::Referrer(); | |
1762 params.source_contents = source_contents; | |
1763 params.disposition = disposition; | |
1764 params.is_renderer_initiated = false; | |
1765 params.initiating_profile = profile_; | |
1766 chrome::Navigate(¶ms); | |
1767 } | |
1768 | |
1769 void Browser::OnWebContentsInstantSupportDisabled( | |
1770 const content::WebContents* web_contents) { | |
1771 DCHECK(web_contents); | |
1772 if (tab_strip_model_->GetActiveWebContents() == web_contents) | |
1773 UpdateToolbar(false); | |
1774 } | |
1775 | |
1776 OmniboxView* Browser::GetOmniboxView() { | |
1777 LocationBar* location_bar = window_ ? window_->GetLocationBar() : NULL; | |
1778 return location_bar ? location_bar->GetOmniboxView() : NULL; | |
Peter Kasting
2014/04/08 20:47:52
Can |window_| ever not have a location bar, e.g. f
kmadhusu
2014/04/08 21:11:36
Done. SearchTabHelper invokes this function. windo
Peter Kasting
2014/04/08 21:45:46
Also make sure to think through:
* Startup/shutdow
kmadhusu
2014/04/09 00:00:42
In the current code (https://code.google.com/p/chr
Peter Kasting
2014/04/09 00:03:24
If your code expects this to be non-NULL, then don
kmadhusu
2014/04/09 01:31:04
Done.
| |
1779 } | |
1780 | |
1781 std::set<std::string> Browser::GetOpenUrls() { | |
1782 history::TopSites* top_sites = profile_->GetTopSites(); | |
1783 if (!tab_strip_model_ || !top_sites) { | |
1784 NOTREACHED(); | |
Peter Kasting
2014/04/08 20:47:52
Do not handle DCHECK failure.
Either just DCHECK
kmadhusu
2014/04/08 21:11:36
Done.
| |
1785 return std::set<std::string>(); | |
1786 } | |
1787 | |
1788 std::set<std::string> open_urls; | |
1789 chrome::GetOpenUrls(*tab_strip_model_, *top_sites, &open_urls); | |
1790 return open_urls; | |
1791 } | |
1792 | |
1793 /////////////////////////////////////////////////////////////////////////////// | |
1757 // Browser, web_modal::WebContentsModalDialogManagerDelegate implementation: | 1794 // Browser, web_modal::WebContentsModalDialogManagerDelegate implementation: |
1758 | 1795 |
1759 void Browser::SetWebContentsBlocked(content::WebContents* web_contents, | 1796 void Browser::SetWebContentsBlocked(content::WebContents* web_contents, |
1760 bool blocked) { | 1797 bool blocked) { |
1761 int index = tab_strip_model_->GetIndexOfWebContents(web_contents); | 1798 int index = tab_strip_model_->GetIndexOfWebContents(web_contents); |
1762 if (index == TabStripModel::kNoTab) { | 1799 if (index == TabStripModel::kNoTab) { |
1763 NOTREACHED(); | 1800 NOTREACHED(); |
1764 return; | 1801 return; |
1765 } | 1802 } |
1766 tab_strip_model_->SetTabBlocked(index, blocked); | 1803 tab_strip_model_->SetTabBlocked(index, blocked); |
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2129 void Browser::SetAsDelegate(WebContents* web_contents, Browser* delegate) { | 2166 void Browser::SetAsDelegate(WebContents* web_contents, Browser* delegate) { |
2130 // WebContents... | 2167 // WebContents... |
2131 web_contents->SetDelegate(delegate); | 2168 web_contents->SetDelegate(delegate); |
2132 | 2169 |
2133 // ...and all the helpers. | 2170 // ...and all the helpers. |
2134 BookmarkTabHelper::FromWebContents(web_contents)->set_delegate(delegate); | 2171 BookmarkTabHelper::FromWebContents(web_contents)->set_delegate(delegate); |
2135 WebContentsModalDialogManager::FromWebContents(web_contents)-> | 2172 WebContentsModalDialogManager::FromWebContents(web_contents)-> |
2136 SetDelegate(delegate); | 2173 SetDelegate(delegate); |
2137 CoreTabHelper::FromWebContents(web_contents)->set_delegate(delegate); | 2174 CoreTabHelper::FromWebContents(web_contents)->set_delegate(delegate); |
2138 SearchEngineTabHelper::FromWebContents(web_contents)->set_delegate(delegate); | 2175 SearchEngineTabHelper::FromWebContents(web_contents)->set_delegate(delegate); |
2176 SearchTabHelper::FromWebContents(web_contents)->set_delegate(delegate); | |
2139 ZoomController::FromWebContents(web_contents)->set_observer(delegate); | 2177 ZoomController::FromWebContents(web_contents)->set_observer(delegate); |
2140 TranslateTabHelper* translate_tab_helper = | 2178 TranslateTabHelper* translate_tab_helper = |
2141 TranslateTabHelper::FromWebContents(web_contents); | 2179 TranslateTabHelper::FromWebContents(web_contents); |
2142 translate_tab_helper->translate_driver().set_observer( | 2180 translate_tab_helper->translate_driver().set_observer( |
2143 delegate ? delegate->translate_driver_observer_.get() : NULL); | 2181 delegate ? delegate->translate_driver_observer_.get() : NULL); |
2144 } | 2182 } |
2145 | 2183 |
2146 void Browser::CloseFrame() { | 2184 void Browser::CloseFrame() { |
2147 window_->Close(); | 2185 window_->Close(); |
2148 } | 2186 } |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2363 if (contents && !allow_js_access) { | 2401 if (contents && !allow_js_access) { |
2364 contents->web_contents()->GetController().LoadURL( | 2402 contents->web_contents()->GetController().LoadURL( |
2365 target_url, | 2403 target_url, |
2366 content::Referrer(), | 2404 content::Referrer(), |
2367 content::PAGE_TRANSITION_LINK, | 2405 content::PAGE_TRANSITION_LINK, |
2368 std::string()); // No extra headers. | 2406 std::string()); // No extra headers. |
2369 } | 2407 } |
2370 | 2408 |
2371 return contents != NULL; | 2409 return contents != NULL; |
2372 } | 2410 } |
OLD | NEW |