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 @@
#ifndef CHROME_BROWSER_SHARESHEET_SHARESHEET_CONTROLLER_H_
#define CHROME_BROWSER_SHARESHEET_SHARESHEET_CONTROLLER_H_
class Profile;
namespace sharesheet {
// The SharesheetController allows ShareActions to request changes to the state
......@@ -17,6 +19,8 @@ class SharesheetController {
// different invocations of the sharesheet.
virtual uint32_t GetId() = 0;
virtual Profile* GetProfile() = 0;
// When called will set the bubble size to |width| and |height|.
// |width| and |height| must be set to a positive int.
virtual void SetSharesheetSize(const int& width, const int& height) = 0;
......
......@@ -24,9 +24,10 @@
namespace sharesheet {
SharesheetService::SharesheetService(Profile* profile)
: sharesheet_action_cache_(std::make_unique<SharesheetActionCache>()),
app_service_proxy_(apps::AppServiceProxyFactory::GetForProfile(profile)) {
}
: profile_(profile),
sharesheet_action_cache_(std::make_unique<SharesheetActionCache>()),
app_service_proxy_(
apps::AppServiceProxyFactory::GetForProfile(profile_)) {}
SharesheetService::~SharesheetService() = default;
......@@ -120,6 +121,10 @@ bool SharesheetService::HasShareTargets(const apps::mojom::IntentPtr& intent) {
return !actions.empty() || !intent_launch_info.empty();
}
Profile* SharesheetService::GetProfile() {
return profile_;
}
void SharesheetService::LoadAppIcons(
std::vector<apps::IntentLaunchInfo> intent_launch_info,
std::vector<TargetInfo> targets,
......
......@@ -60,6 +60,7 @@ class SharesheetService : public KeyedService {
views::View* share_action_view);
SharesheetServiceDelegate* GetDelegate(uint32_t delegate_id);
bool HasShareTargets(const apps::mojom::IntentPtr& intent);
Profile* GetProfile();
private:
using SharesheetServiceIconLoaderCallback =
......@@ -85,6 +86,7 @@ class SharesheetService : public KeyedService {
apps::mojom::IntentPtr intent);
uint32_t delegate_counter_ = 0;
Profile* profile_;
std::unique_ptr<SharesheetActionCache> sharesheet_action_cache_;
apps::AppServiceProxy* app_service_proxy_;
......
......@@ -63,6 +63,10 @@ uint32_t SharesheetServiceDelegate::GetId() {
return id_;
}
Profile* SharesheetServiceDelegate::GetProfile() {
return sharesheet_service_->GetProfile();
}
void SharesheetServiceDelegate::SetSharesheetSize(const int& width,
const int& height) {
DCHECK_GT(width, 0);
......
......@@ -12,6 +12,7 @@
#include "chrome/browser/sharesheet/sharesheet_types.h"
#include "components/services/app_service/public/mojom/types.mojom.h"
class Profile;
class SharesheetBubbleView;
namespace views {
......@@ -52,6 +53,7 @@ class SharesheetServiceDelegate : public SharesheetController {
// SharesheetController overrides
uint32_t GetId() override;
Profile* GetProfile() override;
void SetSharesheetSize(const int& width, const int& height) 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