OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/chromeos/arc/arc_intent_helper_bridge.h" | 5 #include "chrome/browser/chromeos/arc/arc_intent_helper_bridge.h" |
6 | 6 |
7 #include "base/json/json_writer.h" | 7 #include "base/json/json_writer.h" |
8 #include "chrome/browser/profiles/profile_manager.h" | 8 #include "chrome/browser/profiles/profile_manager.h" |
9 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" | 9 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" |
10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 void ArcIntentHelperBridge::OnIntentHelperInstanceClosed() { | 33 void ArcIntentHelperBridge::OnIntentHelperInstanceClosed() { |
34 settings_bridge_.reset(); | 34 settings_bridge_.reset(); |
35 } | 35 } |
36 | 36 |
37 void ArcIntentHelperBridge::OnOpenUrl(const mojo::String& url) { | 37 void ArcIntentHelperBridge::OnOpenUrl(const mojo::String& url) { |
38 GURL gurl(url.get()); | 38 GURL gurl(url.get()); |
39 if (!gurl.is_valid()) | 39 if (!gurl.is_valid()) |
40 return; | 40 return; |
41 | 41 |
42 chrome::ScopedTabbedBrowserDisplayer displayer( | 42 chrome::ScopedTabbedBrowserDisplayer displayer( |
43 ProfileManager::GetActiveUserProfile(), chrome::HOST_DESKTOP_TYPE_ASH); | 43 ProfileManager::GetActiveUserProfile()); |
44 chrome::AddSelectedTabWithURL(displayer.browser(), gurl, | 44 chrome::AddSelectedTabWithURL(displayer.browser(), gurl, |
45 ui::PAGE_TRANSITION_LINK); | 45 ui::PAGE_TRANSITION_LINK); |
46 | 46 |
47 // Since the ScopedTabbedBrowserDisplayer does not guarantee that the | 47 // Since the ScopedTabbedBrowserDisplayer does not guarantee that the |
48 // browser will be shown on the active desktop, we ensure the visibility. | 48 // browser will be shown on the active desktop, we ensure the visibility. |
49 multi_user_util::MoveWindowToCurrentDesktop( | 49 multi_user_util::MoveWindowToCurrentDesktop( |
50 displayer.browser()->window()->GetNativeWindow()); | 50 displayer.browser()->window()->GetNativeWindow()); |
51 } | 51 } |
52 | 52 |
53 void ArcIntentHelperBridge::OnBroadcastNeeded( | 53 void ArcIntentHelperBridge::OnBroadcastNeeded( |
54 const std::string& action, | 54 const std::string& action, |
55 const base::DictionaryValue& extras) { | 55 const base::DictionaryValue& extras) { |
56 if (arc_bridge_service()->state() != ArcBridgeService::State::READY) { | 56 if (arc_bridge_service()->state() != ArcBridgeService::State::READY) { |
57 LOG(ERROR) << "Bridge service is not ready."; | 57 LOG(ERROR) << "Bridge service is not ready."; |
58 return; | 58 return; |
59 } | 59 } |
60 | 60 |
61 std::string extras_json; | 61 std::string extras_json; |
62 bool write_success = base::JSONWriter::Write(extras, &extras_json); | 62 bool write_success = base::JSONWriter::Write(extras, &extras_json); |
63 DCHECK(write_success); | 63 DCHECK(write_success); |
64 | 64 |
65 if (arc_bridge_service()->intent_helper_version() >= 1) { | 65 if (arc_bridge_service()->intent_helper_version() >= 1) { |
66 arc_bridge_service()->intent_helper_instance()->SendBroadcast( | 66 arc_bridge_service()->intent_helper_instance()->SendBroadcast( |
67 action, "org.chromium.arc.intent_helper", | 67 action, "org.chromium.arc.intent_helper", |
68 "org.chromium.arc.intent_helper.SettingsReceiver", extras_json); | 68 "org.chromium.arc.intent_helper.SettingsReceiver", extras_json); |
69 } | 69 } |
70 } | 70 } |
71 | 71 |
72 } // namespace arc | 72 } // namespace arc |
OLD | NEW |