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

Side by Side Diff: chrome/browser/extensions/webstore_inline_installer.cc

Issue 10388252: Refactoring ExtenionInstallUI to abstract the Browser references. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Minor clean-ups Created 8 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/webstore_inline_installer.h" 5 #include "chrome/browser/extensions/webstore_inline_installer.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 // Manifest, number of users, average rating and rating count are required. 253 // Manifest, number of users, average rating and rating count are required.
254 std::string manifest; 254 std::string manifest;
255 if (!webstore_data->GetString(kManifestKey, &manifest) || 255 if (!webstore_data->GetString(kManifestKey, &manifest) ||
256 !webstore_data->GetString(kUsersKey, &localized_user_count_) || 256 !webstore_data->GetString(kUsersKey, &localized_user_count_) ||
257 !webstore_data->GetDouble(kAverageRatingKey, &average_rating_) || 257 !webstore_data->GetDouble(kAverageRatingKey, &average_rating_) ||
258 !webstore_data->GetInteger(kRatingCountKey, &rating_count_)) { 258 !webstore_data->GetInteger(kRatingCountKey, &rating_count_)) {
259 CompleteInstall(kInvalidWebstoreResponseError); 259 CompleteInstall(kInvalidWebstoreResponseError);
260 return; 260 return;
261 } 261 }
262 262
263 if (average_rating_ < ExtensionInstallUI::kMinExtensionRating || 263 if (average_rating_ < ExtensionInstallPrompt::kMinExtensionRating ||
264 average_rating_ >ExtensionInstallUI::kMaxExtensionRating) { 264 average_rating_ >ExtensionInstallPrompt::kMaxExtensionRating) {
Yoyo Zhou 2012/05/23 23:17:49 nit: missing space
Jay Civelli 2012/05/30 20:20:35 Done.
265 CompleteInstall(kInvalidWebstoreResponseError); 265 CompleteInstall(kInvalidWebstoreResponseError);
266 return; 266 return;
267 } 267 }
268 268
269 // Localized name and description are optional. 269 // Localized name and description are optional.
270 if ((webstore_data->HasKey(kLocalizedNameKey) && 270 if ((webstore_data->HasKey(kLocalizedNameKey) &&
271 !webstore_data->GetString(kLocalizedNameKey, &localized_name_)) || 271 !webstore_data->GetString(kLocalizedNameKey, &localized_name_)) ||
272 (webstore_data->HasKey(kLocalizedDescriptionKey) && 272 (webstore_data->HasKey(kLocalizedDescriptionKey) &&
273 !webstore_data->GetString( 273 !webstore_data->GetString(
274 kLocalizedDescriptionKey, &localized_description_))) { 274 kLocalizedDescriptionKey, &localized_description_))) {
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 return; 337 return;
338 } 338 }
339 339
340 CHECK_EQ(id_, id); 340 CHECK_EQ(id_, id);
341 manifest_.reset(manifest); 341 manifest_.reset(manifest);
342 icon_ = icon; 342 icon_ = icon;
343 343
344 Profile* profile = Profile::FromBrowserContext( 344 Profile* profile = Profile::FromBrowserContext(
345 web_contents()->GetBrowserContext()); 345 web_contents()->GetBrowserContext());
346 346
347 ExtensionInstallUI::Prompt prompt(ExtensionInstallUI::INLINE_INSTALL_PROMPT); 347 ExtensionInstallPrompt::Prompt prompt(
348 ExtensionInstallPrompt::INLINE_INSTALL_PROMPT);
348 prompt.SetInlineInstallWebstoreData(localized_user_count_, 349 prompt.SetInlineInstallWebstoreData(localized_user_count_,
349 average_rating_, 350 average_rating_,
350 rating_count_); 351 rating_count_);
351 std::string error; 352 std::string error;
352 dummy_extension_ = ExtensionInstallUI::GetLocalizedExtensionForDisplay( 353 dummy_extension_ = ExtensionInstallPrompt::GetLocalizedExtensionForDisplay(
353 manifest, id_, localized_name_, localized_description_, &error); 354 manifest, id_, localized_name_, localized_description_, &error);
354 if (!dummy_extension_) { 355 if (!dummy_extension_) {
355 OnWebstoreParseFailure(id_, WebstoreInstallHelper::Delegate::MANIFEST_ERROR, 356 OnWebstoreParseFailure(id_, WebstoreInstallHelper::Delegate::MANIFEST_ERROR,
356 kInvalidManifestError); 357 kInvalidManifestError);
357 return; 358 return;
358 } 359 }
359 360
360 install_ui_.reset(new ExtensionInstallUI(profile)); 361 install_ui_.reset(new ExtensionInstallPrompt(profile));
361 install_ui_->ConfirmInlineInstall(this, dummy_extension_, &icon_, prompt); 362 install_ui_->ConfirmInlineInstall(this, dummy_extension_, &icon_, prompt);
362 // Control flow finishes up in InstallUIProceed or InstallUIAbort. 363 // Control flow finishes up in InstallUIProceed or InstallUIAbort.
363 } 364 }
364 365
365 void WebstoreInlineInstaller::OnWebstoreParseFailure( 366 void WebstoreInlineInstaller::OnWebstoreParseFailure(
366 const std::string& id, 367 const std::string& id,
367 InstallHelperResultCode result_code, 368 InstallHelperResultCode result_code,
368 const std::string& error_message) { 369 const std::string& error_message) {
369 CompleteInstall(error_message); 370 CompleteInstall(error_message);
370 } 371 }
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 verified_site_pattern.Parse(verified_site_url); 447 verified_site_pattern.Parse(verified_site_url);
447 if (parse_result != URLPattern::PARSE_SUCCESS) { 448 if (parse_result != URLPattern::PARSE_SUCCESS) {
448 DLOG(WARNING) << "Could not parse " << verified_site_url << 449 DLOG(WARNING) << "Could not parse " << verified_site_url <<
449 " as URL pattern " << parse_result; 450 " as URL pattern " << parse_result;
450 return false; 451 return false;
451 } 452 }
452 verified_site_pattern.SetScheme("*"); 453 verified_site_pattern.SetScheme("*");
453 454
454 return verified_site_pattern.MatchesURL(requestor_url); 455 return verified_site_pattern.MatchesURL(requestor_url);
455 } 456 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698