Commit 727a5ebe authored by Sammie Quon's avatar Sammie Quon Committed by Commit Bot

capture_mode: Adds point of entry in palette tools.

When the feature is turned on, replaces the two screenshot related tools
in the palette bubble. This uses the existing palette tool histogram
recording. Removes some unused functions. Screenshot in linked bug.

Test: manual
Change-Id: I145dd875fac579955b17531c63b5bed2d2e48305
Fixed: 1113014
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2333824
Commit-Queue: Sammie Quon <sammiequon@chromium.org>
Reviewed-by: default avatarAhmed Fakhry <afakhry@chromium.org>
Cr-Commit-Position: refs/heads/master@{#795211}
parent accf09e6
...@@ -1010,6 +1010,8 @@ component("ash") { ...@@ -1010,6 +1010,8 @@ component("ash") {
"system/palette/tools/capture_screen_action.h", "system/palette/tools/capture_screen_action.h",
"system/palette/tools/create_note_action.cc", "system/palette/tools/create_note_action.cc",
"system/palette/tools/create_note_action.h", "system/palette/tools/create_note_action.h",
"system/palette/tools/enter_capture_mode.cc",
"system/palette/tools/enter_capture_mode.h",
"system/palette/tools/laser_pointer_mode.cc", "system/palette/tools/laser_pointer_mode.cc",
"system/palette/tools/laser_pointer_mode.h", "system/palette/tools/laser_pointer_mode.h",
"system/palette/tools/magnifier_mode.cc", "system/palette/tools/magnifier_mode.cc",
......
...@@ -902,6 +902,9 @@ This file contains the strings for ash. ...@@ -902,6 +902,9 @@ This file contains the strings for ash.
<message name="IDS_ASH_STYLUS_TOOLS_CREATE_NOTE_ACTION" desc="Title of the capture screen action in the stylus tools (a pop-up panel next to the status tray). Clicking this opens up an application that the user can quickly jot a note down in."> <message name="IDS_ASH_STYLUS_TOOLS_CREATE_NOTE_ACTION" desc="Title of the capture screen action in the stylus tools (a pop-up panel next to the status tray). Clicking this opens up an application that the user can quickly jot a note down in.">
Create note Create note
</message> </message>
<message name="IDS_ASH_STYLUS_TOOLS_ENTER_CAPTURE_MODE_ACTION" desc="Title of the enter capture mode action in the stylus tools (a pop-up panel next to the status tray). This enters capture mode, which allows users to take screenshots and record video. Capture mode has an UI for users to modify what gets screenshotted or recorded.">
Screen capture
</message>
<message name="IDS_ASH_STYLUS_TOOLS_LASER_POINTER_MODE" desc="Title of the laser pointer in the palette (a pop-up panel next to the status tray). Clicking this turns the mouse into a laser pointer. Additionally, the palette tray is closed."> <message name="IDS_ASH_STYLUS_TOOLS_LASER_POINTER_MODE" desc="Title of the laser pointer in the palette (a pop-up panel next to the status tray). Clicking this turns the mouse into a laser pointer. Additionally, the palette tray is closed.">
Laser pointer Laser pointer
</message> </message>
......
63f784aae96294063012d6d7aa39e8071c1345ef
\ No newline at end of file
...@@ -7,40 +7,6 @@ ...@@ -7,40 +7,6 @@
namespace ash { namespace ash {
std::string PaletteToolIdToString(PaletteToolId tool_id) {
switch (tool_id) {
case PaletteToolId::NONE:
return "NONE";
case PaletteToolId::CREATE_NOTE:
return "CREATE_NOTE";
case PaletteToolId::CAPTURE_REGION:
return "CAPTURE_REGION";
case PaletteToolId::CAPTURE_SCREEN:
return "CAPTURE_SCREEN";
case PaletteToolId::LASER_POINTER:
return "LASER_POINTER";
case PaletteToolId::MAGNIFY:
return "MAGNIFY";
case PaletteToolId::METALAYER:
return "METALAYER";
}
NOTREACHED();
return std::string();
}
std::string PaletteGroupToString(PaletteGroup group) {
switch (group) {
case PaletteGroup::ACTION:
return "ACTION";
case PaletteGroup::MODE:
return "MODE";
}
NOTREACHED();
return std::string();
}
PaletteTrayOptions PaletteToolIdToPaletteTrayOptions(PaletteToolId tool_id) { PaletteTrayOptions PaletteToolIdToPaletteTrayOptions(PaletteToolId tool_id) {
switch (tool_id) { switch (tool_id) {
case PaletteToolId::NONE: case PaletteToolId::NONE:
...@@ -57,6 +23,8 @@ PaletteTrayOptions PaletteToolIdToPaletteTrayOptions(PaletteToolId tool_id) { ...@@ -57,6 +23,8 @@ PaletteTrayOptions PaletteToolIdToPaletteTrayOptions(PaletteToolId tool_id) {
return PALETTE_MAGNIFY; return PALETTE_MAGNIFY;
case PaletteToolId::METALAYER: case PaletteToolId::METALAYER:
return PALETTE_METALAYER; return PALETTE_METALAYER;
case PaletteToolId::ENTER_CAPTURE_MODE:
return PALETTE_ENTER_CAPTURE_MODE;
} }
NOTREACHED(); NOTREACHED();
......
...@@ -5,10 +5,6 @@ ...@@ -5,10 +5,6 @@
#ifndef ASH_SYSTEM_PALETTE_PALETTE_IDS_H_ #ifndef ASH_SYSTEM_PALETTE_PALETTE_IDS_H_
#define ASH_SYSTEM_PALETTE_PALETTE_IDS_H_ #define ASH_SYSTEM_PALETTE_PALETTE_IDS_H_
#include <string>
#include "ash/ash_export.h"
namespace ash { namespace ash {
// Palette tools are grouped into different categories. Each tool corresponds to // Palette tools are grouped into different categories. Each tool corresponds to
...@@ -26,6 +22,7 @@ enum class PaletteToolId { ...@@ -26,6 +22,7 @@ enum class PaletteToolId {
LASER_POINTER, LASER_POINTER,
MAGNIFY, MAGNIFY,
METALAYER, METALAYER,
ENTER_CAPTURE_MODE,
}; };
// Usage of each pen palette option. This enum is used to back an UMA histogram // Usage of each pen palette option. This enum is used to back an UMA histogram
...@@ -40,6 +37,7 @@ enum PaletteTrayOptions { ...@@ -40,6 +37,7 @@ enum PaletteTrayOptions {
PALETTE_MAGNIFY, PALETTE_MAGNIFY,
PALETTE_LASER_POINTER, PALETTE_LASER_POINTER,
PALETTE_METALAYER, PALETTE_METALAYER,
PALETTE_ENTER_CAPTURE_MODE,
PALETTE_OPTIONS_COUNT PALETTE_OPTIONS_COUNT
}; };
...@@ -59,17 +57,13 @@ enum class PaletteInvocationMethod { ...@@ -59,17 +57,13 @@ enum class PaletteInvocationMethod {
SHORTCUT, SHORTCUT,
}; };
// Helper functions that convert PaletteToolIds and PaletteGroups to strings.
ASH_EXPORT std::string PaletteToolIdToString(PaletteToolId tool_id);
ASH_EXPORT std::string PaletteGroupToString(PaletteGroup group);
// Helper functions that convert PaletteToolIds to PaletteTrayOptions. // Helper functions that convert PaletteToolIds to PaletteTrayOptions.
ASH_EXPORT PaletteTrayOptions PaletteTrayOptions PaletteToolIdToPaletteTrayOptions(PaletteToolId tool_id);
PaletteToolIdToPaletteTrayOptions(PaletteToolId tool_id);
// Helper functions that convert PaletteToolIds to PaletteModeCancelType. // Helper functions that convert PaletteToolIds to PaletteModeCancelType.
ASH_EXPORT PaletteModeCancelType PaletteModeCancelType PaletteToolIdToPaletteModeCancelType(
PaletteToolIdToPaletteModeCancelType(PaletteToolId tool_id, bool is_switched); PaletteToolId tool_id,
bool is_switched);
} // namespace ash } // namespace ash
......
...@@ -7,11 +7,13 @@ ...@@ -7,11 +7,13 @@
#include <memory> #include <memory>
#include "ash/assistant/util/assistant_util.h" #include "ash/assistant/util/assistant_util.h"
#include "ash/public/cpp/ash_features.h"
#include "ash/system/palette/palette_tool_manager.h" #include "ash/system/palette/palette_tool_manager.h"
#include "ash/system/palette/palette_utils.h" #include "ash/system/palette/palette_utils.h"
#include "ash/system/palette/tools/capture_region_mode.h" #include "ash/system/palette/tools/capture_region_mode.h"
#include "ash/system/palette/tools/capture_screen_action.h" #include "ash/system/palette/tools/capture_screen_action.h"
#include "ash/system/palette/tools/create_note_action.h" #include "ash/system/palette/tools/create_note_action.h"
#include "ash/system/palette/tools/enter_capture_mode.h"
#include "ash/system/palette/tools/laser_pointer_mode.h" #include "ash/system/palette/tools/laser_pointer_mode.h"
#include "ash/system/palette/tools/magnifier_mode.h" #include "ash/system/palette/tools/magnifier_mode.h"
#include "ash/system/palette/tools/metalayer_mode.h" #include "ash/system/palette/tools/metalayer_mode.h"
...@@ -21,8 +23,12 @@ namespace ash { ...@@ -21,8 +23,12 @@ namespace ash {
// static // static
void PaletteTool::RegisterToolInstances(PaletteToolManager* tool_manager) { void PaletteTool::RegisterToolInstances(PaletteToolManager* tool_manager) {
tool_manager->AddTool(std::make_unique<CaptureRegionMode>(tool_manager)); if (features::IsCaptureModeEnabled()) {
tool_manager->AddTool(std::make_unique<CaptureScreenAction>(tool_manager)); tool_manager->AddTool(std::make_unique<EnterCaptureMode>(tool_manager));
} else {
tool_manager->AddTool(std::make_unique<CaptureRegionMode>(tool_manager));
tool_manager->AddTool(std::make_unique<CaptureScreenAction>(tool_manager));
}
tool_manager->AddTool(std::make_unique<CreateNoteAction>(tool_manager)); tool_manager->AddTool(std::make_unique<CreateNoteAction>(tool_manager));
if (assistant::util::IsGoogleDevice()) if (assistant::util::IsGoogleDevice())
tool_manager->AddTool(std::make_unique<MetalayerMode>(tool_manager)); tool_manager->AddTool(std::make_unique<MetalayerMode>(tool_manager));
......
...@@ -590,8 +590,6 @@ bool PaletteTray::DeactivateActiveTool() { ...@@ -590,8 +590,6 @@ bool PaletteTray::DeactivateActiveTool() {
palette_tool_manager_->GetActiveTool(PaletteGroup::MODE); palette_tool_manager_->GetActiveTool(PaletteGroup::MODE);
if (active_tool_id != PaletteToolId::NONE) { if (active_tool_id != PaletteToolId::NONE) {
palette_tool_manager_->DeactivateTool(active_tool_id); palette_tool_manager_->DeactivateTool(active_tool_id);
// TODO(sammiequon): Investigate whether we should removed |is_switched|
// from PaletteToolIdToPaletteModeCancelType.
RecordPaletteModeCancellation(PaletteToolIdToPaletteModeCancelType( RecordPaletteModeCancellation(PaletteToolIdToPaletteModeCancelType(
active_tool_id, false /*is_switched*/)); active_tool_id, false /*is_switched*/));
return true; return true;
......
// Copyright 2020 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 "ash/system/palette/tools/enter_capture_mode.h"
#include "ash/capture_mode/capture_mode_controller.h"
#include "ash/resources/vector_icons/vector_icons.h"
#include "ash/strings/grit/ash_strings.h"
#include "ash/system/palette/palette_ids.h"
#include "ui/base/l10n/l10n_util.h"
namespace ash {
EnterCaptureMode::EnterCaptureMode(Delegate* delegate)
: CommonPaletteTool(delegate) {}
EnterCaptureMode::~EnterCaptureMode() = default;
PaletteGroup EnterCaptureMode::GetGroup() const {
return PaletteGroup::ACTION;
}
PaletteToolId EnterCaptureMode::GetToolId() const {
return PaletteToolId::ENTER_CAPTURE_MODE;
}
void EnterCaptureMode::OnEnable() {
CommonPaletteTool::OnEnable();
delegate()->DisableTool(GetToolId());
delegate()->HidePaletteImmediately();
CaptureModeController::Get()->Start();
}
views::View* EnterCaptureMode::CreateView() {
return CreateDefaultView(l10n_util::GetStringUTF16(
IDS_ASH_STYLUS_TOOLS_ENTER_CAPTURE_MODE_ACTION));
}
const gfx::VectorIcon& EnterCaptureMode::GetPaletteIcon() const {
return kCaptureModeIcon;
}
} // namespace ash
// Copyright 2020 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 ASH_SYSTEM_PALETTE_TOOLS_ENTER_CAPTURE_MODE_H_
#define ASH_SYSTEM_PALETTE_TOOLS_ENTER_CAPTURE_MODE_H_
#include "ash/system/palette/common_palette_tool.h"
namespace ash {
// This class manages the palette tool which is a point of entry for capture
// mode. Capture mode allows users to take screenshots and record videos.
class EnterCaptureMode : public CommonPaletteTool {
public:
explicit EnterCaptureMode(Delegate* delegate);
EnterCaptureMode(const EnterCaptureMode&) = delete;
EnterCaptureMode& operator=(const EnterCaptureMode&) = delete;
~EnterCaptureMode() override;
// CommonPaletteTool:
PaletteGroup GetGroup() const override;
PaletteToolId GetToolId() const override;
void OnEnable() override;
views::View* CreateView() override;
const gfx::VectorIcon& GetPaletteIcon() const override;
};
} // namespace ash
#endif // ASH_SYSTEM_PALETTE_TOOLS_ENTER_CAPTURE_MODE_H_
...@@ -53375,6 +53375,7 @@ Called by update_net_trust_anchors.py.--> ...@@ -53375,6 +53375,7 @@ Called by update_net_trust_anchors.py.-->
<int value="6" label="Magnifying glass mode"/> <int value="6" label="Magnifying glass mode"/>
<int value="7" label="Laser pointer mode"/> <int value="7" label="Laser pointer mode"/>
<int value="8" label="Assistant mode"/> <int value="8" label="Assistant mode"/>
<int value="9" label="Enter capture mode"/>
</enum> </enum>
<enum name="PanningModelType"> <enum name="PanningModelType">
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment