| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "ash/common/system/chromeos/palette/tools/capture_region_action.h" | 5 #include "ash/common/system/chromeos/palette/tools/capture_region_action.h" |
| 6 | 6 |
| 7 #include "ash/common/accelerators/accelerator_controller.h" | 7 #include "ash/common/accelerators/accelerator_controller.h" |
| 8 #include "ash/common/palette_delegate.h" | 8 #include "ash/common/palette_delegate.h" |
| 9 #include "ash/common/system/chromeos/palette/palette_ids.h" | 9 #include "ash/common/system/chromeos/palette/palette_ids.h" |
| 10 #include "ash/common/system/toast/toast_data.h" | 10 #include "ash/common/system/toast/toast_data.h" |
| 11 #include "ash/common/system/toast/toast_manager.h" | 11 #include "ash/common/system/toast/toast_manager.h" |
| 12 #include "ash/common/wm_shell.h" | 12 #include "ash/common/wm_shell.h" |
| 13 #include "base/strings/utf_string_conversions.h" | |
| 14 #include "grit/ash_strings.h" | 13 #include "grit/ash_strings.h" |
| 15 #include "ui/base/l10n/l10n_util.h" | 14 #include "ui/base/l10n/l10n_util.h" |
| 16 | 15 |
| 17 namespace ash { | 16 namespace ash { |
| 18 | 17 |
| 19 namespace { | 18 namespace { |
| 20 | 19 |
| 21 const char kToastId[] = "palette_capture_region"; | 20 const char kToastId[] = "palette_capture_region"; |
| 22 const int kToastDurationMs = 2500; | 21 const int kToastDurationMs = 2500; |
| 23 | 22 |
| 24 // TODO(jdufault): Localize toast message. See crbug.com/634558. | |
| 25 const char kToastMessage[] = "Select a region"; | |
| 26 | |
| 27 } // namespace | 23 } // namespace |
| 28 | 24 |
| 29 CaptureRegionAction::CaptureRegionAction(Delegate* delegate) | 25 CaptureRegionAction::CaptureRegionAction(Delegate* delegate) |
| 30 : CommonPaletteTool(delegate) {} | 26 : CommonPaletteTool(delegate) {} |
| 31 | 27 |
| 32 CaptureRegionAction::~CaptureRegionAction() {} | 28 CaptureRegionAction::~CaptureRegionAction() {} |
| 33 | 29 |
| 34 PaletteGroup CaptureRegionAction::GetGroup() const { | 30 PaletteGroup CaptureRegionAction::GetGroup() const { |
| 35 return PaletteGroup::ACTION; | 31 return PaletteGroup::ACTION; |
| 36 } | 32 } |
| 37 | 33 |
| 38 PaletteToolId CaptureRegionAction::GetToolId() const { | 34 PaletteToolId CaptureRegionAction::GetToolId() const { |
| 39 return PaletteToolId::CAPTURE_REGION; | 35 return PaletteToolId::CAPTURE_REGION; |
| 40 } | 36 } |
| 41 | 37 |
| 42 void CaptureRegionAction::OnEnable() { | 38 void CaptureRegionAction::OnEnable() { |
| 43 CommonPaletteTool::OnEnable(); | 39 CommonPaletteTool::OnEnable(); |
| 44 | 40 |
| 45 ToastData toast(kToastId, base::ASCIIToUTF16(kToastMessage), kToastDurationMs, | 41 ToastData toast( |
| 46 base::string16()); | 42 kToastId, l10n_util::GetStringUTF16(IDS_ASH_PALETTE_CAPTURE_REGION_TOAST), |
| 43 kToastDurationMs, base::string16()); |
| 47 ash::WmShell::Get()->toast_manager()->Show(toast); | 44 ash::WmShell::Get()->toast_manager()->Show(toast); |
| 48 | 45 |
| 49 WmShell::Get()->palette_delegate()->TakePartialScreenshot(); | 46 WmShell::Get()->palette_delegate()->TakePartialScreenshot(); |
| 50 delegate()->DisableTool(GetToolId()); | 47 delegate()->DisableTool(GetToolId()); |
| 51 delegate()->HidePalette(); | 48 delegate()->HidePalette(); |
| 52 } | 49 } |
| 53 | 50 |
| 54 views::View* CaptureRegionAction::CreateView() { | 51 views::View* CaptureRegionAction::CreateView() { |
| 55 return CreateDefaultView( | 52 return CreateDefaultView( |
| 56 l10n_util::GetStringUTF16(IDS_ASH_PALETTE_CAPTURE_REGION_ACTION)); | 53 l10n_util::GetStringUTF16(IDS_ASH_PALETTE_CAPTURE_REGION_ACTION)); |
| 57 } | 54 } |
| 58 | 55 |
| 59 gfx::VectorIconId CaptureRegionAction::GetPaletteIconId() { | 56 gfx::VectorIconId CaptureRegionAction::GetPaletteIconId() { |
| 60 return gfx::VectorIconId::PALETTE_ACTION_CAPTURE_REGION; | 57 return gfx::VectorIconId::PALETTE_ACTION_CAPTURE_REGION; |
| 61 } | 58 } |
| 62 | 59 |
| 63 } // namespace ash | 60 } // namespace ash |
| OLD | NEW |