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 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
418 #endif | 418 #endif |
419 registrar_.Add(this, chrome::NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED, | 419 registrar_.Add(this, chrome::NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED, |
420 content::NotificationService::AllSources()); | 420 content::NotificationService::AllSources()); |
421 | 421 |
422 PrefService* local_state = g_browser_process->local_state(); | 422 PrefService* local_state = g_browser_process->local_state(); |
423 if (local_state) { | 423 if (local_state) { |
424 local_pref_registrar_.Init(local_state); | 424 local_pref_registrar_.Init(local_state); |
425 local_pref_registrar_.Add(prefs::kPrintingEnabled, this); | 425 local_pref_registrar_.Add(prefs::kPrintingEnabled, this); |
426 local_pref_registrar_.Add(prefs::kAllowFileSelectionDialogs, this); | 426 local_pref_registrar_.Add(prefs::kAllowFileSelectionDialogs, this); |
427 local_pref_registrar_.Add(prefs::kMetricsReportingEnabled, this); | 427 local_pref_registrar_.Add(prefs::kMetricsReportingEnabled, this); |
| 428 local_pref_registrar_.Add(prefs::kInManagedMode, this); |
428 } | 429 } |
429 | 430 |
430 profile_pref_registrar_.Init(profile_->GetPrefs()); | 431 profile_pref_registrar_.Init(profile_->GetPrefs()); |
431 profile_pref_registrar_.Add(prefs::kDevToolsDisabled, this); | 432 profile_pref_registrar_.Add(prefs::kDevToolsDisabled, this); |
432 profile_pref_registrar_.Add(prefs::kEditBookmarksEnabled, this); | 433 profile_pref_registrar_.Add(prefs::kEditBookmarksEnabled, this); |
433 profile_pref_registrar_.Add(prefs::kShowBookmarkBar, this); | 434 profile_pref_registrar_.Add(prefs::kShowBookmarkBar, this); |
434 profile_pref_registrar_.Add(prefs::kHomePage, this); | 435 profile_pref_registrar_.Add(prefs::kHomePage, this); |
435 profile_pref_registrar_.Add(prefs::kInstantEnabled, this); | 436 profile_pref_registrar_.Add(prefs::kInstantEnabled, this); |
436 profile_pref_registrar_.Add(prefs::kIncognitoModeAvailability, this); | 437 profile_pref_registrar_.Add(prefs::kIncognitoModeAvailability, this); |
437 profile_pref_registrar_.Add(prefs::kSearchSuggestEnabled, this); | 438 profile_pref_registrar_.Add(prefs::kSearchSuggestEnabled, this); |
(...skipping 3821 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4259 UpdateCommandsForBookmarkEditing(); | 4260 UpdateCommandsForBookmarkEditing(); |
4260 } else if (pref_name == prefs::kShowBookmarkBar) { | 4261 } else if (pref_name == prefs::kShowBookmarkBar) { |
4261 UpdateCommandsForBookmarkBar(); | 4262 UpdateCommandsForBookmarkBar(); |
4262 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_PREF_CHANGE); | 4263 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_PREF_CHANGE); |
4263 } else if (pref_name == prefs::kHomePage) { | 4264 } else if (pref_name == prefs::kHomePage) { |
4264 PrefService* pref_service = content::Source<PrefService>(source).ptr(); | 4265 PrefService* pref_service = content::Source<PrefService>(source).ptr(); |
4265 MarkHomePageAsChanged(pref_service); | 4266 MarkHomePageAsChanged(pref_service); |
4266 } else if (pref_name == prefs::kAllowFileSelectionDialogs) { | 4267 } else if (pref_name == prefs::kAllowFileSelectionDialogs) { |
4267 UpdateSaveAsState(GetContentRestrictionsForSelectedTab()); | 4268 UpdateSaveAsState(GetContentRestrictionsForSelectedTab()); |
4268 UpdateOpenFileState(); | 4269 UpdateOpenFileState(); |
| 4270 } else if (pref_name == prefs::kInManagedMode) { |
| 4271 UpdateCommandsForMultipleProfiles(); |
4269 } else { | 4272 } else { |
4270 NOTREACHED(); | 4273 NOTREACHED(); |
4271 } | 4274 } |
4272 break; | 4275 break; |
4273 } | 4276 } |
4274 | 4277 |
4275 case chrome::NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED: { | 4278 case chrome::NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED: { |
4276 WebContents* web_contents = content::Source<WebContents>(source).ptr(); | 4279 WebContents* web_contents = content::Source<WebContents>(source).ptr(); |
4277 if (web_contents == GetSelectedWebContents()) { | 4280 if (web_contents == GetSelectedWebContents()) { |
4278 LocationBar* location_bar = window()->GetLocationBar(); | 4281 LocationBar* location_bar = window()->GetLocationBar(); |
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4681 const bool options_enabled = show_main_ui && | 4684 const bool options_enabled = show_main_ui && |
4682 IncognitoModePrefs::GetAvailability( | 4685 IncognitoModePrefs::GetAvailability( |
4683 profile_->GetPrefs()) != IncognitoModePrefs::FORCED; | 4686 profile_->GetPrefs()) != IncognitoModePrefs::FORCED; |
4684 command_updater_.UpdateCommandEnabled(IDC_OPTIONS, options_enabled); | 4687 command_updater_.UpdateCommandEnabled(IDC_OPTIONS, options_enabled); |
4685 command_updater_.UpdateCommandEnabled(IDC_IMPORT_SETTINGS, options_enabled); | 4688 command_updater_.UpdateCommandEnabled(IDC_IMPORT_SETTINGS, options_enabled); |
4686 | 4689 |
4687 command_updater_.UpdateCommandEnabled(IDC_EDIT_SEARCH_ENGINES, show_main_ui); | 4690 command_updater_.UpdateCommandEnabled(IDC_EDIT_SEARCH_ENGINES, show_main_ui); |
4688 command_updater_.UpdateCommandEnabled(IDC_VIEW_PASSWORDS, show_main_ui); | 4691 command_updater_.UpdateCommandEnabled(IDC_VIEW_PASSWORDS, show_main_ui); |
4689 command_updater_.UpdateCommandEnabled(IDC_ABOUT, show_main_ui); | 4692 command_updater_.UpdateCommandEnabled(IDC_ABOUT, show_main_ui); |
4690 command_updater_.UpdateCommandEnabled(IDC_SHOW_APP_MENU, show_main_ui); | 4693 command_updater_.UpdateCommandEnabled(IDC_SHOW_APP_MENU, show_main_ui); |
4691 command_updater_.UpdateCommandEnabled(IDC_SHOW_AVATAR_MENU, | |
4692 show_main_ui && !profile()->IsOffTheRecord()); | |
4693 #if defined (ENABLE_PROFILING) && !defined(NO_TCMALLOC) | 4694 #if defined (ENABLE_PROFILING) && !defined(NO_TCMALLOC) |
4694 command_updater_.UpdateCommandEnabled(IDC_PROFILING_ENABLED, show_main_ui); | 4695 command_updater_.UpdateCommandEnabled(IDC_PROFILING_ENABLED, show_main_ui); |
4695 #endif | 4696 #endif |
4696 | 4697 |
4697 UpdateCommandsForBookmarkBar(); | 4698 UpdateCommandsForBookmarkBar(); |
| 4699 UpdateCommandsForMultipleProfiles(); |
| 4700 } |
| 4701 |
| 4702 void Browser::UpdateCommandsForMultipleProfiles() { |
| 4703 bool show_main_ui = IsShowingMainUI(window_ && window_->IsFullscreen()); |
| 4704 command_updater_.UpdateCommandEnabled(IDC_SHOW_AVATAR_MENU, |
| 4705 show_main_ui && |
| 4706 !profile()->IsOffTheRecord() && |
| 4707 ProfileManager::IsMultipleProfilesEnabled()); |
4698 } | 4708 } |
4699 | 4709 |
4700 void Browser::UpdatePrintingState(int content_restrictions) { | 4710 void Browser::UpdatePrintingState(int content_restrictions) { |
4701 bool print_enabled = true; | 4711 bool print_enabled = true; |
4702 bool advanced_print_enabled = true; | 4712 bool advanced_print_enabled = true; |
4703 if (g_browser_process->local_state()) { | 4713 if (g_browser_process->local_state()) { |
4704 print_enabled = | 4714 print_enabled = |
4705 g_browser_process->local_state()->GetBoolean(prefs::kPrintingEnabled); | 4715 g_browser_process->local_state()->GetBoolean(prefs::kPrintingEnabled); |
4706 advanced_print_enabled = print_enabled; | 4716 advanced_print_enabled = print_enabled; |
4707 } | 4717 } |
(...skipping 787 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5495 if (contents && !allow_js_access) { | 5505 if (contents && !allow_js_access) { |
5496 contents->web_contents()->GetController().LoadURL( | 5506 contents->web_contents()->GetController().LoadURL( |
5497 target_url, | 5507 target_url, |
5498 content::Referrer(), | 5508 content::Referrer(), |
5499 content::PAGE_TRANSITION_LINK, | 5509 content::PAGE_TRANSITION_LINK, |
5500 std::string()); // No extra headers. | 5510 std::string()); // No extra headers. |
5501 } | 5511 } |
5502 | 5512 |
5503 return contents != NULL; | 5513 return contents != NULL; |
5504 } | 5514 } |
OLD | NEW |