| 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 #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 <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 public base::SupportsWeakPtr<ExtensionInstallPrompt> { | 49 public base::SupportsWeakPtr<ExtensionInstallPrompt> { |
| 50 public: | 50 public: |
| 51 enum PromptType { | 51 enum PromptType { |
| 52 UNSET_PROMPT_TYPE = -1, | 52 UNSET_PROMPT_TYPE = -1, |
| 53 INSTALL_PROMPT = 0, | 53 INSTALL_PROMPT = 0, |
| 54 INLINE_INSTALL_PROMPT, | 54 INLINE_INSTALL_PROMPT, |
| 55 BUNDLE_INSTALL_PROMPT, | 55 BUNDLE_INSTALL_PROMPT, |
| 56 RE_ENABLE_PROMPT, | 56 RE_ENABLE_PROMPT, |
| 57 PERMISSIONS_PROMPT, | 57 PERMISSIONS_PROMPT, |
| 58 EXTERNAL_INSTALL_PROMPT, | 58 EXTERNAL_INSTALL_PROMPT, |
| 59 POST_INSTALL_PERMISSIONS_PROMPT, | |
| 60 NUM_PROMPT_TYPES | 59 NUM_PROMPT_TYPES |
| 61 }; | 60 }; |
| 62 | 61 |
| 63 // Extra information needed to display an installation or uninstallation | 62 // Extra information needed to display an installation or uninstallation |
| 64 // prompt. Gets populated with raw data and exposes getters for formatted | 63 // prompt. Gets populated with raw data and exposes getters for formatted |
| 65 // strings so that the GTK/views/Cocoa install dialogs don't have to repeat | 64 // strings so that the GTK/views/Cocoa install dialogs don't have to repeat |
| 66 // that logic. | 65 // that logic. |
| 67 class Prompt { | 66 class Prompt { |
| 68 public: | 67 public: |
| 69 explicit Prompt(PromptType type); | 68 explicit Prompt(PromptType type); |
| 70 ~Prompt(); | 69 ~Prompt(); |
| 71 | 70 |
| 72 void SetPermissions(const std::vector<string16>& permissions); | 71 void SetPermissions(const std::vector<string16>& permissions); |
| 73 void SetInlineInstallWebstoreData(const std::string& localized_user_count, | 72 void SetInlineInstallWebstoreData(const std::string& localized_user_count, |
| 74 double average_rating, | 73 double average_rating, |
| 75 int rating_count); | 74 int rating_count); |
| 76 void SetOAuthIssueAdvice(const IssueAdviceInfo& issue_advice); | 75 void SetOAuthIssueAdvice(const IssueAdviceInfo& issue_advice); |
| 77 void SetUserNameFromProfile(Profile* profile); | 76 void SetUserNameFromProfile(Profile* profile); |
| 78 | 77 |
| 79 PromptType type() const { return type_; } | 78 PromptType type() const { return type_; } |
| 80 void set_type(PromptType type) { type_ = type; } | 79 void set_type(PromptType type) { type_ = type; } |
| 81 | 80 |
| 82 // Getters for UI element labels. | 81 // Getters for UI element labels. |
| 83 string16 GetDialogTitle() const; | 82 string16 GetDialogTitle() const; |
| 84 string16 GetHeading() const; | 83 string16 GetHeading() const; |
| 85 int GetDialogButtons() const; | |
| 86 string16 GetAcceptButtonLabel() const; | 84 string16 GetAcceptButtonLabel() const; |
| 87 bool HasAbortButtonLabel() const; | 85 bool HasAbortButtonLabel() const; |
| 88 string16 GetAbortButtonLabel() const; | 86 string16 GetAbortButtonLabel() const; |
| 89 string16 GetPermissionsHeading() const; | 87 string16 GetPermissionsHeading() const; |
| 90 string16 GetOAuthHeading() const; | 88 string16 GetOAuthHeading() const; |
| 91 | 89 |
| 92 // Getters for webstore metadata. Only populated when the type is | 90 // Getters for webstore metadata. Only populated when the type is |
| 93 // INLINE_INSTALL_PROMPT. | 91 // INLINE_INSTALL_PROMPT. |
| 94 | 92 |
| 95 // The star display logic replicates the one used by the webstore (from | 93 // The star display logic replicates the one used by the webstore (from |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 const extensions::PermissionSet* permissions); | 273 const extensions::PermissionSet* permissions); |
| 276 | 274 |
| 277 // This is called by the extension identity API to verify whether an | 275 // This is called by the extension identity API to verify whether an |
| 278 // extension can be granted an OAuth2 token. | 276 // extension can be granted an OAuth2 token. |
| 279 // | 277 // |
| 280 // We *MUST* eventually call either Proceed() or Abort() on |delegate|. | 278 // We *MUST* eventually call either Proceed() or Abort() on |delegate|. |
| 281 virtual void ConfirmIssueAdvice(Delegate* delegate, | 279 virtual void ConfirmIssueAdvice(Delegate* delegate, |
| 282 const extensions::Extension* extension, | 280 const extensions::Extension* extension, |
| 283 const IssueAdviceInfo& issue_advice); | 281 const IssueAdviceInfo& issue_advice); |
| 284 | 282 |
| 285 // This is called by the app handler launcher to review what permissions the | |
| 286 // extension or app currently has. | |
| 287 // | |
| 288 // This *WILL* call Abort() on |delegate|. | |
| 289 virtual void ReviewPermissions(Delegate* delegate, | |
| 290 const extensions::Extension* extension); | |
| 291 | |
| 292 // Installation was successful. This is declared virtual for testing. | 283 // Installation was successful. This is declared virtual for testing. |
| 293 virtual void OnInstallSuccess(const extensions::Extension* extension, | 284 virtual void OnInstallSuccess(const extensions::Extension* extension, |
| 294 SkBitmap* icon); | 285 SkBitmap* icon); |
| 295 | 286 |
| 296 // Installation failed. This is declared virtual for testing. | 287 // Installation failed. This is declared virtual for testing. |
| 297 virtual void OnInstallFailure(const extensions::CrxInstallerError& error); | 288 virtual void OnInstallFailure(const extensions::CrxInstallerError& error); |
| 298 | 289 |
| 299 protected: | 290 protected: |
| 300 friend class extensions::ExtensionWebstorePrivateApiTest; | 291 friend class extensions::ExtensionWebstorePrivateApiTest; |
| 301 friend class extensions::MockGetAuthTokenFunction; | 292 friend class extensions::MockGetAuthTokenFunction; |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 // A pre-filled prompt. | 349 // A pre-filled prompt. |
| 359 Prompt prompt_; | 350 Prompt prompt_; |
| 360 | 351 |
| 361 scoped_ptr<OAuth2MintTokenFlow> token_flow_; | 352 scoped_ptr<OAuth2MintTokenFlow> token_flow_; |
| 362 | 353 |
| 363 // Used to show the confirm dialog. | 354 // Used to show the confirm dialog. |
| 364 ShowDialogCallback show_dialog_callback_; | 355 ShowDialogCallback show_dialog_callback_; |
| 365 }; | 356 }; |
| 366 | 357 |
| 367 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_INSTALL_PROMPT_H_ | 358 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_INSTALL_PROMPT_H_ |
| OLD | NEW |