| 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/ui/app_list/arc/arc_app_utils.h" | 5 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/json/json_writer.h" | 12 #include "base/json/json_writer.h" |
| 13 #include "base/synchronization/waitable_event.h" | 13 #include "base/synchronization/waitable_event.h" |
| 14 #include "base/values.h" | 14 #include "base/values.h" |
| 15 #include "chrome/browser/chromeos/arc/arc_migration_guide_notification.h" |
| 15 #include "chrome/browser/chromeos/arc/arc_session_manager.h" | 16 #include "chrome/browser/chromeos/arc/arc_session_manager.h" |
| 16 #include "chrome/browser/chromeos/arc/arc_util.h" | 17 #include "chrome/browser/chromeos/arc/arc_util.h" |
| 17 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
| 18 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" | 19 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" |
| 19 #include "chrome/browser/ui/ash/launcher/arc_app_deferred_launcher_controller.h" | 20 #include "chrome/browser/ui/ash/launcher/arc_app_deferred_launcher_controller.h" |
| 20 #include "chrome/browser/ui/ash/launcher/arc_app_shelf_id.h" | 21 #include "chrome/browser/ui/ash/launcher/arc_app_shelf_id.h" |
| 21 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" | 22 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" |
| 22 #include "chromeos/dbus/dbus_thread_manager.h" | 23 #include "chromeos/dbus/dbus_thread_manager.h" |
| 23 #include "chromeos/dbus/session_manager_client.h" | 24 #include "chromeos/dbus/session_manager_client.h" |
| 24 #include "components/arc/arc_bridge_service.h" | 25 #include "components/arc/arc_bridge_service.h" |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 const std::string& app_id, | 259 const std::string& app_id, |
| 259 int event_flags) { | 260 int event_flags) { |
| 260 constexpr bool kUseLandscapeLayout = true; | 261 constexpr bool kUseLandscapeLayout = true; |
| 261 return LaunchApp(context, app_id, kUseLandscapeLayout, event_flags); | 262 return LaunchApp(context, app_id, kUseLandscapeLayout, event_flags); |
| 262 } | 263 } |
| 263 | 264 |
| 264 bool LaunchApp(content::BrowserContext* context, | 265 bool LaunchApp(content::BrowserContext* context, |
| 265 const std::string& app_id, | 266 const std::string& app_id, |
| 266 bool landscape_layout, | 267 bool landscape_layout, |
| 267 int event_flags) { | 268 int event_flags) { |
| 269 Profile* const profile = Profile::FromBrowserContext(context); |
| 270 |
| 271 // Even when ARC is not allowed for the profile, ARC apps may still show up |
| 272 // as a placeholder to show the guide notification for proper configuration. |
| 273 // Handle such a case here and shows the desired notification. |
| 274 if (IsArcAllowedInAppListForProfile(profile) && |
| 275 !IsArcAllowedForProfile(profile)) { |
| 276 arc::ShowArcMigrationGuideNotification(profile); |
| 277 return false; |
| 278 } |
| 279 |
| 268 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(context); | 280 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(context); |
| 269 std::unique_ptr<ArcAppListPrefs::AppInfo> app_info = prefs->GetApp(app_id); | 281 std::unique_ptr<ArcAppListPrefs::AppInfo> app_info = prefs->GetApp(app_id); |
| 270 if (app_info && !app_info->ready) { | 282 if (app_info && !app_info->ready) { |
| 271 Profile* profile = Profile::FromBrowserContext(context); | |
| 272 | |
| 273 if (!IsArcPlayStoreEnabledForProfile(profile)) { | 283 if (!IsArcPlayStoreEnabledForProfile(profile)) { |
| 274 if (prefs->IsDefault(app_id)) { | 284 if (prefs->IsDefault(app_id)) { |
| 275 // The setting can fail if the preference is managed. However, the | 285 // The setting can fail if the preference is managed. However, the |
| 276 // caller is responsible to not call this function in such case. DCHECK | 286 // caller is responsible to not call this function in such case. DCHECK |
| 277 // is here to prevent possible mistake. | 287 // is here to prevent possible mistake. |
| 278 SetArcPlayStoreEnabledForProfile(profile, true); | 288 SetArcPlayStoreEnabledForProfile(profile, true); |
| 279 DCHECK(IsArcPlayStoreEnabledForProfile(profile)); | 289 DCHECK(IsArcPlayStoreEnabledForProfile(profile)); |
| 280 | 290 |
| 281 // PlayStore item has special handling for shelf controllers. In order | 291 // PlayStore item has special handling for shelf controllers. In order |
| 282 // to avoid unwanted initial animation for PlayStore item do not create | 292 // to avoid unwanted initial animation for PlayStore item do not create |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 453 return false; | 463 return false; |
| 454 | 464 |
| 455 const ArcAppListPrefs* const arc_prefs = ArcAppListPrefs::Get(context); | 465 const ArcAppListPrefs* const arc_prefs = ArcAppListPrefs::Get(context); |
| 456 if (!arc_prefs) | 466 if (!arc_prefs) |
| 457 return false; | 467 return false; |
| 458 | 468 |
| 459 return arc_prefs->IsRegistered(ArcAppShelfId::FromString(id).app_id()); | 469 return arc_prefs->IsRegistered(ArcAppShelfId::FromString(id).app_id()); |
| 460 } | 470 } |
| 461 | 471 |
| 462 } // namespace arc | 472 } // namespace arc |
| OLD | NEW |