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

Side by Side Diff: chrome/browser/chromeos/note_taking_helper.cc

Issue 2623273003: arc: Remove ArcServiceManager::Observer (Closed)
Patch Set: Moved Get() to the manager class per (verbal) feedback from Luis Created 3 years, 11 months 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
« no previous file with comments | « chrome/browser/chromeos/note_taking_helper.h ('k') | components/arc/arc_service_manager.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "chrome/browser/chromeos/note_taking_helper.h" 5 #include "chrome/browser/chromeos/note_taking_helper.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "apps/launcher.h" 10 #include "apps/launcher.h"
11 #include "ash/common/system/chromeos/palette/palette_utils.h" 11 #include "ash/common/system/chromeos/palette/palette_utils.h"
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/command_line.h" 13 #include "base/command_line.h"
14 #include "base/files/file_path.h" 14 #include "base/files/file_path.h"
15 #include "base/logging.h" 15 #include "base/logging.h"
16 #include "base/memory/ptr_util.h" 16 #include "base/memory/ptr_util.h"
17 #include "base/memory/ref_counted.h" 17 #include "base/memory/ref_counted.h"
18 #include "base/metrics/histogram_macros.h" 18 #include "base/metrics/histogram_macros.h"
19 #include "base/strings/string_split.h" 19 #include "base/strings/string_split.h"
20 #include "chrome/browser/browser_process.h" 20 #include "chrome/browser/browser_process.h"
21 #include "chrome/browser/chrome_notification_types.h" 21 #include "chrome/browser/chrome_notification_types.h"
22 #include "chrome/browser/chromeos/file_manager/path_util.h" 22 #include "chrome/browser/chromeos/file_manager/path_util.h"
23 #include "chrome/browser/profiles/profile.h" 23 #include "chrome/browser/profiles/profile.h"
24 #include "chrome/browser/profiles/profile_manager.h" 24 #include "chrome/browser/profiles/profile_manager.h"
25 #include "chrome/common/pref_names.h" 25 #include "chrome/common/pref_names.h"
26 #include "chromeos/chromeos_switches.h" 26 #include "chromeos/chromeos_switches.h"
27 #include "components/arc/arc_bridge_service.h" 27 #include "components/arc/arc_bridge_service.h"
28 #include "components/arc/arc_service_manager.h" 28 #include "components/arc/arc_service_manager.h"
29 #include "components/arc/common/intent_helper.mojom.h" 29 #include "components/arc/intent_helper/arc_intent_helper_bridge.h"
30 #include "components/prefs/pref_service.h" 30 #include "components/prefs/pref_service.h"
31 #include "content/public/browser/browser_thread.h" 31 #include "content/public/browser/browser_thread.h"
32 #include "content/public/browser/notification_service.h" 32 #include "content/public/browser/notification_service.h"
33 #include "extensions/browser/extension_registry.h" 33 #include "extensions/browser/extension_registry.h"
34 #include "extensions/common/api/app_runtime.h" 34 #include "extensions/common/api/app_runtime.h"
35 #include "extensions/common/extension.h" 35 #include "extensions/common/extension.h"
36 #include "url/gurl.h" 36 #include "url/gurl.h"
37 37
38 namespace app_runtime = extensions::api::app_runtime; 38 namespace app_runtime = extensions::api::app_runtime;
39 39
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 g_browser_process->profile_manager()->GetLoadedProfiles()) { 221 g_browser_process->profile_manager()->GetLoadedProfiles()) {
222 extension_registry_observer_.Add( 222 extension_registry_observer_.Add(
223 extensions::ExtensionRegistry::Get(profile)); 223 extensions::ExtensionRegistry::Get(profile));
224 } 224 }
225 225
226 // Check if the primary profile has already enabled ARC and watch for changes. 226 // Check if the primary profile has already enabled ARC and watch for changes.
227 auto session_manager = arc::ArcSessionManager::Get(); 227 auto session_manager = arc::ArcSessionManager::Get();
228 session_manager->AddObserver(this); 228 session_manager->AddObserver(this);
229 android_enabled_ = session_manager->IsArcEnabled(); 229 android_enabled_ = session_manager->IsArcEnabled();
230 230
231 // ArcServiceManager will notify us about changes to the list of available 231 // ArcIntentHelperBridge will notify us about changes to the list of available
232 // Android apps. 232 // Android apps.
233 auto service_manager = arc::ArcServiceManager::Get(); 233 auto intent_helper_bridge =
234 service_manager->AddObserver(this); 234 arc::ArcServiceManager::GetGlobalService<arc::ArcIntentHelperBridge>();
235 if (intent_helper_bridge)
236 intent_helper_bridge->AddObserver(this);
235 237
236 // If the ARC intent helper is ready, get the Android apps. Otherwise, 238 // If the ARC intent helper is ready, get the Android apps. Otherwise,
237 // UpdateAndroidApps() will be called when ArcServiceManager calls 239 // UpdateAndroidApps() will be called when ArcServiceManager calls
238 // OnIntentFiltersUpdated(). 240 // OnIntentFiltersUpdated().
239 if (android_enabled_ && 241 if (android_enabled_ &&
240 arc::ArcServiceManager::Get() 242 arc::ArcServiceManager::Get()
241 ->arc_bridge_service() 243 ->arc_bridge_service()
242 ->intent_helper() 244 ->intent_helper()
243 ->has_instance()) 245 ->has_instance())
244 UpdateAndroidApps(); 246 UpdateAndroidApps();
245 } 247 }
246 248
247 NoteTakingHelper::~NoteTakingHelper() { 249 NoteTakingHelper::~NoteTakingHelper() {
248 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 250 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
249 251
250 // ArcSessionManagerTest shuts down ARC before NoteTakingHelper. 252 // ArcSessionManagerTest shuts down ARC before NoteTakingHelper.
251 if (arc::ArcServiceManager::Get()) 253 auto intent_helper_bridge =
252 arc::ArcServiceManager::Get()->RemoveObserver(this); 254 arc::ArcServiceManager::GetGlobalService<arc::ArcIntentHelperBridge>();
255 if (intent_helper_bridge)
256 intent_helper_bridge->RemoveObserver(this);
253 if (arc::ArcSessionManager::Get()) 257 if (arc::ArcSessionManager::Get())
254 arc::ArcSessionManager::Get()->RemoveObserver(this); 258 arc::ArcSessionManager::Get()->RemoveObserver(this);
255 } 259 }
256 260
257 bool NoteTakingHelper::IsWhitelistedChromeApp( 261 bool NoteTakingHelper::IsWhitelistedChromeApp(
258 const extensions::Extension* extension) const { 262 const extensions::Extension* extension) const {
259 DCHECK(extension); 263 DCHECK(extension);
260 return std::find(whitelisted_chrome_app_ids_.begin(), 264 return std::find(whitelisted_chrome_app_ids_.begin(),
261 whitelisted_chrome_app_ids_.end(), 265 whitelisted_chrome_app_ids_.end(),
262 extension->id()) != whitelisted_chrome_app_ids_.end(); 266 extension->id()) != whitelisted_chrome_app_ids_.end();
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 for (auto& observer : observers_) 397 for (auto& observer : observers_)
394 observer.OnAvailableNoteTakingAppsUpdated(); 398 observer.OnAvailableNoteTakingAppsUpdated();
395 } 399 }
396 } 400 }
397 401
398 void NoteTakingHelper::OnShutdown(extensions::ExtensionRegistry* registry) { 402 void NoteTakingHelper::OnShutdown(extensions::ExtensionRegistry* registry) {
399 extension_registry_observer_.Remove(registry); 403 extension_registry_observer_.Remove(registry);
400 } 404 }
401 405
402 } // namespace chromeos 406 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/note_taking_helper.h ('k') | components/arc/arc_service_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698