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_impl.h" | 5 #include "chrome/browser/chromeos/arc/arc_intent_helper_bridge.h" |
6 | 6 |
7 #include "chrome/browser/profiles/profile_manager.h" | 7 #include "chrome/browser/profiles/profile_manager.h" |
8 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" | 8 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" |
9 #include "chrome/browser/ui/browser.h" | 9 #include "chrome/browser/ui/browser.h" |
10 #include "chrome/browser/ui/browser_tabstrip.h" | 10 #include "chrome/browser/ui/browser_tabstrip.h" |
11 #include "chrome/browser/ui/browser_window.h" | 11 #include "chrome/browser/ui/browser_window.h" |
12 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" | 12 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" |
13 #include "components/arc/common/intent_helper.mojom.h" | 13 #include "components/arc/common/intent_helper.mojom.h" |
14 | 14 |
15 namespace arc { | 15 namespace arc { |
16 | 16 |
17 ArcIntentHelperBridgeImpl::ArcIntentHelperBridgeImpl() : binding_(this) {} | 17 ArcIntentHelperBridge::ArcIntentHelperBridge(ArcBridgeService* bridge_service) |
18 | 18 : ArcService(bridge_service), binding_(this) { |
19 ArcIntentHelperBridgeImpl::~ArcIntentHelperBridgeImpl() { | 19 arc_bridge_service()->AddObserver(this); |
20 ArcBridgeService* bridge_service = ArcBridgeService::Get(); | |
21 DCHECK(bridge_service); | |
22 bridge_service->RemoveObserver(this); | |
23 } | 20 } |
24 | 21 |
25 void ArcIntentHelperBridgeImpl::StartObservingBridgeServiceChanges() { | 22 ArcIntentHelperBridge::~ArcIntentHelperBridge() { |
26 ArcBridgeService* bridge_service = ArcBridgeService::Get(); | 23 arc_bridge_service()->RemoveObserver(this); |
27 DCHECK(bridge_service); | |
28 bridge_service->AddObserver(this); | |
29 } | 24 } |
30 | 25 |
31 void ArcIntentHelperBridgeImpl::OnIntentHelperInstanceReady() { | 26 void ArcIntentHelperBridge::OnIntentHelperInstanceReady() { |
32 IntentHelperHostPtr host; | 27 IntentHelperHostPtr host; |
33 binding_.Bind(mojo::GetProxy(&host)); | 28 binding_.Bind(mojo::GetProxy(&host)); |
34 ArcBridgeService* bridge_service = ArcBridgeService::Get(); | 29 arc_bridge_service()->intent_helper_instance()->Init(std::move(host)); |
35 bridge_service->intent_helper_instance()->Init(std::move(host)); | |
36 } | 30 } |
37 | 31 |
38 void ArcIntentHelperBridgeImpl::OnOpenUrl(const mojo::String& url) { | 32 void ArcIntentHelperBridge::OnOpenUrl(const mojo::String& url) { |
39 GURL gurl(url.get()); | 33 GURL gurl(url.get()); |
40 if (!gurl.is_valid()) | 34 if (!gurl.is_valid()) |
41 return; | 35 return; |
42 | 36 |
43 chrome::ScopedTabbedBrowserDisplayer displayer( | 37 chrome::ScopedTabbedBrowserDisplayer displayer( |
44 ProfileManager::GetActiveUserProfile(), chrome::HOST_DESKTOP_TYPE_ASH); | 38 ProfileManager::GetActiveUserProfile(), chrome::HOST_DESKTOP_TYPE_ASH); |
45 chrome::AddSelectedTabWithURL(displayer.browser(), gurl, | 39 chrome::AddSelectedTabWithURL(displayer.browser(), gurl, |
46 ui::PAGE_TRANSITION_LINK); | 40 ui::PAGE_TRANSITION_LINK); |
47 | 41 |
48 // Since the ScopedTabbedBrowserDisplayer does not guarantee that the | 42 // Since the ScopedTabbedBrowserDisplayer does not guarantee that the |
49 // browser will be shown on the active desktop, we ensure the visibility. | 43 // browser will be shown on the active desktop, we ensure the visibility. |
50 multi_user_util::MoveWindowToCurrentDesktop( | 44 multi_user_util::MoveWindowToCurrentDesktop( |
51 displayer.browser()->window()->GetNativeWindow()); | 45 displayer.browser()->window()->GetNativeWindow()); |
52 } | 46 } |
53 | 47 |
54 } // namespace arc | 48 } // namespace arc |
OLD | NEW |