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