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

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

Issue 269573010: Download and cache kiosk app extension when it is added via kiosk mamangement ui. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 | 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/kiosk_app_data.h" 5 #include "chrome/browser/chromeos/app_mode/kiosk_app_data.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 }; 252 };
253 253
254 //////////////////////////////////////////////////////////////////////////////// 254 ////////////////////////////////////////////////////////////////////////////////
255 // KioskAppData 255 // KioskAppData
256 256
257 KioskAppData::KioskAppData(KioskAppDataDelegate* delegate, 257 KioskAppData::KioskAppData(KioskAppDataDelegate* delegate,
258 const std::string& app_id, 258 const std::string& app_id,
259 const std::string& user_id) 259 const std::string& user_id)
260 : delegate_(delegate), 260 : delegate_(delegate),
261 status_(STATUS_INIT), 261 status_(STATUS_INIT),
262 crx_cache_status_(STATUS_INIT),
262 app_id_(app_id), 263 app_id_(app_id),
263 user_id_(user_id) { 264 user_id_(user_id) {
264 } 265 }
265 266
266 KioskAppData::~KioskAppData() {} 267 KioskAppData::~KioskAppData() {}
267 268
268 void KioskAppData::Load() { 269 void KioskAppData::Load() {
269 SetStatus(STATUS_LOADING); 270 SetStatus(STATUS_LOADING);
270 271
271 if (LoadFromCache()) 272 if (LoadFromCache())
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 app, kIconSize, ExtensionIconSet::MATCH_BIGGER); 310 app, kIconSize, ExtensionIconSet::MATCH_BIGGER);
310 extensions::ImageLoader::Get(profile)->LoadImageAsync( 311 extensions::ImageLoader::Get(profile)->LoadImageAsync(
311 app, image, gfx::Size(kIconSize, kIconSize), 312 app, image, gfx::Size(kIconSize, kIconSize),
312 base::Bind(&KioskAppData::OnExtensionIconLoaded, AsWeakPtr())); 313 base::Bind(&KioskAppData::OnExtensionIconLoaded, AsWeakPtr()));
313 } 314 }
314 315
315 bool KioskAppData::IsLoading() const { 316 bool KioskAppData::IsLoading() const {
316 return status_ == STATUS_LOADING; 317 return status_ == STATUS_LOADING;
317 } 318 }
318 319
320 bool KioskAppData::IsCrxCacheLoading() const {
321 return crx_cache_status_ == STATUS_LOADING;
322 }
323
319 void KioskAppData::SetStatus(Status status) { 324 void KioskAppData::SetStatus(Status status) {
320 if (status_ == status) 325 if (status_ == status)
321 return; 326 return;
322 327
323 status_ = status; 328 status_ = status;
324 329
325 if (!delegate_) 330 if (!delegate_)
326 return; 331 return;
327 332
328 switch (status_) { 333 switch (status_) {
329 case STATUS_INIT: 334 case STATUS_INIT:
330 break; 335 break;
331 case STATUS_LOADING: 336 case STATUS_LOADING:
332 case STATUS_LOADED: 337 case STATUS_LOADED:
333 delegate_->OnKioskAppDataChanged(app_id_); 338 delegate_->OnKioskAppDataChanged(app_id_);
334 break; 339 break;
335 case STATUS_ERROR: 340 case STATUS_ERROR:
336 delegate_->OnKioskAppDataLoadFailure(app_id_); 341 delegate_->OnKioskAppDataLoadFailure(app_id_);
337 break; 342 break;
338 }; 343 };
339 } 344 }
340 345
346 void KioskAppData::SetCrxCacheStatus(Status crx_cache_status) {
347 if (crx_cache_status_ == crx_cache_status)
348 return;
349
350 Status old_cache_status = crx_cache_status_;
351 crx_cache_status_ = crx_cache_status;
352
353 if (!delegate_)
354 return;
355
356 switch (crx_cache_status_) {
357 case STATUS_INIT:
358 break;
359 case STATUS_LOADING:
360 delegate_->OnKioskAppDataChanged(app_id_);
361 break;
362 case STATUS_LOADED:
363 if (old_cache_status == STATUS_LOADING)
364 delegate_->OnKioskAppDataChanged(app_id_);
365 break;
366 case STATUS_ERROR:
367 if (old_cache_status == STATUS_LOADING)
368 delegate_->OnKioskAppDataLoadFailure(app_id_);
369 break;
370 }
371 }
372
341 net::URLRequestContextGetter* KioskAppData::GetRequestContextGetter() { 373 net::URLRequestContextGetter* KioskAppData::GetRequestContextGetter() {
342 return g_browser_process->system_request_context(); 374 return g_browser_process->system_request_context();
343 } 375 }
344 376
345 bool KioskAppData::LoadFromCache() { 377 bool KioskAppData::LoadFromCache() {
346 std::string app_key = std::string(KioskAppManager::kKeyApps) + '.' + app_id_; 378 std::string app_key = std::string(KioskAppManager::kKeyApps) + '.' + app_id_;
347 std::string name_key = app_key + '.' + kKeyName; 379 std::string name_key = app_key + '.' + kKeyName;
348 std::string icon_path_key = app_key + '.' + kKeyIcon; 380 std::string icon_path_key = app_key + '.' + kKeyIcon;
349 381
350 PrefService* local_state = g_browser_process->local_state(); 382 PrefService* local_state = g_browser_process->local_state();
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 if (!response->GetString(key, value)) { 526 if (!response->GetString(key, value)) {
495 LOG(ERROR) << "Webstore response error (" << key 527 LOG(ERROR) << "Webstore response error (" << key
496 << "): " << ValueToString(response); 528 << "): " << ValueToString(response);
497 OnWebstoreResponseParseFailure(kInvalidWebstoreResponseError); 529 OnWebstoreResponseParseFailure(kInvalidWebstoreResponseError);
498 return false; 530 return false;
499 } 531 }
500 return true; 532 return true;
501 } 533 }
502 534
503 } // namespace chromeos 535 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698