Commit d5f8becb authored by Evan Stade's avatar Evan Stade Committed by Commit Bot

Mash cleanup: message center part 5

Move GetArcAppIdByPackageName from AshMessageCenterClient to its own
C++ interface.

Also delete ash::mojom::AshMessageCenterClient since it's now empty.

Bug: 958191
Change-Id: I605ae6ae081e54010348dd3e9c4d01ece8aaaed4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1658846
Commit-Queue: Evan Stade <estade@chromium.org>
Reviewed-by: default avatarTom Sepez <tsepez@chromium.org>
Reviewed-by: default avatarSteven Bennetts <stevenjb@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#670166}
parent 184067a8
...@@ -35,6 +35,8 @@ component("cpp") { ...@@ -35,6 +35,8 @@ component("cpp") {
"app_list/tokenized_string_match.h", "app_list/tokenized_string_match.h",
"app_menu_constants.h", "app_menu_constants.h",
"app_types.h", "app_types.h",
"arc_app_id_provider.cc",
"arc_app_id_provider.h",
"ash_constants.h", "ash_constants.h",
"ash_features.cc", "ash_features.cc",
"ash_features.h", "ash_features.h",
......
// Copyright 2019 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/public/cpp/arc_app_id_provider.h"
#include "base/logging.h"
namespace ash {
namespace {
ArcAppIdProvider* g_instance = nullptr;
}
// static
ArcAppIdProvider* ArcAppIdProvider::Get() {
return g_instance;
}
ArcAppIdProvider::ArcAppIdProvider() {
DCHECK_EQ(nullptr, g_instance);
g_instance = this;
}
ArcAppIdProvider::~ArcAppIdProvider() {
DCHECK_EQ(this, g_instance);
g_instance = nullptr;
}
} // namespace ash
// Copyright 2019 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_ARC_APP_ID_PROVIDER_H_
#define ASH_PUBLIC_CPP_ARC_APP_ID_PROVIDER_H_
#include <string>
#include "ash/public/cpp/ash_public_export.h"
namespace ash {
class ASH_PUBLIC_EXPORT ArcAppIdProvider {
public:
static ArcAppIdProvider* Get();
virtual std::string GetAppIdByPackageName(
const std::string& package_name) = 0;
protected:
ArcAppIdProvider();
virtual ~ArcAppIdProvider();
};
} // namespace ash
#endif // ASH_PUBLIC_CPP_ARC_APP_ID_PROVIDER_H_
...@@ -6,23 +6,10 @@ module ash.mojom; ...@@ -6,23 +6,10 @@ module ash.mojom;
import "components/arc/common/notifications.mojom"; import "components/arc/common/notifications.mojom";
// The message center controller funnels notification requests from the client
// to the MessageCenter.
interface AshMessageCenterController { interface AshMessageCenterController {
SetClient(associated AshMessageCenterClient client);
// Sets the ARC notification instance. // Sets the ARC notification instance.
SetArcNotificationsInstance(arc.mojom.NotificationsInstance instance); SetArcNotificationsInstance(arc.mojom.NotificationsInstance instance);
// Changes the quiet mode state in the message center. // Changes the quiet mode state in the message center.
SetQuietMode(bool enabled); SetQuietMode(bool enabled);
}; };
// The message center client interface mimics
// message_center::NotificationDelegate. The ID strings match the id passed in
// |notification| in ShowClientNotification and the format of the ID is up to
// the client.
interface AshMessageCenterClient {
// Gets ARC app id from a given package name.
GetArcAppIdByPackageName(string package_name) => (string app_id);
};
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include <memory> #include <memory>
#include <utility> #include <utility>
#include "ash/public/cpp/arc_app_id_provider.h"
#include "ash/public/cpp/ash_features.h" #include "ash/public/cpp/ash_features.h"
#include "ash/system/message_center/arc/arc_notification_constants.h" #include "ash/system/message_center/arc/arc_notification_constants.h"
#include "ash/system/message_center/arc/arc_notification_delegate.h" #include "ash/system/message_center/arc/arc_notification_delegate.h"
...@@ -191,10 +192,11 @@ void ArcNotificationManager::OnNotificationPosted(ArcNotificationDataPtr data) { ...@@ -191,10 +192,11 @@ void ArcNotificationManager::OnNotificationPosted(ArcNotificationDataPtr data) {
it = result.first; it = result.first;
} }
delegate_->GetAppIdByPackageName( std::string app_id =
data->package_name.value_or(std::string()), data->package_name
base::BindOnce(&ArcNotificationManager::OnGotAppId, ? ArcAppIdProvider::Get()->GetAppIdByPackageName(*data->package_name)
weak_ptr_factory_.GetWeakPtr(), std::move(data))); : std::string();
it->second->OnUpdatedFromAndroid(std::move(data), app_id);
} }
void ArcNotificationManager::OnNotificationUpdated( void ArcNotificationManager::OnNotificationUpdated(
...@@ -235,10 +237,11 @@ void ArcNotificationManager::OnNotificationUpdated( ...@@ -235,10 +237,11 @@ void ArcNotificationManager::OnNotificationUpdated(
previously_focused_notification_key_.clear(); previously_focused_notification_key_.clear();
} }
delegate_->GetAppIdByPackageName( std::string app_id =
data->package_name.value_or(std::string()), data->package_name
base::BindOnce(&ArcNotificationManager::OnGotAppId, ? ArcAppIdProvider::Get()->GetAppIdByPackageName(*data->package_name)
weak_ptr_factory_.GetWeakPtr(), std::move(data))); : std::string();
it->second->OnUpdatedFromAndroid(std::move(data), app_id);
} }
void ArcNotificationManager::OpenMessageCenter() { void ArcNotificationManager::OpenMessageCenter() {
...@@ -489,16 +492,6 @@ bool ArcNotificationManager::ShouldIgnoreNotification( ...@@ -489,16 +492,6 @@ bool ArcNotificationManager::ShouldIgnoreNotification(
return false; return false;
} }
void ArcNotificationManager::OnGotAppId(ArcNotificationDataPtr data,
const std::string& app_id) {
const std::string& key = data->key;
auto it = items_.find(key);
if (it == items_.end())
return;
it->second->OnUpdatedFromAndroid(std::move(data), app_id);
}
void ArcNotificationManager::OnDoNotDisturbStatusUpdated( void ArcNotificationManager::OnDoNotDisturbStatusUpdated(
ArcDoNotDisturbStatusPtr status) { ArcDoNotDisturbStatusPtr status) {
// Remove the observer to prevent from sending the command to Android since // Remove the observer to prevent from sending the command to Android since
......
...@@ -81,10 +81,6 @@ class ArcNotificationManager ...@@ -81,10 +81,6 @@ class ArcNotificationManager
void PerformUserAction(uint32_t id, bool open_message_center); void PerformUserAction(uint32_t id, bool open_message_center);
void CancelUserAction(uint32_t id); void CancelUserAction(uint32_t id);
// Invoked when |get_app_id_callback_| gets back the app id.
void OnGotAppId(arc::mojom::ArcNotificationDataPtr data,
const std::string& app_id);
std::unique_ptr<ArcNotificationManagerDelegate> delegate_; std::unique_ptr<ArcNotificationManagerDelegate> delegate_;
const AccountId main_profile_id_; const AccountId main_profile_id_;
message_center::MessageCenter* const message_center_; message_center::MessageCenter* const message_center_;
......
...@@ -19,13 +19,6 @@ class ArcNotificationManagerDelegate { ...@@ -19,13 +19,6 @@ class ArcNotificationManagerDelegate {
// Whether the current user session is public session or kiosk. // Whether the current user session is public session or kiosk.
virtual bool IsPublicSessionOrKiosk() const = 0; virtual bool IsPublicSessionOrKiosk() const = 0;
// Gets app id by package name.
using GetAppIdByPackageNameCallback =
base::OnceCallback<void(const std::string& app_id)>;
virtual void GetAppIdByPackageName(
const std::string& package_name,
GetAppIdByPackageNameCallback callback) = 0;
// Shows the message center. // Shows the message center.
virtual void ShowMessageCenter() = 0; virtual void ShowMessageCenter() = 0;
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <utility> #include <utility>
#include <vector> #include <vector>
#include "ash/public/cpp/arc_app_id_provider.h"
#include "ash/system/message_center/arc/arc_notification_manager.h" #include "ash/system/message_center/arc/arc_notification_manager.h"
#include "ash/system/message_center/arc/arc_notification_manager_delegate.h" #include "ash/system/message_center/arc/arc_notification_manager_delegate.h"
#include "base/message_loop/message_loop.h" #include "base/message_loop/message_loop.h"
...@@ -27,6 +28,20 @@ namespace { ...@@ -27,6 +28,20 @@ namespace {
const char kDummyNotificationKey[] = "DUMMY_NOTIFICATION_KEY"; const char kDummyNotificationKey[] = "DUMMY_NOTIFICATION_KEY";
class TestArcAppIdProvider : public ArcAppIdProvider {
public:
TestArcAppIdProvider() = default;
~TestArcAppIdProvider() override = default;
// ArcAppIdProvider:
std::string GetAppIdByPackageName(const std::string& package_name) override {
return {};
}
private:
DISALLOW_COPY_AND_ASSIGN(TestArcAppIdProvider);
};
class MockMessageCenter : public message_center::FakeMessageCenter { class MockMessageCenter : public message_center::FakeMessageCenter {
public: public:
MockMessageCenter() = default; MockMessageCenter() = default;
...@@ -80,10 +95,6 @@ class FakeArcNotificationManagerDelegate ...@@ -80,10 +95,6 @@ class FakeArcNotificationManagerDelegate
// ArcNotificationManagerDelegate: // ArcNotificationManagerDelegate:
bool IsPublicSessionOrKiosk() const override { return false; } bool IsPublicSessionOrKiosk() const override { return false; }
void GetAppIdByPackageName(const std::string& package_name,
GetAppIdByPackageNameCallback callback) override {
std::move(callback).Run(std::string());
}
void ShowMessageCenter() override {} void ShowMessageCenter() override {}
void HideMessageCenter() override {} void HideMessageCenter() override {}
...@@ -157,6 +168,7 @@ class ArcNotificationManagerTest : public testing::Test { ...@@ -157,6 +168,7 @@ class ArcNotificationManagerTest : public testing::Test {
} }
base::MessageLoop loop_; base::MessageLoop loop_;
TestArcAppIdProvider app_id_provider_;
std::unique_ptr<arc::FakeNotificationsInstance> arc_notifications_instance_; std::unique_ptr<arc::FakeNotificationsInstance> arc_notifications_instance_;
std::unique_ptr<mojo::Binding<arc::mojom::NotificationsInstance>> binding_; std::unique_ptr<mojo::Binding<arc::mojom::NotificationsInstance>> binding_;
std::unique_ptr<ArcNotificationManager> arc_notification_manager_; std::unique_ptr<ArcNotificationManager> arc_notification_manager_;
......
...@@ -28,18 +28,6 @@ bool ArcNotificationManagerDelegateImpl::IsPublicSessionOrKiosk() const { ...@@ -28,18 +28,6 @@ bool ArcNotificationManagerDelegateImpl::IsPublicSessionOrKiosk() const {
login_status == LoginStatus::ARC_KIOSK_APP; login_status == LoginStatus::ARC_KIOSK_APP;
} }
void ArcNotificationManagerDelegateImpl::GetAppIdByPackageName(
const std::string& package_name,
GetAppIdByPackageNameCallback callback) {
if (package_name.empty()) {
std::move(callback).Run(std::string());
return;
}
Shell::Get()->message_center_controller()->GetArcAppIdByPackageName(
package_name, std::move(callback));
}
void ArcNotificationManagerDelegateImpl::ShowMessageCenter() { void ArcNotificationManagerDelegateImpl::ShowMessageCenter() {
Shell::Get() Shell::Get()
->GetPrimaryRootWindowController() ->GetPrimaryRootWindowController()
......
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
#ifndef ASH_SYSTEM_MESSAGE_CENTER_ARC_NOTIFICATION_MANAGER_DELEGATE_IMPL_H_ #ifndef ASH_SYSTEM_MESSAGE_CENTER_ARC_NOTIFICATION_MANAGER_DELEGATE_IMPL_H_
#define ASH_SYSTEM_MESSAGE_CENTER_ARC_NOTIFICATION_MANAGER_DELEGATE_IMPL_H_ #define ASH_SYSTEM_MESSAGE_CENTER_ARC_NOTIFICATION_MANAGER_DELEGATE_IMPL_H_
#include <string>
#include "ash/system/message_center/arc/arc_notification_manager_delegate.h" #include "ash/system/message_center/arc/arc_notification_manager_delegate.h"
#include "base/macros.h" #include "base/macros.h"
...@@ -18,8 +20,6 @@ class ArcNotificationManagerDelegateImpl ...@@ -18,8 +20,6 @@ class ArcNotificationManagerDelegateImpl
// ArcNotificationManagerDelegate: // ArcNotificationManagerDelegate:
bool IsPublicSessionOrKiosk() const override; bool IsPublicSessionOrKiosk() const override;
void GetAppIdByPackageName(const std::string& package_name,
GetAppIdByPackageNameCallback callback) override;
void ShowMessageCenter() override; void ShowMessageCenter() override;
void HideMessageCenter() override; void HideMessageCenter() override;
......
...@@ -8,19 +8,17 @@ ...@@ -8,19 +8,17 @@
#include "ash/public/cpp/ash_pref_names.h" #include "ash/public/cpp/ash_pref_names.h"
#include "ash/public/cpp/ash_switches.h" #include "ash/public/cpp/ash_switches.h"
#include "ash/public/cpp/vector_icons/vector_icons.h"
#include "ash/session/session_controller_impl.h" #include "ash/session/session_controller_impl.h"
#include "ash/shell.h" #include "ash/shell.h"
#include "ash/strings/grit/ash_strings.h" #include "ash/strings/grit/ash_strings.h"
#include "ash/system/message_center/arc_notification_manager_delegate_impl.h" #include "ash/system/message_center/arc_notification_manager_delegate_impl.h"
#include "ash/system/message_center/ash_message_center_lock_screen_controller.h" #include "ash/system/message_center/ash_message_center_lock_screen_controller.h"
#include "base/bind.h" #include "ash/system/message_center/fullscreen_notification_blocker.h"
#include "ash/system/message_center/inactive_user_notification_blocker.h"
#include "ash/system/message_center/session_state_notification_blocker.h"
#include "base/command_line.h" #include "base/command_line.h"
#include "base/unguessable_token.h"
#include "components/account_id/account_id.h"
#include "components/pref_registry/pref_registry_syncable.h" #include "components/pref_registry/pref_registry_syncable.h"
#include "components/prefs/pref_registry_simple.h" #include "components/prefs/pref_registry_simple.h"
#include "components/vector_icons/vector_icons.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
#include "ui/message_center/message_center.h" #include "ui/message_center/message_center.h"
#include "ui/message_center/public/cpp/notification.h" #include "ui/message_center/public/cpp/notification.h"
...@@ -79,32 +77,6 @@ MessageCenterController::MessageCenterController() { ...@@ -79,32 +77,6 @@ MessageCenterController::MessageCenterController() {
std::make_unique<PopupNotificationBlocker>(MessageCenter::Get()); std::make_unique<PopupNotificationBlocker>(MessageCenter::Get());
} }
message_center::RegisterVectorIcons({&vector_icons::kBusinessIcon,
&kNotificationAssistantIcon,
&kNotificationCaptivePortalIcon,
&kNotificationCellularAlertIcon,
&kNotificationDownloadIcon,
&kNotificationEndOfSupportIcon,
&kNotificationFamilyLinkIcon,
&kNotificationGoogleIcon,
&kNotificationImageIcon,
&kNotificationInstalledIcon,
&kNotificationLinuxIcon,
&kNotificationMessagesIcon,
&kNotificationMultiDeviceSetupIcon,
&kNotificationMobileDataIcon,
&kNotificationMobileDataOffIcon,
&kNotificationPlayPrismIcon,
&kNotificationPrintingDoneIcon,
&kNotificationPrintingIcon,
&kNotificationPrintingWarningIcon,
&kNotificationSettingsIcon,
&kNotificationStorageFullIcon,
&kNotificationSupervisedUserIcon,
&kNotificationVpnIcon,
&kNotificationWarningIcon,
&kNotificationWifiOffIcon});
// Set the system notification source display name ("Chrome OS" or "Chromium // Set the system notification source display name ("Chrome OS" or "Chromium
// OS"). // OS").
message_center::MessageCenter::Get()->SetSystemNotificationAppName( message_center::MessageCenter::Get()->SetSystemNotificationAppName(
...@@ -128,12 +100,6 @@ void MessageCenterController::BindRequest( ...@@ -128,12 +100,6 @@ void MessageCenterController::BindRequest(
binding_set_.AddBinding(this, std::move(request)); binding_set_.AddBinding(this, std::move(request));
} }
void MessageCenterController::SetClient(
mojom::AshMessageCenterClientAssociatedPtrInfo client) {
DCHECK(!client_.is_bound());
client_.Bind(std::move(client));
}
void MessageCenterController::SetArcNotificationsInstance( void MessageCenterController::SetArcNotificationsInstance(
arc::mojom::NotificationsInstancePtr arc_notification_instance) { arc::mojom::NotificationsInstancePtr arc_notification_instance) {
if (!arc_notification_manager_) { if (!arc_notification_manager_) {
...@@ -152,11 +118,4 @@ void MessageCenterController::SetQuietMode(bool enabled) { ...@@ -152,11 +118,4 @@ void MessageCenterController::SetQuietMode(bool enabled) {
MessageCenter::Get()->SetQuietMode(enabled); MessageCenter::Get()->SetQuietMode(enabled);
} }
void MessageCenterController::GetArcAppIdByPackageName(
const std::string& package_name,
GetAppIdByPackageNameCallback callback) {
DCHECK(client_.is_bound());
client_->GetArcAppIdByPackageName(package_name, std::move(callback));
}
} // namespace ash } // namespace ash
...@@ -6,24 +6,26 @@ ...@@ -6,24 +6,26 @@
#define ASH_SYSTEM_MESSAGE_CENTER_MESSAGE_CENTER_CONTROLLER_H_ #define ASH_SYSTEM_MESSAGE_CENTER_MESSAGE_CENTER_CONTROLLER_H_
#include <memory> #include <memory>
#include <string>
#include <vector>
#include "ash/ash_export.h" #include "ash/ash_export.h"
#include "ash/public/interfaces/ash_message_center_controller.mojom.h" #include "ash/public/interfaces/ash_message_center_controller.mojom.h"
#include "ash/system/message_center/arc/arc_notification_manager.h" #include "ash/system/message_center/arc/arc_notification_manager.h"
#include "ash/system/message_center/fullscreen_notification_blocker.h"
#include "ash/system/message_center/inactive_user_notification_blocker.h"
#include "ash/system/message_center/session_state_notification_blocker.h"
#include "base/macros.h" #include "base/macros.h"
#include "components/arc/common/notifications.mojom.h" #include "components/arc/common/notifications.mojom.h"
#include "mojo/public/cpp/bindings/associated_binding.h"
#include "mojo/public/cpp/bindings/binding_set.h" #include "mojo/public/cpp/bindings/binding_set.h"
class PrefRegistrySimple; class PrefRegistrySimple;
namespace message_center {
class NotificationBlocker;
}
namespace ash { namespace ash {
class FullscreenNotificationBlocker;
class InactiveUserNotificationBlocker;
class SessionStateNotificationBlocker;
// This class manages the ash message center and allows clients (like Chrome) to // This class manages the ash message center and allows clients (like Chrome) to
// add and remove notifications. // add and remove notifications.
class ASH_EXPORT MessageCenterController class ASH_EXPORT MessageCenterController
...@@ -37,18 +39,10 @@ class ASH_EXPORT MessageCenterController ...@@ -37,18 +39,10 @@ class ASH_EXPORT MessageCenterController
void BindRequest(mojom::AshMessageCenterControllerRequest request); void BindRequest(mojom::AshMessageCenterControllerRequest request);
// mojom::AshMessageCenterController: // mojom::AshMessageCenterController:
void SetClient(
mojom::AshMessageCenterClientAssociatedPtrInfo client) override;
void SetArcNotificationsInstance( void SetArcNotificationsInstance(
arc::mojom::NotificationsInstancePtr arc_notification_instance) override; arc::mojom::NotificationsInstancePtr arc_notification_instance) override;
void SetQuietMode(bool enabled) override; void SetQuietMode(bool enabled) override;
// Handles get app id calls from ArcNotificationManager.
using GetAppIdByPackageNameCallback =
base::OnceCallback<void(const std::string& app_id)>;
void GetArcAppIdByPackageName(const std::string& package_name,
GetAppIdByPackageNameCallback callback);
InactiveUserNotificationBlocker* InactiveUserNotificationBlocker*
inactive_user_notification_blocker_for_testing() { inactive_user_notification_blocker_for_testing() {
return inactive_user_notification_blocker_.get(); return inactive_user_notification_blocker_.get();
...@@ -65,8 +59,6 @@ class ASH_EXPORT MessageCenterController ...@@ -65,8 +59,6 @@ class ASH_EXPORT MessageCenterController
mojo::BindingSet<mojom::AshMessageCenterController> binding_set_; mojo::BindingSet<mojom::AshMessageCenterController> binding_set_;
mojom::AshMessageCenterClientAssociatedPtr client_;
std::unique_ptr<ArcNotificationManager> arc_notification_manager_; std::unique_ptr<ArcNotificationManager> arc_notification_manager_;
DISALLOW_COPY_AND_ASSIGN(MessageCenterController); DISALLOW_COPY_AND_ASSIGN(MessageCenterController);
......
...@@ -8,20 +8,13 @@ ...@@ -8,20 +8,13 @@
#include <memory> #include <memory>
#include "ash/public/cpp/notifier_metadata.h"
#include "ash/public/cpp/notifier_settings_controller.h" #include "ash/public/cpp/notifier_settings_controller.h"
#include "ash/public/interfaces/ash_message_center_controller.mojom.h"
#include "ash/shell.h" #include "ash/shell.h"
#include "ash/system/message_center/message_center_controller.h"
#include "ash/system/message_center/test_notifier_settings_controller.h" #include "ash/system/message_center/test_notifier_settings_controller.h"
#include "ash/test/ash_test_base.h" #include "ash/test/ash_test_base.h"
#include "ash/test/ash_test_helper.h" #include "ash/test/ash_test_helper.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/run_loop.h" #include "base/run_loop.h"
#include "base/strings/utf_string_conversions.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/message_center/public/cpp/notifier_id.h"
#include "ui/views/controls/scroll_view.h"
namespace ash { namespace ash {
......
...@@ -429,6 +429,8 @@ source_set("chromeos") { ...@@ -429,6 +429,8 @@ source_set("chromeos") {
"arc/app_shortcuts/arc_app_shortcuts_menu_builder.h", "arc/app_shortcuts/arc_app_shortcuts_menu_builder.h",
"arc/app_shortcuts/arc_app_shortcuts_request.cc", "arc/app_shortcuts/arc_app_shortcuts_request.cc",
"arc/app_shortcuts/arc_app_shortcuts_request.h", "arc/app_shortcuts/arc_app_shortcuts_request.h",
"arc/arc_app_id_provider_impl.cc",
"arc/arc_app_id_provider_impl.h",
"arc/arc_migration_constants.h", "arc/arc_migration_constants.h",
"arc/arc_migration_guide_notification.cc", "arc/arc_migration_guide_notification.cc",
"arc/arc_migration_guide_notification.h", "arc/arc_migration_guide_notification.h",
......
// Copyright 2019 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/chromeos/arc/arc_app_id_provider_impl.h"
#include "chrome/browser/chromeos/arc/arc_session_manager.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h"
namespace arc {
ArcAppIdProviderImpl::ArcAppIdProviderImpl() = default;
ArcAppIdProviderImpl::~ArcAppIdProviderImpl() = default;
std::string ArcAppIdProviderImpl::GetAppIdByPackageName(
const std::string& package_name) {
return ArcAppListPrefs::Get(ArcSessionManager::Get()->profile())
->GetAppIdByPackageName(package_name);
}
} // namespace arc
// Copyright 2019 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 CHROME_BROWSER_CHROMEOS_ARC_ARC_APP_ID_PROVIDER_IMPL_H_
#define CHROME_BROWSER_CHROMEOS_ARC_ARC_APP_ID_PROVIDER_IMPL_H_
#include "ash/public/cpp/arc_app_id_provider.h"
#include "base/macros.h"
namespace arc {
class ArcAppIdProviderImpl : public ash::ArcAppIdProvider {
public:
ArcAppIdProviderImpl();
~ArcAppIdProviderImpl() override;
// ash::ArcAppIdProvider:
std::string GetAppIdByPackageName(const std::string& package_name) override;
private:
DISALLOW_COPY_AND_ASSIGN(ArcAppIdProviderImpl);
};
} // namespace arc
#endif // CHROME_BROWSER_CHROMEOS_ARC_ARC_APP_ID_PROVIDER_IMPL_H_
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include "chrome/browser/policy/profile_policy_connector.h" #include "chrome/browser/policy/profile_policy_connector.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/app_list/arc/arc_app_launcher.h" #include "chrome/browser/ui/app_list/arc/arc_app_launcher.h"
#include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h"
#include "chrome/browser/ui/app_list/arc/arc_app_utils.h" #include "chrome/browser/ui/app_list/arc/arc_app_utils.h"
#include "chrome/browser/ui/app_list/arc/arc_fast_app_reinstall_starter.h" #include "chrome/browser/ui/app_list/arc/arc_fast_app_reinstall_starter.h"
#include "chrome/browser/ui/app_list/arc/arc_pai_starter.h" #include "chrome/browser/ui/app_list/arc/arc_pai_starter.h"
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "base/observer_list.h" #include "base/observer_list.h"
#include "base/timer/timer.h" #include "base/timer/timer.h"
#include "chrome/browser/chromeos/arc/arc_app_id_provider_impl.h"
#include "chrome/browser/chromeos/arc/arc_support_host.h" #include "chrome/browser/chromeos/arc/arc_support_host.h"
#include "chrome/browser/chromeos/policy/android_management_client.h" #include "chrome/browser/chromeos/policy/android_management_client.h"
#include "chromeos/dbus/session_manager/session_manager_client.h" #include "chromeos/dbus/session_manager/session_manager_client.h"
...@@ -381,6 +382,8 @@ class ArcSessionManager : public ArcSessionRunner::Observer, ...@@ -381,6 +382,8 @@ class ArcSessionManager : public ArcSessionRunner::Observer,
base::Time arc_start_time_; base::Time arc_start_time_;
base::Closure attempt_user_exit_callback_; base::Closure attempt_user_exit_callback_;
ArcAppIdProviderImpl app_id_provider_;
// Must be the last member. // Must be the last member.
base::WeakPtrFactory<ArcSessionManager> weak_ptr_factory_; base::WeakPtrFactory<ArcSessionManager> weak_ptr_factory_;
......
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
#include "ash/public/cpp/shelf_item.h" #include "ash/public/cpp/shelf_item.h"
#include "ash/public/cpp/shelf_prefs.h" #include "ash/public/cpp/shelf_prefs.h"
#include "ash/public/cpp/tablet_mode.h" #include "ash/public/cpp/tablet_mode.h"
#include "ash/public/interfaces/ash_message_center_controller.mojom.h"
#include "ash/public/interfaces/constants.mojom.h" #include "ash/public/interfaces/constants.mojom.h"
#include "ash/shell.h" #include "ash/shell.h"
#include "base/base64.h" #include "base/base64.h"
......
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
#include "ash/public/cpp/assistant/assistant_state_proxy.h" #include "ash/public/cpp/assistant/assistant_state_proxy.h"
#include "ash/public/cpp/assistant/default_voice_interaction_observer.h" #include "ash/public/cpp/assistant/default_voice_interaction_observer.h"
#include "ash/public/interfaces/ash_message_center_controller.mojom.h"
#include "base/compiler_specific.h" #include "base/compiler_specific.h"
#include "base/timer/timer.h" #include "base/timer/timer.h"
#include "chrome/browser/chromeos/printing/cups_printers_manager.h" #include "chrome/browser/chromeos/printing/cups_printers_manager.h"
...@@ -194,8 +193,6 @@ class AutotestPrivateGetVisibleNotificationsFunction ...@@ -194,8 +193,6 @@ class AutotestPrivateGetVisibleNotificationsFunction
private: private:
~AutotestPrivateGetVisibleNotificationsFunction() override; ~AutotestPrivateGetVisibleNotificationsFunction() override;
ResponseAction Run() override; ResponseAction Run() override;
ash::mojom::AshMessageCenterControllerPtr controller_;
}; };
class AutotestPrivateGetPlayStoreStateFunction class AutotestPrivateGetPlayStoreStateFunction
......
...@@ -6,23 +6,18 @@ ...@@ -6,23 +6,18 @@
#include "ash/public/cpp/notifier_metadata.h" #include "ash/public/cpp/notifier_metadata.h"
#include "ash/public/cpp/notifier_settings_observer.h" #include "ash/public/cpp/notifier_settings_observer.h"
#include "ash/public/interfaces/constants.mojom.h"
#include "base/i18n/string_compare.h" #include "base/i18n/string_compare.h"
#include "base/stl_util.h" #include "base/stl_util.h"
#include "chrome/browser/chrome_notification_types.h" #include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/chromeos/arc/arc_session_manager.h"
#include "chrome/browser/chromeos/profiles/profile_helper.h" #include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/notifications/arc_application_notifier_controller.h" #include "chrome/browser/notifications/arc_application_notifier_controller.h"
#include "chrome/browser/notifications/extension_notifier_controller.h" #include "chrome/browser/notifications/extension_notifier_controller.h"
#include "chrome/browser/notifications/web_page_notifier_controller.h" #include "chrome/browser/notifications/web_page_notifier_controller.h"
#include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h"
#include "chrome/browser/ui/settings_window_manager_chromeos.h" #include "chrome/browser/ui/settings_window_manager_chromeos.h"
#include "chrome/common/webui_url_constants.h" #include "chrome/common/webui_url_constants.h"
#include "components/user_manager/user_manager.h" #include "components/user_manager/user_manager.h"
#include "content/public/browser/notification_service.h" #include "content/public/browser/notification_service.h"
#include "content/public/common/service_manager_connection.h"
#include "services/service_manager/public/cpp/connector.h"
#include "ui/message_center/message_center.h" #include "ui/message_center/message_center.h"
#include "ui/message_center/public/cpp/notifier_id.h" #include "ui/message_center/public/cpp/notifier_id.h"
...@@ -108,22 +103,10 @@ class ForwardingNotificationDelegate ...@@ -108,22 +103,10 @@ class ForwardingNotificationDelegate
ChromeAshMessageCenterClient::ChromeAshMessageCenterClient( ChromeAshMessageCenterClient::ChromeAshMessageCenterClient(
NotificationPlatformBridgeDelegate* delegate) NotificationPlatformBridgeDelegate* delegate)
: delegate_(delegate), binding_(this) { : delegate_(delegate) {
DCHECK(!g_chrome_ash_message_center_client); DCHECK(!g_chrome_ash_message_center_client);
g_chrome_ash_message_center_client = this; g_chrome_ash_message_center_client = this;
// May be null in unit tests.
auto* connection = content::ServiceManagerConnection::GetForProcess();
if (connection) {
connection->GetConnector()->BindInterface(ash::mojom::kServiceName,
&controller_);
// Register this object as the client interface implementation.
ash::mojom::AshMessageCenterClientAssociatedPtrInfo ptr_info;
binding_.Bind(mojo::MakeRequest(&ptr_info));
controller_->SetClient(std::move(ptr_info));
}
sources_.insert( sources_.insert(
std::make_pair(message_center::NotifierType::APPLICATION, std::make_pair(message_center::NotifierType::APPLICATION,
std::make_unique<ExtensionNotifierController>(this))); std::make_unique<ExtensionNotifierController>(this)));
...@@ -203,14 +186,6 @@ void ChromeAshMessageCenterClient::RemoveNotifierSettingsObserver( ...@@ -203,14 +186,6 @@ void ChromeAshMessageCenterClient::RemoveNotifierSettingsObserver(
notifier_observers_.RemoveObserver(observer); notifier_observers_.RemoveObserver(observer);
} }
void ChromeAshMessageCenterClient::GetArcAppIdByPackageName(
const std::string& package_name,
GetArcAppIdByPackageNameCallback callback) {
std::move(callback).Run(
ArcAppListPrefs::Get(arc::ArcSessionManager::Get()->profile())
->GetAppIdByPackageName(package_name));
}
void ChromeAshMessageCenterClient::OnIconImageUpdated( void ChromeAshMessageCenterClient::OnIconImageUpdated(
const NotifierId& notifier_id, const NotifierId& notifier_id,
const gfx::ImageSkia& image) { const gfx::ImageSkia& image) {
...@@ -225,25 +200,14 @@ void ChromeAshMessageCenterClient::OnNotifierEnabledChanged( ...@@ -225,25 +200,14 @@ void ChromeAshMessageCenterClient::OnNotifierEnabledChanged(
MessageCenter::Get()->RemoveNotificationsForNotifierId(notifier_id); MessageCenter::Get()->RemoveNotificationsForNotifierId(notifier_id);
} }
// static
void ChromeAshMessageCenterClient::FlushForTesting() {
g_chrome_ash_message_center_client->binding_.FlushForTesting();
}
void ChromeAshMessageCenterClient::Observe( void ChromeAshMessageCenterClient::Observe(
int type, int type,
const content::NotificationSource& source, const content::NotificationSource& source,
const content::NotificationDetails& details) { const content::NotificationDetails& details) {
switch (type) { DCHECK_EQ(type, chrome::NOTIFICATION_PROFILE_ADDED);
case chrome::NOTIFICATION_PROFILE_ADDED: { Profile* profile = GetProfileForNotifiers();
Profile* profile = GetProfileForNotifiers(); if (profile) {
if (profile) { GetNotifiers();
GetNotifiers(); registrar_.RemoveAll();
registrar_.RemoveAll();
}
break;
}
default:
NOTREACHED();
} }
} }
...@@ -6,14 +6,12 @@ ...@@ -6,14 +6,12 @@
#define CHROME_BROWSER_NOTIFICATIONS_CHROME_ASH_MESSAGE_CENTER_CLIENT_H_ #define CHROME_BROWSER_NOTIFICATIONS_CHROME_ASH_MESSAGE_CENTER_CLIENT_H_
#include "ash/public/cpp/notifier_settings_controller.h" #include "ash/public/cpp/notifier_settings_controller.h"
#include "ash/public/interfaces/ash_message_center_controller.mojom.h" #include "base/observer_list.h"
#include "chrome/browser/notifications/notification_platform_bridge.h" #include "chrome/browser/notifications/notification_platform_bridge.h"
#include "chrome/browser/notifications/notification_platform_bridge_chromeos.h" #include "chrome/browser/notifications/notification_platform_bridge_chromeos.h"
#include "chrome/browser/notifications/notifier_controller.h" #include "chrome/browser/notifications/notifier_controller.h"
#include "content/public/browser/notification_observer.h" #include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h" #include "content/public/browser/notification_registrar.h"
#include "mojo/public/cpp/bindings/associated_binding.h"
#include "ui/message_center/public/cpp/notifier_id.h"
// This class serves as Chrome's AshMessageCenterClient, as well as the // This class serves as Chrome's AshMessageCenterClient, as well as the
// NotificationPlatformBridge for ChromeOS. It dispatches notifications to Ash // NotificationPlatformBridge for ChromeOS. It dispatches notifications to Ash
...@@ -21,7 +19,6 @@ ...@@ -21,7 +19,6 @@
// NotifierControllers to provide notifier settings information to Ash (visible // NotifierControllers to provide notifier settings information to Ash (visible
// in NotifierSettingsView). // in NotifierSettingsView).
class ChromeAshMessageCenterClient : public ash::NotifierSettingsController, class ChromeAshMessageCenterClient : public ash::NotifierSettingsController,
public ash::mojom::AshMessageCenterClient,
public NotifierController::Observer, public NotifierController::Observer,
public content::NotificationObserver { public content::NotificationObserver {
public: public:
...@@ -42,20 +39,12 @@ class ChromeAshMessageCenterClient : public ash::NotifierSettingsController, ...@@ -42,20 +39,12 @@ class ChromeAshMessageCenterClient : public ash::NotifierSettingsController,
void RemoveNotifierSettingsObserver( void RemoveNotifierSettingsObserver(
ash::NotifierSettingsObserver* observer) override; ash::NotifierSettingsObserver* observer) override;
// ash::mojom::AshMessageCenterClient:
void GetArcAppIdByPackageName(
const std::string& package_name,
GetArcAppIdByPackageNameCallback callback) override;
// NotifierController::Observer: // NotifierController::Observer:
void OnIconImageUpdated(const message_center::NotifierId& notifier_id, void OnIconImageUpdated(const message_center::NotifierId& notifier_id,
const gfx::ImageSkia& icon) override; const gfx::ImageSkia& icon) override;
void OnNotifierEnabledChanged(const message_center::NotifierId& notifier_id, void OnNotifierEnabledChanged(const message_center::NotifierId& notifier_id,
bool enabled) override; bool enabled) override;
// Flushs |binding_|.
static void FlushForTesting();
private: private:
// content::NotificationObserver override. // content::NotificationObserver override.
void Observe(int type, void Observe(int type,
...@@ -70,8 +59,6 @@ class ChromeAshMessageCenterClient : public ash::NotifierSettingsController, ...@@ -70,8 +59,6 @@ class ChromeAshMessageCenterClient : public ash::NotifierSettingsController,
base::ObserverList<ash::NotifierSettingsObserver> notifier_observers_; base::ObserverList<ash::NotifierSettingsObserver> notifier_observers_;
ash::mojom::AshMessageCenterControllerPtr controller_;
mojo::AssociatedBinding<ash::mojom::AshMessageCenterClient> binding_;
content::NotificationRegistrar registrar_; content::NotificationRegistrar registrar_;
DISALLOW_COPY_AND_ASSIGN(ChromeAshMessageCenterClient); DISALLOW_COPY_AND_ASSIGN(ChromeAshMessageCenterClient);
......
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