| 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_command_controller.h" | 5 #include "chrome/browser/ui/browser_command_controller.h" |
| 6 | 6 |
| 7 #include "base/prefs/pref_service.h" | 7 #include "base/prefs/pref_service.h" |
| 8 #include "chrome/app/chrome_command_ids.h" | 8 #include "chrome/app/chrome_command_ids.h" |
| 9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
| 10 #include "chrome/browser/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
| 11 #include "chrome/browser/defaults.h" | 11 #include "chrome/browser/defaults.h" |
| 12 #include "chrome/browser/extensions/extension_service.h" | 12 #include "chrome/browser/extensions/extension_service.h" |
| 13 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 13 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
| 14 #include "chrome/browser/profiles/avatar_menu_model.h" | 14 #include "chrome/browser/profiles/avatar_menu_model.h" |
| 15 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
| 16 #include "chrome/browser/profiles/profile_manager.h" | 16 #include "chrome/browser/profiles/profile_manager.h" |
| 17 #include "chrome/browser/sessions/tab_restore_service.h" | 17 #include "chrome/browser/sessions/tab_restore_service.h" |
| 18 #include "chrome/browser/sessions/tab_restore_service_factory.h" | 18 #include "chrome/browser/sessions/tab_restore_service_factory.h" |
| 19 #include "chrome/browser/shell_integration.h" | 19 #include "chrome/browser/shell_integration.h" |
| 20 #include "chrome/browser/sync/profile_sync_service.h" | 20 #include "chrome/browser/sync/profile_sync_service.h" |
| 21 #include "chrome/browser/sync/profile_sync_service_factory.h" | 21 #include "chrome/browser/sync/profile_sync_service_factory.h" |
| 22 #include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h" | 22 #include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h" |
| 23 #include "chrome/browser/ui/browser.h" | 23 #include "chrome/browser/ui/browser.h" |
| 24 #include "chrome/browser/ui/browser_commands.h" | 24 #include "chrome/browser/ui/browser_commands.h" |
| 25 #include "chrome/browser/ui/browser_window.h" | 25 #include "chrome/browser/ui/browser_window.h" |
| 26 #include "chrome/browser/ui/chrome_pages.h" | 26 #include "chrome/browser/ui/chrome_pages.h" |
| 27 #include "chrome/browser/ui/sync/sync_promo_ui.h" | 27 #include "chrome/browser/ui/sync/sync_promo_ui.h" |
| 28 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 28 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 29 #include "chrome/browser/ui/tabs/tab_strip_model_utils.h" | 29 #include "chrome/browser/ui/tabs/tab_strip_model_utils.h" |
| 30 #include "chrome/common/content_restriction.h" |
| 30 #include "chrome/common/pref_names.h" | 31 #include "chrome/common/pref_names.h" |
| 31 #include "chrome/common/profiling.h" | 32 #include "chrome/common/profiling.h" |
| 32 #include "content/public/browser/native_web_keyboard_event.h" | 33 #include "content/public/browser/native_web_keyboard_event.h" |
| 33 #include "content/public/browser/navigation_controller.h" | 34 #include "content/public/browser/navigation_controller.h" |
| 34 #include "content/public/browser/navigation_entry.h" | 35 #include "content/public/browser/navigation_entry.h" |
| 35 #include "content/public/browser/user_metrics.h" | 36 #include "content/public/browser/user_metrics.h" |
| 36 #include "content/public/browser/web_contents.h" | 37 #include "content/public/browser/web_contents.h" |
| 37 #include "content/public/browser/web_contents_observer.h" | 38 #include "content/public/browser/web_contents_observer.h" |
| 38 #include "content/public/common/content_restriction.h" | |
| 39 #include "content/public/common/url_constants.h" | 39 #include "content/public/common/url_constants.h" |
| 40 #include "ui/base/keycodes/keyboard_codes.h" | 40 #include "ui/base/keycodes/keyboard_codes.h" |
| 41 | 41 |
| 42 #if defined(OS_MACOSX) | 42 #if defined(OS_MACOSX) |
| 43 #include "chrome/browser/ui/browser_commands_mac.h" | 43 #include "chrome/browser/ui/browser_commands_mac.h" |
| 44 #endif | 44 #endif |
| 45 | 45 |
| 46 #if defined(OS_WIN) | 46 #if defined(OS_WIN) |
| 47 #include "base/win/metro.h" | 47 #include "base/win/metro.h" |
| 48 #include "base/win/windows_version.h" | 48 #include "base/win/windows_version.h" |
| (...skipping 986 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1035 | 1035 |
| 1036 UpdateCommandsForContentRestrictionState(); | 1036 UpdateCommandsForContentRestrictionState(); |
| 1037 UpdateCommandsForBookmarkEditing(); | 1037 UpdateCommandsForBookmarkEditing(); |
| 1038 UpdateCommandsForFind(); | 1038 UpdateCommandsForFind(); |
| 1039 } | 1039 } |
| 1040 | 1040 |
| 1041 void BrowserCommandController::UpdateCommandsForContentRestrictionState() { | 1041 void BrowserCommandController::UpdateCommandsForContentRestrictionState() { |
| 1042 int restrictions = GetContentRestrictions(browser_); | 1042 int restrictions = GetContentRestrictions(browser_); |
| 1043 | 1043 |
| 1044 command_updater_.UpdateCommandEnabled( | 1044 command_updater_.UpdateCommandEnabled( |
| 1045 IDC_COPY, !(restrictions & content::CONTENT_RESTRICTION_COPY)); | 1045 IDC_COPY, !(restrictions & CONTENT_RESTRICTION_COPY)); |
| 1046 command_updater_.UpdateCommandEnabled( | 1046 command_updater_.UpdateCommandEnabled( |
| 1047 IDC_CUT, !(restrictions & content::CONTENT_RESTRICTION_CUT)); | 1047 IDC_CUT, !(restrictions & CONTENT_RESTRICTION_CUT)); |
| 1048 command_updater_.UpdateCommandEnabled( | 1048 command_updater_.UpdateCommandEnabled( |
| 1049 IDC_PASTE, !(restrictions & content::CONTENT_RESTRICTION_PASTE)); | 1049 IDC_PASTE, !(restrictions & CONTENT_RESTRICTION_PASTE)); |
| 1050 UpdateSaveAsState(); | 1050 UpdateSaveAsState(); |
| 1051 UpdatePrintingState(); | 1051 UpdatePrintingState(); |
| 1052 } | 1052 } |
| 1053 | 1053 |
| 1054 void BrowserCommandController::UpdateCommandsForDevTools() { | 1054 void BrowserCommandController::UpdateCommandsForDevTools() { |
| 1055 bool dev_tools_enabled = | 1055 bool dev_tools_enabled = |
| 1056 !profile()->GetPrefs()->GetBoolean(prefs::kDevToolsDisabled); | 1056 !profile()->GetPrefs()->GetBoolean(prefs::kDevToolsDisabled); |
| 1057 command_updater_.UpdateCommandEnabled(IDC_DEV_TOOLS, | 1057 command_updater_.UpdateCommandEnabled(IDC_DEV_TOOLS, |
| 1058 dev_tools_enabled); | 1058 dev_tools_enabled); |
| 1059 command_updater_.UpdateCommandEnabled(IDC_DEV_TOOLS_CONSOLE, | 1059 command_updater_.UpdateCommandEnabled(IDC_DEV_TOOLS_CONSOLE, |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1236 | 1236 |
| 1237 BrowserWindow* BrowserCommandController::window() { | 1237 BrowserWindow* BrowserCommandController::window() { |
| 1238 return browser_->window(); | 1238 return browser_->window(); |
| 1239 } | 1239 } |
| 1240 | 1240 |
| 1241 Profile* BrowserCommandController::profile() { | 1241 Profile* BrowserCommandController::profile() { |
| 1242 return browser_->profile(); | 1242 return browser_->profile(); |
| 1243 } | 1243 } |
| 1244 | 1244 |
| 1245 } // namespace chrome | 1245 } // namespace chrome |
| OLD | NEW |