forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This CL adds the initial skeleton for the Capture Mode feature. Future CLs will implement the actual functionality. BUG=1105227 Change-Id: I2d8d61aa431b6bd9599e8cec65d4836a42eee695 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2327855 Commit-Queue: Ahmed Fakhry <afakhry@chromium.org> Reviewed-by: James Cook <jamescook@chromium.org> Cr-Commit-Position: refs/heads/master@{#793367}
- Loading branch information
Ahmed Fakhry
authored and
Commit Bot
committed
Jul 30, 2020
1 parent
a2ceefb
commit 0c6efef
Showing
19 changed files
with
282 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
afakhry@chromium.org | ||
|
||
# COMPONENT: UI>Shell>ScreenCapture |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// 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/capture_mode_controller.h" | ||
|
||
#include <utility> | ||
|
||
#include "base/check.h" | ||
#include "base/check_op.h" | ||
|
||
namespace ash { | ||
|
||
namespace { | ||
|
||
CaptureModeController* g_instance = nullptr; | ||
|
||
} // namespace | ||
|
||
CaptureModeController::CaptureModeController( | ||
std::unique_ptr<CaptureModeDelegate> delegate) | ||
: delegate_(std::move(delegate)) { | ||
DCHECK_EQ(g_instance, nullptr); | ||
g_instance = this; | ||
} | ||
|
||
CaptureModeController::~CaptureModeController() { | ||
DCHECK_EQ(g_instance, this); | ||
g_instance = nullptr; | ||
} | ||
|
||
// static | ||
CaptureModeController* CaptureModeController::Get() { | ||
DCHECK(g_instance); | ||
return g_instance; | ||
} | ||
|
||
void CaptureModeController::Start() { | ||
StartWith(type_, source_); | ||
} | ||
|
||
void CaptureModeController::StartWith(CaptureModeType type, | ||
CaptureModeSource source) { | ||
type_ = type; | ||
source_ = source; | ||
// TODO(afakhry): Fill in here. | ||
} | ||
|
||
void CaptureModeController::Stop() { | ||
// TODO(afakhry): Fill in here. | ||
} | ||
|
||
} // namespace ash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// 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_CAPTURE_MODE_CONTROLLER_H_ | ||
#define ASH_CAPTURE_MODE_CAPTURE_MODE_CONTROLLER_H_ | ||
|
||
#include <memory> | ||
|
||
#include "ash/public/cpp/capture_mode_delegate.h" | ||
|
||
namespace ash { | ||
|
||
// Defines the capture type Capture Mode is currently using. | ||
enum class CaptureModeType { | ||
kImage, | ||
kVideo, | ||
}; | ||
|
||
// Defines the source of the capture used by Capture Mode. | ||
enum class CaptureModeSource { | ||
kFullscreen, | ||
kRegion, | ||
kWindow, | ||
}; | ||
|
||
// Controls starting and ending a Capture Mode session and its behavior. | ||
class CaptureModeController { | ||
public: | ||
explicit CaptureModeController(std::unique_ptr<CaptureModeDelegate> delegate); | ||
CaptureModeController(const CaptureModeController&) = delete; | ||
CaptureModeController& operator=(const CaptureModeController&) = delete; | ||
~CaptureModeController(); | ||
|
||
// Convenience function to get the controller instance, which is created and | ||
// owned by Shell. | ||
static CaptureModeController* Get(); | ||
|
||
// Starts a new capture session with the most-recently used |type_| and | ||
// |source_|. | ||
void Start(); | ||
|
||
// Starts a new capture session with the specific given |type| and |source|. | ||
void StartWith(CaptureModeType type, CaptureModeSource source); | ||
|
||
// Stops an existing capture session. | ||
void Stop(); | ||
|
||
private: | ||
std::unique_ptr<CaptureModeDelegate> delegate_; | ||
|
||
CaptureModeType type_ = CaptureModeType::kImage; | ||
CaptureModeSource source_ = CaptureModeSource::kRegion; | ||
}; | ||
|
||
} // namespace ash | ||
|
||
#endif // ASH_CAPTURE_MODE_CAPTURE_MODE_CONTROLLER_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// 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/test_capture_mode_delegate.h" | ||
|
||
#include "base/files/file_path.h" | ||
|
||
namespace ash { | ||
|
||
base::FilePath TestCaptureModeDelegate::GetActiveUserDownloadsDir() const { | ||
// TODO(afakhry): Add proper code to enable testing. | ||
return base::FilePath(); | ||
} | ||
|
||
} // namespace ash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// 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_TEST_CAPTURE_MODE_DELEGATE_H_ | ||
#define ASH_CAPTURE_MODE_TEST_CAPTURE_MODE_DELEGATE_H_ | ||
|
||
#include "ash/public/cpp/capture_mode_delegate.h" | ||
|
||
namespace ash { | ||
|
||
class TestCaptureModeDelegate : public CaptureModeDelegate { | ||
public: | ||
TestCaptureModeDelegate() = default; | ||
TestCaptureModeDelegate(const TestCaptureModeDelegate&) = delete; | ||
TestCaptureModeDelegate& operator=(const TestCaptureModeDelegate&) = delete; | ||
~TestCaptureModeDelegate() override = default; | ||
|
||
// CaptureModeDelegate: | ||
base::FilePath GetActiveUserDownloadsDir() const override; | ||
}; | ||
|
||
} // namespace ash | ||
|
||
#endif // ASH_CAPTURE_MODE_TEST_CAPTURE_MODE_DELEGATE_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// 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_PUBLIC_CPP_CAPTURE_MODE_DELEGATE_H_ | ||
#define ASH_PUBLIC_CPP_CAPTURE_MODE_DELEGATE_H_ | ||
|
||
#include "ash/public/cpp/ash_public_export.h" | ||
|
||
namespace base { | ||
class FilePath; | ||
} // namespace base | ||
|
||
namespace ash { | ||
|
||
// Defines the interface for the delegate of CaptureModeController, that can be | ||
// implemented by an ash client (e.g. Chrome). The CaptureModeController owns | ||
// the instance of this delegate. | ||
class ASH_PUBLIC_EXPORT CaptureModeDelegate { | ||
public: | ||
virtual ~CaptureModeDelegate() = default; | ||
|
||
// Returns the path to the active user's downloads directory. This will never | ||
// be called if the user is not logged in. | ||
virtual base::FilePath GetActiveUserDownloadsDir() const = 0; | ||
}; | ||
|
||
} // namespace ash | ||
|
||
#endif // ASH_PUBLIC_CPP_CAPTURE_MODE_DELEGATE_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// 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 "chrome/browser/ui/ash/chrome_capture_mode_delegate.h" | ||
|
||
#include "base/files/file_path.h" | ||
#include "chrome/browser/download/download_prefs.h" | ||
#include "chrome/browser/profiles/profile_manager.h" | ||
#include "chromeos/login/login_state/login_state.h" | ||
|
||
ChromeCaptureModeDelegate::ChromeCaptureModeDelegate() = default; | ||
|
||
ChromeCaptureModeDelegate::~ChromeCaptureModeDelegate() = default; | ||
|
||
base::FilePath ChromeCaptureModeDelegate::GetActiveUserDownloadsDir() const { | ||
DCHECK(chromeos::LoginState::Get()->IsUserLoggedIn()); | ||
DownloadPrefs* download_prefs = | ||
DownloadPrefs::FromBrowserContext(ProfileManager::GetActiveUserProfile()); | ||
return download_prefs->DownloadPath(); | ||
} |
Oops, something went wrong.