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

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

Issue 2721553004: Remove auto raw pointer deduction from non-linux specific code. (Closed)
Patch Set: rebase Created 3 years, 9 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
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"
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 DCHECK(observer); 115 DCHECK(observer);
116 observers_.RemoveObserver(observer); 116 observers_.RemoveObserver(observer);
117 } 117 }
118 118
119 NoteTakingAppInfos NoteTakingHelper::GetAvailableApps(Profile* profile) { 119 NoteTakingAppInfos NoteTakingHelper::GetAvailableApps(Profile* profile) {
120 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 120 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
121 NoteTakingAppInfos infos; 121 NoteTakingAppInfos infos;
122 122
123 const std::vector<const extensions::Extension*> chrome_apps = 123 const std::vector<const extensions::Extension*> chrome_apps =
124 GetChromeApps(profile); 124 GetChromeApps(profile);
125 for (const auto& app : chrome_apps) 125 for (const auto* app : chrome_apps)
126 infos.push_back(NoteTakingAppInfo{app->name(), app->id(), false}); 126 infos.push_back(NoteTakingAppInfo{app->name(), app->id(), false});
127 127
128 if (arc::IsArcAllowedForProfile(profile)) 128 if (arc::IsArcAllowedForProfile(profile))
129 infos.insert(infos.end(), android_apps_.begin(), android_apps_.end()); 129 infos.insert(infos.end(), android_apps_.begin(), android_apps_.end());
130 130
131 // Determine which app, if any, is preferred. 131 // Determine which app, if any, is preferred.
132 const std::string pref_app_id = 132 const std::string pref_app_id =
133 profile->GetPrefs()->GetString(prefs::kNoteTakingAppId); 133 profile->GetPrefs()->GetString(prefs::kNoteTakingAppId);
134 for (auto& info : infos) { 134 for (auto& info : infos) {
135 if (info.app_id == pref_app_id) { 135 if (info.app_id == pref_app_id) {
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 g_browser_process->profile_manager()->GetLoadedProfiles()) { 226 g_browser_process->profile_manager()->GetLoadedProfiles()) {
227 extension_registry_observer_.Add( 227 extension_registry_observer_.Add(
228 extensions::ExtensionRegistry::Get(profile)); 228 extensions::ExtensionRegistry::Get(profile));
229 // Check if the profile has already enabled Google Play Store. 229 // Check if the profile has already enabled Google Play Store.
230 // IsArcPlayStoreEnabledForProfile() can return true only for the primary 230 // IsArcPlayStoreEnabledForProfile() can return true only for the primary
231 // profile. 231 // profile.
232 android_enabled_ |= arc::IsArcPlayStoreEnabledForProfile(profile); 232 android_enabled_ |= arc::IsArcPlayStoreEnabledForProfile(profile);
233 } 233 }
234 234
235 // Watch for changes of Google Play Store enabled state. 235 // Watch for changes of Google Play Store enabled state.
236 auto session_manager = arc::ArcSessionManager::Get(); 236 auto* session_manager = arc::ArcSessionManager::Get();
237 session_manager->AddObserver(this); 237 session_manager->AddObserver(this);
238 238
239 // ArcIntentHelperBridge will notify us about changes to the list of available 239 // ArcIntentHelperBridge will notify us about changes to the list of available
240 // Android apps. 240 // Android apps.
241 auto intent_helper_bridge = 241 auto* intent_helper_bridge =
242 arc::ArcServiceManager::GetGlobalService<arc::ArcIntentHelperBridge>(); 242 arc::ArcServiceManager::GetGlobalService<arc::ArcIntentHelperBridge>();
243 if (intent_helper_bridge) 243 if (intent_helper_bridge)
244 intent_helper_bridge->AddObserver(this); 244 intent_helper_bridge->AddObserver(this);
245 245
246 // If the ARC intent helper is ready, get the Android apps. Otherwise, 246 // If the ARC intent helper is ready, get the Android apps. Otherwise,
247 // UpdateAndroidApps() will be called when ArcServiceManager calls 247 // UpdateAndroidApps() will be called when ArcServiceManager calls
248 // OnIntentFiltersUpdated(). 248 // OnIntentFiltersUpdated().
249 if (android_enabled_ && 249 if (android_enabled_ &&
250 arc::ArcServiceManager::Get() 250 arc::ArcServiceManager::Get()
251 ->arc_bridge_service() 251 ->arc_bridge_service()
252 ->intent_helper() 252 ->intent_helper()
253 ->has_instance()) 253 ->has_instance())
254 UpdateAndroidApps(); 254 UpdateAndroidApps();
255 } 255 }
256 256
257 NoteTakingHelper::~NoteTakingHelper() { 257 NoteTakingHelper::~NoteTakingHelper() {
258 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 258 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
259 259
260 // ArcSessionManagerTest shuts down ARC before NoteTakingHelper. 260 // ArcSessionManagerTest shuts down ARC before NoteTakingHelper.
261 auto intent_helper_bridge = 261 auto* intent_helper_bridge =
262 arc::ArcServiceManager::GetGlobalService<arc::ArcIntentHelperBridge>(); 262 arc::ArcServiceManager::GetGlobalService<arc::ArcIntentHelperBridge>();
263 if (intent_helper_bridge) 263 if (intent_helper_bridge)
264 intent_helper_bridge->RemoveObserver(this); 264 intent_helper_bridge->RemoveObserver(this);
265 if (arc::ArcSessionManager::Get()) 265 if (arc::ArcSessionManager::Get())
266 arc::ArcSessionManager::Get()->RemoveObserver(this); 266 arc::ArcSessionManager::Get()->RemoveObserver(this);
267 } 267 }
268 268
269 bool NoteTakingHelper::IsWhitelistedChromeApp( 269 bool NoteTakingHelper::IsWhitelistedChromeApp(
270 const extensions::Extension* extension) const { 270 const extensions::Extension* extension) const {
271 DCHECK(extension); 271 DCHECK(extension);
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 launch_chrome_app_callback_.Run(profile, app, std::move(action_data), path); 384 launch_chrome_app_callback_.Run(profile, app, std::move(action_data), path);
385 return LaunchResult::CHROME_SUCCESS; 385 return LaunchResult::CHROME_SUCCESS;
386 } 386 }
387 NOTREACHED(); 387 NOTREACHED();
388 } 388 }
389 389
390 void NoteTakingHelper::Observe(int type, 390 void NoteTakingHelper::Observe(int type,
391 const content::NotificationSource& source, 391 const content::NotificationSource& source,
392 const content::NotificationDetails& details) { 392 const content::NotificationDetails& details) {
393 DCHECK_EQ(type, chrome::NOTIFICATION_PROFILE_ADDED); 393 DCHECK_EQ(type, chrome::NOTIFICATION_PROFILE_ADDED);
394 auto registry = extensions::ExtensionRegistry::Get( 394 auto* registry = extensions::ExtensionRegistry::Get(
395 content::Source<Profile>(source).ptr()); 395 content::Source<Profile>(source).ptr());
396 DCHECK(!extension_registry_observer_.IsObserving(registry)); 396 DCHECK(!extension_registry_observer_.IsObserving(registry));
397 extension_registry_observer_.Add(registry); 397 extension_registry_observer_.Add(registry);
398 } 398 }
399 399
400 void NoteTakingHelper::OnExtensionLoaded( 400 void NoteTakingHelper::OnExtensionLoaded(
401 content::BrowserContext* browser_context, 401 content::BrowserContext* browser_context,
402 const extensions::Extension* extension) { 402 const extensions::Extension* extension) {
403 if (IsWhitelistedChromeApp(extension) || 403 if (IsWhitelistedChromeApp(extension) ||
404 extensions::ActionHandlersInfo::HasActionHandler( 404 extensions::ActionHandlersInfo::HasActionHandler(
(...skipping 13 matching lines...) Expand all
418 for (auto& observer : observers_) 418 for (auto& observer : observers_)
419 observer.OnAvailableNoteTakingAppsUpdated(); 419 observer.OnAvailableNoteTakingAppsUpdated();
420 } 420 }
421 } 421 }
422 422
423 void NoteTakingHelper::OnShutdown(extensions::ExtensionRegistry* registry) { 423 void NoteTakingHelper::OnShutdown(extensions::ExtensionRegistry* registry) {
424 extension_registry_observer_.Remove(registry); 424 extension_registry_observer_.Remove(registry);
425 } 425 }
426 426
427 } // namespace chromeos 427 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698