OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 // OS_WIN | 10 #endif // OS_WIN |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 #include "chrome/browser/extensions/browser_extension_window_controller.h" | 51 #include "chrome/browser/extensions/browser_extension_window_controller.h" |
52 #include "chrome/browser/extensions/default_apps_trial.h" | 52 #include "chrome/browser/extensions/default_apps_trial.h" |
53 #include "chrome/browser/extensions/extension_prefs.h" | 53 #include "chrome/browser/extensions/extension_prefs.h" |
54 #include "chrome/browser/extensions/extension_service.h" | 54 #include "chrome/browser/extensions/extension_service.h" |
55 #include "chrome/browser/extensions/extension_tab_helper.h" | 55 #include "chrome/browser/extensions/extension_tab_helper.h" |
56 #include "chrome/browser/favicon/favicon_tab_helper.h" | 56 #include "chrome/browser/favicon/favicon_tab_helper.h" |
57 #include "chrome/browser/file_select_helper.h" | 57 #include "chrome/browser/file_select_helper.h" |
58 #include "chrome/browser/first_run/first_run.h" | 58 #include "chrome/browser/first_run/first_run.h" |
59 #include "chrome/browser/google/google_url_tracker.h" | 59 #include "chrome/browser/google/google_url_tracker.h" |
60 #include "chrome/browser/infobars/infobar_tab_helper.h" | 60 #include "chrome/browser/infobars/infobar_tab_helper.h" |
61 #include "chrome/browser/instant/instant_controller.h" | |
62 #include "chrome/browser/instant/instant_unload_handler.h" | |
63 #include "chrome/browser/intents/register_intent_handler_infobar_delegate.h" | 61 #include "chrome/browser/intents/register_intent_handler_infobar_delegate.h" |
64 #include "chrome/browser/intents/web_intents_util.h" | 62 #include "chrome/browser/intents/web_intents_util.h" |
65 #include "chrome/browser/lifetime/application_lifetime.h" | 63 #include "chrome/browser/lifetime/application_lifetime.h" |
66 #include "chrome/browser/media/media_stream_devices_controller.h" | 64 #include "chrome/browser/media/media_stream_devices_controller.h" |
67 #include "chrome/browser/net/url_fixer_upper.h" | 65 #include "chrome/browser/net/url_fixer_upper.h" |
68 #include "chrome/browser/notifications/notification_ui_manager.h" | 66 #include "chrome/browser/notifications/notification_ui_manager.h" |
69 #include "chrome/browser/platform_util.h" | 67 #include "chrome/browser/platform_util.h" |
70 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 68 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
71 #include "chrome/browser/prefs/pref_service.h" | 69 #include "chrome/browser/prefs/pref_service.h" |
72 #include "chrome/browser/printing/cloud_print/cloud_print_setup_flow.h" | 70 #include "chrome/browser/printing/cloud_print/cloud_print_setup_flow.h" |
(...skipping 19 matching lines...) Expand all Loading... |
92 #include "chrome/browser/themes/theme_service.h" | 90 #include "chrome/browser/themes/theme_service.h" |
93 #include "chrome/browser/themes/theme_service_factory.h" | 91 #include "chrome/browser/themes/theme_service_factory.h" |
94 #include "chrome/browser/ui/app_modal_dialogs/javascript_dialog_creator.h" | 92 #include "chrome/browser/ui/app_modal_dialogs/javascript_dialog_creator.h" |
95 #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper.h" | 93 #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper.h" |
96 #include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h" | 94 #include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h" |
97 #include "chrome/browser/ui/browser_command_controller.h" | 95 #include "chrome/browser/ui/browser_command_controller.h" |
98 #include "chrome/browser/ui/browser_commands.h" | 96 #include "chrome/browser/ui/browser_commands.h" |
99 #include "chrome/browser/ui/browser_content_setting_bubble_model_delegate.h" | 97 #include "chrome/browser/ui/browser_content_setting_bubble_model_delegate.h" |
100 #include "chrome/browser/ui/browser_dialogs.h" | 98 #include "chrome/browser/ui/browser_dialogs.h" |
101 #include "chrome/browser/ui/browser_finder.h" | 99 #include "chrome/browser/ui/browser_finder.h" |
| 100 #include "chrome/browser/ui/browser_instant_controller.h" |
102 #include "chrome/browser/ui/browser_list.h" | 101 #include "chrome/browser/ui/browser_list.h" |
103 #include "chrome/browser/ui/browser_navigator.h" | 102 #include "chrome/browser/ui/browser_navigator.h" |
104 #include "chrome/browser/ui/browser_tab_restore_service_delegate.h" | 103 #include "chrome/browser/ui/browser_tab_restore_service_delegate.h" |
105 #include "chrome/browser/ui/browser_tab_strip_model_delegate.h" | 104 #include "chrome/browser/ui/browser_tab_strip_model_delegate.h" |
106 #include "chrome/browser/ui/browser_tabstrip.h" | 105 #include "chrome/browser/ui/browser_tabstrip.h" |
107 #include "chrome/browser/ui/browser_toolbar_model_delegate.h" | 106 #include "chrome/browser/ui/browser_toolbar_model_delegate.h" |
108 #include "chrome/browser/ui/browser_ui_prefs.h" | 107 #include "chrome/browser/ui/browser_ui_prefs.h" |
109 #include "chrome/browser/ui/browser_window.h" | 108 #include "chrome/browser/ui/browser_window.h" |
110 #include "chrome/browser/ui/chrome_pages.h" | 109 #include "chrome/browser/ui/chrome_pages.h" |
111 #include "chrome/browser/ui/chrome_select_file_policy.h" | 110 #include "chrome/browser/ui/chrome_select_file_policy.h" |
(...skipping 20 matching lines...) Expand all Loading... |
132 #include "chrome/browser/ui/status_bubble.h" | 131 #include "chrome/browser/ui/status_bubble.h" |
133 #include "chrome/browser/ui/sync/browser_synced_window_delegate.h" | 132 #include "chrome/browser/ui/sync/browser_synced_window_delegate.h" |
134 #include "chrome/browser/ui/tab_contents/core_tab_helper.h" | 133 #include "chrome/browser/ui/tab_contents/core_tab_helper.h" |
135 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 134 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
136 #include "chrome/browser/ui/tabs/dock_info.h" | 135 #include "chrome/browser/ui/tabs/dock_info.h" |
137 #include "chrome/browser/ui/tabs/tab_menu_model.h" | 136 #include "chrome/browser/ui/tabs/tab_menu_model.h" |
138 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 137 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
139 #include "chrome/browser/ui/unload_controller.h" | 138 #include "chrome/browser/ui/unload_controller.h" |
140 #include "chrome/browser/ui/web_applications/web_app_ui.h" | 139 #include "chrome/browser/ui/web_applications/web_app_ui.h" |
141 #include "chrome/browser/ui/webui/feedback_ui.h" | 140 #include "chrome/browser/ui/webui/feedback_ui.h" |
142 #include "chrome/browser/ui/webui/ntp/app_launcher_handler.h" | |
143 #include "chrome/browser/ui/webui/signin/login_ui_service.h" | 141 #include "chrome/browser/ui/webui/signin/login_ui_service.h" |
144 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" | 142 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" |
145 #include "chrome/browser/ui/window_sizer/window_sizer.h" | 143 #include "chrome/browser/ui/window_sizer/window_sizer.h" |
146 #include "chrome/browser/upgrade_detector.h" | 144 #include "chrome/browser/upgrade_detector.h" |
147 #include "chrome/browser/web_applications/web_app.h" | 145 #include "chrome/browser/web_applications/web_app.h" |
148 #include "chrome/common/chrome_constants.h" | 146 #include "chrome/common/chrome_constants.h" |
149 #include "chrome/common/chrome_notification_types.h" | 147 #include "chrome/common/chrome_notification_types.h" |
150 #include "chrome/common/chrome_switches.h" | 148 #include "chrome/common/chrome_switches.h" |
151 #include "chrome/common/custom_handlers/protocol_handler.h" | 149 #include "chrome/common/custom_handlers/protocol_handler.h" |
152 #include "chrome/common/extensions/extension.h" | 150 #include "chrome/common/extensions/extension.h" |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 content::Source<ThemeService>( | 352 content::Source<ThemeService>( |
355 ThemeServiceFactory::GetForProfile(profile_))); | 353 ThemeServiceFactory::GetForProfile(profile_))); |
356 #endif | 354 #endif |
357 registrar_.Add(this, chrome::NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED, | 355 registrar_.Add(this, chrome::NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED, |
358 content::NotificationService::AllSources()); | 356 content::NotificationService::AllSources()); |
359 | 357 |
360 profile_pref_registrar_.Init(profile_->GetPrefs()); | 358 profile_pref_registrar_.Init(profile_->GetPrefs()); |
361 profile_pref_registrar_.Add(prefs::kDevToolsDisabled, this); | 359 profile_pref_registrar_.Add(prefs::kDevToolsDisabled, this); |
362 profile_pref_registrar_.Add(prefs::kShowBookmarkBar, this); | 360 profile_pref_registrar_.Add(prefs::kShowBookmarkBar, this); |
363 profile_pref_registrar_.Add(prefs::kHomePage, this); | 361 profile_pref_registrar_.Add(prefs::kHomePage, this); |
364 profile_pref_registrar_.Add(prefs::kInstantEnabled, this); | |
365 | 362 |
366 BrowserList::AddBrowser(this); | 363 BrowserList::AddBrowser(this); |
367 | 364 |
368 // NOTE: These prefs all need to be explicitly destroyed in the destructor | 365 // NOTE: These prefs all need to be explicitly destroyed in the destructor |
369 // or you'll get a nasty surprise when you run the incognito tests. | 366 // or you'll get a nasty surprise when you run the incognito tests. |
370 encoding_auto_detect_.Init(prefs::kWebKitUsesUniversalDetector, | 367 encoding_auto_detect_.Init(prefs::kWebKitUsesUniversalDetector, |
371 profile_->GetPrefs(), NULL); | 368 profile_->GetPrefs(), NULL); |
372 | 369 |
373 CreateInstantIfNecessary(); | 370 instant_controller_.reset(new chrome::BrowserInstantController(this)); |
374 | 371 |
375 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_INIT); | 372 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_INIT); |
376 | 373 |
377 FilePath profile_path = profile->GetPath(); | 374 FilePath profile_path = profile->GetPath(); |
378 ProfileMetrics::LogProfileLaunch(profile_path); | 375 ProfileMetrics::LogProfileLaunch(profile_path); |
379 } | 376 } |
380 | 377 |
381 Browser::~Browser() { | 378 Browser::~Browser() { |
382 // The tab strip should not have any tabs at this point. | 379 // The tab strip should not have any tabs at this point. |
383 if (!browser_shutdown::ShuttingDownWithoutClosingBrowsers()) | 380 if (!browser_shutdown::ShuttingDownWithoutClosingBrowsers()) |
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
810 string16(), directory, | 807 string16(), directory, |
811 NULL, 0, FILE_PATH_LITERAL(""), | 808 NULL, 0, FILE_PATH_LITERAL(""), |
812 parent_window, NULL); | 809 parent_window, NULL); |
813 } | 810 } |
814 | 811 |
815 void Browser::UpdateDownloadShelfVisibility(bool visible) { | 812 void Browser::UpdateDownloadShelfVisibility(bool visible) { |
816 if (GetStatusBubble()) | 813 if (GetStatusBubble()) |
817 GetStatusBubble()->UpdateDownloadShelfVisibility(visible); | 814 GetStatusBubble()->UpdateDownloadShelfVisibility(visible); |
818 } | 815 } |
819 | 816 |
820 bool Browser::OpenInstant(WindowOpenDisposition disposition) { | |
821 if (!instant() || !instant()->PrepareForCommit() || | |
822 disposition == NEW_BACKGROUND_TAB) { | |
823 // NEW_BACKGROUND_TAB results in leaving the omnibox open, so we don't | |
824 // attempt to use the instant preview. | |
825 return false; | |
826 } | |
827 | |
828 if (disposition == CURRENT_TAB) { | |
829 content::NotificationService::current()->Notify( | |
830 chrome::NOTIFICATION_INSTANT_COMMITTED, | |
831 content::Source<TabContents>(instant()->CommitCurrentPreview( | |
832 INSTANT_COMMIT_PRESSED_ENTER)), | |
833 content::NotificationService::NoDetails()); | |
834 return true; | |
835 } | |
836 if (disposition == NEW_FOREGROUND_TAB) { | |
837 TabContents* preview_contents = instant()->ReleasePreviewContents( | |
838 INSTANT_COMMIT_PRESSED_ENTER, NULL); | |
839 // HideInstant is invoked after release so that InstantController is not | |
840 // active when HideInstant asks it for its state. | |
841 HideInstant(); | |
842 preview_contents->web_contents()->GetController().PruneAllButActive(); | |
843 tab_strip_model_->AddTabContents( | |
844 preview_contents, | |
845 -1, | |
846 instant()->last_transition_type(), | |
847 TabStripModel::ADD_ACTIVE); | |
848 instant()->CompleteRelease(preview_contents); | |
849 content::NotificationService::current()->Notify( | |
850 chrome::NOTIFICATION_INSTANT_COMMITTED, | |
851 content::Source<TabContents>(preview_contents), | |
852 content::NotificationService::NoDetails()); | |
853 return true; | |
854 } | |
855 // The omnibox currently doesn't use other dispositions, so we don't attempt | |
856 // to handle them. If you hit this NOTREACHED file a bug and I'll (sky) add | |
857 // support for the new disposition. | |
858 NOTREACHED(); | |
859 return false; | |
860 } | |
861 | |
862 /////////////////////////////////////////////////////////////////////////////// | 817 /////////////////////////////////////////////////////////////////////////////// |
863 | 818 |
864 // static | 819 // static |
865 bool Browser::RunUnloadEventsHelper(WebContents* contents) { | 820 bool Browser::RunUnloadEventsHelper(WebContents* contents) { |
866 // If the WebContents is not connected yet, then there's no unload | 821 // If the WebContents is not connected yet, then there's no unload |
867 // handler we can fire even if the WebContents has an unload listener. | 822 // handler we can fire even if the WebContents has an unload listener. |
868 // One case where we hit this is in a tab that has an infinite loop | 823 // One case where we hit this is in a tab that has an infinite loop |
869 // before load. | 824 // before load. |
870 if (contents->NeedToFireBeforeUnload()) { | 825 if (contents->NeedToFireBeforeUnload()) { |
871 // If the page has unload listeners, then we tell the renderer to fire | 826 // If the page has unload listeners, then we tell the renderer to fire |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1054 } | 1009 } |
1055 | 1010 |
1056 void Browser::TabDetachedAt(TabContents* contents, int index) { | 1011 void Browser::TabDetachedAt(TabContents* contents, int index) { |
1057 TabDetachedAtImpl(contents, index, DETACH_TYPE_DETACH); | 1012 TabDetachedAtImpl(contents, index, DETACH_TYPE_DETACH); |
1058 } | 1013 } |
1059 | 1014 |
1060 void Browser::TabDeactivated(TabContents* contents) { | 1015 void Browser::TabDeactivated(TabContents* contents) { |
1061 fullscreen_controller_->OnTabDeactivated(contents); | 1016 fullscreen_controller_->OnTabDeactivated(contents); |
1062 search_delegate_->OnTabDeactivated(contents); | 1017 search_delegate_->OnTabDeactivated(contents); |
1063 | 1018 |
1064 if (instant()) | |
1065 instant()->Hide(); | |
1066 | |
1067 // Save what the user's currently typing, so it can be restored when we | 1019 // Save what the user's currently typing, so it can be restored when we |
1068 // switch back to this tab. | 1020 // switch back to this tab. |
1069 window_->GetLocationBar()->SaveStateToContents(contents->web_contents()); | 1021 window_->GetLocationBar()->SaveStateToContents(contents->web_contents()); |
1070 } | 1022 } |
1071 | 1023 |
1072 void Browser::ActiveTabChanged(TabContents* old_contents, | 1024 void Browser::ActiveTabChanged(TabContents* old_contents, |
1073 TabContents* new_contents, | 1025 TabContents* new_contents, |
1074 int index, | 1026 int index, |
1075 bool user_gesture) { | 1027 bool user_gesture) { |
1076 // On some platforms we want to automatically reload tabs that are | 1028 // On some platforms we want to automatically reload tabs that are |
(...skipping 794 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1871 | 1823 |
1872 #if defined(ENABLE_THEMES) | 1824 #if defined(ENABLE_THEMES) |
1873 case chrome::NOTIFICATION_BROWSER_THEME_CHANGED: | 1825 case chrome::NOTIFICATION_BROWSER_THEME_CHANGED: |
1874 window()->UserChangedTheme(); | 1826 window()->UserChangedTheme(); |
1875 break; | 1827 break; |
1876 #endif | 1828 #endif |
1877 | 1829 |
1878 case chrome::NOTIFICATION_PREF_CHANGED: { | 1830 case chrome::NOTIFICATION_PREF_CHANGED: { |
1879 const std::string& pref_name = | 1831 const std::string& pref_name = |
1880 *content::Details<std::string>(details).ptr(); | 1832 *content::Details<std::string>(details).ptr(); |
1881 if (pref_name == prefs::kInstantEnabled) { | 1833 if (pref_name == prefs::kDevToolsDisabled) { |
1882 if (browser_shutdown::ShuttingDownWithoutClosingBrowsers() || | |
1883 !InstantController::IsEnabled(profile())) { | |
1884 if (instant()) { | |
1885 instant()->DestroyPreviewContents(); | |
1886 instant_.reset(); | |
1887 instant_unload_handler_.reset(); | |
1888 } | |
1889 } else { | |
1890 CreateInstantIfNecessary(); | |
1891 } | |
1892 } else if (pref_name == prefs::kDevToolsDisabled) { | |
1893 if (profile_->GetPrefs()->GetBoolean(prefs::kDevToolsDisabled)) | 1834 if (profile_->GetPrefs()->GetBoolean(prefs::kDevToolsDisabled)) |
1894 content::DevToolsManager::GetInstance()->CloseAllClientHosts(); | 1835 content::DevToolsManager::GetInstance()->CloseAllClientHosts(); |
1895 } else if (pref_name == prefs::kShowBookmarkBar) { | 1836 } else if (pref_name == prefs::kShowBookmarkBar) { |
1896 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_PREF_CHANGE); | 1837 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_PREF_CHANGE); |
1897 } else if (pref_name == prefs::kHomePage) { | 1838 } else if (pref_name == prefs::kHomePage) { |
1898 PrefService* pref_service = content::Source<PrefService>(source).ptr(); | 1839 PrefService* pref_service = content::Source<PrefService>(source).ptr(); |
1899 MarkHomePageAsChanged(pref_service); | 1840 MarkHomePageAsChanged(pref_service); |
1900 } else { | 1841 } else { |
1901 NOTREACHED(); | 1842 NOTREACHED(); |
1902 } | 1843 } |
(...skipping 17 matching lines...) Expand all Loading... |
1920 case content::NOTIFICATION_INTERSTITIAL_DETACHED: | 1861 case content::NOTIFICATION_INTERSTITIAL_DETACHED: |
1921 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TAB_STATE); | 1862 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TAB_STATE); |
1922 break; | 1863 break; |
1923 | 1864 |
1924 default: | 1865 default: |
1925 NOTREACHED() << "Got a notification we didn't register for."; | 1866 NOTREACHED() << "Got a notification we didn't register for."; |
1926 } | 1867 } |
1927 } | 1868 } |
1928 | 1869 |
1929 /////////////////////////////////////////////////////////////////////////////// | 1870 /////////////////////////////////////////////////////////////////////////////// |
1930 // Browser, InstantControllerDelegate implementation: | |
1931 | |
1932 void Browser::ShowInstant(TabContents* preview_contents) { | |
1933 window_->ShowInstant(preview_contents); | |
1934 | |
1935 // TODO(beng): investigate if we can avoid this and instead rely on the | |
1936 // visibility of the WebContentsView | |
1937 chrome::GetActiveWebContents(this)->WasHidden(); | |
1938 preview_contents->web_contents()->WasRestored(); | |
1939 } | |
1940 | |
1941 void Browser::HideInstant() { | |
1942 window_->HideInstant(); | |
1943 if (chrome::GetActiveWebContents(this)) | |
1944 chrome::GetActiveWebContents(this)->WasRestored(); | |
1945 if (instant_->GetPreviewContents()) | |
1946 instant_->GetPreviewContents()->web_contents()->WasHidden(); | |
1947 } | |
1948 | |
1949 void Browser::CommitInstant(TabContents* preview_contents) { | |
1950 TabContents* tab_contents = chrome::GetActiveTabContents(this); | |
1951 int index = tab_strip_model_->GetIndexOfTabContents(tab_contents); | |
1952 DCHECK_NE(TabStripModel::kNoTab, index); | |
1953 // TabStripModel takes ownership of preview_contents. | |
1954 tab_strip_model_->ReplaceTabContentsAt(index, preview_contents); | |
1955 // InstantUnloadHandler takes ownership of tab_contents. | |
1956 instant_unload_handler_->RunUnloadListenersOrDestroy(tab_contents, index); | |
1957 | |
1958 GURL url = preview_contents->web_contents()->GetURL(); | |
1959 DCHECK(profile_->GetExtensionService()); | |
1960 if (profile_->GetExtensionService()->IsInstalledApp(url)) { | |
1961 AppLauncherHandler::RecordAppLaunchType( | |
1962 extension_misc::APP_LAUNCH_OMNIBOX_INSTANT); | |
1963 } | |
1964 } | |
1965 | |
1966 void Browser::SetSuggestedText(const string16& text, | |
1967 InstantCompleteBehavior behavior) { | |
1968 if (window()->GetLocationBar()) | |
1969 window()->GetLocationBar()->SetSuggestedText(text, behavior); | |
1970 } | |
1971 | |
1972 gfx::Rect Browser::GetInstantBounds() { | |
1973 return window()->GetInstantBounds(); | |
1974 } | |
1975 | |
1976 void Browser::InstantPreviewFocused() { | |
1977 // NOTE: This is only invoked on aura. | |
1978 window_->WebContentsFocused(instant_->GetPreviewContents()->web_contents()); | |
1979 } | |
1980 | |
1981 TabContents* Browser::GetInstantHostTabContents() const { | |
1982 return chrome::GetActiveTabContents(this); | |
1983 } | |
1984 | |
1985 /////////////////////////////////////////////////////////////////////////////// | |
1986 // Browser, Command and state updating (private): | 1871 // Browser, Command and state updating (private): |
1987 | 1872 |
1988 void Browser::MarkHomePageAsChanged(PrefService* pref_service) { | 1873 void Browser::MarkHomePageAsChanged(PrefService* pref_service) { |
1989 pref_service->SetBoolean(prefs::kHomePageChanged, true); | 1874 pref_service->SetBoolean(prefs::kHomePageChanged, true); |
1990 } | 1875 } |
1991 | 1876 |
1992 /////////////////////////////////////////////////////////////////////////////// | 1877 /////////////////////////////////////////////////////////////////////////////// |
1993 // Browser, UI update coalescing and handling (private): | 1878 // Browser, UI update coalescing and handling (private): |
1994 | 1879 |
1995 void Browser::UpdateToolbar(bool should_restore_state) { | 1880 void Browser::UpdateToolbar(bool should_restore_state) { |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2257 | 2142 |
2258 if (is_type_tabbed()) | 2143 if (is_type_tabbed()) |
2259 features |= FEATURE_TOOLBAR; | 2144 features |= FEATURE_TOOLBAR; |
2260 | 2145 |
2261 if (!is_app()) | 2146 if (!is_app()) |
2262 features |= FEATURE_LOCATIONBAR; | 2147 features |= FEATURE_LOCATIONBAR; |
2263 } | 2148 } |
2264 return !!(features & feature); | 2149 return !!(features & feature); |
2265 } | 2150 } |
2266 | 2151 |
2267 void Browser::CreateInstantIfNecessary() { | |
2268 if (is_type_tabbed() && InstantController::IsEnabled(profile()) && | |
2269 !profile()->IsOffTheRecord()) { | |
2270 instant_.reset(new InstantController(this, InstantController::INSTANT)); | |
2271 instant_unload_handler_.reset(new InstantUnloadHandler(this)); | |
2272 } | |
2273 } | |
2274 | |
2275 void Browser::UpdateBookmarkBarState(BookmarkBarStateChangeReason reason) { | 2152 void Browser::UpdateBookmarkBarState(BookmarkBarStateChangeReason reason) { |
2276 BookmarkBar::State state; | 2153 BookmarkBar::State state; |
2277 // The bookmark bar is hidden in fullscreen mode, unless on the new tab page. | 2154 // The bookmark bar is hidden in fullscreen mode, unless on the new tab page. |
2278 if (browser_defaults::bookmarks_enabled && | 2155 if (browser_defaults::bookmarks_enabled && |
2279 profile_->GetPrefs()->GetBoolean(prefs::kShowBookmarkBar) && | 2156 profile_->GetPrefs()->GetBoolean(prefs::kShowBookmarkBar) && |
2280 (!window_ || !window_->IsFullscreen())) { | 2157 (!window_ || !window_->IsFullscreen())) { |
2281 state = BookmarkBar::SHOW; | 2158 state = BookmarkBar::SHOW; |
2282 } else { | 2159 } else { |
2283 TabContents* tab = chrome::GetActiveTabContents(this); | 2160 TabContents* tab = chrome::GetActiveTabContents(this); |
2284 if (tab && tab->bookmark_tab_helper()->ShouldShowBookmarkBar()) | 2161 if (tab && tab->bookmark_tab_helper()->ShouldShowBookmarkBar()) |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2386 if (contents && !allow_js_access) { | 2263 if (contents && !allow_js_access) { |
2387 contents->web_contents()->GetController().LoadURL( | 2264 contents->web_contents()->GetController().LoadURL( |
2388 target_url, | 2265 target_url, |
2389 content::Referrer(), | 2266 content::Referrer(), |
2390 content::PAGE_TRANSITION_LINK, | 2267 content::PAGE_TRANSITION_LINK, |
2391 std::string()); // No extra headers. | 2268 std::string()); // No extra headers. |
2392 } | 2269 } |
2393 | 2270 |
2394 return contents != NULL; | 2271 return contents != NULL; |
2395 } | 2272 } |
OLD | NEW |