| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 318 if (local_state) { | 318 if (local_state) { |
| 319 local_pref_registrar_.Init(local_state); | 319 local_pref_registrar_.Init(local_state); |
| 320 local_pref_registrar_.Add(prefs::kPrintingEnabled, this); | 320 local_pref_registrar_.Add(prefs::kPrintingEnabled, this); |
| 321 local_pref_registrar_.Add(prefs::kAllowFileSelectionDialogs, this); | 321 local_pref_registrar_.Add(prefs::kAllowFileSelectionDialogs, this); |
| 322 local_pref_registrar_.Add(prefs::kMetricsReportingEnabled, this); | 322 local_pref_registrar_.Add(prefs::kMetricsReportingEnabled, this); |
| 323 } | 323 } |
| 324 | 324 |
| 325 profile_pref_registrar_.Init(profile_->GetPrefs()); | 325 profile_pref_registrar_.Init(profile_->GetPrefs()); |
| 326 profile_pref_registrar_.Add(prefs::kDevToolsDisabled, this); | 326 profile_pref_registrar_.Add(prefs::kDevToolsDisabled, this); |
| 327 profile_pref_registrar_.Add(prefs::kEditBookmarksEnabled, this); | 327 profile_pref_registrar_.Add(prefs::kEditBookmarksEnabled, this); |
| 328 profile_pref_registrar_.Add(prefs::kEnableBookmarkBar, this); | 328 profile_pref_registrar_.Add(prefs::kShowBookmarkBar, this); |
| 329 profile_pref_registrar_.Add(prefs::kHomePage, this); | 329 profile_pref_registrar_.Add(prefs::kHomePage, this); |
| 330 profile_pref_registrar_.Add(prefs::kInstantEnabled, this); | 330 profile_pref_registrar_.Add(prefs::kInstantEnabled, this); |
| 331 profile_pref_registrar_.Add(prefs::kIncognitoModeAvailability, this); | 331 profile_pref_registrar_.Add(prefs::kIncognitoModeAvailability, this); |
| 332 profile_pref_registrar_.Add(prefs::kSearchSuggestEnabled, this); | 332 profile_pref_registrar_.Add(prefs::kSearchSuggestEnabled, this); |
| 333 | 333 |
| 334 InitCommandState(); | 334 InitCommandState(); |
| 335 BrowserList::AddBrowser(this); | 335 BrowserList::AddBrowser(this); |
| 336 | 336 |
| 337 // NOTE: These prefs all need to be explicitly destroyed in the destructor | 337 // NOTE: These prefs all need to be explicitly destroyed in the destructor |
| 338 // or you'll get a nasty surprise when you run the incognito tests. | 338 // or you'll get a nasty surprise when you run the incognito tests. |
| (...skipping 1951 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2290 PrefService::UNSYNCABLE_PREF); | 2290 PrefService::UNSYNCABLE_PREF); |
| 2291 prefs->RegisterBooleanPref(prefs::kWebAppCreateInQuickLaunchBar, | 2291 prefs->RegisterBooleanPref(prefs::kWebAppCreateInQuickLaunchBar, |
| 2292 true, | 2292 true, |
| 2293 PrefService::UNSYNCABLE_PREF); | 2293 PrefService::UNSYNCABLE_PREF); |
| 2294 prefs->RegisterBooleanPref(prefs::kUseVerticalTabs, | 2294 prefs->RegisterBooleanPref(prefs::kUseVerticalTabs, |
| 2295 false, | 2295 false, |
| 2296 PrefService::UNSYNCABLE_PREF); | 2296 PrefService::UNSYNCABLE_PREF); |
| 2297 prefs->RegisterBooleanPref(prefs::kEnableTranslate, | 2297 prefs->RegisterBooleanPref(prefs::kEnableTranslate, |
| 2298 true, | 2298 true, |
| 2299 PrefService::SYNCABLE_PREF); | 2299 PrefService::SYNCABLE_PREF); |
| 2300 prefs->RegisterBooleanPref(prefs::kEnableBookmarkBar, | |
| 2301 true, | |
| 2302 PrefService::UNSYNCABLE_PREF); | |
| 2303 prefs->RegisterStringPref(prefs::kCloudPrintEmail, | 2300 prefs->RegisterStringPref(prefs::kCloudPrintEmail, |
| 2304 std::string(), | 2301 std::string(), |
| 2305 PrefService::UNSYNCABLE_PREF); | 2302 PrefService::UNSYNCABLE_PREF); |
| 2306 prefs->RegisterBooleanPref(prefs::kCloudPrintProxyEnabled, | 2303 prefs->RegisterBooleanPref(prefs::kCloudPrintProxyEnabled, |
| 2307 true, | 2304 true, |
| 2308 PrefService::UNSYNCABLE_PREF); | 2305 PrefService::UNSYNCABLE_PREF); |
| 2309 prefs->RegisterBooleanPref(prefs::kDevToolsDisabled, | 2306 prefs->RegisterBooleanPref(prefs::kDevToolsDisabled, |
| 2310 false, | 2307 false, |
| 2311 PrefService::UNSYNCABLE_PREF); | 2308 PrefService::UNSYNCABLE_PREF); |
| 2312 prefs->RegisterIntegerPref(prefs::kDevToolsSplitLocation, | 2309 prefs->RegisterIntegerPref(prefs::kDevToolsSplitLocation, |
| (...skipping 1791 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4104 available != IncognitoModePrefs::FORCED); | 4101 available != IncognitoModePrefs::FORCED); |
| 4105 command_updater_.UpdateCommandEnabled( | 4102 command_updater_.UpdateCommandEnabled( |
| 4106 IDC_NEW_INCOGNITO_WINDOW, | 4103 IDC_NEW_INCOGNITO_WINDOW, |
| 4107 available != IncognitoModePrefs::DISABLED); | 4104 available != IncognitoModePrefs::DISABLED); |
| 4108 } else if (pref_name == prefs::kDevToolsDisabled) { | 4105 } else if (pref_name == prefs::kDevToolsDisabled) { |
| 4109 UpdateCommandsForDevTools(); | 4106 UpdateCommandsForDevTools(); |
| 4110 if (profile_->GetPrefs()->GetBoolean(prefs::kDevToolsDisabled)) | 4107 if (profile_->GetPrefs()->GetBoolean(prefs::kDevToolsDisabled)) |
| 4111 g_browser_process->devtools_manager()->CloseAllClientHosts(); | 4108 g_browser_process->devtools_manager()->CloseAllClientHosts(); |
| 4112 } else if (pref_name == prefs::kEditBookmarksEnabled) { | 4109 } else if (pref_name == prefs::kEditBookmarksEnabled) { |
| 4113 UpdateCommandsForBookmarkEditing(); | 4110 UpdateCommandsForBookmarkEditing(); |
| 4114 } else if (pref_name == prefs::kEnableBookmarkBar) { | 4111 } else if (pref_name == prefs::kShowBookmarkBar) { |
| 4115 UpdateCommandsForBookmarkBar(); | 4112 UpdateCommandsForBookmarkBar(); |
| 4116 } else if (pref_name == prefs::kHomePage) { | 4113 } else if (pref_name == prefs::kHomePage) { |
| 4117 PrefService* pref_service = Source<PrefService>(source).ptr(); | 4114 PrefService* pref_service = Source<PrefService>(source).ptr(); |
| 4118 MarkHomePageAsChanged(pref_service); | 4115 MarkHomePageAsChanged(pref_service); |
| 4119 } else if (pref_name == prefs::kAllowFileSelectionDialogs) { | 4116 } else if (pref_name == prefs::kAllowFileSelectionDialogs) { |
| 4120 UpdateSaveAsState(GetContentRestrictionsForSelectedTab()); | 4117 UpdateSaveAsState(GetContentRestrictionsForSelectedTab()); |
| 4121 UpdateOpenFileState(); | 4118 UpdateOpenFileState(); |
| 4122 } else { | 4119 } else { |
| 4123 NOTREACHED(); | 4120 NOTREACHED(); |
| 4124 } | 4121 } |
| (...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4568 | 4565 |
| 4569 void Browser::UpdateCommandsForBookmarkBar() { | 4566 void Browser::UpdateCommandsForBookmarkBar() { |
| 4570 #if !defined(OS_MACOSX) | 4567 #if !defined(OS_MACOSX) |
| 4571 const bool show_main_ui = is_type_tabbed() && | 4568 const bool show_main_ui = is_type_tabbed() && |
| 4572 (!window_ || !window_->IsFullscreen()); | 4569 (!window_ || !window_->IsFullscreen()); |
| 4573 #else | 4570 #else |
| 4574 const bool show_main_ui = is_type_tabbed(); | 4571 const bool show_main_ui = is_type_tabbed(); |
| 4575 #endif | 4572 #endif |
| 4576 command_updater_.UpdateCommandEnabled(IDC_SHOW_BOOKMARK_BAR, | 4573 command_updater_.UpdateCommandEnabled(IDC_SHOW_BOOKMARK_BAR, |
| 4577 browser_defaults::bookmarks_enabled && | 4574 browser_defaults::bookmarks_enabled && |
| 4578 !profile_->GetPrefs()->IsManagedPreference(prefs::kEnableBookmarkBar) && | 4575 !profile_->GetPrefs()->IsManagedPreference(prefs::kShowBookmarkBar) && |
| 4579 show_main_ui); | 4576 show_main_ui); |
| 4580 } | 4577 } |
| 4581 | 4578 |
| 4582 void Browser::MarkHomePageAsChanged(PrefService* pref_service) { | 4579 void Browser::MarkHomePageAsChanged(PrefService* pref_service) { |
| 4583 pref_service->SetBoolean(prefs::kHomePageChanged, true); | 4580 pref_service->SetBoolean(prefs::kHomePageChanged, true); |
| 4584 pref_service->ScheduleSavePersistentPrefs(); | 4581 pref_service->ScheduleSavePersistentPrefs(); |
| 4585 } | 4582 } |
| 4586 | 4583 |
| 4587 void Browser::UpdateSaveAsState(int content_restrictions) { | 4584 void Browser::UpdateSaveAsState(int content_restrictions) { |
| 4588 bool enabled = !(content_restrictions & CONTENT_RESTRICTION_SAVE); | 4585 bool enabled = !(content_restrictions & CONTENT_RESTRICTION_SAVE); |
| (...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5221 // See comment in UpdateCommandsForTabState about why we call url(). | 5218 // See comment in UpdateCommandsForTabState about why we call url(). |
| 5222 if (!SavePackage::IsSavableURL(active_entry ? active_entry->url() : GURL())) | 5219 if (!SavePackage::IsSavableURL(active_entry ? active_entry->url() : GURL())) |
| 5223 content_restrictions |= CONTENT_RESTRICTION_SAVE; | 5220 content_restrictions |= CONTENT_RESTRICTION_SAVE; |
| 5224 } | 5221 } |
| 5225 return content_restrictions; | 5222 return content_restrictions; |
| 5226 } | 5223 } |
| 5227 | 5224 |
| 5228 void Browser::UpdateBookmarkBarState(BookmarkBarStateChangeReason reason) { | 5225 void Browser::UpdateBookmarkBarState(BookmarkBarStateChangeReason reason) { |
| 5229 BookmarkBar::State state; | 5226 BookmarkBar::State state; |
| 5230 // The bookmark bar is hidden in fullscreen mode, unless on the new tab page. | 5227 // The bookmark bar is hidden in fullscreen mode, unless on the new tab page. |
| 5231 if ((profile_->GetPrefs()->GetBoolean(prefs::kShowBookmarkBar) && | 5228 if (profile_->GetPrefs()->GetBoolean(prefs::kShowBookmarkBar) && |
| 5232 profile_->GetPrefs()->GetBoolean(prefs::kEnableBookmarkBar)) && | |
| 5233 (!window_ || !window_->IsFullscreen())) { | 5229 (!window_ || !window_->IsFullscreen())) { |
| 5234 state = BookmarkBar::SHOW; | 5230 state = BookmarkBar::SHOW; |
| 5235 } else { | 5231 } else { |
| 5236 TabContentsWrapper* tab = GetSelectedTabContentsWrapper(); | 5232 TabContentsWrapper* tab = GetSelectedTabContentsWrapper(); |
| 5237 if (tab && tab->bookmark_tab_helper()->ShouldShowBookmarkBar()) | 5233 if (tab && tab->bookmark_tab_helper()->ShouldShowBookmarkBar()) |
| 5238 state = BookmarkBar::DETACHED; | 5234 state = BookmarkBar::DETACHED; |
| 5239 else | 5235 else |
| 5240 state = BookmarkBar::HIDDEN; | 5236 state = BookmarkBar::HIDDEN; |
| 5241 } | 5237 } |
| 5242 if (state == bookmark_bar_state_) | 5238 if (state == bookmark_bar_state_) |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5299 window_->GetLocationBar()->ShowFirstRunBubble(bubble_type); | 5295 window_->GetLocationBar()->ShowFirstRunBubble(bubble_type); |
| 5300 } else if (is_type_tabbed()) { | 5296 } else if (is_type_tabbed()) { |
| 5301 GlobalErrorService* service = | 5297 GlobalErrorService* service = |
| 5302 GlobalErrorServiceFactory::GetForProfile(profile()); | 5298 GlobalErrorServiceFactory::GetForProfile(profile()); |
| 5303 GlobalError* error = service->GetFirstGlobalErrorWithBubbleView(); | 5299 GlobalError* error = service->GetFirstGlobalErrorWithBubbleView(); |
| 5304 if (error) { | 5300 if (error) { |
| 5305 error->ShowBubbleView(this); | 5301 error->ShowBubbleView(this); |
| 5306 } | 5302 } |
| 5307 } | 5303 } |
| 5308 } | 5304 } |
| OLD | NEW |