Commit a63f029c authored by Maggie Cai's avatar Maggie Cai Committed by Commit Bot

[IntentHandling] Request verification status update after ARC settings activated.

There is no easy way to add the domain verification status update
listener in ARC code, therefore, before moving the domain verification
status settings from ARC to Chrome OS settings, manually request the
update from ARC everytime after the ARC settings app activated.

BUG=853604

Change-Id: I269db90ecae765695b06dbdbf5c043da006ba96a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2214585Reviewed-by: default avatarDominick Ng <dominickn@chromium.org>
Commit-Queue: Maggie Cai <mxcai@chromium.org>
Cr-Commit-Position: refs/heads/master@{#773010}
parent 903f7c39
...@@ -351,6 +351,21 @@ bool ShouldShow(const ArcAppListPrefs::AppInfo& app_info) { ...@@ -351,6 +351,21 @@ bool ShouldShow(const ArcAppListPrefs::AppInfo& app_info) {
return app_info.show_in_launcher; return app_info.show_in_launcher;
} }
void RequestDomainVerificationStatusUpdate(ArcAppListPrefs* prefs) {
auto* arc_service_manager = arc::ArcServiceManager::Get();
arc::mojom::IntentHelperInstance* instance = nullptr;
if (arc_service_manager) {
instance = ARC_GET_INSTANCE_FOR_METHOD(
arc_service_manager->arc_bridge_service()->intent_helper(),
RequestDomainVerificationStatusUpdate);
}
if (!instance) {
return;
}
instance->RequestDomainVerificationStatusUpdate();
}
} // namespace } // namespace
namespace apps { namespace apps {
...@@ -369,7 +384,9 @@ ArcApps* ArcApps::CreateForTesting(Profile* profile, ...@@ -369,7 +384,9 @@ ArcApps* ArcApps::CreateForTesting(Profile* profile,
ArcApps::ArcApps(Profile* profile) : ArcApps(profile, nullptr) {} ArcApps::ArcApps(Profile* profile) : ArcApps(profile, nullptr) {}
ArcApps::ArcApps(Profile* profile, apps::AppServiceProxy* proxy) ArcApps::ArcApps(Profile* profile, apps::AppServiceProxy* proxy)
: profile_(profile), arc_icon_once_loader_(profile) { : profile_(profile),
arc_icon_once_loader_(profile),
settings_app_is_active_(false) {
if (!arc::IsArcAllowedForProfile(profile_) || if (!arc::IsArcAllowedForProfile(profile_) ||
(arc::ArcServiceManager::Get() == nullptr)) { (arc::ArcServiceManager::Get() == nullptr)) {
return; return;
...@@ -404,6 +421,11 @@ ArcApps::ArcApps(Profile* profile, apps::AppServiceProxy* proxy) ...@@ -404,6 +421,11 @@ ArcApps::ArcApps(Profile* profile, apps::AppServiceProxy* proxy)
ash::ArcNotificationsHostInitializer::Get()); ash::ArcNotificationsHostInitializer::Get());
} }
auto* instance_registry = &proxy->InstanceRegistry();
if (instance_registry) {
instance_registry_observer_.Add(instance_registry);
}
PublisherBase::Initialize(app_service, apps::mojom::AppType::kArc); PublisherBase::Initialize(app_service, apps::mojom::AppType::kArc);
} }
...@@ -991,6 +1013,30 @@ void ArcApps::OnArcNotificationManagerDestroyed( ...@@ -991,6 +1013,30 @@ void ArcApps::OnArcNotificationManagerDestroyed(
notification_observer_.Remove(notification_manager); notification_observer_.Remove(notification_manager);
} }
void ArcApps::OnInstanceUpdate(const apps::InstanceUpdate& update) {
if (!update.StateChanged()) {
return;
}
if (update.AppId() != arc::kSettingsAppId) {
return;
}
if (update.State() & apps::InstanceState::kActive) {
settings_app_is_active_ = true;
} else if (settings_app_is_active_) {
settings_app_is_active_ = false;
ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile_);
if (!prefs) {
return;
}
RequestDomainVerificationStatusUpdate(prefs);
}
}
void ArcApps::OnInstanceRegistryWillBeDestroyed(
apps::InstanceRegistry* instance_registry) {
instance_registry_observer_.Remove(instance_registry);
}
void ArcApps::LoadPlayStoreIcon(apps::mojom::IconCompression icon_compression, void ArcApps::LoadPlayStoreIcon(apps::mojom::IconCompression icon_compression,
int32_t size_hint_in_dip, int32_t size_hint_in_dip,
IconEffects icon_effects, IconEffects icon_effects,
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include "components/arc/intent_helper/arc_intent_helper_bridge.h" #include "components/arc/intent_helper/arc_intent_helper_bridge.h"
#include "components/arc/intent_helper/arc_intent_helper_observer.h" #include "components/arc/intent_helper/arc_intent_helper_observer.h"
#include "components/keyed_service/core/keyed_service.h" #include "components/keyed_service/core/keyed_service.h"
#include "components/services/app_service/public/cpp/instance_registry.h"
#include "components/services/app_service/public/cpp/publisher_base.h" #include "components/services/app_service/public/cpp/publisher_base.h"
#include "components/services/app_service/public/mojom/app_service.mojom.h" #include "components/services/app_service/public/mojom/app_service.mojom.h"
#include "mojo/public/cpp/bindings/pending_remote.h" #include "mojo/public/cpp/bindings/pending_remote.h"
...@@ -49,7 +50,8 @@ class ArcApps : public KeyedService, ...@@ -49,7 +50,8 @@ class ArcApps : public KeyedService,
public ArcAppListPrefs::Observer, public ArcAppListPrefs::Observer,
public arc::ArcIntentHelperObserver, public arc::ArcIntentHelperObserver,
public ash::ArcNotificationManagerBase::Observer, public ash::ArcNotificationManagerBase::Observer,
public ash::ArcNotificationsHostInitializer::Observer { public ash::ArcNotificationsHostInitializer::Observer,
public apps::InstanceRegistry::Observer {
public: public:
static ArcApps* Get(Profile* profile); static ArcApps* Get(Profile* profile);
...@@ -145,6 +147,11 @@ class ArcApps : public KeyedService, ...@@ -145,6 +147,11 @@ class ArcApps : public KeyedService,
void OnArcNotificationManagerDestroyed( void OnArcNotificationManagerDestroyed(
ash::ArcNotificationManagerBase* notification_manager) override; ash::ArcNotificationManagerBase* notification_manager) override;
// apps::InstanceRegistry::Observer overrides.
void OnInstanceUpdate(const apps::InstanceUpdate& update) override;
void OnInstanceRegistryWillBeDestroyed(
apps::InstanceRegistry* instance_registry) override;
void LoadPlayStoreIcon(apps::mojom::IconCompression icon_compression, void LoadPlayStoreIcon(apps::mojom::IconCompression icon_compression,
int32_t size_hint_in_dip, int32_t size_hint_in_dip,
IconEffects icon_effects, IconEffects icon_effects,
...@@ -203,6 +210,11 @@ class ArcApps : public KeyedService, ...@@ -203,6 +210,11 @@ class ArcApps : public KeyedService,
AppNotifications app_notifications_; AppNotifications app_notifications_;
ScopedObserver<apps::InstanceRegistry, apps::InstanceRegistry::Observer>
instance_registry_observer_{this};
bool settings_app_is_active_;
base::WeakPtrFactory<ArcApps> weak_ptr_factory_{this}; base::WeakPtrFactory<ArcApps> weak_ptr_factory_{this};
DISALLOW_COPY_AND_ASSIGN(ArcApps); DISALLOW_COPY_AND_ASSIGN(ArcApps);
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// //
// Next MinVersion: 37 // Next MinVersion: 38
module arc.mojom; module arc.mojom;
...@@ -314,7 +314,7 @@ interface IntentHelperHost { ...@@ -314,7 +314,7 @@ interface IntentHelperHost {
}; };
// Sends intents to ARC on behalf of Chrome. // Sends intents to ARC on behalf of Chrome.
// Next method ID: 19 // Next method ID: 20
interface IntentHelperInstance { interface IntentHelperInstance {
// Sets the given package as a preferred package. The next time an ACTION_VIEW // Sets the given package as a preferred package. The next time an ACTION_VIEW
// intent is sent with a URL that requires disambiguation, instead of opening // intent is sent with a URL that requires disambiguation, instead of opening
...@@ -413,4 +413,8 @@ interface IntentHelperInstance { ...@@ -413,4 +413,8 @@ interface IntentHelperInstance {
CameraIntentAction action, CameraIntentAction action,
array<uint8> data) array<uint8> data)
=> (bool is_success); => (bool is_success);
// Request ARC to send the domain verification status update for all packages
// to Chrome OS.
[MinVersion=37] RequestDomainVerificationStatusUpdate@19();
}; };
...@@ -163,4 +163,6 @@ FakeIntentHelperInstance::GetBroadcastsForAction( ...@@ -163,4 +163,6 @@ FakeIntentHelperInstance::GetBroadcastsForAction(
return result; return result;
} }
void FakeIntentHelperInstance::RequestDomainVerificationStatusUpdate() {}
} // namespace arc } // namespace arc
...@@ -134,6 +134,8 @@ class FakeIntentHelperInstance : public mojom::IntentHelperInstance { ...@@ -134,6 +134,8 @@ class FakeIntentHelperInstance : public mojom::IntentHelperInstance {
const std::vector<uint8_t>& data, const std::vector<uint8_t>& data,
HandleCameraResultCallback callback) override; HandleCameraResultCallback callback) override;
void RequestDomainVerificationStatusUpdate() override;
private: private:
std::vector<Broadcast> broadcasts_; std::vector<Broadcast> broadcasts_;
......
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