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

Side by Side Diff: chrome/browser/extensions/api/inline_install_private/inline_install_private_api.cc

Issue 1871713002: Convert //chrome/browser/extensions from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase and fix header Created 4 years, 8 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
OLDNEW
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/api/inline_install_private/inline_install_pr ivate_api.h" 5 #include "chrome/browser/extensions/api/inline_install_private/inline_install_pr ivate_api.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/memory/ptr_util.h"
8 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
9 #include "chrome/browser/extensions/webstore_install_with_prompt.h" 10 #include "chrome/browser/extensions/webstore_install_with_prompt.h"
10 #include "chrome/browser/profiles/profile.h" 11 #include "chrome/browser/profiles/profile.h"
11 #include "chrome/common/extensions/api/inline_install_private.h" 12 #include "chrome/common/extensions/api/inline_install_private.h"
12 #include "chrome/common/extensions/api/webstore/webstore_api_constants.h" 13 #include "chrome/common/extensions/api/webstore/webstore_api_constants.h"
13 #include "components/crx_file/id_util.h" 14 #include "components/crx_file/id_util.h"
14 #include "content/public/browser/browser_thread.h" 15 #include "content/public/browser/browser_thread.h"
15 #include "extensions/browser/extension_registry.h" 16 #include "extensions/browser/extension_registry.h"
16 17
17 namespace extensions { 18 namespace extensions {
18 19
19 namespace { 20 namespace {
20 21
21 class Installer : public WebstoreInstallWithPrompt { 22 class Installer : public WebstoreInstallWithPrompt {
22 public: 23 public:
23 Installer(const std::string& id, 24 Installer(const std::string& id,
24 const GURL& requestor_url, 25 const GURL& requestor_url,
25 Profile* profile, 26 Profile* profile,
26 const Callback& callback); 27 const Callback& callback);
27 protected: 28 protected:
28 friend class base::RefCountedThreadSafe<Installer>; 29 friend class base::RefCountedThreadSafe<Installer>;
29 ~Installer() override; 30 ~Installer() override;
30 31
31 // Needed so that we send the right referrer value in requests to the 32 // Needed so that we send the right referrer value in requests to the
32 // webstore. 33 // webstore.
33 const GURL& GetRequestorURL() const override { return requestor_url_; } 34 const GURL& GetRequestorURL() const override { return requestor_url_; }
34 35
35 scoped_ptr<ExtensionInstallPrompt::Prompt> CreateInstallPrompt() 36 std::unique_ptr<ExtensionInstallPrompt::Prompt> CreateInstallPrompt()
36 const override; 37 const override;
37 38
38 void OnManifestParsed() override; 39 void OnManifestParsed() override;
39 40
40 GURL requestor_url_; 41 GURL requestor_url_;
41 }; 42 };
42 43
43 Installer::Installer(const std::string& id, 44 Installer::Installer(const std::string& id,
44 const GURL& requestor_url, 45 const GURL& requestor_url,
45 Profile* profile, 46 Profile* profile,
46 const Callback& callback) : 47 const Callback& callback) :
47 WebstoreInstallWithPrompt(id, profile, callback), 48 WebstoreInstallWithPrompt(id, profile, callback),
48 requestor_url_(requestor_url) { 49 requestor_url_(requestor_url) {
49 set_show_post_install_ui(false); 50 set_show_post_install_ui(false);
50 } 51 }
51 52
52 Installer::~Installer() { 53 Installer::~Installer() {
53 } 54 }
54 55
55 scoped_ptr<ExtensionInstallPrompt::Prompt> Installer::CreateInstallPrompt() 56 std::unique_ptr<ExtensionInstallPrompt::Prompt> Installer::CreateInstallPrompt()
56 const { 57 const {
57 scoped_ptr<ExtensionInstallPrompt::Prompt> prompt( 58 std::unique_ptr<ExtensionInstallPrompt::Prompt> prompt(
58 new ExtensionInstallPrompt::Prompt( 59 new ExtensionInstallPrompt::Prompt(
59 ExtensionInstallPrompt::INLINE_INSTALL_PROMPT)); 60 ExtensionInstallPrompt::INLINE_INSTALL_PROMPT));
60 prompt->SetWebstoreData(localized_user_count(), 61 prompt->SetWebstoreData(localized_user_count(),
61 show_user_count(), 62 show_user_count(),
62 average_rating(), 63 average_rating(),
63 rating_count()); 64 rating_count());
64 return prompt; 65 return prompt;
65 } 66 }
66 67
67 68
68 void Installer::OnManifestParsed() { 69 void Installer::OnManifestParsed() {
69 if (manifest() == nullptr) { 70 if (manifest() == nullptr) {
70 CompleteInstall(webstore_install::INVALID_MANIFEST, std::string()); 71 CompleteInstall(webstore_install::INVALID_MANIFEST, std::string());
71 return; 72 return;
72 } 73 }
73 74
74 Manifest parsed_manifest(Manifest::INTERNAL, 75 Manifest parsed_manifest(Manifest::INTERNAL,
75 make_scoped_ptr(manifest()->DeepCopy())); 76 base::WrapUnique(manifest()->DeepCopy()));
76 77
77 std::string manifest_error; 78 std::string manifest_error;
78 std::vector<InstallWarning> warnings; 79 std::vector<InstallWarning> warnings;
79 80
80 if (!parsed_manifest.is_platform_app()) { 81 if (!parsed_manifest.is_platform_app()) {
81 CompleteInstall(webstore_install::NOT_PERMITTED, std::string()); 82 CompleteInstall(webstore_install::NOT_PERMITTED, std::string());
82 return; 83 return;
83 } 84 }
84 85
85 ProceedWithInstallPrompt(); 86 ProceedWithInstallPrompt();
86 } 87 }
87 88
88 89
89 } // namespace 90 } // namespace
90 91
91 InlineInstallPrivateInstallFunction:: 92 InlineInstallPrivateInstallFunction::
92 InlineInstallPrivateInstallFunction() { 93 InlineInstallPrivateInstallFunction() {
93 } 94 }
94 95
95 InlineInstallPrivateInstallFunction:: 96 InlineInstallPrivateInstallFunction::
96 ~InlineInstallPrivateInstallFunction() { 97 ~InlineInstallPrivateInstallFunction() {
97 } 98 }
98 99
99 ExtensionFunction::ResponseAction 100 ExtensionFunction::ResponseAction
100 InlineInstallPrivateInstallFunction::Run() { 101 InlineInstallPrivateInstallFunction::Run() {
101 typedef api::inline_install_private::Install::Params Params; 102 typedef api::inline_install_private::Install::Params Params;
102 scoped_ptr<Params> params(Params::Create(*args_)); 103 std::unique_ptr<Params> params(Params::Create(*args_));
103 104
104 if (!user_gesture()) 105 if (!user_gesture())
105 return RespondNow(CreateResponse("Must be called with a user gesture", 106 return RespondNow(CreateResponse("Must be called with a user gesture",
106 webstore_install::NOT_PERMITTED)); 107 webstore_install::NOT_PERMITTED));
107 108
108 content::WebContents* web_contents = GetAssociatedWebContents(); 109 content::WebContents* web_contents = GetAssociatedWebContents();
109 if (!web_contents) 110 if (!web_contents)
110 return RespondNow(CreateResponse("Must be called from a foreground page", 111 return RespondNow(CreateResponse("Must be called from a foreground page",
111 webstore_install::NOT_PERMITTED)); 112 webstore_install::NOT_PERMITTED));
112 113
(...skipping 25 matching lines...) Expand all
138 139
139 ExtensionFunction::ResponseValue 140 ExtensionFunction::ResponseValue
140 InlineInstallPrivateInstallFunction::CreateResponse( 141 InlineInstallPrivateInstallFunction::CreateResponse(
141 const std::string& error, webstore_install::Result result) { 142 const std::string& error, webstore_install::Result result) {
142 return ArgumentList(api::inline_install_private::Install::Results::Create( 143 return ArgumentList(api::inline_install_private::Install::Results::Create(
143 error, 144 error,
144 api::webstore::kInstallResultCodes[result])); 145 api::webstore::kInstallResultCodes[result]));
145 } 146 }
146 147
147 } // namespace extensions 148 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698