| 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/ash/launcher/arc_playstore_shortcut_launcher_item_co
ntroller.h" | 5 #include "chrome/browser/ui/ash/launcher/arc_playstore_shortcut_launcher_item_co
ntroller.h" |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "chrome/browser/chromeos/arc/arc_support_host.h" | 8 #include "chrome/browser/chromeos/arc/arc_support_host.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/ui/app_list/arc/arc_app_launcher.h" | 10 #include "chrome/browser/ui/app_list/arc/arc_app_launcher.h" |
| 11 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h" | 11 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h" |
| 12 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" | 12 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" |
| 13 #include "ui/events/event_constants.h" | 13 #include "ui/events/event_constants.h" |
| 14 | 14 |
| 15 ArcPlaystoreShortcutLauncherItemController:: | 15 ArcPlaystoreShortcutLauncherItemController:: |
| 16 ArcPlaystoreShortcutLauncherItemController() | 16 ArcPlaystoreShortcutLauncherItemController() |
| 17 : AppShortcutLauncherItemController( | 17 : AppShortcutLauncherItemController( |
| 18 ash::AppLaunchId(ArcSupportHost::kHostAppId)) {} | 18 ash::ShelfID(ArcSupportHost::kHostAppId)) {} |
| 19 | 19 |
| 20 ArcPlaystoreShortcutLauncherItemController:: | 20 ArcPlaystoreShortcutLauncherItemController:: |
| 21 ~ArcPlaystoreShortcutLauncherItemController() {} | 21 ~ArcPlaystoreShortcutLauncherItemController() {} |
| 22 | 22 |
| 23 void ArcPlaystoreShortcutLauncherItemController::ItemSelected( | 23 void ArcPlaystoreShortcutLauncherItemController::ItemSelected( |
| 24 std::unique_ptr<ui::Event> event, | 24 std::unique_ptr<ui::Event> event, |
| 25 int64_t display_id, | 25 int64_t display_id, |
| 26 ash::ShelfLaunchSource source, | 26 ash::ShelfLaunchSource source, |
| 27 const ItemSelectedCallback& callback) { | 27 const ItemSelectedCallback& callback) { |
| 28 if (!playstore_launcher_) { | 28 if (!playstore_launcher_) { |
| 29 // Play Store launch request has never been scheduled. | 29 // Play Store launch request has never been scheduled. |
| 30 std::unique_ptr<ArcAppLauncher> playstore_launcher = | 30 std::unique_ptr<ArcAppLauncher> playstore_launcher = |
| 31 base::MakeUnique<ArcAppLauncher>( | 31 base::MakeUnique<ArcAppLauncher>( |
| 32 ChromeLauncherController::instance()->profile(), | 32 ChromeLauncherController::instance()->profile(), |
| 33 arc::kPlayStoreAppId, true /* landscape_layout */, | 33 arc::kPlayStoreAppId, true /* landscape_layout */, |
| 34 true /* deferred_launch_allowed */); | 34 true /* deferred_launch_allowed */); |
| 35 // ArcAppLauncher may launch Play Store in case it exists already. In this | 35 // ArcAppLauncher may launch Play Store in case it exists already. In this |
| 36 // case this instance of ArcPlaystoreShortcutLauncherItemController may be | 36 // case this instance of ArcPlaystoreShortcutLauncherItemController may be |
| 37 // deleted. If Play Store does not exist at this moment, then let | 37 // deleted. If Play Store does not exist at this moment, then let |
| 38 // |playstore_launcher_| wait until it appears. | 38 // |playstore_launcher_| wait until it appears. |
| 39 if (!playstore_launcher->app_launched()) | 39 if (!playstore_launcher->app_launched()) |
| 40 playstore_launcher_ = std::move(playstore_launcher); | 40 playstore_launcher_ = std::move(playstore_launcher); |
| 41 } | 41 } |
| 42 callback.Run(ash::SHELF_ACTION_NONE, base::nullopt); | 42 callback.Run(ash::SHELF_ACTION_NONE, base::nullopt); |
| 43 } | 43 } |
| OLD | NEW |