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

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

Issue 8375034: Update WebstoreInstaller to be ref counted. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 9 years, 1 month 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 CompleteInstall(kNotFromVerifiedSiteError); 299 CompleteInstall(kNotFromVerifiedSiteError);
300 return; 300 return;
301 } 301 }
302 } else { 302 } else {
303 CompleteInstall(kNoVerifiedSiteError); 303 CompleteInstall(kNoVerifiedSiteError);
304 return; 304 return;
305 } 305 }
306 306
307 scoped_refptr<WebstoreInstallHelper> helper = new WebstoreInstallHelper( 307 scoped_refptr<WebstoreInstallHelper> helper = new WebstoreInstallHelper(
308 this, 308 this,
309 id_,
309 manifest, 310 manifest,
310 "", // We don't have any icon data. 311 "", // We don't have any icon data.
311 icon_url, 312 icon_url,
312 Profile::FromBrowserContext(tab_contents()->browser_context())-> 313 Profile::FromBrowserContext(tab_contents()->browser_context())->
313 GetRequestContext()); 314 GetRequestContext());
314 // The helper will call us back via OnWebstoreParseSucces or 315 // The helper will call us back via OnWebstoreParseSucces or
315 // OnWebstoreParseFailure. 316 // OnWebstoreParseFailure.
316 helper->Start(); 317 helper->Start();
317 } 318 }
318 319
319 void WebstoreInlineInstaller::OnWebstoreResponseParseFailure( 320 void WebstoreInlineInstaller::OnWebstoreResponseParseFailure(
320 const std::string& error) { 321 const std::string& error) {
321 CompleteInstall(error); 322 CompleteInstall(error);
322 } 323 }
323 324
324 void WebstoreInlineInstaller::OnWebstoreParseSuccess( 325 void WebstoreInlineInstaller::OnWebstoreParseSuccess(
326 const std::string& id,
325 const SkBitmap& icon, 327 const SkBitmap& icon,
326 base::DictionaryValue* manifest) { 328 base::DictionaryValue* manifest) {
327 // Check if the tab has gone away in the meantime. 329 // Check if the tab has gone away in the meantime.
328 if (!tab_contents()) { 330 if (!tab_contents()) {
329 CompleteInstall(""); 331 CompleteInstall("");
330 return; 332 return;
331 } 333 }
332 334
335 CHECK_EQ(id_, id);
333 manifest_.reset(manifest); 336 manifest_.reset(manifest);
334 icon_ = icon; 337 icon_ = icon;
335 338
336 Profile* profile = Profile::FromBrowserContext( 339 Profile* profile = Profile::FromBrowserContext(
337 tab_contents()->browser_context()); 340 tab_contents()->browser_context());
338 341
339 ExtensionInstallUI::Prompt prompt(ExtensionInstallUI::INLINE_INSTALL_PROMPT); 342 ExtensionInstallUI::Prompt prompt(ExtensionInstallUI::INLINE_INSTALL_PROMPT);
340 prompt.SetInlineInstallWebstoreData(localized_user_count_, 343 prompt.SetInlineInstallWebstoreData(localized_user_count_,
341 average_rating_, 344 average_rating_,
342 rating_count_); 345 rating_count_);
343 346
344 if (!ShowExtensionInstallDialogForManifest(profile, 347 if (!ShowExtensionInstallDialogForManifest(profile,
345 this, 348 this,
346 manifest, 349 manifest,
347 id_, 350 id_,
348 localized_name_, 351 localized_name_,
349 localized_description_, 352 localized_description_,
350 &icon_, 353 &icon_,
351 prompt, 354 prompt,
352 &dummy_extension_)) { 355 &dummy_extension_)) {
353 CompleteInstall(kInvalidManifestError); 356 CompleteInstall(kInvalidManifestError);
354 return; 357 return;
355 } 358 }
356 359
357 // Control flow finishes up in InstallUIProceed or InstallUIAbort. 360 // Control flow finishes up in InstallUIProceed or InstallUIAbort.
358 } 361 }
359 362
360 void WebstoreInlineInstaller::OnWebstoreParseFailure( 363 void WebstoreInlineInstaller::OnWebstoreParseFailure(
364 const std::string& id,
361 InstallHelperResultCode result_code, 365 InstallHelperResultCode result_code,
362 const std::string& error_message) { 366 const std::string& error_message) {
363 CompleteInstall(error_message); 367 CompleteInstall(error_message);
364 } 368 }
365 369
366 void WebstoreInlineInstaller::InstallUIProceed() { 370 void WebstoreInlineInstaller::InstallUIProceed() {
367 // Check if the tab has gone away in the meantime. 371 // Check if the tab has gone away in the meantime.
368 if (!tab_contents()) { 372 if (!tab_contents()) {
369 CompleteInstall(""); 373 CompleteInstall("");
370 return; 374 return;
371 } 375 }
372 376
373 CrxInstaller::WhitelistEntry* entry = new CrxInstaller::WhitelistEntry; 377 CrxInstaller::WhitelistEntry* entry = new CrxInstaller::WhitelistEntry;
374 378
375 entry->parsed_manifest.reset(manifest_.get()->DeepCopy()); 379 entry->parsed_manifest.reset(manifest_.get()->DeepCopy());
376 entry->localized_name = localized_name_; 380 entry->localized_name = localized_name_;
377 entry->use_app_installed_bubble = true; 381 entry->use_app_installed_bubble = true;
378 CrxInstaller::SetWhitelistEntry(id_, entry); 382 CrxInstaller::SetWhitelistEntry(id_, entry);
379 383
380 Profile* profile = Profile::FromBrowserContext( 384 Profile* profile = Profile::FromBrowserContext(
381 tab_contents()->browser_context()); 385 tab_contents()->browser_context());
382 386
383 WebstoreInstaller* installer = 387 scoped_refptr<WebstoreInstaller> installer = new WebstoreInstaller(
384 profile->GetExtensionService()->webstore_installer(); 388 profile, this, &(tab_contents()->controller()), id_,
385 installer->InstallExtension( 389 WebstoreInstaller::FLAG_INLINE_INSTALL);
386 id_, this, WebstoreInstaller::FLAG_INLINE_INSTALL); 390 installer->Start();
387 } 391 }
388 392
389 void WebstoreInlineInstaller::InstallUIAbort(bool user_initiated) { 393 void WebstoreInlineInstaller::InstallUIAbort(bool user_initiated) {
390 CompleteInstall(kUserCancelledError); 394 CompleteInstall(kUserCancelledError);
391 } 395 }
392 396
393 void WebstoreInlineInstaller::TabContentsDestroyed(TabContents* tab_contents) { 397 void WebstoreInlineInstaller::TabContentsDestroyed(TabContents* tab_contents) {
394 // Abort any in-progress fetches. 398 // Abort any in-progress fetches.
395 if (webstore_data_url_fetcher_.get()) { 399 if (webstore_data_url_fetcher_.get()) {
396 webstore_data_url_fetcher_.reset(); 400 webstore_data_url_fetcher_.reset();
(...skipping 18 matching lines...) Expand all
415 if (tab_contents()) { 419 if (tab_contents()) {
416 if (error.empty()) { 420 if (error.empty()) {
417 delegate_->OnInlineInstallSuccess(install_id_); 421 delegate_->OnInlineInstallSuccess(install_id_);
418 } else { 422 } else {
419 delegate_->OnInlineInstallFailure(install_id_, error); 423 delegate_->OnInlineInstallFailure(install_id_, error);
420 } 424 }
421 } 425 }
422 426
423 Release(); // Matches the AddRef in BeginInstall. 427 Release(); // Matches the AddRef in BeginInstall.
424 } 428 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/webstore_inline_installer.h ('k') | chrome/browser/extensions/webstore_install_helper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698