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

Side by Side Diff: chrome/browser/extensions/extension_install_prompt.h

Issue 1534123002: [Extensions] Migrate ExtensionInstallPrompt::Delegate to be a callback (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_INSTALL_PROMPT_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_INSTALL_PROMPT_H_
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_INSTALL_PROMPT_H_ 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_INSTALL_PROMPT_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <string> 10 #include <string>
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 252
253 std::vector<base::FilePath> retained_files_; 253 std::vector<base::FilePath> retained_files_;
254 std::vector<base::string16> retained_device_messages_; 254 std::vector<base::string16> retained_device_messages_;
255 255
256 DISALLOW_COPY_AND_ASSIGN(Prompt); 256 DISALLOW_COPY_AND_ASSIGN(Prompt);
257 }; 257 };
258 258
259 static const int kMinExtensionRating = 0; 259 static const int kMinExtensionRating = 0;
260 static const int kMaxExtensionRating = 5; 260 static const int kMaxExtensionRating = 5;
261 261
262 class Delegate { 262 enum class Result {
263 public: 263 ACCEPTED,
264 // We call this method to signal that the installation should continue. 264 USER_CANCELED,
265 virtual void InstallUIProceed() = 0; 265 ABORTED,
266
267 // We call this method to signal that the installation should stop, with
268 // |user_initiated| true if the installation was stopped by the user.
269 virtual void InstallUIAbort(bool user_initiated) = 0;
270
271 protected:
272 virtual ~Delegate() {}
273 }; 266 };
274 267
268 using DoneCallback = base::Callback<void(Result result)>;
269
275 typedef base::Callback<void(ExtensionInstallPromptShowParams*, 270 typedef base::Callback<void(ExtensionInstallPromptShowParams*,
276 ExtensionInstallPrompt::Delegate*, 271 const DoneCallback&,
277 scoped_ptr<ExtensionInstallPrompt::Prompt>)> 272 scoped_ptr<ExtensionInstallPrompt::Prompt>)>
278 ShowDialogCallback; 273 ShowDialogCallback;
279 274
280 // Callback to show the default extension install dialog. 275 // Callback to show the default extension install dialog.
281 // The implementations of this function are platform-specific. 276 // The implementations of this function are platform-specific.
282 static ShowDialogCallback GetDefaultShowDialogCallback(); 277 static ShowDialogCallback GetDefaultShowDialogCallback();
283 278
284 // Returns the appropriate prompt type for the given |extension|. 279 // Returns the appropriate prompt type for the given |extension|.
285 // TODO(devlin): This method is yucky - callers probably only care about one 280 // TODO(devlin): This method is yucky - callers probably only care about one
286 // prompt type. We just need to comb through and figure out what it is. 281 // prompt type. We just need to comb through and figure out what it is.
(...skipping 29 matching lines...) Expand all
316 // null), sets up the Prompt, and calls |show_dialog_callback| when ready to 311 // null), sets up the Prompt, and calls |show_dialog_callback| when ready to
317 // show. 312 // show.
318 // |extension| can be null in the case of a bndle install. 313 // |extension| can be null in the case of a bndle install.
319 // If |icon| is null, this will attempt to load the extension's icon. 314 // If |icon| is null, this will attempt to load the extension's icon.
320 // |prompt| is used to pass in a prompt with additional data (like retained 315 // |prompt| is used to pass in a prompt with additional data (like retained
321 // device permissions) or a different type. If not provided, |prompt| will 316 // device permissions) or a different type. If not provided, |prompt| will
322 // be created as an INSTALL_PROMPT. 317 // be created as an INSTALL_PROMPT.
323 // |custom_permissions| will be used if provided; otherwise, the extensions 318 // |custom_permissions| will be used if provided; otherwise, the extensions
324 // current permissions are used. 319 // current permissions are used.
325 // 320 //
326 // We *MUST* eventually call either Proceed() or Abort() on |delegate|. 321 // The |install_callback| *MUST* eventually be called.
327 void ShowDialog(Delegate* delegate, 322 void ShowDialog(const DoneCallback& install_callback,
328 const extensions::Extension* extension, 323 const extensions::Extension* extension,
329 const SkBitmap* icon, 324 const SkBitmap* icon,
330 const ShowDialogCallback& show_dialog_callback); 325 const ShowDialogCallback& show_dialog_callback);
331 void ShowDialog(Delegate* delegate, 326 void ShowDialog(const DoneCallback& install_callback,
332 const extensions::Extension* extension, 327 const extensions::Extension* extension,
333 const SkBitmap* icon, 328 const SkBitmap* icon,
334 scoped_ptr<Prompt> prompt, 329 scoped_ptr<Prompt> prompt,
335 const ShowDialogCallback& show_dialog_callback); 330 const ShowDialogCallback& show_dialog_callback);
336 // Declared virtual for testing purposes. 331 // Declared virtual for testing purposes.
337 // Note: if all you want to do is automatically confirm or cancel, prefer 332 // Note: if all you want to do is automatically confirm or cancel, prefer
338 // ScopedTestDialogAutoConfirm from extension_dialog_auto_confirm.h 333 // ScopedTestDialogAutoConfirm from extension_dialog_auto_confirm.h
339 virtual void ShowDialog( 334 virtual void ShowDialog(
340 Delegate* delegate, 335 const DoneCallback& install_callback,
341 const extensions::Extension* extension, 336 const extensions::Extension* extension,
342 const SkBitmap* icon, 337 const SkBitmap* icon,
343 scoped_ptr<Prompt> prompt, 338 scoped_ptr<Prompt> prompt,
344 scoped_ptr<const extensions::PermissionSet> custom_permissions, 339 scoped_ptr<const extensions::PermissionSet> custom_permissions,
345 const ShowDialogCallback& show_dialog_callback); 340 const ShowDialogCallback& show_dialog_callback);
346 341
347 // Installation was successful. This is declared virtual for testing. 342 // Installation was successful. This is declared virtual for testing.
348 virtual void OnInstallSuccess(const extensions::Extension* extension, 343 virtual void OnInstallSuccess(const extensions::Extension* extension,
349 SkBitmap* icon); 344 SkBitmap* icon);
350 345
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 // A custom set of permissions to show in the install prompt instead of the 384 // A custom set of permissions to show in the install prompt instead of the
390 // extension's active permissions. 385 // extension's active permissions.
391 scoped_ptr<const extensions::PermissionSet> custom_permissions_; 386 scoped_ptr<const extensions::PermissionSet> custom_permissions_;
392 387
393 // The object responsible for doing the UI specific actions. 388 // The object responsible for doing the UI specific actions.
394 scoped_ptr<extensions::ExtensionInstallUI> install_ui_; 389 scoped_ptr<extensions::ExtensionInstallUI> install_ui_;
395 390
396 // Parameters to show the confirmation UI. 391 // Parameters to show the confirmation UI.
397 scoped_ptr<ExtensionInstallPromptShowParams> show_params_; 392 scoped_ptr<ExtensionInstallPromptShowParams> show_params_;
398 393
399 // The delegate we will call Proceed/Abort on after confirmation UI. 394 // The callback to run with the result.
400 Delegate* delegate_; 395 DoneCallback done_callback_;
401 396
402 // A pre-filled prompt. 397 // A pre-filled prompt.
403 scoped_ptr<Prompt> prompt_; 398 scoped_ptr<Prompt> prompt_;
404 399
405 // Used to show the confirm dialog. 400 // Used to show the confirm dialog.
406 ShowDialogCallback show_dialog_callback_; 401 ShowDialogCallback show_dialog_callback_;
407 402
408 // Whether or not the |show_dialog_callback_| was called. 403 // Whether or not the |show_dialog_callback_| was called.
409 bool did_call_show_dialog_; 404 bool did_call_show_dialog_;
410 405
411 DISALLOW_COPY_AND_ASSIGN(ExtensionInstallPrompt); 406 DISALLOW_COPY_AND_ASSIGN(ExtensionInstallPrompt);
412 }; 407 };
413 408
414 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_INSTALL_PROMPT_H_ 409 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_INSTALL_PROMPT_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_disabled_ui.cc ('k') | chrome/browser/extensions/extension_install_prompt.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698