| 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 962 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1754 | 1750 |
| 1755 /////////////////////////////////////////////////////////////////////////////// | 1751 /////////////////////////////////////////////////////////////////////////////// |
| 1756 // Browser, SearchEngineTabHelperDelegate implementation: | 1752 // Browser, SearchEngineTabHelperDelegate implementation: |
| 1757 | 1753 |
| 1758 void Browser::ConfirmAddSearchProvider(TemplateURL* template_url, | 1754 void Browser::ConfirmAddSearchProvider(TemplateURL* template_url, |
| 1759 Profile* profile) { | 1755 Profile* profile) { |
| 1760 window()->ConfirmAddSearchProvider(template_url, profile); | 1756 window()->ConfirmAddSearchProvider(template_url, profile); |
| 1761 } | 1757 } |
| 1762 | 1758 |
| 1763 /////////////////////////////////////////////////////////////////////////////// | 1759 /////////////////////////////////////////////////////////////////////////////// |
| 1760 // Browser, SearchTabHelperDelegate implementation: |
| 1761 |
| 1762 void Browser::NavigateOnThumbnailClick(const GURL& url, |
| 1763 WindowOpenDisposition disposition, |
| 1764 content::WebContents* source_contents) { |
| 1765 DCHECK(source_contents); |
| 1766 // We're guaranteed that AUTO_BOOKMARK is the right transition since this only |
| 1767 // gets called to handle clicks in the new tab page (to navigate to most |
| 1768 // visited item URLs) and in the search results page (to navigate to |
| 1769 // privileged destinations (e.g. chrome://URLs)). |
| 1770 // |
| 1771 // TODO(kmadhusu): Page transitions to privileged destinations should be |
| 1772 // marked as "LINK" instead of "AUTO_BOOKMARK"? |
| 1773 chrome::NavigateParams params(this, url, |
| 1774 content::PAGE_TRANSITION_AUTO_BOOKMARK); |
| 1775 params.referrer = content::Referrer(); |
| 1776 params.source_contents = source_contents; |
| 1777 params.disposition = disposition; |
| 1778 params.is_renderer_initiated = false; |
| 1779 params.initiating_profile = profile_; |
| 1780 chrome::Navigate(¶ms); |
| 1781 } |
| 1782 |
| 1783 void Browser::OnWebContentsInstantSupportDisabled( |
| 1784 const content::WebContents* web_contents) { |
| 1785 DCHECK(web_contents); |
| 1786 if (tab_strip_model_->GetActiveWebContents() == web_contents) |
| 1787 UpdateToolbar(false); |
| 1788 } |
| 1789 |
| 1790 OmniboxView* Browser::GetOmniboxView() { |
| 1791 return window_->GetLocationBar()->GetOmniboxView(); |
| 1792 } |
| 1793 |
| 1794 std::set<std::string> Browser::GetOpenUrls() { |
| 1795 history::TopSites* top_sites = profile_->GetTopSites(); |
| 1796 if (!top_sites) // NULL for Incognito profiles. |
| 1797 return std::set<std::string>(); |
| 1798 |
| 1799 std::set<std::string> open_urls; |
| 1800 chrome::GetOpenUrls(*tab_strip_model_, *top_sites, &open_urls); |
| 1801 return open_urls; |
| 1802 } |
| 1803 |
| 1804 /////////////////////////////////////////////////////////////////////////////// |
| 1764 // Browser, web_modal::WebContentsModalDialogManagerDelegate implementation: | 1805 // Browser, web_modal::WebContentsModalDialogManagerDelegate implementation: |
| 1765 | 1806 |
| 1766 void Browser::SetWebContentsBlocked(content::WebContents* web_contents, | 1807 void Browser::SetWebContentsBlocked(content::WebContents* web_contents, |
| 1767 bool blocked) { | 1808 bool blocked) { |
| 1768 int index = tab_strip_model_->GetIndexOfWebContents(web_contents); | 1809 int index = tab_strip_model_->GetIndexOfWebContents(web_contents); |
| 1769 if (index == TabStripModel::kNoTab) { | 1810 if (index == TabStripModel::kNoTab) { |
| 1770 NOTREACHED(); | 1811 NOTREACHED(); |
| 1771 return; | 1812 return; |
| 1772 } | 1813 } |
| 1773 tab_strip_model_->SetTabBlocked(index, blocked); | 1814 tab_strip_model_->SetTabBlocked(index, blocked); |
| (...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2136 void Browser::SetAsDelegate(WebContents* web_contents, Browser* delegate) { | 2177 void Browser::SetAsDelegate(WebContents* web_contents, Browser* delegate) { |
| 2137 // WebContents... | 2178 // WebContents... |
| 2138 web_contents->SetDelegate(delegate); | 2179 web_contents->SetDelegate(delegate); |
| 2139 | 2180 |
| 2140 // ...and all the helpers. | 2181 // ...and all the helpers. |
| 2141 BookmarkTabHelper::FromWebContents(web_contents)->set_delegate(delegate); | 2182 BookmarkTabHelper::FromWebContents(web_contents)->set_delegate(delegate); |
| 2142 WebContentsModalDialogManager::FromWebContents(web_contents)-> | 2183 WebContentsModalDialogManager::FromWebContents(web_contents)-> |
| 2143 SetDelegate(delegate); | 2184 SetDelegate(delegate); |
| 2144 CoreTabHelper::FromWebContents(web_contents)->set_delegate(delegate); | 2185 CoreTabHelper::FromWebContents(web_contents)->set_delegate(delegate); |
| 2145 SearchEngineTabHelper::FromWebContents(web_contents)->set_delegate(delegate); | 2186 SearchEngineTabHelper::FromWebContents(web_contents)->set_delegate(delegate); |
| 2187 SearchTabHelper::FromWebContents(web_contents)->set_delegate(delegate); |
| 2146 ZoomController::FromWebContents(web_contents)->set_observer(delegate); | 2188 ZoomController::FromWebContents(web_contents)->set_observer(delegate); |
| 2147 TranslateTabHelper* translate_tab_helper = | 2189 TranslateTabHelper* translate_tab_helper = |
| 2148 TranslateTabHelper::FromWebContents(web_contents); | 2190 TranslateTabHelper::FromWebContents(web_contents); |
| 2149 translate_tab_helper->translate_driver().set_observer( | 2191 translate_tab_helper->translate_driver().set_observer( |
| 2150 delegate ? delegate->translate_driver_observer_.get() : NULL); | 2192 delegate ? delegate->translate_driver_observer_.get() : NULL); |
| 2151 } | 2193 } |
| 2152 | 2194 |
| 2153 void Browser::CloseFrame() { | 2195 void Browser::CloseFrame() { |
| 2154 window_->Close(); | 2196 window_->Close(); |
| 2155 } | 2197 } |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2370 if (contents && !allow_js_access) { | 2412 if (contents && !allow_js_access) { |
| 2371 contents->web_contents()->GetController().LoadURL( | 2413 contents->web_contents()->GetController().LoadURL( |
| 2372 target_url, | 2414 target_url, |
| 2373 content::Referrer(), | 2415 content::Referrer(), |
| 2374 content::PAGE_TRANSITION_LINK, | 2416 content::PAGE_TRANSITION_LINK, |
| 2375 std::string()); // No extra headers. | 2417 std::string()); // No extra headers. |
| 2376 } | 2418 } |
| 2377 | 2419 |
| 2378 return contents != NULL; | 2420 return contents != NULL; |
| 2379 } | 2421 } |
| OLD | NEW |