OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/extensions/external_install_error.h" | 5 #include "chrome/browser/extensions/external_install_error.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "chrome/app/chrome_command_ids.h" | 9 #include "chrome/app/chrome_command_ids.h" |
10 #include "chrome/browser/extensions/extension_service.h" | 10 #include "chrome/browser/extensions/extension_service.h" |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 ->GetExtensionById(extension_id_, ExtensionRegistry::EVERYTHING); | 313 ->GetExtensionById(extension_id_, ExtensionRegistry::EVERYTHING); |
314 } | 314 } |
315 | 315 |
316 void ExternalInstallError::OnWebstoreRequestFailure() { | 316 void ExternalInstallError::OnWebstoreRequestFailure() { |
317 OnFetchComplete(); | 317 OnFetchComplete(); |
318 } | 318 } |
319 | 319 |
320 void ExternalInstallError::OnWebstoreResponseParseSuccess( | 320 void ExternalInstallError::OnWebstoreResponseParseSuccess( |
321 scoped_ptr<base::DictionaryValue> webstore_data) { | 321 scoped_ptr<base::DictionaryValue> webstore_data) { |
322 std::string localized_user_count; | 322 std::string localized_user_count; |
323 double average_rating; | 323 double average_rating = 0; |
324 int rating_count; | 324 int rating_count = 0; |
325 if (!webstore_data->GetString(kUsersKey, &localized_user_count) || | 325 if (!webstore_data->GetString(kUsersKey, &localized_user_count) || |
326 !webstore_data->GetDouble(kAverageRatingKey, &average_rating) || | 326 !webstore_data->GetDouble(kAverageRatingKey, &average_rating) || |
327 !webstore_data->GetInteger(kRatingCountKey, &rating_count)) { | 327 !webstore_data->GetInteger(kRatingCountKey, &rating_count)) { |
328 // If we don't get a valid webstore response, short circuit, and continue | 328 // If we don't get a valid webstore response, short circuit, and continue |
329 // to show a prompt without webstore data. | 329 // to show a prompt without webstore data. |
330 OnFetchComplete(); | 330 OnFetchComplete(); |
331 return; | 331 return; |
332 } | 332 } |
333 | 333 |
334 bool show_user_count = true; | 334 bool show_user_count = true; |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 if (browser) | 382 if (browser) |
383 global_error_->ShowBubbleView(browser); | 383 global_error_->ShowBubbleView(browser); |
384 } else { | 384 } else { |
385 DCHECK(alert_type_ == MENU_ALERT); | 385 DCHECK(alert_type_ == MENU_ALERT); |
386 global_error_.reset(new ExternalInstallMenuAlert(this)); | 386 global_error_.reset(new ExternalInstallMenuAlert(this)); |
387 error_service_->AddGlobalError(global_error_.get()); | 387 error_service_->AddGlobalError(global_error_.get()); |
388 } | 388 } |
389 } | 389 } |
390 | 390 |
391 } // namespace extensions | 391 } // namespace extensions |
OLD | NEW |