Commit 575490ae authored by Melissa Zhang's avatar Melissa Zhang Committed by Commit Bot

[Sharesheet] Profile getter in SharesheetController

This CL adds a Profile getter in SharesheetController
for ShareActions to use to get the Profile.

Bug: 1097623
Change-Id: I4af0c095d453b87d826d2ac029b1e35dd02c3f7c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2384711Reviewed-by: default avatarDominick Ng <dominickn@chromium.org>
Commit-Queue: Melissa Zhang <melzhang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#803024}
parent c499b31c
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
#ifndef CHROME_BROWSER_SHARESHEET_SHARESHEET_CONTROLLER_H_ #ifndef CHROME_BROWSER_SHARESHEET_SHARESHEET_CONTROLLER_H_
#define CHROME_BROWSER_SHARESHEET_SHARESHEET_CONTROLLER_H_ #define CHROME_BROWSER_SHARESHEET_SHARESHEET_CONTROLLER_H_
class Profile;
namespace sharesheet { namespace sharesheet {
// The SharesheetController allows ShareActions to request changes to the state // The SharesheetController allows ShareActions to request changes to the state
...@@ -17,6 +19,8 @@ class SharesheetController { ...@@ -17,6 +19,8 @@ class SharesheetController {
// different invocations of the sharesheet. // different invocations of the sharesheet.
virtual uint32_t GetId() = 0; virtual uint32_t GetId() = 0;
virtual Profile* GetProfile() = 0;
// When called will set the bubble size to |width| and |height|. // When called will set the bubble size to |width| and |height|.
// |width| and |height| must be set to a positive int. // |width| and |height| must be set to a positive int.
virtual void SetSharesheetSize(const int& width, const int& height) = 0; virtual void SetSharesheetSize(const int& width, const int& height) = 0;
......
...@@ -24,9 +24,10 @@ ...@@ -24,9 +24,10 @@
namespace sharesheet { namespace sharesheet {
SharesheetService::SharesheetService(Profile* profile) SharesheetService::SharesheetService(Profile* profile)
: sharesheet_action_cache_(std::make_unique<SharesheetActionCache>()), : profile_(profile),
app_service_proxy_(apps::AppServiceProxyFactory::GetForProfile(profile)) { sharesheet_action_cache_(std::make_unique<SharesheetActionCache>()),
} app_service_proxy_(
apps::AppServiceProxyFactory::GetForProfile(profile_)) {}
SharesheetService::~SharesheetService() = default; SharesheetService::~SharesheetService() = default;
...@@ -120,6 +121,10 @@ bool SharesheetService::HasShareTargets(const apps::mojom::IntentPtr& intent) { ...@@ -120,6 +121,10 @@ bool SharesheetService::HasShareTargets(const apps::mojom::IntentPtr& intent) {
return !actions.empty() || !intent_launch_info.empty(); return !actions.empty() || !intent_launch_info.empty();
} }
Profile* SharesheetService::GetProfile() {
return profile_;
}
void SharesheetService::LoadAppIcons( void SharesheetService::LoadAppIcons(
std::vector<apps::IntentLaunchInfo> intent_launch_info, std::vector<apps::IntentLaunchInfo> intent_launch_info,
std::vector<TargetInfo> targets, std::vector<TargetInfo> targets,
......
...@@ -60,6 +60,7 @@ class SharesheetService : public KeyedService { ...@@ -60,6 +60,7 @@ class SharesheetService : public KeyedService {
views::View* share_action_view); views::View* share_action_view);
SharesheetServiceDelegate* GetDelegate(uint32_t delegate_id); SharesheetServiceDelegate* GetDelegate(uint32_t delegate_id);
bool HasShareTargets(const apps::mojom::IntentPtr& intent); bool HasShareTargets(const apps::mojom::IntentPtr& intent);
Profile* GetProfile();
private: private:
using SharesheetServiceIconLoaderCallback = using SharesheetServiceIconLoaderCallback =
...@@ -85,6 +86,7 @@ class SharesheetService : public KeyedService { ...@@ -85,6 +86,7 @@ class SharesheetService : public KeyedService {
apps::mojom::IntentPtr intent); apps::mojom::IntentPtr intent);
uint32_t delegate_counter_ = 0; uint32_t delegate_counter_ = 0;
Profile* profile_;
std::unique_ptr<SharesheetActionCache> sharesheet_action_cache_; std::unique_ptr<SharesheetActionCache> sharesheet_action_cache_;
apps::AppServiceProxy* app_service_proxy_; apps::AppServiceProxy* app_service_proxy_;
......
...@@ -63,6 +63,10 @@ uint32_t SharesheetServiceDelegate::GetId() { ...@@ -63,6 +63,10 @@ uint32_t SharesheetServiceDelegate::GetId() {
return id_; return id_;
} }
Profile* SharesheetServiceDelegate::GetProfile() {
return sharesheet_service_->GetProfile();
}
void SharesheetServiceDelegate::SetSharesheetSize(const int& width, void SharesheetServiceDelegate::SetSharesheetSize(const int& width,
const int& height) { const int& height) {
DCHECK_GT(width, 0); DCHECK_GT(width, 0);
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "chrome/browser/sharesheet/sharesheet_types.h" #include "chrome/browser/sharesheet/sharesheet_types.h"
#include "components/services/app_service/public/mojom/types.mojom.h" #include "components/services/app_service/public/mojom/types.mojom.h"
class Profile;
class SharesheetBubbleView; class SharesheetBubbleView;
namespace views { namespace views {
...@@ -52,6 +53,7 @@ class SharesheetServiceDelegate : public SharesheetController { ...@@ -52,6 +53,7 @@ class SharesheetServiceDelegate : public SharesheetController {
// SharesheetController overrides // SharesheetController overrides
uint32_t GetId() override; uint32_t GetId() override;
Profile* GetProfile() override;
void SetSharesheetSize(const int& width, const int& height) override; void SetSharesheetSize(const int& width, const int& height) override;
void CloseSharesheet() override; void CloseSharesheet() override;
......
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