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

Side by Side Diff: chrome/browser/chromeos/app_mode/startup_app_launcher.cc

Issue 79113002: kiosk: Network connectivity test during launch. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: hide spacer for non-kiosk error Created 7 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/chromeos/app_mode/startup_app_launcher.h" 5 #include "chrome/browser/chromeos/app_mode/startup_app_launcher.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/json/json_file_value_serializer.h" 9 #include "base/json/json_file_value_serializer.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 GetInstalledExtension(app_id); 50 GetInstalledExtension(app_id);
51 } 51 }
52 52
53 } // namespace 53 } // namespace
54 54
55 55
56 StartupAppLauncher::StartupAppLauncher(Profile* profile, 56 StartupAppLauncher::StartupAppLauncher(Profile* profile,
57 const std::string& app_id) 57 const std::string& app_id)
58 : profile_(profile), 58 : profile_(profile),
59 app_id_(app_id), 59 app_id_(app_id),
60 install_attempted_(false),
60 ready_to_launch_(false) { 61 ready_to_launch_(false) {
61 DCHECK(profile_); 62 DCHECK(profile_);
62 DCHECK(Extension::IdIsValid(app_id_)); 63 DCHECK(Extension::IdIsValid(app_id_));
63 } 64 }
64 65
65 StartupAppLauncher::~StartupAppLauncher() { 66 StartupAppLauncher::~StartupAppLauncher() {
66 // StartupAppLauncher can be deleted at anytime during the launch process 67 // StartupAppLauncher can be deleted at anytime during the launch process
67 // through a user bailout shortcut. 68 // through a user bailout shortcut.
68 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_) 69 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_)
69 ->RemoveObserver(this); 70 ->RemoveObserver(this);
70 net::NetworkChangeNotifier::RemoveNetworkChangeObserver(this);
71 } 71 }
72 72
73 void StartupAppLauncher::Initialize() { 73 void StartupAppLauncher::Initialize() {
74 DVLOG(1) << "Starting... connection = "
75 << net::NetworkChangeNotifier::GetConnectionType();
76 StartLoadingOAuthFile(); 74 StartLoadingOAuthFile();
77 } 75 }
78 76
77 void StartupAppLauncher::ContinueWithNetworkReady() {
78 // Starts install if it is not started.
79 if (!install_attempted_) {
80 install_attempted_ = true;
81 BeginInstall();
82 }
83 }
84
79 void StartupAppLauncher::AddObserver(Observer* observer) { 85 void StartupAppLauncher::AddObserver(Observer* observer) {
80 observer_list_.AddObserver(observer); 86 observer_list_.AddObserver(observer);
81 } 87 }
82 88
83 void StartupAppLauncher::RemoveObserver(Observer* observer) { 89 void StartupAppLauncher::RemoveObserver(Observer* observer) {
84 observer_list_.RemoveObserver(observer); 90 observer_list_.RemoveObserver(observer);
85 } 91 }
86 92
87 void StartupAppLauncher::StartLoadingOAuthFile() { 93 void StartupAppLauncher::StartLoadingOAuthFile() {
88 FOR_EACH_OBSERVER(Observer, observer_list_, OnLoadingOAuthFile()); 94 FOR_EACH_OBSERVER(Observer, observer_list_, OnLoadingOAuthFile());
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 auth_params_.client_secret); 137 auth_params_.client_secret);
132 } 138 }
133 139
134 // If we are restarting chrome (i.e. on crash), we need to initialize 140 // If we are restarting chrome (i.e. on crash), we need to initialize
135 // OAuth2TokenService as well. 141 // OAuth2TokenService as well.
136 InitializeTokenService(); 142 InitializeTokenService();
137 } 143 }
138 144
139 void StartupAppLauncher::InitializeNetwork() { 145 void StartupAppLauncher::InitializeNetwork() {
140 FOR_EACH_OBSERVER(Observer, observer_list_, OnInitializingNetwork()); 146 FOR_EACH_OBSERVER(Observer, observer_list_, OnInitializingNetwork());
141
142 // TODO(tengs): Use NetworkStateInformer instead because it can handle
143 // portal and proxy detection. We will need to do some refactoring to
144 // make NetworkStateInformer more independent from the WebUI handlers.
145 net::NetworkChangeNotifier::AddNetworkChangeObserver(this);
146 OnNetworkChanged(net::NetworkChangeNotifier::GetConnectionType());
147 } 147 }
148 148
149 void StartupAppLauncher::InitializeTokenService() { 149 void StartupAppLauncher::InitializeTokenService() {
150 FOR_EACH_OBSERVER(Observer, observer_list_, OnInitializingTokenService()); 150 FOR_EACH_OBSERVER(Observer, observer_list_, OnInitializingTokenService());
151 151
152 ProfileOAuth2TokenService* profile_token_service = 152 ProfileOAuth2TokenService* profile_token_service =
153 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_); 153 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_);
154 if (profile_token_service->RefreshTokenIsAvailable( 154 if (profile_token_service->RefreshTokenIsAvailable(
155 profile_token_service->GetPrimaryAccountId()) || 155 profile_token_service->GetPrimaryAccountId()) ||
156 auth_params_.refresh_token.empty()) { 156 auth_params_.refresh_token.empty()) {
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 chrome::NOTIFICATION_KIOSK_APP_LAUNCHED, 226 chrome::NOTIFICATION_KIOSK_APP_LAUNCHED,
227 content::NotificationService::AllSources(), 227 content::NotificationService::AllSources(),
228 content::NotificationService::NoDetails()); 228 content::NotificationService::NoDetails());
229 229
230 OnLaunchSuccess(); 230 OnLaunchSuccess();
231 } 231 }
232 232
233 void StartupAppLauncher::BeginInstall() { 233 void StartupAppLauncher::BeginInstall() {
234 FOR_EACH_OBSERVER(Observer, observer_list_, OnInstallingApp()); 234 FOR_EACH_OBSERVER(Observer, observer_list_, OnInstallingApp());
235 235
236 DVLOG(1) << "BeginInstall... connection = "
237 << net::NetworkChangeNotifier::GetConnectionType();
238
239 if (IsAppInstalled(profile_, app_id_)) { 236 if (IsAppInstalled(profile_, app_id_)) {
240 OnReadyToLaunch(); 237 OnReadyToLaunch();
241 return; 238 return;
242 } 239 }
243 240
244 installer_ = new WebstoreStartupInstaller( 241 installer_ = new WebstoreStartupInstaller(
245 app_id_, 242 app_id_,
246 profile_, 243 profile_,
247 false, 244 false,
248 base::Bind(&StartupAppLauncher::InstallCallback, AsWeakPtr())); 245 base::Bind(&StartupAppLauncher::InstallCallback, AsWeakPtr()));
(...skipping 16 matching lines...) Expand all
265 262
266 LOG(ERROR) << "App install failed: " << error; 263 LOG(ERROR) << "App install failed: " << error;
267 OnLaunchFailure(KioskAppLaunchError::UNABLE_TO_INSTALL); 264 OnLaunchFailure(KioskAppLaunchError::UNABLE_TO_INSTALL);
268 } 265 }
269 266
270 void StartupAppLauncher::OnReadyToLaunch() { 267 void StartupAppLauncher::OnReadyToLaunch() {
271 ready_to_launch_ = true; 268 ready_to_launch_ = true;
272 FOR_EACH_OBSERVER(Observer, observer_list_, OnReadyToLaunch()); 269 FOR_EACH_OBSERVER(Observer, observer_list_, OnReadyToLaunch());
273 } 270 }
274 271
275 void StartupAppLauncher::OnNetworkChanged(
276 net::NetworkChangeNotifier::ConnectionType type) {
277 DVLOG(1) << "OnNetworkChanged... connection = "
278 << net::NetworkChangeNotifier::GetConnectionType();
279 if (!net::NetworkChangeNotifier::IsOffline()) {
280 DVLOG(1) << "Network up and running!";
281 net::NetworkChangeNotifier::RemoveNetworkChangeObserver(this);
282
283 BeginInstall();
284 } else {
285 DVLOG(1) << "Network not running yet!";
286 }
287 }
288
289 } // namespace chromeos 272 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698