OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/ui/browser_command_controller_base.h" |
| 6 |
| 7 #include "chrome/app/chrome_command_ids.h" |
| 8 #include "chrome/browser/browser_process.h" |
| 9 #include "chrome/browser/command_updater.h" |
| 10 #include "chrome/browser/defaults.h" |
| 11 #include "chrome/browser/extensions/extension_service.h" |
| 12 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
| 13 #include "chrome/browser/prefs/pref_service.h" |
| 14 #include "chrome/browser/profiles/profile.h" |
| 15 #include "chrome/common/pref_names.h" |
| 16 |
| 17 namespace chrome { |
| 18 |
| 19 void BrowserCommandControllerBase::UpdateCommandsForIncognitoAvailability( |
| 20 CommandUpdater* command_updater, |
| 21 Profile* profile) { |
| 22 IncognitoModePrefs::Availability incognito_availability = |
| 23 IncognitoModePrefs::GetAvailability(profile->GetPrefs()); |
| 24 command_updater->UpdateCommandEnabled( |
| 25 IDC_NEW_WINDOW, |
| 26 incognito_availability != IncognitoModePrefs::FORCED); |
| 27 command_updater->UpdateCommandEnabled( |
| 28 IDC_NEW_INCOGNITO_WINDOW, |
| 29 incognito_availability != IncognitoModePrefs::DISABLED); |
| 30 |
| 31 // Bookmark manager and settings page/subpages are forced to open in normal |
| 32 // mode. For this reason we disable these commands when incognito is forced. |
| 33 const bool command_enabled = |
| 34 incognito_availability != IncognitoModePrefs::FORCED; |
| 35 command_updater->UpdateCommandEnabled( |
| 36 IDC_SHOW_BOOKMARK_MANAGER, |
| 37 browser_defaults::bookmarks_enabled && command_enabled); |
| 38 ExtensionService* extension_service = profile->GetExtensionService(); |
| 39 bool enable_extensions = |
| 40 extension_service && extension_service->extensions_enabled(); |
| 41 command_updater->UpdateCommandEnabled(IDC_MANAGE_EXTENSIONS, |
| 42 enable_extensions && command_enabled); |
| 43 |
| 44 command_updater->UpdateCommandEnabled(IDC_IMPORT_SETTINGS, command_enabled); |
| 45 command_updater->UpdateCommandEnabled(IDC_OPTIONS, command_enabled); |
| 46 } |
| 47 |
| 48 void BrowserCommandControllerBase::UpdateOpenFileState( |
| 49 CommandUpdater* command_updater) { |
| 50 bool enabled = true; |
| 51 PrefService* local_state = g_browser_process->local_state(); |
| 52 if (local_state) |
| 53 enabled = local_state->GetBoolean(prefs::kAllowFileSelectionDialogs); |
| 54 |
| 55 command_updater->UpdateCommandEnabled(IDC_OPEN_FILE, enabled); |
| 56 } |
| 57 |
| 58 } // namespace chrome |
OLD | NEW |