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

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

Issue 384823002: Introduce a stable set of errors for inline install (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Replace printf with vlog(1) in unrelated code so it passes presubmit Created 6 years, 5 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_standalone_installer.h" 5 #include "chrome/browser/extensions/webstore_standalone_installer.h"
6 6
7 #include "base/values.h" 7 #include "base/values.h"
8 #include "base/version.h" 8 #include "base/version.h"
9 #include "chrome/browser/extensions/crx_installer.h" 9 #include "chrome/browser/extensions/crx_installer.h"
10 #include "chrome/browser/extensions/extension_install_prompt.h" 10 #include "chrome/browser/extensions/extension_install_prompt.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 // Add a ref to keep this alive for WebstoreDataFetcher. 52 // Add a ref to keep this alive for WebstoreDataFetcher.
53 // All code paths from here eventually lead to either CompleteInstall or 53 // All code paths from here eventually lead to either CompleteInstall or
54 // AbortInstall, which both release this ref. 54 // AbortInstall, which both release this ref.
55 AddRef(); 55 AddRef();
56 56
57 if (!Extension::IdIsValid(id_)) { 57 if (!Extension::IdIsValid(id_)) {
58 CompleteInstall(webstore_install::INVALID_ID, kInvalidWebstoreItemId); 58 CompleteInstall(webstore_install::INVALID_ID, kInvalidWebstoreItemId);
59 return; 59 return;
60 } 60 }
61 61
62 webstore_install::Result result = webstore_install::UNKNOWN_ERROR; 62 webstore_install::Result result = webstore_install::OTHER_ERROR;
63 std::string error; 63 std::string error;
64 if (!EnsureUniqueInstall(&result, &error)) { 64 if (!EnsureUniqueInstall(&result, &error)) {
65 CompleteInstall(result, error); 65 CompleteInstall(result, error);
66 return; 66 return;
67 } 67 }
68 68
69 // Use the requesting page as the referrer both since that is more correct 69 // Use the requesting page as the referrer both since that is more correct
70 // (it is the page that caused this request to happen) and so that we can 70 // (it is the page that caused this request to happen) and so that we can
71 // track top sites that trigger inline install requests. 71 // track top sites that trigger inline install requests.
72 webstore_data_fetcher_.reset(new WebstoreDataFetcher( 72 webstore_data_fetcher_.reset(new WebstoreDataFetcher(
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 InitInstallData(&install_data); 117 InitInstallData(&install_data);
118 scoped_active_install_.reset(new ScopedActiveInstall(tracker, install_data)); 118 scoped_active_install_.reset(new ScopedActiveInstall(tracker, install_data));
119 return true; 119 return true;
120 } 120 }
121 121
122 void WebstoreStandaloneInstaller::CompleteInstall( 122 void WebstoreStandaloneInstaller::CompleteInstall(
123 webstore_install::Result result, 123 webstore_install::Result result,
124 const std::string& error) { 124 const std::string& error) {
125 scoped_active_install_.reset(); 125 scoped_active_install_.reset();
126 if (!callback_.is_null()) 126 if (!callback_.is_null())
127 callback_.Run(result == webstore_install::SUCCESS, error); 127 callback_.Run(result == webstore_install::SUCCESS, error, result);
128 Release(); // Matches the AddRef in BeginInstall. 128 Release(); // Matches the AddRef in BeginInstall.
129 } 129 }
130 130
131 void WebstoreStandaloneInstaller::ProceedWithInstallPrompt() { 131 void WebstoreStandaloneInstaller::ProceedWithInstallPrompt() {
132 install_prompt_ = CreateInstallPrompt(); 132 install_prompt_ = CreateInstallPrompt();
133 if (install_prompt_) { 133 if (install_prompt_) {
134 ShowInstallUI(); 134 ShowInstallUI();
135 // Control flow finishes up in InstallUIProceed or InstallUIAbort. 135 // Control flow finishes up in InstallUIProceed or InstallUIAbort.
136 } else { 136 } else {
137 InstallUIProceed(); 137 InstallUIProceed();
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 manifest_.reset(manifest); 299 manifest_.reset(manifest);
300 icon_ = icon; 300 icon_ = icon;
301 301
302 OnManifestParsed(); 302 OnManifestParsed();
303 } 303 }
304 304
305 void WebstoreStandaloneInstaller::OnWebstoreParseFailure( 305 void WebstoreStandaloneInstaller::OnWebstoreParseFailure(
306 const std::string& id, 306 const std::string& id,
307 InstallHelperResultCode result_code, 307 InstallHelperResultCode result_code,
308 const std::string& error_message) { 308 const std::string& error_message) {
309 webstore_install::Result install_result = webstore_install::UNKNOWN_ERROR; 309 webstore_install::Result install_result = webstore_install::OTHER_ERROR;
310 switch (result_code) { 310 switch (result_code) {
311 case WebstoreInstallHelper::Delegate::MANIFEST_ERROR: 311 case WebstoreInstallHelper::Delegate::MANIFEST_ERROR:
312 install_result = webstore_install::INVALID_MANIFEST; 312 install_result = webstore_install::INVALID_MANIFEST;
313 break; 313 break;
314 case WebstoreInstallHelper::Delegate::ICON_ERROR: 314 case WebstoreInstallHelper::Delegate::ICON_ERROR:
315 install_result = webstore_install::ICON_ERROR; 315 install_result = webstore_install::ICON_ERROR;
316 break; 316 break;
317 default: 317 default:
318 break; 318 break;
319 } 319 }
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 CHECK_EQ(id_, id); 393 CHECK_EQ(id_, id);
394 CompleteInstall(webstore_install::SUCCESS, std::string()); 394 CompleteInstall(webstore_install::SUCCESS, std::string());
395 } 395 }
396 396
397 void WebstoreStandaloneInstaller::OnExtensionInstallFailure( 397 void WebstoreStandaloneInstaller::OnExtensionInstallFailure(
398 const std::string& id, 398 const std::string& id,
399 const std::string& error, 399 const std::string& error,
400 WebstoreInstaller::FailureReason reason) { 400 WebstoreInstaller::FailureReason reason) {
401 CHECK_EQ(id_, id); 401 CHECK_EQ(id_, id);
402 402
403 webstore_install::Result install_result = webstore_install::UNKNOWN_ERROR; 403 webstore_install::Result install_result = webstore_install::OTHER_ERROR;
404 switch (reason) { 404 switch (reason) {
405 case WebstoreInstaller::FAILURE_REASON_CANCELLED: 405 case WebstoreInstaller::FAILURE_REASON_CANCELLED:
406 install_result = webstore_install::USER_CANCELLED; 406 install_result = webstore_install::USER_CANCELLED;
407 break; 407 break;
408 case WebstoreInstaller::FAILURE_REASON_DEPENDENCY_NOT_FOUND: 408 case WebstoreInstaller::FAILURE_REASON_DEPENDENCY_NOT_FOUND:
409 case WebstoreInstaller::FAILURE_REASON_DEPENDENCY_NOT_SHARED_MODULE: 409 case WebstoreInstaller::FAILURE_REASON_DEPENDENCY_NOT_SHARED_MODULE:
410 install_result = webstore_install::MISSING_DEPENDENCIES; 410 install_result = webstore_install::MISSING_DEPENDENCIES;
411 break; 411 break;
412 default: 412 default:
413 break; 413 break;
(...skipping 17 matching lines...) Expand all
431 void WebstoreStandaloneInstaller::OnWebStoreDataFetcherDone() { 431 void WebstoreStandaloneInstaller::OnWebStoreDataFetcherDone() {
432 // An instance of this class is passed in as a delegate for the 432 // An instance of this class is passed in as a delegate for the
433 // WebstoreInstallHelper, ExtensionInstallPrompt and WebstoreInstaller, and 433 // WebstoreInstallHelper, ExtensionInstallPrompt and WebstoreInstaller, and
434 // therefore needs to remain alive until they are done. Clear the webstore 434 // therefore needs to remain alive until they are done. Clear the webstore
435 // data fetcher to avoid calling Release in AbortInstall while any of these 435 // data fetcher to avoid calling Release in AbortInstall while any of these
436 // operations are in progress. 436 // operations are in progress.
437 webstore_data_fetcher_.reset(); 437 webstore_data_fetcher_.reset();
438 } 438 }
439 439
440 } // namespace extensions 440 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698