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

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

Issue 2642783003: Move more utility functions to arc_util. (Closed)
Patch Set: address comments Created 3 years, 10 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"
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/arc/arc_util.h"
22 #include "chrome/browser/chromeos/file_manager/path_util.h" 23 #include "chrome/browser/chromeos/file_manager/path_util.h"
23 #include "chrome/browser/profiles/profile.h" 24 #include "chrome/browser/profiles/profile.h"
24 #include "chrome/browser/profiles/profile_manager.h" 25 #include "chrome/browser/profiles/profile_manager.h"
25 #include "chrome/common/pref_names.h" 26 #include "chrome/common/pref_names.h"
26 #include "chromeos/chromeos_switches.h" 27 #include "chromeos/chromeos_switches.h"
27 #include "components/arc/arc_bridge_service.h" 28 #include "components/arc/arc_bridge_service.h"
28 #include "components/arc/arc_service_manager.h" 29 #include "components/arc/arc_service_manager.h"
29 #include "components/arc/intent_helper/arc_intent_helper_bridge.h" 30 #include "components/arc/intent_helper/arc_intent_helper_bridge.h"
30 #include "components/prefs/pref_service.h" 31 #include "components/prefs/pref_service.h"
31 #include "content/public/browser/browser_thread.h" 32 #include "content/public/browser/browser_thread.h"
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 116
116 NoteTakingAppInfos NoteTakingHelper::GetAvailableApps(Profile* profile) { 117 NoteTakingAppInfos NoteTakingHelper::GetAvailableApps(Profile* profile) {
117 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 118 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
118 NoteTakingAppInfos infos; 119 NoteTakingAppInfos infos;
119 120
120 const std::vector<const extensions::Extension*> chrome_apps = 121 const std::vector<const extensions::Extension*> chrome_apps =
121 GetChromeApps(profile); 122 GetChromeApps(profile);
122 for (const auto& app : chrome_apps) 123 for (const auto& app : chrome_apps)
123 infos.push_back(NoteTakingAppInfo{app->name(), app->id(), false}); 124 infos.push_back(NoteTakingAppInfo{app->name(), app->id(), false});
124 125
125 if (arc::ArcSessionManager::Get()->IsAllowedForProfile(profile)) 126 if (arc::IsArcAllowedForProfile(profile))
126 infos.insert(infos.end(), android_apps_.begin(), android_apps_.end()); 127 infos.insert(infos.end(), android_apps_.begin(), android_apps_.end());
127 128
128 // Determine which app, if any, is preferred. 129 // Determine which app, if any, is preferred.
129 const std::string pref_app_id = 130 const std::string pref_app_id =
130 profile->GetPrefs()->GetString(prefs::kNoteTakingAppId); 131 profile->GetPrefs()->GetString(prefs::kNoteTakingAppId);
131 for (auto& info : infos) { 132 for (auto& info : infos) {
132 if (info.app_id == pref_app_id) { 133 if (info.app_id == pref_app_id) {
133 info.preferred = true; 134 info.preferred = true;
134 break; 135 break;
135 } 136 }
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 } 318 }
318 319
319 NoteTakingHelper::LaunchResult NoteTakingHelper::LaunchAppInternal( 320 NoteTakingHelper::LaunchResult NoteTakingHelper::LaunchAppInternal(
320 Profile* profile, 321 Profile* profile,
321 const std::string& app_id, 322 const std::string& app_id,
322 const base::FilePath& path) { 323 const base::FilePath& path) {
323 DCHECK(profile); 324 DCHECK(profile);
324 325
325 if (LooksLikeAndroidPackageName(app_id)) { 326 if (LooksLikeAndroidPackageName(app_id)) {
326 // Android app. 327 // Android app.
327 if (!arc::ArcSessionManager::Get()->IsAllowedForProfile(profile)) { 328 if (!arc::IsArcAllowedForProfile(profile)) {
328 LOG(WARNING) << "Can't launch Android app " << app_id << " for profile"; 329 LOG(WARNING) << "Can't launch Android app " << app_id << " for profile";
329 return LaunchResult::ANDROID_NOT_SUPPORTED_BY_PROFILE; 330 return LaunchResult::ANDROID_NOT_SUPPORTED_BY_PROFILE;
330 } 331 }
331 auto* helper = ARC_GET_INSTANCE_FOR_METHOD( 332 auto* helper = ARC_GET_INSTANCE_FOR_METHOD(
332 arc::ArcServiceManager::Get()->arc_bridge_service()->intent_helper(), 333 arc::ArcServiceManager::Get()->arc_bridge_service()->intent_helper(),
333 HandleIntent); 334 HandleIntent);
334 if (!helper) 335 if (!helper)
335 return LaunchResult::ANDROID_NOT_RUNNING; 336 return LaunchResult::ANDROID_NOT_RUNNING;
336 337
337 GURL clip_data_uri; 338 GURL clip_data_uri;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 for (auto& observer : observers_) 398 for (auto& observer : observers_)
398 observer.OnAvailableNoteTakingAppsUpdated(); 399 observer.OnAvailableNoteTakingAppsUpdated();
399 } 400 }
400 } 401 }
401 402
402 void NoteTakingHelper::OnShutdown(extensions::ExtensionRegistry* registry) { 403 void NoteTakingHelper::OnShutdown(extensions::ExtensionRegistry* registry) {
403 extension_registry_observer_.Remove(registry); 404 extension_registry_observer_.Remove(registry);
404 } 405 }
405 406
406 } // namespace chromeos 407 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/wizard_controller.cc ('k') | chrome/browser/ui/app_list/app_list_syncable_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698