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