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