Chromium Code Reviews| 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 "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. | |
|
Yusuke Sato
2016/11/17 04:22:37
Adding more global pointers to components/arc/ see
hidehiko
2016/11/17 07:34:19
ArcIntentHelperBridge's ctor, and
ArcServiceManage
Yusuke Sato
2016/11/17 09:15:27
Well, I wanted to make the code *look* slightly be
oka
2016/11/21 07:02:15
Thank you for the suggestion. I will try the const
oka
2016/11/21 07:02:15
Abe-san suggested this solution. @hidehiko what do
Yusuke Sato
2016/11/21 17:21:05
What do you mean by "the next patch"? Next patch s
oka
2016/11/24 15:14:17
Updated the construct as you suggested.
| |
| 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 Loading... | |
| 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 | |
| 93 std::unique_ptr<ash::LinkHandlerModel> ArcIntentHelperBridge::CreateModel( | 113 std::unique_ptr<ash::LinkHandlerModel> ArcIntentHelperBridge::CreateModel( |
| 94 const GURL& url) { | 114 const GURL& url) { |
| 95 DCHECK(thread_checker_.CalledOnValidThread()); | 115 DCHECK(thread_checker_.CalledOnValidThread()); |
| 96 std::unique_ptr<LinkHandlerModelImpl> impl( | 116 std::unique_ptr<LinkHandlerModelImpl> impl( |
| 97 new LinkHandlerModelImpl(icon_loader_)); | 117 new LinkHandlerModelImpl(icon_loader_)); |
| 98 if (!impl->Init(url)) | 118 if (!impl->Init(url)) |
| 99 return nullptr; | 119 return nullptr; |
| 100 return std::move(impl); | 120 return std::move(impl); |
| 101 } | 121 } |
| 102 | 122 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 161 const std::string& method_name_for_logging, | 181 const std::string& method_name_for_logging, |
| 162 uint32_t min_instance_version) { | 182 uint32_t min_instance_version) { |
| 163 return GetIntentHelperInstanceWithErrorCode(method_name_for_logging, | 183 return GetIntentHelperInstanceWithErrorCode(method_name_for_logging, |
| 164 min_instance_version, nullptr); | 184 min_instance_version, nullptr); |
| 165 } | 185 } |
| 166 | 186 |
| 167 void ArcIntentHelperBridge::OnIntentFiltersUpdated( | 187 void ArcIntentHelperBridge::OnIntentFiltersUpdated( |
| 168 mojo::Array<mojom::IntentFilterPtr> filters) { | 188 mojo::Array<mojom::IntentFilterPtr> filters) { |
| 169 DCHECK(thread_checker_.CalledOnValidThread()); | 189 DCHECK(thread_checker_.CalledOnValidThread()); |
| 170 activity_resolver_->UpdateIntentFilters(std::move(filters)); | 190 activity_resolver_->UpdateIntentFilters(std::move(filters)); |
| 191 | |
| 192 for (auto& observer : observer_list_) { | |
|
Yusuke Sato
2016/11/17 02:29:54
nit: no {}
oka
2016/11/21 07:02:15
Done.
| |
| 193 observer.OnAppsUpdated(); | |
| 194 } | |
| 171 } | 195 } |
| 172 | 196 |
| 173 } // namespace arc | 197 } // namespace arc |
| OLD | NEW |