| 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_session_manager.h" |
| 15 #include "chrome/browser/chromeos/arc/arc_util.h" | 16 #include "chrome/browser/chromeos/arc/arc_util.h" |
| 16 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
| 17 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" | 18 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" |
| 18 #include "chrome/browser/ui/ash/launcher/arc_app_deferred_launcher_controller.h" | 19 #include "chrome/browser/ui/ash/launcher/arc_app_deferred_launcher_controller.h" |
| 19 #include "chrome/browser/ui/ash/launcher/arc_app_shelf_id.h" | 20 #include "chrome/browser/ui/ash/launcher/arc_app_shelf_id.h" |
| 20 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" | 21 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" |
| 21 #include "chromeos/dbus/dbus_thread_manager.h" | 22 #include "chromeos/dbus/dbus_thread_manager.h" |
| 22 #include "chromeos/dbus/session_manager_client.h" | 23 #include "chromeos/dbus/session_manager_client.h" |
| 23 #include "components/arc/arc_bridge_service.h" | 24 #include "components/arc/arc_bridge_service.h" |
| 24 #include "components/arc/arc_service_manager.h" | 25 #include "components/arc/arc_service_manager.h" |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 NOTREACHED(); | 274 NOTREACHED(); |
| 274 return false; | 275 return false; |
| 275 } | 276 } |
| 276 | 277 |
| 277 SetArcPlayStoreEnabledForProfile(profile, true); | 278 SetArcPlayStoreEnabledForProfile(profile, true); |
| 278 if (!IsArcPlayStoreEnabledForProfile(profile)) { | 279 if (!IsArcPlayStoreEnabledForProfile(profile)) { |
| 279 NOTREACHED(); | 280 NOTREACHED(); |
| 280 return false; | 281 return false; |
| 281 } | 282 } |
| 282 play_store_activated = true; | 283 play_store_activated = true; |
| 284 } else { |
| 285 // Handle the case when default app tries to re-activate OptIn flow. |
| 286 if (IsArcPlayStoreEnabledPreferenceManagedForProfile(profile) && |
| 287 !ArcSessionManager::Get()->enable_requested() && |
| 288 prefs->IsDefault(app_id)) { |
| 289 SetArcPlayStoreEnabledForProfile(profile, true); |
| 290 // PlayStore item has special handling for shelf controllers. In order |
| 291 // to avoid unwanted initial animation for PlayStore item do not create |
| 292 // deferred launch request when PlayStore item enables Google Play |
| 293 // Store. |
| 294 if (app_id == kPlayStoreAppId) { |
| 295 prefs->SetLastLaunchTime(app_id, base::Time::Now()); |
| 296 return true; |
| 297 } |
| 298 } |
| 283 } | 299 } |
| 284 | 300 |
| 285 // PlayStore item has special handling for shelf controllers. In order to | 301 // PlayStore item has special handling for shelf controllers. In order to |
| 286 // avoid unwanted initial animation for PlayStore item do not create | 302 // avoid unwanted initial animation for PlayStore item do not create |
| 287 // deferred launch request when PlayStore item enables Google Play Store. | 303 // deferred launch request when PlayStore item enables Google Play Store. |
| 288 if (!play_store_activated || app_id != kPlayStoreAppId) { | 304 if (!play_store_activated || app_id != kPlayStoreAppId) { |
| 289 ChromeLauncherController* chrome_controller = | 305 ChromeLauncherController* chrome_controller = |
| 290 ChromeLauncherController::instance(); | 306 ChromeLauncherController::instance(); |
| 291 DCHECK(chrome_controller || !ash::Shell::HasInstance()); | 307 DCHECK(chrome_controller || !ash::Shell::HasInstance()); |
| 292 if (chrome_controller) { | 308 if (chrome_controller) { |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 434 return false; | 450 return false; |
| 435 | 451 |
| 436 const ArcAppListPrefs* const arc_prefs = ArcAppListPrefs::Get(context); | 452 const ArcAppListPrefs* const arc_prefs = ArcAppListPrefs::Get(context); |
| 437 if (!arc_prefs) | 453 if (!arc_prefs) |
| 438 return false; | 454 return false; |
| 439 | 455 |
| 440 return arc_prefs->IsRegistered(ArcAppShelfId::FromString(id).app_id()); | 456 return arc_prefs->IsRegistered(ArcAppShelfId::FromString(id).app_id()); |
| 441 } | 457 } |
| 442 | 458 |
| 443 } // namespace arc | 459 } // namespace arc |
| OLD | NEW |