Commit fb005beb authored by Sammie Quon's avatar Sammie Quon Committed by Commit Bot

capture_mode: Add a tray item (shelf pod) to stop a recording session.

It will be between the IME pod and palette pod. Will add a simple test
and place it on the correct shelf in a latter CL.

Test: manual
Change-Id: If67b781f558643aa42c501dddb8ebaba1017f445
Fixed: 1113938
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2342117
Commit-Queue: Sammie Quon <sammiequon@chromium.org>
Reviewed-by: default avatarAhmed Fakhry <afakhry@chromium.org>
Reviewed-by: default avatarIlya Sherman <isherman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#796513}
parent b368c0e9
...@@ -267,6 +267,8 @@ component("ash") { ...@@ -267,6 +267,8 @@ component("ash") {
"capture_mode/capture_mode_type_view.cc", "capture_mode/capture_mode_type_view.cc",
"capture_mode/capture_mode_type_view.h", "capture_mode/capture_mode_type_view.h",
"capture_mode/capture_mode_types.h", "capture_mode/capture_mode_types.h",
"capture_mode/stop_recording_button_tray.cc",
"capture_mode/stop_recording_button_tray.h",
"capture_mode/view_with_ink_drop.h", "capture_mode/view_with_ink_drop.h",
"clipboard/clipboard_history.cc", "clipboard/clipboard_history.cc",
"clipboard/clipboard_history.h", "clipboard/clipboard_history.h",
......
...@@ -1011,6 +1011,10 @@ This file contains the strings for ash. ...@@ -1011,6 +1011,10 @@ This file contains the strings for ash.
Collapse status area Collapse status area
</message> </message>
<message name="IDS_ASH_STATUS_AREA_STOP_RECORDING_BUTTON_ACCESSIBLE_NAME" desc="The accessible name for the capture mode recording button in the system tray.">
Stop screen recording
</message>
<!-- Overview Mode --> <!-- Overview Mode -->
<message name="IDS_ASH_OVERVIEW_BUTTON_ACCESSIBLE_NAME" desc="The accessible name for the Overview button in the system tray."> <message name="IDS_ASH_OVERVIEW_BUTTON_ACCESSIBLE_NAME" desc="The accessible name for the Overview button in the system tray.">
Toggle window overview Toggle window overview
......
7dc8304d44e5fd345d3be2e37815200ba2e9e5b1
\ No newline at end of file
...@@ -70,4 +70,8 @@ void CaptureModeController::Stop() { ...@@ -70,4 +70,8 @@ void CaptureModeController::Stop() {
capture_mode_session_.reset(); capture_mode_session_.reset();
} }
void CaptureModeController::EndVideoRecording() {
// TODO(afakhry): Fill in here.
}
} // namespace ash } // namespace ash
...@@ -48,6 +48,8 @@ class ASH_EXPORT CaptureModeController { ...@@ -48,6 +48,8 @@ class ASH_EXPORT CaptureModeController {
// Stops an existing capture session. // Stops an existing capture session.
void Stop(); void Stop();
void EndVideoRecording();
private: private:
std::unique_ptr<CaptureModeDelegate> delegate_; std::unique_ptr<CaptureModeDelegate> delegate_;
......
// 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/capture_mode/stop_recording_button_tray.h"
#include "ash/capture_mode/capture_mode_controller.h"
#include "ash/public/cpp/shelf_config.h"
#include "ash/resources/vector_icons/vector_icons.h"
#include "ash/strings/grit/ash_strings.h"
#include "ash/system/tray/tray_constants.h"
#include "ash/system/tray/tray_container.h"
#include "base/metrics/user_metrics.h"
#include "base/metrics/user_metrics_action.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/gfx/paint_vector_icon.h"
#include "ui/views/controls/image_view.h"
namespace ash {
StopRecordingButtonTray::StopRecordingButtonTray(Shelf* shelf)
: TrayBackgroundView(shelf) {
auto image_view = std::make_unique<views::ImageView>();
image_view->SetImage(gfx::CreateVectorIcon(
kCaptureModeCircleStopIcon, ShelfConfig::Get()->shelf_icon_color()));
image_view->set_tooltip_text(GetAccessibleNameForTray());
image_view->SetHorizontalAlignment(views::ImageView::Alignment::kCenter);
image_view->SetVerticalAlignment(views::ImageView::Alignment::kCenter);
image_view->SetPreferredSize(gfx::Size(kTrayItemSize, kTrayItemSize));
tray_container()->AddChildView(std::move(image_view));
}
StopRecordingButtonTray::~StopRecordingButtonTray() = default;
bool StopRecordingButtonTray::PerformAction(const ui::Event& event) {
DCHECK(event.type() == ui::ET_MOUSE_RELEASED ||
event.type() == ui::ET_GESTURE_TAP);
// TODO(sammiequon): Add a simple test for this button's visibility once
// CaptureModeController is a bit more fleshed out.
// Stop recording and hide this button.
base::RecordAction(base::UserMetricsAction("Tray_StopRecording"));
CaptureModeController::Get()->EndVideoRecording();
SetVisiblePreferred(false);
return true;
}
base::string16 StopRecordingButtonTray::GetAccessibleNameForTray() {
return l10n_util::GetStringUTF16(
IDS_ASH_STATUS_AREA_STOP_RECORDING_BUTTON_ACCESSIBLE_NAME);
}
} // 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_CAPTURE_MODE_STOP_RECORDING_BUTTON_TRAY_H_
#define ASH_CAPTURE_MODE_STOP_RECORDING_BUTTON_TRAY_H_
#include "ash/system/tray/tray_background_view.h"
namespace ash {
// Status area tray which is visible when a video is being recorded using
// capture mode. Tapping this tray will stop recording. This tray does not
// provide any bubble view windows.
class StopRecordingButtonTray : public TrayBackgroundView {
public:
explicit StopRecordingButtonTray(Shelf* shelf);
StopRecordingButtonTray(const StopRecordingButtonTray&) = delete;
StopRecordingButtonTray& operator=(const StopRecordingButtonTray&) = delete;
~StopRecordingButtonTray() override;
// TrayBackgroundView:
bool PerformAction(const ui::Event& event) override;
void ClickedOutsideBubble() override {}
base::string16 GetAccessibleNameForTray() override;
void HandleLocaleChange() override {}
void HideBubbleWithView(const TrayBubbleView* bubble_view) override {}
};
} // namespace ash
#endif // ASH_CAPTURE_MODE_STOP_RECORDING_BUTTON_TRAY_H_
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "ash/system/status_area_widget.h" #include "ash/system/status_area_widget.h"
#include "ash/capture_mode/stop_recording_button_tray.h"
#include "ash/keyboard/ui/keyboard_ui_controller.h" #include "ash/keyboard/ui/keyboard_ui_controller.h"
#include "ash/public/cpp/ash_features.h" #include "ash/public/cpp/ash_features.h"
#include "ash/public/cpp/ash_switches.h" #include "ash/public/cpp/ash_switches.h"
...@@ -104,6 +105,12 @@ void StatusAreaWidget::Initialize() { ...@@ -104,6 +105,12 @@ void StatusAreaWidget::Initialize() {
virtual_keyboard_tray_ = std::make_unique<VirtualKeyboardTray>(shelf_); virtual_keyboard_tray_ = std::make_unique<VirtualKeyboardTray>(shelf_);
AddTrayButton(virtual_keyboard_tray_.get()); AddTrayButton(virtual_keyboard_tray_.get());
if (features::IsCaptureModeEnabled()) {
stop_recording_button_tray_ =
std::make_unique<StopRecordingButtonTray>(shelf_);
AddTrayButton(stop_recording_button_tray_.get());
}
palette_tray_ = std::make_unique<PaletteTray>(shelf_); palette_tray_ = std::make_unique<PaletteTray>(shelf_);
AddTrayButton(palette_tray_.get()); AddTrayButton(palette_tray_.get());
......
...@@ -29,6 +29,7 @@ class PaletteTray; ...@@ -29,6 +29,7 @@ class PaletteTray;
class SelectToSpeakTray; class SelectToSpeakTray;
class Shelf; class Shelf;
class StatusAreaWidgetDelegate; class StatusAreaWidgetDelegate;
class StopRecordingButtonTray;
class UnifiedSystemTray; class UnifiedSystemTray;
class TrayBackgroundView; class TrayBackgroundView;
class VirtualKeyboardTray; class VirtualKeyboardTray;
...@@ -115,6 +116,9 @@ class ASH_EXPORT StatusAreaWidget : public SessionObserver, ...@@ -115,6 +116,9 @@ class ASH_EXPORT StatusAreaWidget : public SessionObserver,
return overview_button_tray_.get(); return overview_button_tray_.get();
} }
PaletteTray* palette_tray() { return palette_tray_.get(); } PaletteTray* palette_tray() { return palette_tray_.get(); }
StopRecordingButtonTray* stop_recording_button_tray() {
return stop_recording_button_tray_.get();
}
ImeMenuTray* ime_menu_tray() { return ime_menu_tray_.get(); } ImeMenuTray* ime_menu_tray() { return ime_menu_tray_.get(); }
HoldingSpaceTray* holding_space_tray() { return holding_space_tray_.get(); } HoldingSpaceTray* holding_space_tray() { return holding_space_tray_.get(); }
...@@ -211,6 +215,7 @@ class ASH_EXPORT StatusAreaWidget : public SessionObserver, ...@@ -211,6 +215,7 @@ class ASH_EXPORT StatusAreaWidget : public SessionObserver,
std::unique_ptr<UnifiedSystemTray> unified_system_tray_; std::unique_ptr<UnifiedSystemTray> unified_system_tray_;
std::unique_ptr<LogoutButtonTray> logout_button_tray_; std::unique_ptr<LogoutButtonTray> logout_button_tray_;
std::unique_ptr<PaletteTray> palette_tray_; std::unique_ptr<PaletteTray> palette_tray_;
std::unique_ptr<StopRecordingButtonTray> stop_recording_button_tray_;
std::unique_ptr<VirtualKeyboardTray> virtual_keyboard_tray_; std::unique_ptr<VirtualKeyboardTray> virtual_keyboard_tray_;
std::unique_ptr<ImeMenuTray> ime_menu_tray_; std::unique_ptr<ImeMenuTray> ime_menu_tray_;
std::unique_ptr<SelectToSpeakTray> select_to_speak_tray_; std::unique_ptr<SelectToSpeakTray> select_to_speak_tray_;
......
...@@ -25445,6 +25445,15 @@ should be able to be added at any place in this file. ...@@ -25445,6 +25445,15 @@ should be able to be added at any place in this file.
<description>Please enter the description of this user action.</description> <description>Please enter the description of this user action.</description>
</action> </action>
<action name="Tray_StopRecording">
<owner>afakhry@chromium.org</owner>
<owner>sammiequon@chromium.org</owner>
<description>
Records when the user presses the stop recording button in the Ash system
tray to stop the current screen recording session.
</description>
</action>
<action name="Tray_SwipeToClose_Successful"> <action name="Tray_SwipeToClose_Successful">
<obsolete> <obsolete>
No longer needed since swipe on the tray bubble to close it has been No longer needed since swipe on the tray bubble to close it has been
......
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