diff options
-rw-r--r-- | chrome/app/chrome_command_ids.h | 1 | ||||
-rw-r--r-- | chrome/app/generated_resources.grd | 6 | ||||
-rw-r--r-- | chrome/browser/ui/browser_command_controller.cc | 7 | ||||
-rw-r--r-- | chrome/browser/ui/browser_commands_chromeos.cc | 24 | ||||
-rw-r--r-- | chrome/browser/ui/browser_commands_chromeos.h | 11 | ||||
-rw-r--r-- | chrome/browser/ui/toolbar/wrench_menu_model.cc | 4 | ||||
-rw-r--r-- | chrome/browser/ui/views/toolbar/wrench_menu.cc | 25 | ||||
-rw-r--r-- | chrome/browser/ui/views/toolbar/wrench_menu.h | 3 | ||||
-rw-r--r-- | chrome/chrome_browser_ui.gypi | 2 |
9 files changed, 75 insertions, 8 deletions
diff --git a/chrome/app/chrome_command_ids.h b/chrome/app/chrome_command_ids.h index b3ecb3b..4b7a3fe 100644 --- a/chrome/app/chrome_command_ids.h +++ b/chrome/app/chrome_command_ids.h @@ -213,6 +213,7 @@ #define IDC_EXTENSIONS_OVERFLOW_MENU 40245 #define IDC_SHOW_SRT_BUBBLE 40246 #define IDC_ELEVATED_RECOVERY_DIALOG 40247 +#define IDC_TAKE_SCREENSHOT 40248 // Spell-check // Insert any additional suggestions before _LAST; these have to be consecutive. diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd index c1dc7af..c5c1a3b 100644 --- a/chrome/app/generated_resources.grd +++ b/chrome/app/generated_resources.grd @@ -1417,6 +1417,9 @@ Psst! Incognito mode <ph name="SHORTCUT_KEY">$1<ex>(Ctrl+Shift+N)</ex></ph> may <message name="IDS_TASK_MANAGER" desc="The text label of the Task Manager menu item"> &Task manager </message> + <message name="IDS_TAKE_SCREENSHOT" desc="The text label of the Take Screenshot menu item"> + T&ake screenshot + </message> <message name="IDS_RESTORE_TAB" desc="The text label of the Restore Tab menu item"> R&eopen closed tab </message> @@ -1443,6 +1446,9 @@ Psst! Incognito mode <ph name="SHORTCUT_KEY">$1<ex>(Ctrl+Shift+N)</ex></ph> may <message name="IDS_TASK_MANAGER" desc="In Title Case: The text label of the Task Manager menu item"> &Task Manager </message> + <message name="IDS_TAKE_SCREENSHOT" desc="The text label of the Take Screenshot menu item"> + T&ake Screenshot + </message> <message name="IDS_RESTORE_TAB" desc="In Title Case: The text label of the Restore Tab menu item"> R&eopen Closed Tab </message> diff --git a/chrome/browser/ui/browser_command_controller.cc b/chrome/browser/ui/browser_command_controller.cc index 0b47a1a..d0c8e57 100644 --- a/chrome/browser/ui/browser_command_controller.cc +++ b/chrome/browser/ui/browser_command_controller.cc @@ -66,6 +66,7 @@ #include "ash/shell.h" #include "chrome/browser/ui/ash/multi_user/multi_user_context_menu.h" #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h" +#include "chrome/browser/ui/browser_commands_chromeos.h" #endif #if defined(OS_LINUX) && !defined(OS_CHROMEOS) @@ -695,6 +696,11 @@ void BrowserCommandController::ExecuteCommandWithDisposition( case IDC_TASK_MANAGER: OpenTaskManager(browser_); break; +#if defined(OS_CHROMEOS) + case IDC_TAKE_SCREENSHOT: + TakeScreenshot(); + break; +#endif #if defined(GOOGLE_CHROME_BUILD) case IDC_FEEDBACK: OpenFeedbackDialog(browser_); @@ -966,6 +972,7 @@ void BrowserCommandController::InitCommandState() { !profile()->IsOffTheRecord()); command_updater_.UpdateCommandEnabled(IDC_CLEAR_BROWSING_DATA, normal_window); #if defined(OS_CHROMEOS) + command_updater_.UpdateCommandEnabled(IDC_TAKE_SCREENSHOT, true); command_updater_.UpdateCommandEnabled(IDC_TOUCH_HUD_PROJECTION_TOGGLE, true); #else // Chrome OS uses the system tray menu to handle multi-profiles. diff --git a/chrome/browser/ui/browser_commands_chromeos.cc b/chrome/browser/ui/browser_commands_chromeos.cc new file mode 100644 index 0000000..d6e6dbb --- /dev/null +++ b/chrome/browser/ui/browser_commands_chromeos.cc @@ -0,0 +1,24 @@ +// Copyright 2015 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_commands_chromeos.h" + +#include "ash/accelerators/accelerator_controller.h" +#include "ash/metrics/user_metrics_recorder.h" +#include "ash/screenshot_delegate.h" +#include "ash/shell.h" +#include "base/metrics/user_metrics_action.h" +#include "content/public/browser/user_metrics.h" + +using base::UserMetricsAction; + +void TakeScreenshot() { + content::RecordAction(UserMetricsAction("Menu_Take_Screenshot")); + ash::ScreenshotDelegate* screenshot_delegate = ash::Shell::GetInstance()-> + accelerator_controller()->screenshot_delegate(); + if (screenshot_delegate && + screenshot_delegate->CanTakeScreenshot()) { + screenshot_delegate->HandleTakeScreenshotForAllRootWindows(); + } +} diff --git a/chrome/browser/ui/browser_commands_chromeos.h b/chrome/browser/ui/browser_commands_chromeos.h new file mode 100644 index 0000000..ab457f1 --- /dev/null +++ b/chrome/browser/ui/browser_commands_chromeos.h @@ -0,0 +1,11 @@ +// Copyright 2015 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. + +#ifndef CHROME_BROWSER_UI_BROWSER_COMMANDS_CHROMEOS_H_ +#define CHROME_BROWSER_UI_BROWSER_COMMANDS_CHROMEOS_H_ + +// Takes a screenshot of the entire desktop (not just the browser window). +void TakeScreenshot(); + +#endif // CHROME_BROWSER_UI_BROWSER_COMMANDS_CHROMEOS_H_ diff --git a/chrome/browser/ui/toolbar/wrench_menu_model.cc b/chrome/browser/ui/toolbar/wrench_menu_model.cc index f8dbcf8..010f4d2 100644 --- a/chrome/browser/ui/toolbar/wrench_menu_model.cc +++ b/chrome/browser/ui/toolbar/wrench_menu_model.cc @@ -254,6 +254,10 @@ void ToolsMenuModel::Build(Browser* browser) { AddItemWithStringId(IDC_CLEAR_BROWSING_DATA, IDS_CLEAR_BROWSING_DATA); +#if defined(OS_CHROMEOS) + AddItemWithStringId(IDC_TAKE_SCREENSHOT, IDS_TAKE_SCREENSHOT); +#endif + AddSeparator(ui::NORMAL_SEPARATOR); encoding_menu_model_.reset(new EncodingMenuModel(browser)); diff --git a/chrome/browser/ui/views/toolbar/wrench_menu.cc b/chrome/browser/ui/views/toolbar/wrench_menu.cc index 55c85ab..3d3f5ca 100644 --- a/chrome/browser/ui/views/toolbar/wrench_menu.cc +++ b/chrome/browser/ui/views/toolbar/wrench_menu.cc @@ -787,12 +787,13 @@ class WrenchMenu::RecentTabsMenuModelDelegate : public ui::MenuModelDelegate { // WrenchMenu ------------------------------------------------------------------ WrenchMenu::WrenchMenu(Browser* browser, int run_flags) - : root_(NULL), + : root_(nullptr), browser_(browser), - selected_menu_model_(NULL), + selected_menu_model_(nullptr), selected_index_(0), - bookmark_menu_(NULL), - feedback_menu_item_(NULL), + bookmark_menu_(nullptr), + feedback_menu_item_(nullptr), + screenshot_menu_item_(nullptr), run_flags_(run_flags) { registrar_.Add(this, chrome::NOTIFICATION_GLOBAL_ERRORS_CHANGED, content::Source<Profile>(browser_->profile())); @@ -1053,10 +1054,11 @@ void WrenchMenu::WillShowMenu(MenuItemView* menu) { void WrenchMenu::WillHideMenu(MenuItemView* menu) { // Turns off the fade out animation of the wrench menus if - // |feedback_menu_item_| is selected. This excludes the wrench menu itself - // from the snapshot in the feedback UI. - if (menu->HasSubmenu() && feedback_menu_item_ && - feedback_menu_item_->IsSelected()) { + // |feedback_menu_item_| or |screenshot_menu_item_| is selected. This + // excludes the wrench menu itself from the screenshot. + if (menu->HasSubmenu() && + ((feedback_menu_item_ && feedback_menu_item_->IsSelected()) || + (screenshot_menu_item_ && screenshot_menu_item_->IsSelected()))) { // It's okay to just turn off the animation and no to take care the // animation back because the menu widget will be recreated next time // it's opened. See ToolbarView::RunMenu() and Init() of this class. @@ -1161,6 +1163,13 @@ void WrenchMenu::PopulateMenu(MenuItemView* parent, break; #endif +#if defined(OS_CHROMEOS) + case IDC_TAKE_SCREENSHOT: + DCHECK(!screenshot_menu_item_); + screenshot_menu_item_ = item; + break; +#endif + case IDC_RECENT_TABS_MENU: DCHECK(!recent_tabs_menu_model_delegate_.get()); recent_tabs_menu_model_delegate_.reset( diff --git a/chrome/browser/ui/views/toolbar/wrench_menu.h b/chrome/browser/ui/views/toolbar/wrench_menu.h index 1966dd2..22fb897 100644 --- a/chrome/browser/ui/views/toolbar/wrench_menu.h +++ b/chrome/browser/ui/views/toolbar/wrench_menu.h @@ -176,6 +176,9 @@ class WrenchMenu : public views::MenuDelegate, // Menu corresponding to IDC_FEEDBACK. views::MenuItemView* feedback_menu_item_; + // Menu corresponding to IDC_TAKE_SCREENSHOT. + views::MenuItemView* screenshot_menu_item_; + // Used for managing "Recent tabs" menu items. scoped_ptr<RecentTabsMenuModelDelegate> recent_tabs_menu_model_delegate_; diff --git a/chrome/chrome_browser_ui.gypi b/chrome/chrome_browser_ui.gypi index 16899e2..d75dcb6 100644 --- a/chrome/chrome_browser_ui.gypi +++ b/chrome/chrome_browser_ui.gypi @@ -127,6 +127,8 @@ 'browser/ui/bookmarks/bookmark_utils.h', 'browser/ui/bookmarks/recently_used_folders_combo_model.cc', 'browser/ui/bookmarks/recently_used_folders_combo_model.h', + 'browser/ui/browser_commands_chromeos.cc', + 'browser/ui/browser_commands_chromeos.h', 'browser/ui/browser_commands_mac.cc', 'browser/ui/browser_commands_mac.h', 'browser/ui/browser_content_translate_driver_observer.cc', |