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/api/webstore_private/webstore_private_api.h" | 5 #include "chrome/browser/extensions/api/webstore_private/webstore_private_api.h" |
6 | 6 |
7 #include "base/bind_helpers.h" | 7 #include "base/bind_helpers.h" |
8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
9 #include "base/memory/scoped_vector.h" | 9 #include "base/memory/scoped_vector.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 28 matching lines...) Expand all Loading... | |
39 namespace CompleteInstall = api::webstore_private::CompleteInstall; | 39 namespace CompleteInstall = api::webstore_private::CompleteInstall; |
40 namespace GetBrowserLogin = api::webstore_private::GetBrowserLogin; | 40 namespace GetBrowserLogin = api::webstore_private::GetBrowserLogin; |
41 namespace GetEphemeralAppsEnabled = | 41 namespace GetEphemeralAppsEnabled = |
42 api::webstore_private::GetEphemeralAppsEnabled; | 42 api::webstore_private::GetEphemeralAppsEnabled; |
43 namespace GetIsLauncherEnabled = api::webstore_private::GetIsLauncherEnabled; | 43 namespace GetIsLauncherEnabled = api::webstore_private::GetIsLauncherEnabled; |
44 namespace GetStoreLogin = api::webstore_private::GetStoreLogin; | 44 namespace GetStoreLogin = api::webstore_private::GetStoreLogin; |
45 namespace GetWebGLStatus = api::webstore_private::GetWebGLStatus; | 45 namespace GetWebGLStatus = api::webstore_private::GetWebGLStatus; |
46 namespace IsInIncognitoMode = api::webstore_private::IsInIncognitoMode; | 46 namespace IsInIncognitoMode = api::webstore_private::IsInIncognitoMode; |
47 namespace LaunchEphemeralApp = api::webstore_private::LaunchEphemeralApp; | 47 namespace LaunchEphemeralApp = api::webstore_private::LaunchEphemeralApp; |
48 namespace SetStoreLogin = api::webstore_private::SetStoreLogin; | 48 namespace SetStoreLogin = api::webstore_private::SetStoreLogin; |
49 namespace ShowPermissionPromptForDelegatedInstall = | |
50 api::webstore_private::ShowPermissionPromptForDelegatedInstall; | |
49 | 51 |
50 namespace { | 52 namespace { |
51 | 53 |
52 // Holds the Approvals between the time we prompt and start the installs. | 54 // Holds the Approvals between the time we prompt and start the installs. |
53 class PendingApprovals { | 55 class PendingApprovals { |
54 public: | 56 public: |
55 PendingApprovals(); | 57 PendingApprovals(); |
56 ~PendingApprovals(); | 58 ~PendingApprovals(); |
57 | 59 |
58 void PushApproval(scoped_ptr<WebstoreInstaller::Approval> approval); | 60 void PushApproval(scoped_ptr<WebstoreInstaller::Approval> approval); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
126 return api::webstore_private::RESULT_UNSUPPORTED_EXTENSION_TYPE; | 128 return api::webstore_private::RESULT_UNSUPPORTED_EXTENSION_TYPE; |
127 case webstore_install::INSTALL_IN_PROGRESS: | 129 case webstore_install::INSTALL_IN_PROGRESS: |
128 return api::webstore_private::RESULT_INSTALL_IN_PROGRESS; | 130 return api::webstore_private::RESULT_INSTALL_IN_PROGRESS; |
129 case webstore_install::LAUNCH_IN_PROGRESS: | 131 case webstore_install::LAUNCH_IN_PROGRESS: |
130 return api::webstore_private::RESULT_LAUNCH_IN_PROGRESS; | 132 return api::webstore_private::RESULT_LAUNCH_IN_PROGRESS; |
131 } | 133 } |
132 NOTREACHED(); | 134 NOTREACHED(); |
133 return api::webstore_private::RESULT_NONE; | 135 return api::webstore_private::RESULT_NONE; |
134 } | 136 } |
135 | 137 |
138 api::webstore_private::Result WebstoreInstallHelperResultToApiResult( | |
139 WebstoreInstallHelper::Delegate::InstallHelperResultCode result) { | |
140 switch (result) { | |
141 case WebstoreInstallHelper::Delegate::UNKNOWN_ERROR: | |
142 return api::webstore_private::RESULT_UNKNOWN_ERROR; | |
143 case WebstoreInstallHelper::Delegate::ICON_ERROR: | |
144 return api::webstore_private::RESULT_ICON_ERROR; | |
145 case WebstoreInstallHelper::Delegate::MANIFEST_ERROR: | |
146 return api::webstore_private::RESULT_MANIFEST_ERROR; | |
147 } | |
148 NOTREACHED(); | |
149 return api::webstore_private::RESULT_NONE; | |
150 } | |
151 | |
136 static base::LazyInstance<PendingApprovals> g_pending_approvals = | 152 static base::LazyInstance<PendingApprovals> g_pending_approvals = |
137 LAZY_INSTANCE_INITIALIZER; | 153 LAZY_INSTANCE_INITIALIZER; |
138 | 154 |
139 // A preference set by the web store to indicate login information for | 155 // A preference set by the web store to indicate login information for |
140 // purchased apps. | 156 // purchased apps. |
141 const char kWebstoreLogin[] = "extensions.webstore_login"; | 157 const char kWebstoreLogin[] = "extensions.webstore_login"; |
142 const char kAlreadyInstalledError[] = "This item is already installed"; | 158 const char kAlreadyInstalledError[] = "This item is already installed"; |
143 const char kCannotSpecifyIconDataAndUrlError[] = | 159 const char kCannotSpecifyIconDataAndUrlError[] = |
144 "You cannot specify both icon data and an icon url"; | 160 "You cannot specify both icon data and an icon url"; |
145 const char kInvalidIconUrlError[] = "Invalid icon url"; | 161 const char kInvalidIconUrlError[] = "Invalid icon url"; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
178 test_webstore_installer_delegate = delegate; | 194 test_webstore_installer_delegate = delegate; |
179 } | 195 } |
180 | 196 |
181 // static | 197 // static |
182 scoped_ptr<WebstoreInstaller::Approval> | 198 scoped_ptr<WebstoreInstaller::Approval> |
183 WebstorePrivateApi::PopApprovalForTesting( | 199 WebstorePrivateApi::PopApprovalForTesting( |
184 Profile* profile, const std::string& extension_id) { | 200 Profile* profile, const std::string& extension_id) { |
185 return g_pending_approvals.Get().PopApproval(profile, extension_id); | 201 return g_pending_approvals.Get().PopApproval(profile, extension_id); |
186 } | 202 } |
187 | 203 |
188 WebstorePrivateBeginInstallWithManifest3Function:: | 204 template<typename Params> |
189 WebstorePrivateBeginInstallWithManifest3Function() : chrome_details_(this) { | 205 WebstorePrivateFunctionWithPermissionPrompt<Params>:: |
206 WebstorePrivateFunctionWithPermissionPrompt() { | |
190 } | 207 } |
191 | 208 |
192 WebstorePrivateBeginInstallWithManifest3Function:: | 209 template<typename Params> |
193 ~WebstorePrivateBeginInstallWithManifest3Function() { | 210 WebstorePrivateFunctionWithPermissionPrompt<Params>:: |
211 ~WebstorePrivateFunctionWithPermissionPrompt() { | |
194 } | 212 } |
195 | 213 |
214 template<typename Params> | |
215 ExtensionFunction::ResponseValue | |
216 WebstorePrivateFunctionWithPermissionPrompt<Params>::RunExtraForResponse() { | |
217 return ExtensionFunction::ResponseValue(); | |
218 } | |
219 | |
220 template<typename Params> | |
221 ExtensionFunction::ResponseValue | |
222 WebstorePrivateFunctionWithPermissionPrompt<Params>::BuildResponse( | |
223 api::webstore_private::Result result, const std::string& error) { | |
224 if (result != api::webstore_private::RESULT_SUCCESS) | |
225 return ErrorWithArguments(CreateResults(result), error); | |
226 | |
227 // The web store expects an empty string on success, so don't use | |
228 // RESULT_SUCCESS here. | |
229 return ArgumentList( | |
230 CreateResults(api::webstore_private::RESULT_EMPTY_STRING)); | |
231 } | |
232 | |
233 template<typename Params> | |
234 scoped_ptr<base::DictionaryValue> | |
235 WebstorePrivateFunctionWithPermissionPrompt<Params>::PassParsedManifest() { | |
236 return parsed_manifest_.Pass(); | |
237 } | |
238 | |
239 template<typename Params> | |
196 ExtensionFunction::ResponseAction | 240 ExtensionFunction::ResponseAction |
197 WebstorePrivateBeginInstallWithManifest3Function::Run() { | 241 WebstorePrivateFunctionWithPermissionPrompt<Params>::Run() { |
198 params_ = BeginInstallWithManifest3::Params::Create(*args_); | 242 params_ = Params::Create(*args_); |
199 EXTENSION_FUNCTION_VALIDATE(params_); | 243 EXTENSION_FUNCTION_VALIDATE(params_); |
200 | 244 |
201 if (!crx_file::id_util::IdIsValid(params_->details.id)) { | 245 if (!crx_file::id_util::IdIsValid(params_->details.id)) { |
202 return RespondNow(BuildResponseForError( | 246 return RespondNow(BuildResponse(api::webstore_private::RESULT_INVALID_ID, |
203 api::webstore_private::RESULT_INVALID_ID, | 247 kInvalidIdError)); |
204 kInvalidIdError)); | |
205 } | 248 } |
206 | 249 |
207 if (params_->details.icon_data && params_->details.icon_url) { | 250 if (params_->details.icon_data && params_->details.icon_url) { |
208 return RespondNow(BuildResponseForError( | 251 return RespondNow(BuildResponse(api::webstore_private::RESULT_ICON_ERROR, |
209 api::webstore_private::RESULT_ICON_ERROR, | 252 kCannotSpecifyIconDataAndUrlError)); |
210 kCannotSpecifyIconDataAndUrlError)); | |
211 } | 253 } |
212 | 254 |
213 GURL icon_url; | 255 GURL icon_url; |
214 if (params_->details.icon_url) { | 256 if (params_->details.icon_url) { |
215 std::string tmp_url; | |
216 icon_url = source_url().Resolve(*params_->details.icon_url); | 257 icon_url = source_url().Resolve(*params_->details.icon_url); |
217 if (!icon_url.is_valid()) { | 258 if (!icon_url.is_valid()) { |
218 return RespondNow(BuildResponseForError( | 259 return RespondNow(BuildResponse( |
219 api::webstore_private::RESULT_INVALID_ICON_URL, | 260 api::webstore_private::RESULT_INVALID_ICON_URL, |
220 kInvalidIconUrlError)); | 261 kInvalidIconUrlError)); |
221 } | 262 } |
222 } | 263 } |
223 | 264 |
224 if (params_->details.authuser) { | |
225 authuser_ = *params_->details.authuser; | |
226 } | |
227 | |
228 std::string icon_data = params_->details.icon_data ? | 265 std::string icon_data = params_->details.icon_data ? |
229 *params_->details.icon_data : std::string(); | 266 *params_->details.icon_data : std::string(); |
230 | 267 |
231 InstallTracker* tracker = InstallTracker::Get(browser_context()); | 268 ExtensionFunction::ResponseValue response = RunExtraForResponse(); |
232 DCHECK(tracker); | 269 if (response) |
233 if (util::IsExtensionInstalledPermanently(params_->details.id, | 270 return RespondNow(response.Pass()); |
234 browser_context()) || | |
235 tracker->GetActiveInstall(params_->details.id)) { | |
236 return RespondNow(BuildResponseForError( | |
237 api::webstore_private::RESULT_ALREADY_INSTALLED, | |
238 kAlreadyInstalledError)); | |
239 } | |
240 ActiveInstallData install_data(params_->details.id); | |
241 scoped_active_install_.reset(new ScopedActiveInstall(tracker, install_data)); | |
242 | 271 |
243 net::URLRequestContextGetter* context_getter = NULL; | 272 net::URLRequestContextGetter* context_getter = NULL; |
244 if (!icon_url.is_empty()) | 273 if (!icon_url.is_empty()) |
245 context_getter = browser_context()->GetRequestContext(); | 274 context_getter = browser_context()->GetRequestContext(); |
246 | 275 |
247 scoped_refptr<WebstoreInstallHelper> helper = new WebstoreInstallHelper( | 276 scoped_refptr<WebstoreInstallHelper> helper = new WebstoreInstallHelper( |
248 this, params_->details.id, params_->details.manifest, icon_data, icon_url, | 277 this, params_->details.id, params_->details.manifest, icon_data, icon_url, |
249 context_getter); | 278 context_getter); |
250 | 279 |
251 // The helper will call us back via OnWebstoreParseSuccess or | 280 // The helper will call us back via OnWebstoreParseSuccess or |
252 // OnWebstoreParseFailure. | 281 // OnWebstoreParseFailure. |
253 helper->Start(); | 282 helper->Start(); |
254 | 283 |
255 // Matched with a Release in OnWebstoreParseSuccess/OnWebstoreParseFailure. | 284 // Matched with a Release in OnWebstoreParseSuccess/OnWebstoreParseFailure. |
256 AddRef(); | 285 AddRef(); |
257 | 286 |
258 // The response is sent asynchronously in OnWebstoreParseSuccess/ | 287 // The response is sent asynchronously in OnWebstoreParseSuccess/ |
259 // OnWebstoreParseFailure. | 288 // OnWebstoreParseFailure. |
260 return RespondLater(); | 289 return RespondLater(); |
261 } | 290 } |
262 | 291 |
263 void WebstorePrivateBeginInstallWithManifest3Function::OnWebstoreParseSuccess( | 292 template<typename Params> |
293 void | |
294 WebstorePrivateFunctionWithPermissionPrompt<Params>::OnWebstoreParseSuccess( | |
264 const std::string& id, | 295 const std::string& id, |
265 const SkBitmap& icon, | 296 const SkBitmap& icon, |
266 base::DictionaryValue* parsed_manifest) { | 297 base::DictionaryValue* parsed_manifest) { |
267 CHECK_EQ(params_->details.id, id); | 298 CHECK_EQ(params_->details.id, id); |
268 CHECK(parsed_manifest); | 299 CHECK(parsed_manifest); |
269 icon_ = icon; | 300 icon_ = icon; |
270 parsed_manifest_.reset(parsed_manifest); | 301 parsed_manifest_.reset(parsed_manifest); |
271 | 302 |
272 std::string localized_name = params_->details.localized_name ? | 303 std::string localized_name = params_->details.localized_name ? |
273 *params_->details.localized_name : std::string(); | 304 *params_->details.localized_name : std::string(); |
274 | 305 |
275 std::string error; | 306 std::string error; |
276 dummy_extension_ = ExtensionInstallPrompt::GetLocalizedExtensionForDisplay( | 307 dummy_extension_ = ExtensionInstallPrompt::GetLocalizedExtensionForDisplay( |
277 parsed_manifest_.get(), | 308 parsed_manifest_.get(), |
278 Extension::FROM_WEBSTORE, | 309 Extension::FROM_WEBSTORE, |
279 id, | 310 id, |
280 localized_name, | 311 localized_name, |
281 std::string(), | 312 std::string(), |
282 &error); | 313 &error); |
283 | 314 |
284 if (!dummy_extension_.get()) { | 315 if (!dummy_extension_.get()) { |
285 OnWebstoreParseFailure(params_->details.id, | 316 OnWebstoreParseFailure(params_->details.id, |
286 WebstoreInstallHelper::Delegate::MANIFEST_ERROR, | 317 WebstoreInstallHelper::Delegate::MANIFEST_ERROR, |
287 kInvalidManifestError); | 318 kInvalidManifestError); |
288 return; | 319 return; |
289 } | 320 } |
290 | 321 |
291 content::WebContents* web_contents = GetAssociatedWebContents(); | 322 content::WebContents* web_contents = GetAssociatedWebContents(); |
292 if (!web_contents) // The browser window has gone away. | 323 if (!web_contents) { |
324 // The browser window has gone away. | |
325 Respond(BuildResponse(api::webstore_private::RESULT_USER_CANCELLED, | |
326 kUserCancelledError)); | |
327 // Matches the AddRef in Run(). | |
328 Release(); | |
293 return; | 329 return; |
330 } | |
294 install_prompt_.reset(new ExtensionInstallPrompt(web_contents)); | 331 install_prompt_.reset(new ExtensionInstallPrompt(web_contents)); |
295 install_prompt_->ConfirmWebstoreInstall( | 332 ShowPrompt(install_prompt_.get()); |
296 this, | |
297 dummy_extension_.get(), | |
298 &icon_, | |
299 ExtensionInstallPrompt::GetDefaultShowDialogCallback()); | |
300 // Control flow finishes up in InstallUIProceed or InstallUIAbort. | 333 // Control flow finishes up in InstallUIProceed or InstallUIAbort. |
301 } | 334 } |
302 | 335 |
303 void WebstorePrivateBeginInstallWithManifest3Function::OnWebstoreParseFailure( | 336 template<typename Params> |
337 void | |
338 WebstorePrivateFunctionWithPermissionPrompt<Params>::OnWebstoreParseFailure( | |
304 const std::string& id, | 339 const std::string& id, |
305 WebstoreInstallHelper::Delegate::InstallHelperResultCode result, | 340 WebstoreInstallHelper::Delegate::InstallHelperResultCode result, |
306 const std::string& error_message) { | 341 const std::string& error_message) { |
307 CHECK_EQ(params_->details.id, id); | 342 CHECK_EQ(params_->details.id, id); |
308 | 343 |
309 // Map from WebstoreInstallHelper's result codes to ours. | 344 Respond(BuildResponse(WebstoreInstallHelperResultToApiResult(result), |
310 api::webstore_private::Result api_result = | 345 error_message)); |
311 api::webstore_private::RESULT_NONE; | |
312 switch (result) { | |
313 case WebstoreInstallHelper::Delegate::UNKNOWN_ERROR: | |
314 api_result = api::webstore_private::RESULT_UNKNOWN_ERROR; | |
315 break; | |
316 case WebstoreInstallHelper::Delegate::ICON_ERROR: | |
317 api_result = api::webstore_private::RESULT_ICON_ERROR; | |
318 break; | |
319 case WebstoreInstallHelper::Delegate::MANIFEST_ERROR: | |
320 api_result = api::webstore_private::RESULT_MANIFEST_ERROR; | |
321 break; | |
322 } | |
323 DCHECK_NE(api_result, api::webstore_private::RESULT_NONE); | |
324 Respond(BuildResponseForError(api_result, error_message)); | |
325 | 346 |
326 // Matches the AddRef in Run(). | 347 // Matches the AddRef in Run(). |
327 Release(); | 348 Release(); |
328 } | 349 } |
329 | 350 |
330 void WebstorePrivateBeginInstallWithManifest3Function::InstallUIProceed() { | 351 template<typename Params> |
352 void WebstorePrivateFunctionWithPermissionPrompt<Params>::InstallUIProceed() { | |
353 InstallUIProceedHook(); | |
354 | |
355 Respond(BuildResponse(api::webstore_private::RESULT_SUCCESS, std::string())); | |
356 | |
357 // Matches the AddRef in Run(). | |
358 Release(); | |
359 } | |
360 | |
361 template<typename Params> | |
362 void WebstorePrivateFunctionWithPermissionPrompt<Params>::InstallUIAbort( | |
363 bool user_initiated) { | |
364 InstallUIAbortHook(user_initiated); | |
not at google - send to devlin
2015/02/26 17:25:07
Yep, this is what I meant. Thanks.
| |
365 | |
366 Respond(BuildResponse(api::webstore_private::RESULT_USER_CANCELLED, | |
367 kUserCancelledError)); | |
368 | |
369 // Matches the AddRef in Run(). | |
370 Release(); | |
371 } | |
372 | |
373 WebstorePrivateBeginInstallWithManifest3Function:: | |
374 WebstorePrivateBeginInstallWithManifest3Function() : chrome_details_(this) { | |
375 } | |
376 | |
377 WebstorePrivateBeginInstallWithManifest3Function:: | |
378 ~WebstorePrivateBeginInstallWithManifest3Function() { | |
379 } | |
380 | |
381 ExtensionFunction::ResponseValue | |
382 WebstorePrivateBeginInstallWithManifest3Function::RunExtraForResponse() { | |
383 InstallTracker* tracker = InstallTracker::Get(browser_context()); | |
384 DCHECK(tracker); | |
385 if (util::IsExtensionInstalledPermanently(params().details.id, | |
386 browser_context()) || | |
387 tracker->GetActiveInstall(params().details.id)) { | |
388 return BuildResponse(api::webstore_private::RESULT_ALREADY_INSTALLED, | |
389 kAlreadyInstalledError); | |
390 } | |
391 ActiveInstallData install_data(params().details.id); | |
392 scoped_active_install_.reset(new ScopedActiveInstall(tracker, install_data)); | |
393 return ExtensionFunction::ResponseValue(); | |
394 } | |
395 | |
396 void WebstorePrivateBeginInstallWithManifest3Function::InstallUIProceedHook() { | |
331 // This gets cleared in CrxInstaller::ConfirmInstall(). TODO(asargent) - in | 397 // This gets cleared in CrxInstaller::ConfirmInstall(). TODO(asargent) - in |
332 // the future we may also want to add time-based expiration, where a whitelist | 398 // the future we may also want to add time-based expiration, where a whitelist |
333 // entry is only valid for some number of minutes. | 399 // entry is only valid for some number of minutes. |
334 scoped_ptr<WebstoreInstaller::Approval> approval( | 400 scoped_ptr<WebstoreInstaller::Approval> approval( |
335 WebstoreInstaller::Approval::CreateWithNoInstallPrompt( | 401 WebstoreInstaller::Approval::CreateWithNoInstallPrompt( |
336 chrome_details_.GetProfile(), | 402 chrome_details_.GetProfile(), |
337 params_->details.id, | 403 params().details.id, |
338 parsed_manifest_.Pass(), | 404 PassParsedManifest(), |
339 false)); | 405 false)); |
340 approval->use_app_installed_bubble = params_->details.app_install_bubble; | 406 approval->use_app_installed_bubble = params().details.app_install_bubble; |
341 approval->enable_launcher = params_->details.enable_launcher; | 407 approval->enable_launcher = params().details.enable_launcher; |
342 // If we are enabling the launcher, we should not show the app list in order | 408 // If we are enabling the launcher, we should not show the app list in order |
343 // to train the user to open it themselves at least once. | 409 // to train the user to open it themselves at least once. |
344 approval->skip_post_install_ui = params_->details.enable_launcher; | 410 approval->skip_post_install_ui = params().details.enable_launcher; |
345 approval->dummy_extension = dummy_extension_; | 411 approval->dummy_extension = dummy_extension(); |
346 approval->installing_icon = gfx::ImageSkia::CreateFrom1xBitmap(icon_); | 412 approval->installing_icon = gfx::ImageSkia::CreateFrom1xBitmap(icon()); |
347 approval->authuser = authuser_; | 413 if (params().details.authuser) |
414 approval->authuser = *params().details.authuser; | |
348 g_pending_approvals.Get().PushApproval(approval.Pass()); | 415 g_pending_approvals.Get().PushApproval(approval.Pass()); |
349 | 416 |
350 DCHECK(scoped_active_install_.get()); | 417 DCHECK(scoped_active_install_.get()); |
351 scoped_active_install_->CancelDeregister(); | 418 scoped_active_install_->CancelDeregister(); |
352 | 419 |
353 Respond(BuildResponseForSuccess()); | |
354 | |
355 // The Permissions_Install histogram is recorded from the ExtensionService | 420 // The Permissions_Install histogram is recorded from the ExtensionService |
356 // for all extension installs, so we only need to record the web store | 421 // for all extension installs, so we only need to record the web store |
357 // specific histogram here. | 422 // specific histogram here. |
358 ExtensionService::RecordPermissionMessagesHistogram( | 423 ExtensionService::RecordPermissionMessagesHistogram( |
359 dummy_extension_.get(), "Extensions.Permissions_WebStoreInstall2"); | 424 dummy_extension().get(), "Extensions.Permissions_WebStoreInstall2"); |
360 | |
361 // Matches the AddRef in Run(). | |
362 Release(); | |
363 } | 425 } |
364 | 426 |
365 void WebstorePrivateBeginInstallWithManifest3Function::InstallUIAbort( | 427 void WebstorePrivateBeginInstallWithManifest3Function::InstallUIAbortHook( |
366 bool user_initiated) { | 428 bool user_initiated) { |
367 Respond(BuildResponseForError( | |
368 api::webstore_private::RESULT_USER_CANCELLED, | |
369 kUserCancelledError)); | |
370 | |
371 // The web store install histograms are a subset of the install histograms. | 429 // The web store install histograms are a subset of the install histograms. |
372 // We need to record both histograms here since CrxInstaller::InstallUIAbort | 430 // We need to record both histograms here since CrxInstaller::InstallUIAbort |
373 // is never called for web store install cancellations. | 431 // is never called for web store install cancellations. |
374 std::string histogram_name = | 432 std::string histogram_name = |
375 user_initiated ? "Extensions.Permissions_WebStoreInstallCancel2" | 433 user_initiated ? "Extensions.Permissions_WebStoreInstallCancel2" |
376 : "Extensions.Permissions_WebStoreInstallAbort2"; | 434 : "Extensions.Permissions_WebStoreInstallAbort2"; |
377 ExtensionService::RecordPermissionMessagesHistogram(dummy_extension_.get(), | 435 ExtensionService::RecordPermissionMessagesHistogram(dummy_extension().get(), |
378 histogram_name.c_str()); | 436 histogram_name.c_str()); |
379 | 437 |
380 histogram_name = user_initiated ? "Extensions.Permissions_InstallCancel2" | 438 histogram_name = user_initiated ? "Extensions.Permissions_InstallCancel2" |
381 : "Extensions.Permissions_InstallAbort2"; | 439 : "Extensions.Permissions_InstallAbort2"; |
382 ExtensionService::RecordPermissionMessagesHistogram(dummy_extension_.get(), | 440 ExtensionService::RecordPermissionMessagesHistogram(dummy_extension().get(), |
383 histogram_name.c_str()); | 441 histogram_name.c_str()); |
384 | |
385 // Matches the AddRef in Run(). | |
386 Release(); | |
387 } | 442 } |
388 | 443 |
389 ExtensionFunction::ResponseValue | 444 void WebstorePrivateBeginInstallWithManifest3Function::ShowPrompt( |
390 WebstorePrivateBeginInstallWithManifest3Function::BuildResponseForSuccess() { | 445 ExtensionInstallPrompt* install_prompt) { |
391 // The web store expects an empty string on success, so don't use | 446 install_prompt->ConfirmWebstoreInstall( |
392 // RESULT_SUCCESS here. | 447 this, dummy_extension().get(), &icon(), |
393 return ArgumentList(BeginInstallWithManifest3::Results::Create( | 448 ExtensionInstallPrompt::GetDefaultShowDialogCallback()); |
394 api::webstore_private::RESULT_EMPTY_STRING)); | |
395 } | 449 } |
396 | 450 |
397 ExtensionFunction::ResponseValue | 451 scoped_ptr<base::ListValue> |
398 WebstorePrivateBeginInstallWithManifest3Function::BuildResponseForError( | 452 WebstorePrivateBeginInstallWithManifest3Function::CreateResults( |
not at google - send to devlin
2015/02/26 17:25:08
You can share the implementation here by templatis
Marc Treib
2015/02/27 09:33:19
Unfortunatly I can't (unless I'm missing something
not at google - send to devlin
2015/02/27 16:24:03
Ah, bummer, these are namespaces. Ugh well that wa
| |
399 api::webstore_private::Result result, const std::string& error) { | 453 api::webstore_private::Result result) const { |
400 return ErrorWithArguments(BeginInstallWithManifest3::Results::Create(result), | 454 return BeginInstallWithManifest3::Results::Create(result); |
401 error); | |
402 } | 455 } |
403 | 456 |
404 WebstorePrivateCompleteInstallFunction:: | 457 WebstorePrivateCompleteInstallFunction:: |
405 WebstorePrivateCompleteInstallFunction() : chrome_details_(this) {} | 458 WebstorePrivateCompleteInstallFunction() : chrome_details_(this) {} |
406 | 459 |
407 WebstorePrivateCompleteInstallFunction:: | 460 WebstorePrivateCompleteInstallFunction:: |
408 ~WebstorePrivateCompleteInstallFunction() {} | 461 ~WebstorePrivateCompleteInstallFunction() {} |
409 | 462 |
410 ExtensionFunction::ResponseAction | 463 ExtensionFunction::ResponseAction |
411 WebstorePrivateCompleteInstallFunction::Run() { | 464 WebstorePrivateCompleteInstallFunction::Run() { |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
509 // Matches the AddRef in Run(). | 562 // Matches the AddRef in Run(). |
510 Release(); | 563 Release(); |
511 } | 564 } |
512 | 565 |
513 void WebstorePrivateCompleteInstallFunction::OnInstallSuccess( | 566 void WebstorePrivateCompleteInstallFunction::OnInstallSuccess( |
514 const std::string& id) { | 567 const std::string& id) { |
515 if (test_webstore_installer_delegate) | 568 if (test_webstore_installer_delegate) |
516 test_webstore_installer_delegate->OnExtensionInstallSuccess(id); | 569 test_webstore_installer_delegate->OnExtensionInstallSuccess(id); |
517 } | 570 } |
518 | 571 |
572 WebstorePrivateShowPermissionPromptForDelegatedInstallFunction:: | |
573 WebstorePrivateShowPermissionPromptForDelegatedInstallFunction() { | |
574 } | |
575 | |
576 WebstorePrivateShowPermissionPromptForDelegatedInstallFunction:: | |
577 ~WebstorePrivateShowPermissionPromptForDelegatedInstallFunction() { | |
578 } | |
579 | |
580 void WebstorePrivateShowPermissionPromptForDelegatedInstallFunction::ShowPrompt( | |
581 ExtensionInstallPrompt* install_prompt) { | |
582 install_prompt->ConfirmPermissionsForDelegatedInstall( | |
583 this, dummy_extension().get(), params().details.delegated_user, &icon()); | |
584 } | |
585 | |
586 scoped_ptr<base::ListValue> | |
587 WebstorePrivateShowPermissionPromptForDelegatedInstallFunction::CreateResults( | |
588 api::webstore_private::Result result) const { | |
589 return ShowPermissionPromptForDelegatedInstall::Results::Create(result); | |
590 } | |
591 | |
519 WebstorePrivateEnableAppLauncherFunction:: | 592 WebstorePrivateEnableAppLauncherFunction:: |
520 WebstorePrivateEnableAppLauncherFunction() : chrome_details_(this) {} | 593 WebstorePrivateEnableAppLauncherFunction() : chrome_details_(this) {} |
521 | 594 |
522 WebstorePrivateEnableAppLauncherFunction:: | 595 WebstorePrivateEnableAppLauncherFunction:: |
523 ~WebstorePrivateEnableAppLauncherFunction() {} | 596 ~WebstorePrivateEnableAppLauncherFunction() {} |
524 | 597 |
525 ExtensionFunction::ResponseAction | 598 ExtensionFunction::ResponseAction |
526 WebstorePrivateEnableAppLauncherFunction::Run() { | 599 WebstorePrivateEnableAppLauncherFunction::Run() { |
527 AppListService* app_list_service = AppListService::Get( | 600 AppListService* app_list_service = AppListService::Get( |
528 GetHostDesktopTypeForWebContents( | 601 GetHostDesktopTypeForWebContents( |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
689 WebstorePrivateGetEphemeralAppsEnabledFunction:: | 762 WebstorePrivateGetEphemeralAppsEnabledFunction:: |
690 ~WebstorePrivateGetEphemeralAppsEnabledFunction() {} | 763 ~WebstorePrivateGetEphemeralAppsEnabledFunction() {} |
691 | 764 |
692 ExtensionFunction::ResponseAction | 765 ExtensionFunction::ResponseAction |
693 WebstorePrivateGetEphemeralAppsEnabledFunction::Run() { | 766 WebstorePrivateGetEphemeralAppsEnabledFunction::Run() { |
694 return RespondNow(ArgumentList(GetEphemeralAppsEnabled::Results::Create( | 767 return RespondNow(ArgumentList(GetEphemeralAppsEnabled::Results::Create( |
695 EphemeralAppLauncher::IsFeatureEnabled()))); | 768 EphemeralAppLauncher::IsFeatureEnabled()))); |
696 } | 769 } |
697 | 770 |
698 } // namespace extensions | 771 } // namespace extensions |
OLD | NEW |