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 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
402 GURL(), | 402 GURL(), |
403 app_id_)); | 403 app_id_)); |
404 webstore_fetcher_->Start(); | 404 webstore_fetcher_->Start(); |
405 } | 405 } |
406 | 406 |
407 void KioskAppData::OnWebstoreRequestFailure() { | 407 void KioskAppData::OnWebstoreRequestFailure() { |
408 SetStatus(STATUS_ERROR); | 408 SetStatus(STATUS_ERROR); |
409 } | 409 } |
410 | 410 |
411 void KioskAppData::OnWebstoreResponseParseSuccess( | 411 void KioskAppData::OnWebstoreResponseParseSuccess( |
412 scoped_ptr<base::DictionaryValue> webstore_data) { | 412 base::DictionaryValue* webstore_data) { |
413 // Takes ownership of |webstore_data|. | 413 // Takes ownership of |webstore_data|. |
| 414 scoped_ptr<base::DictionaryValue> data(webstore_data); |
| 415 |
414 webstore_fetcher_.reset(); | 416 webstore_fetcher_.reset(); |
415 | 417 |
416 std::string manifest; | 418 std::string manifest; |
417 if (!CheckResponseKeyValue(webstore_data.get(), kManifestKey, &manifest)) | 419 if (!CheckResponseKeyValue(data.get(), kManifestKey, &manifest)) |
418 return; | 420 return; |
419 | 421 |
420 if (!CheckResponseKeyValue(webstore_data.get(), kLocalizedNameKey, &name_)) | 422 if (!CheckResponseKeyValue(data.get(), kLocalizedNameKey, &name_)) |
421 return; | 423 return; |
422 | 424 |
423 std::string icon_url_string; | 425 std::string icon_url_string; |
424 if (!CheckResponseKeyValue(webstore_data.get(), kIconUrlKey, | 426 if (!CheckResponseKeyValue(data.get(), kIconUrlKey, &icon_url_string)) |
425 &icon_url_string)) | |
426 return; | 427 return; |
427 | 428 |
428 GURL icon_url = GURL(extension_urls::GetWebstoreLaunchURL()).Resolve( | 429 GURL icon_url = GURL(extension_urls::GetWebstoreLaunchURL()).Resolve( |
429 icon_url_string); | 430 icon_url_string); |
430 if (!icon_url.is_valid()) { | 431 if (!icon_url.is_valid()) { |
431 LOG(ERROR) << "Webstore response error (icon url): " | 432 LOG(ERROR) << "Webstore response error (icon url): " |
432 << ValueToString(webstore_data.get()); | 433 << ValueToString(data.get()); |
433 OnWebstoreResponseParseFailure(kInvalidWebstoreResponseError); | 434 OnWebstoreResponseParseFailure(kInvalidWebstoreResponseError); |
434 return; | 435 return; |
435 } | 436 } |
436 | 437 |
437 // WebstoreDataParser deletes itself when done. | 438 // WebstoreDataParser deletes itself when done. |
438 (new WebstoreDataParser(AsWeakPtr()))->Start(app_id_, | 439 (new WebstoreDataParser(AsWeakPtr()))->Start(app_id_, |
439 manifest, | 440 manifest, |
440 icon_url, | 441 icon_url, |
441 GetRequestContextGetter()); | 442 GetRequestContextGetter()); |
442 } | 443 } |
(...skipping 11 matching lines...) Expand all Loading... |
454 if (!response->GetString(key, value)) { | 455 if (!response->GetString(key, value)) { |
455 LOG(ERROR) << "Webstore response error (" << key | 456 LOG(ERROR) << "Webstore response error (" << key |
456 << "): " << ValueToString(response); | 457 << "): " << ValueToString(response); |
457 OnWebstoreResponseParseFailure(kInvalidWebstoreResponseError); | 458 OnWebstoreResponseParseFailure(kInvalidWebstoreResponseError); |
458 return false; | 459 return false; |
459 } | 460 } |
460 return true; | 461 return true; |
461 } | 462 } |
462 | 463 |
463 } // namespace chromeos | 464 } // namespace chromeos |
OLD | NEW |