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

Side by Side Diff: chrome/browser/extensions/api/webstore_private/webstore_private_api.cc

Issue 850283003: Add a new webstorePrivate API to show a permission prompt for delegated installs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@testext_permission_prompt
Patch Set: common base class Created 5 years, 9 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 (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
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
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
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 bool WebstorePrivateFunctionWithPermissionPrompt<Params>::RunImpl(
216 api::webstore_private::Result* result,
217 std::string* error) {
218 return false;
219 }
220
221 template<typename Params>
222 scoped_ptr<base::DictionaryValue>
223 WebstorePrivateFunctionWithPermissionPrompt<Params>::PassParsedManifest() {
224 return parsed_manifest_.Pass();
225 }
226
227 template<typename Params>
196 ExtensionFunction::ResponseAction 228 ExtensionFunction::ResponseAction
197 WebstorePrivateBeginInstallWithManifest3Function::Run() { 229 WebstorePrivateFunctionWithPermissionPrompt<Params>::Run() {
198 params_ = BeginInstallWithManifest3::Params::Create(*args_); 230 params_ = Params::Create(*args_);
199 EXTENSION_FUNCTION_VALIDATE(params_); 231 EXTENSION_FUNCTION_VALIDATE(params_);
200 232
201 if (!crx_file::id_util::IdIsValid(params_->details.id)) { 233 if (!crx_file::id_util::IdIsValid(params_->details.id)) {
202 return RespondNow(BuildResponseForError( 234 return RespondNow(BuildResponse(api::webstore_private::RESULT_INVALID_ID,
203 api::webstore_private::RESULT_INVALID_ID, 235 kInvalidIdError));
204 kInvalidIdError));
205 } 236 }
206 237
207 if (params_->details.icon_data && params_->details.icon_url) { 238 if (params_->details.icon_data && params_->details.icon_url) {
208 return RespondNow(BuildResponseForError( 239 return RespondNow(BuildResponse(api::webstore_private::RESULT_ICON_ERROR,
209 api::webstore_private::RESULT_ICON_ERROR, 240 kCannotSpecifyIconDataAndUrlError));
210 kCannotSpecifyIconDataAndUrlError));
211 } 241 }
212 242
213 GURL icon_url; 243 GURL icon_url;
214 if (params_->details.icon_url) { 244 if (params_->details.icon_url) {
215 std::string tmp_url;
216 icon_url = source_url().Resolve(*params_->details.icon_url); 245 icon_url = source_url().Resolve(*params_->details.icon_url);
217 if (!icon_url.is_valid()) { 246 if (!icon_url.is_valid()) {
218 return RespondNow(BuildResponseForError( 247 return RespondNow(BuildResponse(
219 api::webstore_private::RESULT_INVALID_ICON_URL, 248 api::webstore_private::RESULT_INVALID_ICON_URL,
220 kInvalidIconUrlError)); 249 kInvalidIconUrlError));
221 } 250 }
222 } 251 }
223 252
224 if (params_->details.authuser) {
225 authuser_ = *params_->details.authuser;
226 }
227
228 std::string icon_data = params_->details.icon_data ? 253 std::string icon_data = params_->details.icon_data ?
229 *params_->details.icon_data : std::string(); 254 *params_->details.icon_data : std::string();
230 255
231 InstallTracker* tracker = InstallTracker::Get(browser_context()); 256 api::webstore_private::Result result;
232 DCHECK(tracker); 257 std::string error;
233 if (util::IsExtensionInstalledPermanently(params_->details.id, 258 if (RunImpl(&result, &error))
not at google - send to devlin 2015/02/25 17:23:00 RunImpl isn't a very helpful name. How about a met
not at google - send to devlin 2015/02/25 17:24:41 RunExtraForResponse? RunHookForResponse?
Marc Treib 2015/02/26 11:49:58 Done.
234 browser_context()) || 259 return RespondNow(BuildResponse(result, error));
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 260
243 net::URLRequestContextGetter* context_getter = NULL; 261 net::URLRequestContextGetter* context_getter = NULL;
244 if (!icon_url.is_empty()) 262 if (!icon_url.is_empty())
245 context_getter = browser_context()->GetRequestContext(); 263 context_getter = browser_context()->GetRequestContext();
246 264
247 scoped_refptr<WebstoreInstallHelper> helper = new WebstoreInstallHelper( 265 scoped_refptr<WebstoreInstallHelper> helper = new WebstoreInstallHelper(
248 this, params_->details.id, params_->details.manifest, icon_data, icon_url, 266 this, params_->details.id, params_->details.manifest, icon_data, icon_url,
249 context_getter); 267 context_getter);
250 268
251 // The helper will call us back via OnWebstoreParseSuccess or 269 // The helper will call us back via OnWebstoreParseSuccess or
252 // OnWebstoreParseFailure. 270 // OnWebstoreParseFailure.
253 helper->Start(); 271 helper->Start();
254 272
255 // Matched with a Release in OnWebstoreParseSuccess/OnWebstoreParseFailure. 273 // Matched with a Release in OnWebstoreParseSuccess/OnWebstoreParseFailure.
256 AddRef(); 274 AddRef();
257 275
258 // The response is sent asynchronously in OnWebstoreParseSuccess/ 276 // The response is sent asynchronously in OnWebstoreParseSuccess/
259 // OnWebstoreParseFailure. 277 // OnWebstoreParseFailure.
260 return RespondLater(); 278 return RespondLater();
261 } 279 }
262 280
263 void WebstorePrivateBeginInstallWithManifest3Function::OnWebstoreParseSuccess( 281 template<typename Params>
282 void
283 WebstorePrivateFunctionWithPermissionPrompt<Params>::OnWebstoreParseSuccess(
264 const std::string& id, 284 const std::string& id,
265 const SkBitmap& icon, 285 const SkBitmap& icon,
266 base::DictionaryValue* parsed_manifest) { 286 base::DictionaryValue* parsed_manifest) {
267 CHECK_EQ(params_->details.id, id); 287 CHECK_EQ(params_->details.id, id);
268 CHECK(parsed_manifest); 288 CHECK(parsed_manifest);
269 icon_ = icon; 289 icon_ = icon;
270 parsed_manifest_.reset(parsed_manifest); 290 parsed_manifest_.reset(parsed_manifest);
271 291
272 std::string localized_name = params_->details.localized_name ? 292 std::string localized_name = params_->details.localized_name ?
273 *params_->details.localized_name : std::string(); 293 *params_->details.localized_name : std::string();
274 294
275 std::string error; 295 std::string error;
276 dummy_extension_ = ExtensionInstallPrompt::GetLocalizedExtensionForDisplay( 296 dummy_extension_ = ExtensionInstallPrompt::GetLocalizedExtensionForDisplay(
277 parsed_manifest_.get(), 297 parsed_manifest_.get(),
278 Extension::FROM_WEBSTORE, 298 Extension::FROM_WEBSTORE,
279 id, 299 id,
280 localized_name, 300 localized_name,
281 std::string(), 301 std::string(),
282 &error); 302 &error);
283 303
284 if (!dummy_extension_.get()) { 304 if (!dummy_extension_.get()) {
285 OnWebstoreParseFailure(params_->details.id, 305 OnWebstoreParseFailure(params_->details.id,
286 WebstoreInstallHelper::Delegate::MANIFEST_ERROR, 306 WebstoreInstallHelper::Delegate::MANIFEST_ERROR,
287 kInvalidManifestError); 307 kInvalidManifestError);
288 return; 308 return;
289 } 309 }
290 310
291 content::WebContents* web_contents = GetAssociatedWebContents(); 311 content::WebContents* web_contents = GetAssociatedWebContents();
292 if (!web_contents) // The browser window has gone away. 312 if (!web_contents) {
313 // The browser window has gone away.
314 Respond(BuildResponse(api::webstore_private::RESULT_USER_CANCELLED,
315 kUserCancelledError));
316 // Matches the AddRef in Run().
317 Release();
293 return; 318 return;
319 }
294 install_prompt_.reset(new ExtensionInstallPrompt(web_contents)); 320 install_prompt_.reset(new ExtensionInstallPrompt(web_contents));
295 install_prompt_->ConfirmWebstoreInstall( 321 ShowPrompt(install_prompt_.get());
296 this,
297 dummy_extension_.get(),
298 &icon_,
299 ExtensionInstallPrompt::GetDefaultShowDialogCallback());
300 // Control flow finishes up in InstallUIProceed or InstallUIAbort. 322 // Control flow finishes up in InstallUIProceed or InstallUIAbort.
301 } 323 }
302 324
303 void WebstorePrivateBeginInstallWithManifest3Function::OnWebstoreParseFailure( 325 template<typename Params>
326 void
327 WebstorePrivateFunctionWithPermissionPrompt<Params>::OnWebstoreParseFailure(
304 const std::string& id, 328 const std::string& id,
305 WebstoreInstallHelper::Delegate::InstallHelperResultCode result, 329 WebstoreInstallHelper::Delegate::InstallHelperResultCode result,
306 const std::string& error_message) { 330 const std::string& error_message) {
307 CHECK_EQ(params_->details.id, id); 331 CHECK_EQ(params_->details.id, id);
308 332
309 // Map from WebstoreInstallHelper's result codes to ours. 333 Respond(BuildResponse(WebstoreInstallHelperResultToApiResult(result),
310 api::webstore_private::Result api_result = 334 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 335
326 // Matches the AddRef in Run(). 336 // Matches the AddRef in Run().
327 Release(); 337 Release();
328 } 338 }
329 339
330 void WebstorePrivateBeginInstallWithManifest3Function::InstallUIProceed() { 340 template<typename Params>
341 void WebstorePrivateFunctionWithPermissionPrompt<Params>::InstallUIProceed() {
not at google - send to devlin 2015/02/25 17:23:00 It would be nice to avoid needing these extra Inst
Marc Treib 2015/02/26 11:49:58 I'm not sure I understand the question. These are
342 OnInstallUIProceed();
343
344 Respond(BuildResponse(api::webstore_private::RESULT_SUCCESS, std::string()));
345
346 // Matches the AddRef in Run().
347 Release();
348 }
349
350 template<typename Params>
351 void WebstorePrivateFunctionWithPermissionPrompt<Params>::InstallUIAbort(
352 bool user_initiated) {
353 OnInstallUIAbort(user_initiated);
354
355 Respond(BuildResponse(api::webstore_private::RESULT_USER_CANCELLED,
356 kUserCancelledError));
357
358 // Matches the AddRef in Run().
359 Release();
360 }
361
362 WebstorePrivateBeginInstallWithManifest3Function::
363 WebstorePrivateBeginInstallWithManifest3Function() : chrome_details_(this) {
364 }
365
366 WebstorePrivateBeginInstallWithManifest3Function::
367 ~WebstorePrivateBeginInstallWithManifest3Function() {
368 }
369
370 bool WebstorePrivateBeginInstallWithManifest3Function::RunImpl(
371 api::webstore_private::Result* result,
372 std::string* error) {
373 InstallTracker* tracker = InstallTracker::Get(browser_context());
374 DCHECK(tracker);
375 if (util::IsExtensionInstalledPermanently(params().details.id,
376 browser_context()) ||
377 tracker->GetActiveInstall(params().details.id)) {
378 *result = api::webstore_private::RESULT_ALREADY_INSTALLED;
379 *error = kAlreadyInstalledError;
380 return true;
381 }
382 ActiveInstallData install_data(params().details.id);
383 scoped_active_install_.reset(new ScopedActiveInstall(tracker, install_data));
384 return false;
385 }
386
387 void WebstorePrivateBeginInstallWithManifest3Function::OnInstallUIProceed() {
331 // This gets cleared in CrxInstaller::ConfirmInstall(). TODO(asargent) - in 388 // This gets cleared in CrxInstaller::ConfirmInstall(). TODO(asargent) - in
332 // the future we may also want to add time-based expiration, where a whitelist 389 // the future we may also want to add time-based expiration, where a whitelist
333 // entry is only valid for some number of minutes. 390 // entry is only valid for some number of minutes.
334 scoped_ptr<WebstoreInstaller::Approval> approval( 391 scoped_ptr<WebstoreInstaller::Approval> approval(
335 WebstoreInstaller::Approval::CreateWithNoInstallPrompt( 392 WebstoreInstaller::Approval::CreateWithNoInstallPrompt(
336 chrome_details_.GetProfile(), 393 chrome_details_.GetProfile(),
337 params_->details.id, 394 params().details.id,
338 parsed_manifest_.Pass(), 395 PassParsedManifest(),
339 false)); 396 false));
340 approval->use_app_installed_bubble = params_->details.app_install_bubble; 397 approval->use_app_installed_bubble = params().details.app_install_bubble;
341 approval->enable_launcher = params_->details.enable_launcher; 398 approval->enable_launcher = params().details.enable_launcher;
342 // If we are enabling the launcher, we should not show the app list in order 399 // 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. 400 // to train the user to open it themselves at least once.
344 approval->skip_post_install_ui = params_->details.enable_launcher; 401 approval->skip_post_install_ui = params().details.enable_launcher;
345 approval->dummy_extension = dummy_extension_; 402 approval->dummy_extension = dummy_extension();
346 approval->installing_icon = gfx::ImageSkia::CreateFrom1xBitmap(icon_); 403 approval->installing_icon = gfx::ImageSkia::CreateFrom1xBitmap(icon());
347 approval->authuser = authuser_; 404 if (params().details.authuser)
405 approval->authuser = *params().details.authuser;
348 g_pending_approvals.Get().PushApproval(approval.Pass()); 406 g_pending_approvals.Get().PushApproval(approval.Pass());
349 407
350 DCHECK(scoped_active_install_.get()); 408 DCHECK(scoped_active_install_.get());
351 scoped_active_install_->CancelDeregister(); 409 scoped_active_install_->CancelDeregister();
352 410
353 Respond(BuildResponseForSuccess());
354
355 // The Permissions_Install histogram is recorded from the ExtensionService 411 // The Permissions_Install histogram is recorded from the ExtensionService
356 // for all extension installs, so we only need to record the web store 412 // for all extension installs, so we only need to record the web store
357 // specific histogram here. 413 // specific histogram here.
358 ExtensionService::RecordPermissionMessagesHistogram( 414 ExtensionService::RecordPermissionMessagesHistogram(
359 dummy_extension_.get(), "Extensions.Permissions_WebStoreInstall2"); 415 dummy_extension().get(), "Extensions.Permissions_WebStoreInstall2");
360
361 // Matches the AddRef in Run().
362 Release();
363 } 416 }
364 417
365 void WebstorePrivateBeginInstallWithManifest3Function::InstallUIAbort( 418 void WebstorePrivateBeginInstallWithManifest3Function::OnInstallUIAbort(
366 bool user_initiated) { 419 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. 420 // The web store install histograms are a subset of the install histograms.
372 // We need to record both histograms here since CrxInstaller::InstallUIAbort 421 // We need to record both histograms here since CrxInstaller::InstallUIAbort
373 // is never called for web store install cancellations. 422 // is never called for web store install cancellations.
374 std::string histogram_name = 423 std::string histogram_name =
375 user_initiated ? "Extensions.Permissions_WebStoreInstallCancel2" 424 user_initiated ? "Extensions.Permissions_WebStoreInstallCancel2"
376 : "Extensions.Permissions_WebStoreInstallAbort2"; 425 : "Extensions.Permissions_WebStoreInstallAbort2";
377 ExtensionService::RecordPermissionMessagesHistogram(dummy_extension_.get(), 426 ExtensionService::RecordPermissionMessagesHistogram(dummy_extension().get(),
378 histogram_name.c_str()); 427 histogram_name.c_str());
379 428
380 histogram_name = user_initiated ? "Extensions.Permissions_InstallCancel2" 429 histogram_name = user_initiated ? "Extensions.Permissions_InstallCancel2"
381 : "Extensions.Permissions_InstallAbort2"; 430 : "Extensions.Permissions_InstallAbort2";
382 ExtensionService::RecordPermissionMessagesHistogram(dummy_extension_.get(), 431 ExtensionService::RecordPermissionMessagesHistogram(dummy_extension().get(),
383 histogram_name.c_str()); 432 histogram_name.c_str());
433 }
384 434
385 // Matches the AddRef in Run(). 435 void WebstorePrivateBeginInstallWithManifest3Function::ShowPrompt(
386 Release(); 436 ExtensionInstallPrompt* install_prompt) {
437 install_prompt->ConfirmWebstoreInstall(
438 this, dummy_extension().get(), &icon(),
439 ExtensionInstallPrompt::GetDefaultShowDialogCallback());
387 } 440 }
388 441
389 ExtensionFunction::ResponseValue 442 ExtensionFunction::ResponseValue
390 WebstorePrivateBeginInstallWithManifest3Function::BuildResponseForSuccess() { 443 WebstorePrivateBeginInstallWithManifest3Function::BuildResponse(
444 api::webstore_private::Result result, const std::string& error) {
445 if (result != api::webstore_private::RESULT_SUCCESS) {
446 return ErrorWithArguments(
447 BeginInstallWithManifest3::Results::Create(result), error);
448 }
391 // The web store expects an empty string on success, so don't use 449 // The web store expects an empty string on success, so don't use
392 // RESULT_SUCCESS here. 450 // RESULT_SUCCESS here.
393 return ArgumentList(BeginInstallWithManifest3::Results::Create( 451 return ArgumentList(BeginInstallWithManifest3::Results::Create(
394 api::webstore_private::RESULT_EMPTY_STRING)); 452 api::webstore_private::RESULT_EMPTY_STRING));
395 } 453 }
396 454
397 ExtensionFunction::ResponseValue
398 WebstorePrivateBeginInstallWithManifest3Function::BuildResponseForError(
399 api::webstore_private::Result result, const std::string& error) {
400 return ErrorWithArguments(BeginInstallWithManifest3::Results::Create(result),
401 error);
402 }
403
404 WebstorePrivateCompleteInstallFunction:: 455 WebstorePrivateCompleteInstallFunction::
405 WebstorePrivateCompleteInstallFunction() : chrome_details_(this) {} 456 WebstorePrivateCompleteInstallFunction() : chrome_details_(this) {}
406 457
407 WebstorePrivateCompleteInstallFunction:: 458 WebstorePrivateCompleteInstallFunction::
408 ~WebstorePrivateCompleteInstallFunction() {} 459 ~WebstorePrivateCompleteInstallFunction() {}
409 460
410 ExtensionFunction::ResponseAction 461 ExtensionFunction::ResponseAction
411 WebstorePrivateCompleteInstallFunction::Run() { 462 WebstorePrivateCompleteInstallFunction::Run() {
412 scoped_ptr<CompleteInstall::Params> params( 463 scoped_ptr<CompleteInstall::Params> params(
413 CompleteInstall::Params::Create(*args_)); 464 CompleteInstall::Params::Create(*args_));
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 // Matches the AddRef in Run(). 560 // Matches the AddRef in Run().
510 Release(); 561 Release();
511 } 562 }
512 563
513 void WebstorePrivateCompleteInstallFunction::OnInstallSuccess( 564 void WebstorePrivateCompleteInstallFunction::OnInstallSuccess(
514 const std::string& id) { 565 const std::string& id) {
515 if (test_webstore_installer_delegate) 566 if (test_webstore_installer_delegate)
516 test_webstore_installer_delegate->OnExtensionInstallSuccess(id); 567 test_webstore_installer_delegate->OnExtensionInstallSuccess(id);
517 } 568 }
518 569
570 WebstorePrivateShowPermissionPromptForDelegatedInstallFunction::
571 WebstorePrivateShowPermissionPromptForDelegatedInstallFunction() {
572 }
573
574 WebstorePrivateShowPermissionPromptForDelegatedInstallFunction::
575 ~WebstorePrivateShowPermissionPromptForDelegatedInstallFunction() {
576 }
577
578 void WebstorePrivateShowPermissionPromptForDelegatedInstallFunction::ShowPrompt(
579 ExtensionInstallPrompt* install_prompt) {
580 install_prompt->ConfirmPermissionsForDelegatedInstall(
581 this, dummy_extension().get(), params().details.delegated_user, &icon());
582 }
583
584 ExtensionFunction::ResponseValue
585 WebstorePrivateShowPermissionPromptForDelegatedInstallFunction::BuildResponse(
586 api::webstore_private::Result result, const std::string& error) {
587 if (result != api::webstore_private::RESULT_SUCCESS) {
588 return ErrorWithArguments(
589 ShowPermissionPromptForDelegatedInstall::Results::Create(result),
590 error);
591 }
592 return ArgumentList(
593 ShowPermissionPromptForDelegatedInstall::Results::Create(result));
not at google - send to devlin 2015/02/25 17:23:00 For better or worse, I think showPermissionPromptF
Marc Treib 2015/02/26 11:49:58 Hrm... alright, consistency over correctness, I gu
not at google - send to devlin 2015/02/26 17:25:07 See last comment I left.
594 }
595
519 WebstorePrivateEnableAppLauncherFunction:: 596 WebstorePrivateEnableAppLauncherFunction::
520 WebstorePrivateEnableAppLauncherFunction() : chrome_details_(this) {} 597 WebstorePrivateEnableAppLauncherFunction() : chrome_details_(this) {}
521 598
522 WebstorePrivateEnableAppLauncherFunction:: 599 WebstorePrivateEnableAppLauncherFunction::
523 ~WebstorePrivateEnableAppLauncherFunction() {} 600 ~WebstorePrivateEnableAppLauncherFunction() {}
524 601
525 ExtensionFunction::ResponseAction 602 ExtensionFunction::ResponseAction
526 WebstorePrivateEnableAppLauncherFunction::Run() { 603 WebstorePrivateEnableAppLauncherFunction::Run() {
527 AppListService* app_list_service = AppListService::Get( 604 AppListService* app_list_service = AppListService::Get(
528 GetHostDesktopTypeForWebContents( 605 GetHostDesktopTypeForWebContents(
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
689 WebstorePrivateGetEphemeralAppsEnabledFunction:: 766 WebstorePrivateGetEphemeralAppsEnabledFunction::
690 ~WebstorePrivateGetEphemeralAppsEnabledFunction() {} 767 ~WebstorePrivateGetEphemeralAppsEnabledFunction() {}
691 768
692 ExtensionFunction::ResponseAction 769 ExtensionFunction::ResponseAction
693 WebstorePrivateGetEphemeralAppsEnabledFunction::Run() { 770 WebstorePrivateGetEphemeralAppsEnabledFunction::Run() {
694 return RespondNow(ArgumentList(GetEphemeralAppsEnabled::Results::Create( 771 return RespondNow(ArgumentList(GetEphemeralAppsEnabled::Results::Create(
695 EphemeralAppLauncher::IsFeatureEnabled()))); 772 EphemeralAppLauncher::IsFeatureEnabled())));
696 } 773 }
697 774
698 } // namespace extensions 775 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698