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

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

Issue 2751913004: arc: Fix race conditon when Play Store is started too early. (Closed)
Patch Set: nits Created 3 years, 9 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 #include "ui/events/event_constants.h"
10 11
11 ArcAppLauncher::ArcAppLauncher(content::BrowserContext* context, 12 ArcAppLauncher::ArcAppLauncher(content::BrowserContext* context,
12 const std::string& app_id, 13 const std::string& app_id,
13 bool landscape_layout) 14 bool landscape_layout,
14 : context_(context), app_id_(app_id), landscape_layout_(landscape_layout) { 15 bool deferred_launch_allowed)
16 : context_(context),
17 app_id_(app_id),
18 landscape_layout_(landscape_layout),
19 deferred_launch_allowed_(deferred_launch_allowed) {
15 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(context_); 20 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(context_);
16 DCHECK(prefs); 21 DCHECK(prefs);
17 22
18 std::unique_ptr<ArcAppListPrefs::AppInfo> app_info = prefs->GetApp(app_id_); 23 std::unique_ptr<ArcAppListPrefs::AppInfo> app_info = prefs->GetApp(app_id_);
19 if (app_info && app_info->ready) 24 if (app_info && (app_info->ready || deferred_launch_allowed_))
20 LaunchApp(); 25 LaunchApp();
21 else 26 else
22 prefs->AddObserver(this); 27 prefs->AddObserver(this);
23 } 28 }
24 29
25 ArcAppLauncher::~ArcAppLauncher() { 30 ArcAppLauncher::~ArcAppLauncher() {
26 if (!app_launched_) { 31 if (!app_launched_) {
27 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(context_); 32 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(context_);
28 if (prefs) 33 if (prefs)
29 prefs->RemoveObserver(this); 34 prefs->RemoveObserver(this);
30 VLOG(2) << "App " << app_id_ << "was not launched."; 35 VLOG(2) << "App " << app_id_ << "was not launched.";
31 } 36 }
32 } 37 }
33 38
34 void ArcAppLauncher::OnAppRegistered( 39 void ArcAppLauncher::OnAppRegistered(
35 const std::string& app_id, 40 const std::string& app_id,
36 const ArcAppListPrefs::AppInfo& app_info) { 41 const ArcAppListPrefs::AppInfo& app_info) {
37 if (app_id == app_id_ && app_info.ready) 42 if (app_id == app_id_ && (app_info.ready || deferred_launch_allowed_))
38 LaunchApp(); 43 LaunchApp();
39 } 44 }
40 45
41 void ArcAppLauncher::OnAppReadyChanged(const std::string& app_id, bool ready) { 46 void ArcAppLauncher::OnAppReadyChanged(const std::string& app_id, bool ready) {
42 if (app_id == app_id_ && ready) 47 if (app_id == app_id_ && (ready || deferred_launch_allowed_))
43 LaunchApp(); 48 LaunchApp();
44 } 49 }
45 50
46 void ArcAppLauncher::LaunchApp() { 51 void ArcAppLauncher::LaunchApp() {
47 DCHECK(!app_launched_); 52 DCHECK(!app_launched_);
48 53
49 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(context_); 54 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(context_);
50 DCHECK(prefs && prefs->GetApp(app_id_)); 55 DCHECK(prefs && prefs->GetApp(app_id_));
51 prefs->RemoveObserver(this); 56 prefs->RemoveObserver(this);
52 57
53 if (!arc::LaunchApp(context_, app_id_, landscape_layout_)) 58 if (!arc::LaunchApp(context_, app_id_, landscape_layout_, ui::EF_NONE))
54 VLOG(2) << "Failed to launch app: " + app_id_ + "."; 59 VLOG(2) << "Failed to launch app: " + app_id_ + ".";
55 60
56 app_launched_ = true; 61 app_launched_ = true;
57 } 62 }
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.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698