OLD | NEW |
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 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 switch (status_) { | 329 switch (status_) { |
330 case STATUS_INIT: | 330 case STATUS_INIT: |
331 break; | 331 break; |
332 case STATUS_LOADING: | 332 case STATUS_LOADING: |
333 case STATUS_LOADED: | 333 case STATUS_LOADED: |
334 delegate_->OnKioskAppDataChanged(app_id_); | 334 delegate_->OnKioskAppDataChanged(app_id_); |
335 break; | 335 break; |
336 case STATUS_ERROR: | 336 case STATUS_ERROR: |
337 delegate_->OnKioskAppDataLoadFailure(app_id_); | 337 delegate_->OnKioskAppDataLoadFailure(app_id_); |
338 break; | 338 break; |
339 }; | 339 } |
340 } | 340 } |
341 | 341 |
342 net::URLRequestContextGetter* KioskAppData::GetRequestContextGetter() { | 342 net::URLRequestContextGetter* KioskAppData::GetRequestContextGetter() { |
343 return g_browser_process->system_request_context(); | 343 return g_browser_process->system_request_context(); |
344 } | 344 } |
345 | 345 |
346 bool KioskAppData::LoadFromCache() { | 346 bool KioskAppData::LoadFromCache() { |
347 std::string app_key = std::string(KioskAppManager::kKeyApps) + '.' + app_id_; | 347 std::string app_key = std::string(KioskAppManager::kKeyApps) + '.' + app_id_; |
348 std::string name_key = app_key + '.' + kKeyName; | 348 std::string name_key = app_key + '.' + kKeyName; |
349 std::string icon_path_key = app_key + '.' + kKeyIcon; | 349 std::string icon_path_key = app_key + '.' + kKeyIcon; |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
435 void KioskAppData::OnWebstoreParseFailure() { | 435 void KioskAppData::OnWebstoreParseFailure() { |
436 SetStatus(STATUS_ERROR); | 436 SetStatus(STATUS_ERROR); |
437 } | 437 } |
438 | 438 |
439 void KioskAppData::StartFetch() { | 439 void KioskAppData::StartFetch() { |
440 webstore_fetcher_.reset(new extensions::WebstoreDataFetcher( | 440 webstore_fetcher_.reset(new extensions::WebstoreDataFetcher( |
441 this, | 441 this, |
442 GetRequestContextGetter(), | 442 GetRequestContextGetter(), |
443 GURL(), | 443 GURL(), |
444 app_id_)); | 444 app_id_)); |
| 445 webstore_fetcher_->set_max_auto_retries(3); |
445 webstore_fetcher_->Start(); | 446 webstore_fetcher_->Start(); |
446 } | 447 } |
447 | 448 |
448 void KioskAppData::OnWebstoreRequestFailure() { | 449 void KioskAppData::OnWebstoreRequestFailure() { |
449 SetStatus(STATUS_ERROR); | 450 SetStatus(STATUS_ERROR); |
450 } | 451 } |
451 | 452 |
452 void KioskAppData::OnWebstoreResponseParseSuccess( | 453 void KioskAppData::OnWebstoreResponseParseSuccess( |
453 scoped_ptr<base::DictionaryValue> webstore_data) { | 454 scoped_ptr<base::DictionaryValue> webstore_data) { |
454 // Takes ownership of |webstore_data|. | 455 // Takes ownership of |webstore_data|. |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
495 if (!response->GetString(key, value)) { | 496 if (!response->GetString(key, value)) { |
496 LOG(ERROR) << "Webstore response error (" << key | 497 LOG(ERROR) << "Webstore response error (" << key |
497 << "): " << ValueToString(response); | 498 << "): " << ValueToString(response); |
498 OnWebstoreResponseParseFailure(kInvalidWebstoreResponseError); | 499 OnWebstoreResponseParseFailure(kInvalidWebstoreResponseError); |
499 return false; | 500 return false; |
500 } | 501 } |
501 return true; | 502 return true; |
502 } | 503 } |
503 | 504 |
504 } // namespace chromeos | 505 } // namespace chromeos |
OLD | NEW |