 Chromium Code Reviews
 Chromium Code Reviews Issue 2487623002:
  Notify Files App when ARC++ app is installed/removed  (Closed)
    
  
    Issue 2487623002:
  Notify Files App when ARC++ app is installed/removed  (Closed) 
  | Index: components/arc/intent_helper/arc_intent_helper_bridge.cc | 
| diff --git a/components/arc/intent_helper/arc_intent_helper_bridge.cc b/components/arc/intent_helper/arc_intent_helper_bridge.cc | 
| index b691412c6e00863612c455b2230e235936bf3f83..e12cc2d8e6623621ee099977d50b68ad7aaf7fb0 100644 | 
| --- a/components/arc/intent_helper/arc_intent_helper_bridge.cc | 
| +++ b/components/arc/intent_helper/arc_intent_helper_bridge.cc | 
| @@ -23,6 +23,9 @@ | 
| namespace arc { | 
| +// 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.
 | 
| +ArcIntentHelperBridge* g_arc_intent_helper_bridge = nullptr; | 
| + | 
| // static | 
| const char ArcIntentHelperBridge::kArcIntentHelperPackageName[] = | 
| "org.chromium.arc.intent_helper"; | 
| @@ -36,12 +39,25 @@ ArcIntentHelperBridge::ArcIntentHelperBridge( | 
| icon_loader_(icon_loader), | 
| activity_resolver_(activity_resolver) { | 
| DCHECK(thread_checker_.CalledOnValidThread()); | 
| + DCHECK(!g_arc_intent_helper_bridge); | 
| + | 
| arc_bridge_service()->intent_helper()->AddObserver(this); | 
| + | 
| + g_arc_intent_helper_bridge = this; | 
| } | 
| ArcIntentHelperBridge::~ArcIntentHelperBridge() { | 
| DCHECK(thread_checker_.CalledOnValidThread()); | 
| + DCHECK_EQ(this, g_arc_intent_helper_bridge); | 
| + | 
| arc_bridge_service()->intent_helper()->RemoveObserver(this); | 
| + | 
| + g_arc_intent_helper_bridge = nullptr; | 
| +} | 
| + | 
| +// static | 
| +ArcIntentHelperBridge* ArcIntentHelperBridge::Get() { | 
| + return g_arc_intent_helper_bridge; | 
| } | 
| void ArcIntentHelperBridge::OnInstanceReady() { | 
| @@ -90,6 +106,10 @@ void ArcIntentHelperBridge::SetWallpaperDeprecated( | 
| LOG(ERROR) << "IntentHelper.SetWallpaper is deprecated"; | 
| } | 
| +void ArcIntentHelperBridge::AddObserver(Observer* observer) { | 
| + observer_list_.AddObserver(observer); | 
| +} | 
| + | 
| std::unique_ptr<ash::LinkHandlerModel> ArcIntentHelperBridge::CreateModel( | 
| const GURL& url) { | 
| DCHECK(thread_checker_.CalledOnValidThread()); | 
| @@ -168,6 +188,10 @@ void ArcIntentHelperBridge::OnIntentFiltersUpdated( | 
| mojo::Array<mojom::IntentFilterPtr> filters) { | 
| DCHECK(thread_checker_.CalledOnValidThread()); | 
| activity_resolver_->UpdateIntentFilters(std::move(filters)); | 
| + | 
| + for (auto& observer : observer_list_) { | 
| 
Yusuke Sato
2016/11/17 02:29:54
nit: no {}
 
oka
2016/11/21 07:02:15
Done.
 | 
| + observer.OnAppsUpdated(); | 
| + } | 
| } | 
| } // namespace arc |