Commit f4b8e3d9 authored by Kyle Horimoto's avatar Kyle Horimoto Committed by Commit Bot

[CrOS PhoneHub] Provide an instance of PhoneHubManager to SystemTray

This CL removes PhoneHubManager::Get(), and instead provides
PhoneHubManager to //ash via new function
SystemTray::SetPhoneHubManager().

This function is left as a TODO for now; a follow-up CL will use the
provided PhoneHubManager pointer to render the UI in //ash.

Bug: 1106937
Change-Id: I4a69d700d4e086d3e59ceaaf5ae1a364824a3633
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2368485Reviewed-by: default avatarJames Cook <jamescook@chromium.org>
Commit-Queue: Kyle Horimoto <khorimoto@chromium.org>
Cr-Commit-Position: refs/heads/master@{#800779}
parent cc1a3a85
...@@ -10,6 +10,12 @@ ...@@ -10,6 +10,12 @@
#include "ash/public/cpp/ash_public_export.h" #include "ash/public/cpp/ash_public_export.h"
#include "base/strings/string16.h" #include "base/strings/string16.h"
namespace chromeos {
namespace phonehub {
class PhoneHubManager;
} // namespace phonehub
} // namespace chromeos
namespace ash { namespace ash {
struct LocaleInfo; struct LocaleInfo;
...@@ -101,6 +107,10 @@ class ASH_PUBLIC_EXPORT SystemTray { ...@@ -101,6 +107,10 @@ class ASH_PUBLIC_EXPORT SystemTray {
// click (it is used e.g. for timing histograms). // click (it is used e.g. for timing histograms).
virtual void ShowNetworkDetailedViewBubble(bool show_by_click) = 0; virtual void ShowNetworkDetailedViewBubble(bool show_by_click) = 0;
// Provides Phone Hub functionality to the system tray.
virtual void SetPhoneHubManager(
chromeos::phonehub::PhoneHubManager* phone_hub_manager) = 0;
protected: protected:
SystemTray(); SystemTray();
virtual ~SystemTray(); virtual ~SystemTray();
......
...@@ -115,4 +115,9 @@ void SystemTrayModel::ShowNetworkDetailedViewBubble(bool show_by_click) { ...@@ -115,4 +115,9 @@ void SystemTrayModel::ShowNetworkDetailedViewBubble(bool show_by_click) {
system_tray->ShowNetworkDetailedViewBubble(show_by_click); system_tray->ShowNetworkDetailedViewBubble(show_by_click);
} }
void SystemTrayModel::SetPhoneHubManager(
chromeos::phonehub::PhoneHubManager* phone_hub_manager) {
// TODO(tengs): Use |phone_hub_manager|.
}
} // namespace ash } // namespace ash
...@@ -50,6 +50,8 @@ class SystemTrayModel : public SystemTray { ...@@ -50,6 +50,8 @@ class SystemTrayModel : public SystemTray {
void SetUpdateOverCellularAvailableIconVisible(bool visible) override; void SetUpdateOverCellularAvailableIconVisible(bool visible) override;
void ShowVolumeSliderBubble() override; void ShowVolumeSliderBubble() override;
void ShowNetworkDetailedViewBubble(bool show_by_click) override; void ShowNetworkDetailedViewBubble(bool show_by_click) override;
void SetPhoneHubManager(
chromeos::phonehub::PhoneHubManager* phone_hub_manager) override;
ClockModel* clock() { return clock_.get(); } ClockModel* clock() { return clock_.get(); }
EnterpriseDomainModel* enterprise_domain() { EnterpriseDomainModel* enterprise_domain() {
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "chrome/browser/chromeos/phonehub/phone_hub_manager_factory.h" #include "chrome/browser/chromeos/phonehub/phone_hub_manager_factory.h"
#include "ash/public/cpp/system_tray.h"
#include "chrome/browser/chromeos/device_sync/device_sync_client_factory.h" #include "chrome/browser/chromeos/device_sync/device_sync_client_factory.h"
#include "chrome/browser/chromeos/multidevice_setup/multidevice_setup_client_factory.h" #include "chrome/browser/chromeos/multidevice_setup/multidevice_setup_client_factory.h"
#include "chrome/browser/chromeos/profiles/profile_helper.h" #include "chrome/browser/chromeos/profiles/profile_helper.h"
...@@ -74,10 +75,16 @@ KeyedService* PhoneHubManagerFactory::BuildServiceInstanceFor( ...@@ -74,10 +75,16 @@ KeyedService* PhoneHubManagerFactory::BuildServiceInstanceFor(
if (IsProhibitedByPolicy(profile)) if (IsProhibitedByPolicy(profile))
return nullptr; return nullptr;
return new PhoneHubManager( PhoneHubManager* phone_hub_manager = new PhoneHubManager(
profile->GetPrefs(), profile->GetPrefs(),
device_sync::DeviceSyncClientFactory::GetForProfile(profile), device_sync::DeviceSyncClientFactory::GetForProfile(profile),
multidevice_setup::MultiDeviceSetupClientFactory::GetForProfile(profile)); multidevice_setup::MultiDeviceSetupClientFactory::GetForProfile(profile));
// Provide |phone_hub_manager| to the system tray so that it can be used by
// the UI.
ash::SystemTray::Get()->SetPhoneHubManager(phone_hub_manager);
return phone_hub_manager;
} }
bool PhoneHubManagerFactory::ServiceIsCreatedWithBrowserContext() const { bool PhoneHubManagerFactory::ServiceIsCreatedWithBrowserContext() const {
......
...@@ -13,14 +13,6 @@ ...@@ -13,14 +13,6 @@
namespace chromeos { namespace chromeos {
namespace phonehub { namespace phonehub {
namespace {
PhoneHubManager* g_instance = nullptr;
} // namespace
// static
PhoneHubManager* PhoneHubManager::Get() {
return g_instance;
}
PhoneHubManager::PhoneHubManager( PhoneHubManager::PhoneHubManager(
PrefService* pref_service, PrefService* pref_service,
...@@ -33,17 +25,11 @@ PhoneHubManager::PhoneHubManager( ...@@ -33,17 +25,11 @@ PhoneHubManager::PhoneHubManager(
std::make_unique<NotificationAccessManagerImpl>(pref_service)), std::make_unique<NotificationAccessManagerImpl>(pref_service)),
phone_model_(std::make_unique<MutablePhoneModel>()), phone_model_(std::make_unique<MutablePhoneModel>()),
tether_controller_( tether_controller_(
std::make_unique<TetherControllerImpl>(multidevice_setup_client)) { std::make_unique<TetherControllerImpl>(multidevice_setup_client)) {}
DCHECK(!g_instance);
g_instance = this;
}
PhoneHubManager::~PhoneHubManager() = default; PhoneHubManager::~PhoneHubManager() = default;
void PhoneHubManager::Shutdown() { void PhoneHubManager::Shutdown() {
DCHECK(g_instance);
g_instance = nullptr;
tether_controller_.reset(); tether_controller_.reset();
phone_model_.reset(); phone_model_.reset();
notification_access_manager_.reset(); notification_access_manager_.reset();
......
...@@ -35,12 +35,6 @@ class TetherController; ...@@ -35,12 +35,6 @@ class TetherController;
// a singleton. // a singleton.
class PhoneHubManager : public KeyedService { class PhoneHubManager : public KeyedService {
public: public:
// Returns a pointer to the singleton once it has been instantiated. Returns
// null if the primary profile has not yet been initialized or has already
// shut down, if the kPhoneHub flag is disabled, or if the feature is
// prohibited by policy.
static PhoneHubManager* Get();
PhoneHubManager( PhoneHubManager(
PrefService* pref_service, PrefService* pref_service,
device_sync::DeviceSyncClient* device_sync_client, device_sync::DeviceSyncClient* device_sync_client,
......
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