Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7122)

Unified Diff: chrome/browser/ui/browser_command_controller_base.cc

Issue 11906008: Make Mac menu code obey incognito availability. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: test fix Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/browser_command_controller_base.cc
diff --git a/chrome/browser/ui/browser_command_controller_base.cc b/chrome/browser/ui/browser_command_controller_base.cc
new file mode 100644
index 0000000000000000000000000000000000000000..7c4dffb42f99724c0efb01ca25c1e67f521758f5
--- /dev/null
+++ b/chrome/browser/ui/browser_command_controller_base.cc
@@ -0,0 +1,58 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/browser_command_controller_base.h"
+
+#include "chrome/app/chrome_command_ids.h"
+#include "chrome/browser/browser_process.h"
+#include "chrome/browser/command_updater.h"
+#include "chrome/browser/defaults.h"
+#include "chrome/browser/extensions/extension_service.h"
+#include "chrome/browser/prefs/incognito_mode_prefs.h"
+#include "chrome/browser/prefs/pref_service.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/common/pref_names.h"
+
+namespace chrome {
+
+void BrowserCommandControllerBase::UpdateCommandsForIncognitoAvailability(
+ CommandUpdater* command_updater,
+ Profile* profile) {
+ IncognitoModePrefs::Availability incognito_availability =
+ IncognitoModePrefs::GetAvailability(profile->GetPrefs());
+ command_updater->UpdateCommandEnabled(
+ IDC_NEW_WINDOW,
+ incognito_availability != IncognitoModePrefs::FORCED);
+ command_updater->UpdateCommandEnabled(
+ IDC_NEW_INCOGNITO_WINDOW,
+ incognito_availability != IncognitoModePrefs::DISABLED);
+
+ // Bookmark manager and settings page/subpages are forced to open in normal
+ // mode. For this reason we disable these commands when incognito is forced.
+ const bool command_enabled =
+ incognito_availability != IncognitoModePrefs::FORCED;
+ command_updater->UpdateCommandEnabled(
+ IDC_SHOW_BOOKMARK_MANAGER,
+ browser_defaults::bookmarks_enabled && command_enabled);
+ ExtensionService* extension_service = profile->GetExtensionService();
+ bool enable_extensions =
+ extension_service && extension_service->extensions_enabled();
+ command_updater->UpdateCommandEnabled(IDC_MANAGE_EXTENSIONS,
+ enable_extensions && command_enabled);
+
+ command_updater->UpdateCommandEnabled(IDC_IMPORT_SETTINGS, command_enabled);
+ command_updater->UpdateCommandEnabled(IDC_OPTIONS, command_enabled);
+}
+
+void BrowserCommandControllerBase::UpdateOpenFileState(
+ CommandUpdater* command_updater) {
+ bool enabled = true;
+ PrefService* local_state = g_browser_process->local_state();
+ if (local_state)
+ enabled = local_state->GetBoolean(prefs::kAllowFileSelectionDialogs);
+
+ command_updater->UpdateCommandEnabled(IDC_OPEN_FILE, enabled);
+}
+
+} // namespace chrome

Powered by Google App Engine
This is Rietveld 408576698