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