Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(297)

Side by Side Diff: chrome/browser/ui/app_list/arc/arc_app_launcher.cc

Issue 2308643002: arc: Make Play Store item persistent in app list. (Closed)
Patch Set: fix unit_tests Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_launcher.h" 5 #include "chrome/browser/ui/app_list/arc/arc_app_launcher.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h" 9 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h"
10 10
11 ArcAppLauncher::ArcAppLauncher(content::BrowserContext* context, 11 ArcAppLauncher::ArcAppLauncher(content::BrowserContext* context,
12 const std::string& app_id, 12 const std::string& app_id,
13 bool landscape_layout) 13 bool landscape_layout)
14 : context_(context), app_id_(app_id), landscape_layout_(landscape_layout) { 14 : context_(context), app_id_(app_id), landscape_layout_(landscape_layout) {
15 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(context_); 15 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(context_);
16 DCHECK(prefs); 16 DCHECK(prefs);
17 17
18 std::unique_ptr<ArcAppListPrefs::AppInfo> app_info = prefs->GetApp(app_id_); 18 std::unique_ptr<ArcAppListPrefs::AppInfo> app_info = prefs->GetApp(app_id_);
19 if (app_info) 19 if (app_info && app_info->ready)
20 LaunchApp(); 20 LaunchApp();
21 else 21 else
22 prefs->AddObserver(this); 22 prefs->AddObserver(this);
23 } 23 }
24 24
25 ArcAppLauncher::~ArcAppLauncher() { 25 ArcAppLauncher::~ArcAppLauncher() {
26 if (!app_launched_) { 26 if (!app_launched_) {
27 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(context_); 27 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(context_);
28 if (prefs) 28 if (prefs)
29 prefs->RemoveObserver(this); 29 prefs->RemoveObserver(this);
30 VLOG(2) << "App " << app_id_ << "was not launched."; 30 VLOG(2) << "App " << app_id_ << "was not launched.";
31 } 31 }
32 } 32 }
33 33
34 void ArcAppLauncher::OnAppRegistered( 34 void ArcAppLauncher::OnAppRegistered(
35 const std::string& app_id, 35 const std::string& app_id,
36 const ArcAppListPrefs::AppInfo& app_info) { 36 const ArcAppListPrefs::AppInfo& app_info) {
37 if (app_id == app_id_) 37 if (app_id == app_id_ && app_info.ready)
38 LaunchApp(); 38 LaunchApp();
39 } 39 }
40 40
41 void ArcAppLauncher::OnAppReadyChanged(const std::string& app_id, bool ready) {
42 if (app_id == app_id_ && ready)
43 LaunchApp();
44 }
45
41 void ArcAppLauncher::LaunchApp() { 46 void ArcAppLauncher::LaunchApp() {
42 DCHECK(!app_launched_); 47 DCHECK(!app_launched_);
43 48
44 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(context_); 49 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(context_);
45 DCHECK(prefs && prefs->GetApp(app_id_)); 50 DCHECK(prefs && prefs->GetApp(app_id_));
46 prefs->RemoveObserver(this); 51 prefs->RemoveObserver(this);
47 52
48 if (!arc::LaunchApp(context_, app_id_, landscape_layout_)) 53 if (!arc::LaunchApp(context_, app_id_, landscape_layout_))
49 VLOG(2) << "Failed to launch app: " + app_id_ + "."; 54 VLOG(2) << "Failed to launch app: " + app_id_ + ".";
50 55
51 app_launched_ = true; 56 app_launched_ = true;
52 } 57 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/app_list/arc/arc_app_launcher.h ('k') | chrome/browser/ui/app_list/arc/arc_app_list_prefs.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698