| Index: chrome/browser/chromeos/arc/arc_intent_helper_bridge_impl.cc
|
| diff --git a/chrome/browser/chromeos/arc/arc_intent_helper_bridge_impl.cc b/chrome/browser/chromeos/arc/arc_intent_helper_bridge_impl.cc
|
| index 9e4781a8b0b0c45026e1083284bb65bd5b0a2e99..5930bb79a45c86318cd9d4ad95399ab118e92c3b 100644
|
| --- a/chrome/browser/chromeos/arc/arc_intent_helper_bridge_impl.cc
|
| +++ b/chrome/browser/chromeos/arc/arc_intent_helper_bridge_impl.cc
|
| @@ -4,6 +4,7 @@
|
|
|
| #include "chrome/browser/chromeos/arc/arc_intent_helper_bridge_impl.h"
|
|
|
| +#include "base/json/json_writer.h"
|
| #include "chrome/browser/profiles/profile_manager.h"
|
| #include "chrome/browser/ui/ash/multi_user/multi_user_util.h"
|
| #include "chrome/browser/ui/browser.h"
|
| @@ -28,11 +29,21 @@ void ArcIntentHelperBridgeImpl::StartObservingBridgeServiceChanges() {
|
| bridge_service->AddObserver(this);
|
| }
|
|
|
| +void ArcIntentHelperBridgeImpl::OnStateChanged(ArcBridgeService::State state) {
|
| + // ArcBridgeService::State::READY is emitted before ArcIntentHelper app is
|
| + // ready to send broadcasts. Instead we wait for the IntentHelperInstance
|
| + // to be ready.
|
| + if (state == ArcBridgeService::State::STOPPING) {
|
| + settings_bridge_.reset();
|
| + }
|
| +}
|
| +
|
| void ArcIntentHelperBridgeImpl::OnIntentHelperInstanceReady() {
|
| IntentHelperHostPtr host;
|
| binding_.Bind(mojo::GetProxy(&host));
|
| ArcBridgeService* bridge_service = ArcBridgeService::Get();
|
| bridge_service->intent_helper_instance()->Init(std::move(host));
|
| + settings_bridge_.reset(new SettingsBridge(this));
|
| }
|
|
|
| void ArcIntentHelperBridgeImpl::OnOpenUrl(const mojo::String& url) {
|
| @@ -51,4 +62,22 @@ void ArcIntentHelperBridgeImpl::OnOpenUrl(const mojo::String& url) {
|
| displayer.browser()->window()->GetNativeWindow());
|
| }
|
|
|
| +void ArcIntentHelperBridgeImpl::OnBroadcastNeeded(
|
| + const std::string& action,
|
| + const base::DictionaryValue& extras) {
|
| + ArcBridgeService* bridge_service = ArcBridgeService::Get();
|
| + if (!bridge_service ||
|
| + bridge_service->state() != ArcBridgeService::State::READY) {
|
| + LOG(ERROR) << "Bridge service is not ready.";
|
| + return;
|
| + }
|
| +
|
| + std::string extras_json;
|
| + bool write_success = base::JSONWriter::Write(extras, &extras_json);
|
| + DCHECK(write_success);
|
| + bridge_service->intent_helper_instance()->SendBroadcast(
|
| + action, "org.chromium.arc.intent_helper",
|
| + "org.chromium.arc.intent_helper.SettingsReceiver", extras_json);
|
| +}
|
| +
|
| } // namespace arc
|
|
|