OLD | NEW |
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 "chrome/browser/extensions/crx_installer.h" | 8 #include "chrome/browser/extensions/crx_installer.h" |
9 #include "chrome/browser/extensions/extension_install_prompt.h" | 9 #include "chrome/browser/extensions/extension_install_prompt.h" |
10 #include "chrome/browser/extensions/extension_install_ui.h" | 10 #include "chrome/browser/extensions/extension_install_ui.h" |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 webstore_data_fetcher_->Start(); | 73 webstore_data_fetcher_->Start(); |
74 } | 74 } |
75 | 75 |
76 void WebstoreStandaloneInstaller::OnWebstoreRequestFailure() { | 76 void WebstoreStandaloneInstaller::OnWebstoreRequestFailure() { |
77 CompleteInstall(kWebstoreRequestError); | 77 CompleteInstall(kWebstoreRequestError); |
78 } | 78 } |
79 | 79 |
80 void WebstoreStandaloneInstaller::OnWebstoreResponseParseSuccess( | 80 void WebstoreStandaloneInstaller::OnWebstoreResponseParseSuccess( |
81 DictionaryValue* webstore_data) { | 81 DictionaryValue* webstore_data) { |
82 if (!CheckRequestorAlive()) { | 82 if (!CheckRequestorAlive()) { |
83 CompleteInstall(""); | 83 CompleteInstall(std::string()); |
84 return; | 84 return; |
85 } | 85 } |
86 | 86 |
87 std::string error; | 87 std::string error; |
88 | 88 |
89 if (!CheckInlineInstallPermitted(*webstore_data, &error)) { | 89 if (!CheckInlineInstallPermitted(*webstore_data, &error)) { |
90 CompleteInstall(error); | 90 CompleteInstall(error); |
91 return; | 91 return; |
92 } | 92 } |
93 | 93 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 icon_url_string); | 134 icon_url_string); |
135 if (!icon_url.is_valid()) { | 135 if (!icon_url.is_valid()) { |
136 CompleteInstall(kInvalidWebstoreResponseError); | 136 CompleteInstall(kInvalidWebstoreResponseError); |
137 return; | 137 return; |
138 } | 138 } |
139 } | 139 } |
140 | 140 |
141 // Assume ownership of webstore_data. | 141 // Assume ownership of webstore_data. |
142 webstore_data_.reset(webstore_data); | 142 webstore_data_.reset(webstore_data); |
143 | 143 |
144 scoped_refptr<WebstoreInstallHelper> helper = new WebstoreInstallHelper( | 144 scoped_refptr<WebstoreInstallHelper> helper = |
145 this, | 145 new WebstoreInstallHelper(this, |
146 id_, | 146 id_, |
147 manifest, | 147 manifest, |
148 "", // We don't have any icon data. | 148 std::string(), // We don't have any icon data. |
149 icon_url, | 149 icon_url, |
150 profile_->GetRequestContext()); | 150 profile_->GetRequestContext()); |
151 // The helper will call us back via OnWebstoreParseSucces or | 151 // The helper will call us back via OnWebstoreParseSucces or |
152 // OnWebstoreParseFailure. | 152 // OnWebstoreParseFailure. |
153 helper->Start(); | 153 helper->Start(); |
154 } | 154 } |
155 | 155 |
156 void WebstoreStandaloneInstaller::OnWebstoreResponseParseFailure( | 156 void WebstoreStandaloneInstaller::OnWebstoreResponseParseFailure( |
157 const std::string& error) { | 157 const std::string& error) { |
158 CompleteInstall(error); | 158 CompleteInstall(error); |
159 } | 159 } |
160 | 160 |
161 void WebstoreStandaloneInstaller::OnWebstoreParseSuccess( | 161 void WebstoreStandaloneInstaller::OnWebstoreParseSuccess( |
162 const std::string& id, | 162 const std::string& id, |
163 const SkBitmap& icon, | 163 const SkBitmap& icon, |
164 base::DictionaryValue* manifest) { | 164 base::DictionaryValue* manifest) { |
165 CHECK_EQ(id_, id); | 165 CHECK_EQ(id_, id); |
166 | 166 |
167 if (!CheckRequestorAlive()) { | 167 if (!CheckRequestorAlive()) { |
168 CompleteInstall(""); | 168 CompleteInstall(std::string()); |
169 return; | 169 return; |
170 } | 170 } |
171 | 171 |
172 manifest_.reset(manifest); | 172 manifest_.reset(manifest); |
173 icon_ = icon; | 173 icon_ = icon; |
174 | 174 |
175 install_prompt_ = CreateInstallPrompt(); | 175 install_prompt_ = CreateInstallPrompt(); |
176 if (install_prompt_) { | 176 if (install_prompt_) { |
177 CreateInstallUI(); | 177 CreateInstallUI(); |
178 // Control flow finishes up in InstallUIProceed or InstallUIAbort. | 178 // Control flow finishes up in InstallUIProceed or InstallUIAbort. |
179 } else { | 179 } else { |
180 InstallUIProceed(); | 180 InstallUIProceed(); |
181 } | 181 } |
182 } | 182 } |
183 | 183 |
184 void WebstoreStandaloneInstaller::OnWebstoreParseFailure( | 184 void WebstoreStandaloneInstaller::OnWebstoreParseFailure( |
185 const std::string& id, | 185 const std::string& id, |
186 InstallHelperResultCode result_code, | 186 InstallHelperResultCode result_code, |
187 const std::string& error_message) { | 187 const std::string& error_message) { |
188 CompleteInstall(error_message); | 188 CompleteInstall(error_message); |
189 } | 189 } |
190 | 190 |
191 void WebstoreStandaloneInstaller::InstallUIProceed() { | 191 void WebstoreStandaloneInstaller::InstallUIProceed() { |
192 if (!CheckRequestorAlive()) { | 192 if (!CheckRequestorAlive()) { |
193 CompleteInstall(""); | 193 CompleteInstall(std::string()); |
194 return; | 194 return; |
195 } | 195 } |
196 | 196 |
197 scoped_ptr<WebstoreInstaller::Approval> approval( | 197 scoped_ptr<WebstoreInstaller::Approval> approval( |
198 WebstoreInstaller::Approval::CreateWithNoInstallPrompt( | 198 WebstoreInstaller::Approval::CreateWithNoInstallPrompt( |
199 profile_, | 199 profile_, |
200 id_, | 200 id_, |
201 scoped_ptr<base::DictionaryValue>(manifest_.get()->DeepCopy()))); | 201 scoped_ptr<base::DictionaryValue>(manifest_.get()->DeepCopy()))); |
202 approval->skip_post_install_ui = !ShouldShowPostInstallUI(); | 202 approval->skip_post_install_ui = !ShouldShowPostInstallUI(); |
203 approval->use_app_installed_bubble = ShouldShowAppInstalledBubble(); | 203 approval->use_app_installed_bubble = ShouldShowAppInstalledBubble(); |
204 | 204 |
205 scoped_refptr<WebstoreInstaller> installer = new WebstoreInstaller( | 205 scoped_refptr<WebstoreInstaller> installer = new WebstoreInstaller( |
206 profile_, | 206 profile_, |
207 this, | 207 this, |
208 &(GetWebContents()->GetController()), | 208 &(GetWebContents()->GetController()), |
209 id_, | 209 id_, |
210 approval.Pass(), | 210 approval.Pass(), |
211 WebstoreInstaller::FLAG_INLINE_INSTALL); | 211 WebstoreInstaller::FLAG_INLINE_INSTALL); |
212 installer->Start(); | 212 installer->Start(); |
213 } | 213 } |
214 | 214 |
215 void WebstoreStandaloneInstaller::InstallUIAbort(bool user_initiated) { | 215 void WebstoreStandaloneInstaller::InstallUIAbort(bool user_initiated) { |
216 CompleteInstall(kUserCancelledError); | 216 CompleteInstall(kUserCancelledError); |
217 } | 217 } |
218 | 218 |
219 void WebstoreStandaloneInstaller::OnExtensionInstallSuccess( | 219 void WebstoreStandaloneInstaller::OnExtensionInstallSuccess( |
220 const std::string& id) { | 220 const std::string& id) { |
221 CHECK_EQ(id_, id); | 221 CHECK_EQ(id_, id); |
222 CompleteInstall(""); | 222 CompleteInstall(std::string()); |
223 } | 223 } |
224 | 224 |
225 void WebstoreStandaloneInstaller::OnExtensionInstallFailure( | 225 void WebstoreStandaloneInstaller::OnExtensionInstallFailure( |
226 const std::string& id, | 226 const std::string& id, |
227 const std::string& error, | 227 const std::string& error, |
228 WebstoreInstaller::FailureReason cancelled) { | 228 WebstoreInstaller::FailureReason cancelled) { |
229 CHECK_EQ(id_, id); | 229 CHECK_EQ(id_, id); |
230 CompleteInstall(error); | 230 CompleteInstall(error); |
231 } | 231 } |
232 | 232 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 } | 267 } |
268 | 268 |
269 install_ui_.reset(new ExtensionInstallPrompt(GetWebContents())); | 269 install_ui_.reset(new ExtensionInstallPrompt(GetWebContents())); |
270 install_ui_->ConfirmStandaloneInstall(this, | 270 install_ui_->ConfirmStandaloneInstall(this, |
271 localized_extension_for_display_, | 271 localized_extension_for_display_, |
272 &icon_, | 272 &icon_, |
273 *install_prompt_); | 273 *install_prompt_); |
274 } | 274 } |
275 | 275 |
276 } // namespace extensions | 276 } // namespace extensions |
OLD | NEW |