Commit aa721e8c authored by Cattalyya Nuengsigkapian's avatar Cattalyya Nuengsigkapian Committed by Commit Bot

capture_mode: opens an image editor from an edit button.

Opens an image editor, an Essential App's Backlight from an edit button in a screenshot notification.

Important Note: the edit button is only available
for image screen capturing but not video.

Testing:
- Screen recording showing that edit button open the screenshot image in Backlight
https://bugs.chromium.org/p/chromium/issues/attachment?aid=469945&signed_aid=7kntFxv5qL2TWN8JYNxQ4Q==&inline=1

Bug: 1135247
Change-Id: Ia9f48cd82021b96fc3bbda8f140e90477b1a0152
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2457306
Commit-Queue: Cattalyya Nuengsigkapian <cattalyya@chromium.org>
Reviewed-by: default avatarMitsuru Oshima <oshima@chromium.org>
Reviewed-by: default avatarAhmed Fakhry <afakhry@chromium.org>
Cr-Commit-Position: refs/heads/master@{#815845}
parent abec83b6
...@@ -455,9 +455,10 @@ void CaptureModeController::HandleNotificationClicked( ...@@ -455,9 +455,10 @@ void CaptureModeController::HandleNotificationClicked(
// Show the item in the folder. // Show the item in the folder.
delegate_->ShowScreenCaptureItemInFolder(screen_capture_path); delegate_->ShowScreenCaptureItemInFolder(screen_capture_path);
} else { } else {
// TODO: fill in here. // TODO(crbug.com/1136666): Remove edit button for video recording.
switch (button_index.value()) { switch (button_index.value()) {
case NotificationButtonIndex::BUTTON_EDIT: case NotificationButtonIndex::BUTTON_EDIT:
delegate_->OpenScreenshotInImageEditor(screen_capture_path);
break; break;
case NotificationButtonIndex::BUTTON_DELETE: case NotificationButtonIndex::BUTTON_DELETE:
DeleteFileAsync(screen_capture_path); DeleteFileAsync(screen_capture_path);
......
...@@ -16,6 +16,9 @@ base::FilePath TestCaptureModeDelegate::GetActiveUserDownloadsDir() const { ...@@ -16,6 +16,9 @@ base::FilePath TestCaptureModeDelegate::GetActiveUserDownloadsDir() const {
void TestCaptureModeDelegate::ShowScreenCaptureItemInFolder( void TestCaptureModeDelegate::ShowScreenCaptureItemInFolder(
const base::FilePath& file_path) {} const base::FilePath& file_path) {}
void TestCaptureModeDelegate::OpenScreenshotInImageEditor(
const base::FilePath& file_path) {}
bool TestCaptureModeDelegate::Uses24HourFormat() const { bool TestCaptureModeDelegate::Uses24HourFormat() const {
return false; return false;
} }
......
...@@ -19,6 +19,7 @@ class TestCaptureModeDelegate : public CaptureModeDelegate { ...@@ -19,6 +19,7 @@ class TestCaptureModeDelegate : public CaptureModeDelegate {
// CaptureModeDelegate: // CaptureModeDelegate:
base::FilePath GetActiveUserDownloadsDir() const override; base::FilePath GetActiveUserDownloadsDir() const override;
void ShowScreenCaptureItemInFolder(const base::FilePath& file_path) override; void ShowScreenCaptureItemInFolder(const base::FilePath& file_path) override;
void OpenScreenshotInImageEditor(const base::FilePath& file_path) override;
bool Uses24HourFormat() const override; bool Uses24HourFormat() const override;
bool IsCaptureAllowed(const aura::Window* window, bool IsCaptureAllowed(const aura::Window* window,
const gfx::Rect& bounds, const gfx::Rect& bounds,
......
...@@ -36,6 +36,9 @@ class ASH_PUBLIC_EXPORT CaptureModeDelegate { ...@@ -36,6 +36,9 @@ class ASH_PUBLIC_EXPORT CaptureModeDelegate {
virtual void ShowScreenCaptureItemInFolder( virtual void ShowScreenCaptureItemInFolder(
const base::FilePath& file_path) = 0; const base::FilePath& file_path) = 0;
// Opens the screenshot item in an image editor.
virtual void OpenScreenshotInImageEditor(const base::FilePath& file_path) = 0;
// Returns true if the current user is using the 24-hour format (i.e. 14:00 // Returns true if the current user is using the 24-hour format (i.e. 14:00
// vs. 2:00 PM). This is used to build the file name of the captured image or // vs. 2:00 PM). This is used to build the file name of the captured image or
// video. // video.
......
...@@ -6,7 +6,11 @@ ...@@ -6,7 +6,11 @@
#include "base/files/file_path.h" #include "base/files/file_path.h"
#include "base/i18n/time_formatting.h" #include "base/i18n/time_formatting.h"
#include "chrome/browser/apps/app_service/app_service_proxy.h"
#include "chrome/browser/apps/app_service/app_service_proxy_factory.h"
#include "chrome/browser/apps/app_service/launch_utils.h"
#include "chrome/browser/chromeos/policy/dlp/dlp_content_manager.h" #include "chrome/browser/chromeos/policy/dlp/dlp_content_manager.h"
#include "chrome/browser/chromeos/web_applications/default_web_app_ids.h"
#include "chrome/browser/download/download_prefs.h" #include "chrome/browser/download/download_prefs.h"
#include "chrome/browser/platform_util.h" #include "chrome/browser/platform_util.h"
#include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/profiles/profile_manager.h"
...@@ -15,6 +19,7 @@ ...@@ -15,6 +19,7 @@
#include "chromeos/login/login_state/login_state.h" #include "chromeos/login/login_state/login_state.h"
#include "components/prefs/pref_service.h" #include "components/prefs/pref_service.h"
#include "ui/aura/window.h" #include "ui/aura/window.h"
#include "ui/base/window_open_disposition.h"
namespace { namespace {
...@@ -44,6 +49,27 @@ void ChromeCaptureModeDelegate::ShowScreenCaptureItemInFolder( ...@@ -44,6 +49,27 @@ void ChromeCaptureModeDelegate::ShowScreenCaptureItemInFolder(
file_path); file_path);
} }
void ChromeCaptureModeDelegate::OpenScreenshotInImageEditor(
const base::FilePath& file_path) {
Profile* profile = ProfileManager::GetActiveUserProfile();
if (!profile)
return;
apps::AppServiceProxy* proxy = apps::AppServiceProxyFactory::GetForProfile(
profile->GetOriginalProfile());
apps::mojom::FilePathsPtr file_paths_ptr =
apps::mojom::FilePaths::New(std::vector<base::FilePath>({file_path}));
// open the image with Essential App: Backlight.
proxy->LaunchAppWithFiles(
chromeos::default_web_apps::kMediaAppId,
apps::mojom::LaunchContainer::kLaunchContainerWindow,
apps::GetEventFlags(apps::mojom::LaunchContainer::kLaunchContainerWindow,
WindowOpenDisposition::NEW_WINDOW,
/*preferred_container=*/true),
apps::mojom::LaunchSource::kFromFileManager, std::move(file_paths_ptr));
}
bool ChromeCaptureModeDelegate::Uses24HourFormat() const { bool ChromeCaptureModeDelegate::Uses24HourFormat() const {
Profile* profile = ProfileManager::GetActiveUserProfile(); Profile* profile = ProfileManager::GetActiveUserProfile();
// TODO(afakhry): Consider moving |prefs::kUse24HourClock| to ash/public so // TODO(afakhry): Consider moving |prefs::kUse24HourClock| to ash/public so
......
...@@ -20,6 +20,7 @@ class ChromeCaptureModeDelegate : public ash::CaptureModeDelegate { ...@@ -20,6 +20,7 @@ class ChromeCaptureModeDelegate : public ash::CaptureModeDelegate {
// ash::CaptureModeDelegate: // ash::CaptureModeDelegate:
base::FilePath GetActiveUserDownloadsDir() const override; base::FilePath GetActiveUserDownloadsDir() const override;
void ShowScreenCaptureItemInFolder(const base::FilePath& file_path) override; void ShowScreenCaptureItemInFolder(const base::FilePath& file_path) override;
void OpenScreenshotInImageEditor(const base::FilePath& file_path) override;
bool Uses24HourFormat() const override; bool Uses24HourFormat() const override;
bool IsCaptureAllowed(const aura::Window* window, bool IsCaptureAllowed(const aura::Window* window,
const gfx::Rect& bounds, const gfx::Rect& bounds,
......
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