| 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 3826 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4264 UpdateCommandsForBookmarkEditing(); | 4265 UpdateCommandsForBookmarkEditing(); |
| 4265 } else if (pref_name == prefs::kShowBookmarkBar) { | 4266 } else if (pref_name == prefs::kShowBookmarkBar) { |
| 4266 UpdateCommandsForBookmarkBar(); | 4267 UpdateCommandsForBookmarkBar(); |
| 4267 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_PREF_CHANGE); | 4268 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_PREF_CHANGE); |
| 4268 } else if (pref_name == prefs::kHomePage) { | 4269 } else if (pref_name == prefs::kHomePage) { |
| 4269 PrefService* pref_service = content::Source<PrefService>(source).ptr(); | 4270 PrefService* pref_service = content::Source<PrefService>(source).ptr(); |
| 4270 MarkHomePageAsChanged(pref_service); | 4271 MarkHomePageAsChanged(pref_service); |
| 4271 } else if (pref_name == prefs::kAllowFileSelectionDialogs) { | 4272 } else if (pref_name == prefs::kAllowFileSelectionDialogs) { |
| 4272 UpdateSaveAsState(GetContentRestrictionsForSelectedTab()); | 4273 UpdateSaveAsState(GetContentRestrictionsForSelectedTab()); |
| 4273 UpdateOpenFileState(); | 4274 UpdateOpenFileState(); |
| 4275 } else if (pref_name == prefs::kInManagedMode) { |
| 4276 UpdateCommandsForMultipleProfiles(); |
| 4274 } else { | 4277 } else { |
| 4275 NOTREACHED(); | 4278 NOTREACHED(); |
| 4276 } | 4279 } |
| 4277 break; | 4280 break; |
| 4278 } | 4281 } |
| 4279 | 4282 |
| 4280 case chrome::NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED: { | 4283 case chrome::NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED: { |
| 4281 WebContents* web_contents = content::Source<WebContents>(source).ptr(); | 4284 WebContents* web_contents = content::Source<WebContents>(source).ptr(); |
| 4282 if (web_contents == GetSelectedWebContents()) { | 4285 if (web_contents == GetSelectedWebContents()) { |
| 4283 LocationBar* location_bar = window()->GetLocationBar(); | 4286 LocationBar* location_bar = window()->GetLocationBar(); |
| (...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4686 const bool options_enabled = show_main_ui && | 4689 const bool options_enabled = show_main_ui && |
| 4687 IncognitoModePrefs::GetAvailability( | 4690 IncognitoModePrefs::GetAvailability( |
| 4688 profile_->GetPrefs()) != IncognitoModePrefs::FORCED; | 4691 profile_->GetPrefs()) != IncognitoModePrefs::FORCED; |
| 4689 command_updater_.UpdateCommandEnabled(IDC_OPTIONS, options_enabled); | 4692 command_updater_.UpdateCommandEnabled(IDC_OPTIONS, options_enabled); |
| 4690 command_updater_.UpdateCommandEnabled(IDC_IMPORT_SETTINGS, options_enabled); | 4693 command_updater_.UpdateCommandEnabled(IDC_IMPORT_SETTINGS, options_enabled); |
| 4691 | 4694 |
| 4692 command_updater_.UpdateCommandEnabled(IDC_EDIT_SEARCH_ENGINES, show_main_ui); | 4695 command_updater_.UpdateCommandEnabled(IDC_EDIT_SEARCH_ENGINES, show_main_ui); |
| 4693 command_updater_.UpdateCommandEnabled(IDC_VIEW_PASSWORDS, show_main_ui); | 4696 command_updater_.UpdateCommandEnabled(IDC_VIEW_PASSWORDS, show_main_ui); |
| 4694 command_updater_.UpdateCommandEnabled(IDC_ABOUT, show_main_ui); | 4697 command_updater_.UpdateCommandEnabled(IDC_ABOUT, show_main_ui); |
| 4695 command_updater_.UpdateCommandEnabled(IDC_SHOW_APP_MENU, show_main_ui); | 4698 command_updater_.UpdateCommandEnabled(IDC_SHOW_APP_MENU, show_main_ui); |
| 4696 command_updater_.UpdateCommandEnabled(IDC_SHOW_AVATAR_MENU, | |
| 4697 show_main_ui && !profile()->IsOffTheRecord()); | |
| 4698 #if defined (ENABLE_PROFILING) && !defined(NO_TCMALLOC) | 4699 #if defined (ENABLE_PROFILING) && !defined(NO_TCMALLOC) |
| 4699 command_updater_.UpdateCommandEnabled(IDC_PROFILING_ENABLED, show_main_ui); | 4700 command_updater_.UpdateCommandEnabled(IDC_PROFILING_ENABLED, show_main_ui); |
| 4700 #endif | 4701 #endif |
| 4701 | 4702 |
| 4702 UpdateCommandsForBookmarkBar(); | 4703 UpdateCommandsForBookmarkBar(); |
| 4704 UpdateCommandsForMultipleProfiles(); |
| 4705 } |
| 4706 |
| 4707 void Browser::UpdateCommandsForMultipleProfiles() { |
| 4708 bool show_main_ui = IsShowingMainUI(window_ && window_->IsFullscreen()); |
| 4709 command_updater_.UpdateCommandEnabled(IDC_SHOW_AVATAR_MENU, |
| 4710 show_main_ui && |
| 4711 !profile()->IsOffTheRecord() && |
| 4712 ProfileManager::IsMultipleProfilesEnabled()); |
| 4703 } | 4713 } |
| 4704 | 4714 |
| 4705 void Browser::UpdatePrintingState(int content_restrictions) { | 4715 void Browser::UpdatePrintingState(int content_restrictions) { |
| 4706 bool print_enabled = true; | 4716 bool print_enabled = true; |
| 4707 bool advanced_print_enabled = true; | 4717 bool advanced_print_enabled = true; |
| 4708 if (g_browser_process->local_state()) { | 4718 if (g_browser_process->local_state()) { |
| 4709 print_enabled = | 4719 print_enabled = |
| 4710 g_browser_process->local_state()->GetBoolean(prefs::kPrintingEnabled); | 4720 g_browser_process->local_state()->GetBoolean(prefs::kPrintingEnabled); |
| 4711 advanced_print_enabled = print_enabled; | 4721 advanced_print_enabled = print_enabled; |
| 4712 } | 4722 } |
| (...skipping 787 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5500 if (contents && !allow_js_access) { | 5510 if (contents && !allow_js_access) { |
| 5501 contents->web_contents()->GetController().LoadURL( | 5511 contents->web_contents()->GetController().LoadURL( |
| 5502 target_url, | 5512 target_url, |
| 5503 content::Referrer(), | 5513 content::Referrer(), |
| 5504 content::PAGE_TRANSITION_LINK, | 5514 content::PAGE_TRANSITION_LINK, |
| 5505 std::string()); // No extra headers. | 5515 std::string()); // No extra headers. |
| 5506 } | 5516 } |
| 5507 | 5517 |
| 5508 return contents != NULL; | 5518 return contents != NULL; |
| 5509 } | 5519 } |
| OLD | NEW |