Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(64)

Side by Side Diff: components/arc/intent_helper/arc_intent_helper_bridge.cc

Issue 2487623002: Notify Files App when ARC++ app is installed/removed (Closed)
Patch Set: Add RemoverObserver. Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "components/arc/intent_helper/arc_intent_helper_bridge.h" 5 #include "components/arc/intent_helper/arc_intent_helper_bridge.h"
6 6
7 #include <utility> 7 #include <utility>
8 #include <vector> 8 #include <vector>
9 9
10 #include "ash/common/shell_delegate.h" 10 #include "ash/common/shell_delegate.h"
11 #include "ash/common/wallpaper/wallpaper_controller.h" 11 #include "ash/common/wallpaper/wallpaper_controller.h"
12 #include "ash/common/wm_shell.h" 12 #include "ash/common/wm_shell.h"
13 #include "ash/public/interfaces/new_window.mojom.h" 13 #include "ash/public/interfaces/new_window.mojom.h"
14 #include "ash/shell.h" 14 #include "ash/shell.h"
15 #include "base/command_line.h" 15 #include "base/command_line.h"
16 #include "base/memory/weak_ptr.h" 16 #include "base/memory/weak_ptr.h"
17 #include "components/arc/arc_bridge_service.h" 17 #include "components/arc/arc_bridge_service.h"
18 #include "components/arc/intent_helper/activity_icon_loader.h" 18 #include "components/arc/intent_helper/activity_icon_loader.h"
19 #include "components/arc/intent_helper/link_handler_model_impl.h" 19 #include "components/arc/intent_helper/link_handler_model_impl.h"
20 #include "components/arc/intent_helper/local_activity_resolver.h" 20 #include "components/arc/intent_helper/local_activity_resolver.h"
21 #include "ui/base/layout.h" 21 #include "ui/base/layout.h"
22 #include "url/gurl.h" 22 #include "url/gurl.h"
23 23
24 namespace arc { 24 namespace arc {
25 25
26 // TODO(oka): Avoid to assume the class is singleton.
27 ArcIntentHelperBridge* g_arc_intent_helper_bridge = nullptr;
28
26 // static 29 // static
27 const char ArcIntentHelperBridge::kArcIntentHelperPackageName[] = 30 const char ArcIntentHelperBridge::kArcIntentHelperPackageName[] =
28 "org.chromium.arc.intent_helper"; 31 "org.chromium.arc.intent_helper";
29 32
30 ArcIntentHelperBridge::ArcIntentHelperBridge( 33 ArcIntentHelperBridge::ArcIntentHelperBridge(
31 ArcBridgeService* bridge_service, 34 ArcBridgeService* bridge_service,
32 const scoped_refptr<ActivityIconLoader>& icon_loader, 35 const scoped_refptr<ActivityIconLoader>& icon_loader,
33 const scoped_refptr<LocalActivityResolver>& activity_resolver) 36 const scoped_refptr<LocalActivityResolver>& activity_resolver)
34 : ArcService(bridge_service), 37 : ArcService(bridge_service),
35 binding_(this), 38 binding_(this),
36 icon_loader_(icon_loader), 39 icon_loader_(icon_loader),
37 activity_resolver_(activity_resolver) { 40 activity_resolver_(activity_resolver) {
38 DCHECK(thread_checker_.CalledOnValidThread()); 41 DCHECK(thread_checker_.CalledOnValidThread());
42 DCHECK(!g_arc_intent_helper_bridge);
43
39 arc_bridge_service()->intent_helper()->AddObserver(this); 44 arc_bridge_service()->intent_helper()->AddObserver(this);
45
46 g_arc_intent_helper_bridge = this;
40 } 47 }
41 48
42 ArcIntentHelperBridge::~ArcIntentHelperBridge() { 49 ArcIntentHelperBridge::~ArcIntentHelperBridge() {
43 DCHECK(thread_checker_.CalledOnValidThread()); 50 DCHECK(thread_checker_.CalledOnValidThread());
51 DCHECK_EQ(this, g_arc_intent_helper_bridge);
52
44 arc_bridge_service()->intent_helper()->RemoveObserver(this); 53 arc_bridge_service()->intent_helper()->RemoveObserver(this);
54
55 g_arc_intent_helper_bridge = nullptr;
56 }
57
58 // static
59 ArcIntentHelperBridge* ArcIntentHelperBridge::Get() {
60 return g_arc_intent_helper_bridge;
45 } 61 }
46 62
47 void ArcIntentHelperBridge::OnInstanceReady() { 63 void ArcIntentHelperBridge::OnInstanceReady() {
48 DCHECK(thread_checker_.CalledOnValidThread()); 64 DCHECK(thread_checker_.CalledOnValidThread());
49 ash::Shell::GetInstance()->set_link_handler_model_factory(this); 65 ash::Shell::GetInstance()->set_link_handler_model_factory(this);
50 auto* instance = 66 auto* instance =
51 arc_bridge_service()->intent_helper()->GetInstanceForMethod("Init"); 67 arc_bridge_service()->intent_helper()->GetInstanceForMethod("Init");
52 DCHECK(instance); 68 DCHECK(instance);
53 instance->Init(binding_.CreateInterfacePtrAndBind()); 69 instance->Init(binding_.CreateInterfacePtrAndBind());
54 } 70 }
(...skipping 28 matching lines...) Expand all
83 DCHECK(thread_checker_.CalledOnValidThread()); 99 DCHECK(thread_checker_.CalledOnValidThread());
84 ash::WmShell::Get()->wallpaper_controller()->OpenSetWallpaperPage(); 100 ash::WmShell::Get()->wallpaper_controller()->OpenSetWallpaperPage();
85 } 101 }
86 102
87 void ArcIntentHelperBridge::SetWallpaperDeprecated( 103 void ArcIntentHelperBridge::SetWallpaperDeprecated(
88 mojo::Array<uint8_t> jpeg_data) { 104 mojo::Array<uint8_t> jpeg_data) {
89 DCHECK(thread_checker_.CalledOnValidThread()); 105 DCHECK(thread_checker_.CalledOnValidThread());
90 LOG(ERROR) << "IntentHelper.SetWallpaper is deprecated"; 106 LOG(ERROR) << "IntentHelper.SetWallpaper is deprecated";
91 } 107 }
92 108
109 void ArcIntentHelperBridge::AddObserver(Observer* observer) {
110 observer_list_.AddObserver(observer);
111 }
112
113 void ArcIntentHelperBridge::RemoveObserver(Observer* observer) {
114 observer_list_.RemoveObserver(observer);
115 }
116
93 std::unique_ptr<ash::LinkHandlerModel> ArcIntentHelperBridge::CreateModel( 117 std::unique_ptr<ash::LinkHandlerModel> ArcIntentHelperBridge::CreateModel(
94 const GURL& url) { 118 const GURL& url) {
95 DCHECK(thread_checker_.CalledOnValidThread()); 119 DCHECK(thread_checker_.CalledOnValidThread());
96 std::unique_ptr<LinkHandlerModelImpl> impl( 120 std::unique_ptr<LinkHandlerModelImpl> impl(
97 new LinkHandlerModelImpl(icon_loader_)); 121 new LinkHandlerModelImpl(icon_loader_));
98 if (!impl->Init(url)) 122 if (!impl->Init(url))
99 return nullptr; 123 return nullptr;
100 return std::move(impl); 124 return std::move(impl);
101 } 125 }
102 126
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 const std::string& method_name_for_logging, 185 const std::string& method_name_for_logging,
162 uint32_t min_instance_version) { 186 uint32_t min_instance_version) {
163 return GetIntentHelperInstanceWithErrorCode(method_name_for_logging, 187 return GetIntentHelperInstanceWithErrorCode(method_name_for_logging,
164 min_instance_version, nullptr); 188 min_instance_version, nullptr);
165 } 189 }
166 190
167 void ArcIntentHelperBridge::OnIntentFiltersUpdated( 191 void ArcIntentHelperBridge::OnIntentFiltersUpdated(
168 mojo::Array<mojom::IntentFilterPtr> filters) { 192 mojo::Array<mojom::IntentFilterPtr> filters) {
169 DCHECK(thread_checker_.CalledOnValidThread()); 193 DCHECK(thread_checker_.CalledOnValidThread());
170 activity_resolver_->UpdateIntentFilters(std::move(filters)); 194 activity_resolver_->UpdateIntentFilters(std::move(filters));
195
196 for (auto& observer : observer_list_)
197 observer.OnAppsUpdated();
171 } 198 }
172 199
173 } // namespace arc 200 } // namespace arc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698