| 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 |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/string16.h" | 13 #include "base/string16.h" |
| 14 #include "chrome/browser/extensions/crx_installer_error.h" | 14 #include "chrome/browser/extensions/crx_installer_error.h" |
| 15 #include "chrome/browser/extensions/image_loading_tracker.h" | |
| 16 #include "chrome/common/extensions/url_pattern.h" | 15 #include "chrome/common/extensions/url_pattern.h" |
| 17 #include "google_apis/gaia/oauth2_mint_token_flow.h" | 16 #include "google_apis/gaia/oauth2_mint_token_flow.h" |
| 18 #include "third_party/skia/include/core/SkBitmap.h" | 17 #include "third_party/skia/include/core/SkBitmap.h" |
| 19 #include "ui/gfx/image/image.h" | 18 #include "ui/gfx/image/image.h" |
| 20 #include "ui/gfx/image/image_skia.h" | 19 #include "ui/gfx/image/image_skia.h" |
| 21 #include "ui/gfx/native_widget_types.h" | 20 #include "ui/gfx/native_widget_types.h" |
| 22 | 21 |
| 23 class Browser; | 22 class Browser; |
| 24 class ExtensionInstallUI; | 23 class ExtensionInstallUI; |
| 25 class InfoBarDelegate; | 24 class InfoBarDelegate; |
| 26 class MessageLoop; | 25 class MessageLoop; |
| 27 class Profile; | 26 class Profile; |
| 28 | 27 |
| 29 namespace base { | 28 namespace base { |
| 30 class DictionaryValue; | 29 class DictionaryValue; |
| 31 } // namespace base | 30 } // namespace base |
| 32 | 31 |
| 33 namespace content { | 32 namespace content { |
| 34 class PageNavigator; | 33 class PageNavigator; |
| 35 } | 34 } |
| 36 | 35 |
| 37 namespace extensions { | 36 namespace extensions { |
| 38 class BundleInstaller; | 37 class BundleInstaller; |
| 39 class Extension; | 38 class Extension; |
| 40 class ExtensionWebstorePrivateApiTest; | 39 class ExtensionWebstorePrivateApiTest; |
| 41 class PermissionSet; | 40 class PermissionSet; |
| 42 } // namespace extensions | 41 } // namespace extensions |
| 43 | 42 |
| 44 // Displays all the UI around extension installation. | 43 // Displays all the UI around extension installation. |
| 45 class ExtensionInstallPrompt : public ImageLoadingTracker::Observer, | 44 class ExtensionInstallPrompt |
| 46 public OAuth2MintTokenFlow::Delegate { | 45 : public OAuth2MintTokenFlow::Delegate, |
| 46 public base::SupportsWeakPtr<ExtensionInstallPrompt> { |
| 47 public: | 47 public: |
| 48 enum PromptType { | 48 enum PromptType { |
| 49 UNSET_PROMPT_TYPE = -1, | 49 UNSET_PROMPT_TYPE = -1, |
| 50 INSTALL_PROMPT = 0, | 50 INSTALL_PROMPT = 0, |
| 51 INLINE_INSTALL_PROMPT, | 51 INLINE_INSTALL_PROMPT, |
| 52 BUNDLE_INSTALL_PROMPT, | 52 BUNDLE_INSTALL_PROMPT, |
| 53 RE_ENABLE_PROMPT, | 53 RE_ENABLE_PROMPT, |
| 54 PERMISSIONS_PROMPT, | 54 PERMISSIONS_PROMPT, |
| 55 NUM_PROMPT_TYPES | 55 NUM_PROMPT_TYPES |
| 56 }; | 56 }; |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 const extensions::Extension* extension, | 233 const extensions::Extension* extension, |
| 234 const IssueAdviceInfo& issue_advice); | 234 const IssueAdviceInfo& issue_advice); |
| 235 | 235 |
| 236 // Installation was successful. This is declared virtual for testing. | 236 // Installation was successful. This is declared virtual for testing. |
| 237 virtual void OnInstallSuccess(const extensions::Extension* extension, | 237 virtual void OnInstallSuccess(const extensions::Extension* extension, |
| 238 SkBitmap* icon); | 238 SkBitmap* icon); |
| 239 | 239 |
| 240 // Installation failed. This is declared virtual for testing. | 240 // Installation failed. This is declared virtual for testing. |
| 241 virtual void OnInstallFailure(const extensions::CrxInstallerError& error); | 241 virtual void OnInstallFailure(const extensions::CrxInstallerError& error); |
| 242 | 242 |
| 243 // ImageLoadingTracker::Observer: | |
| 244 virtual void OnImageLoaded(const gfx::Image& image, | |
| 245 const std::string& extension_id, | |
| 246 int index) OVERRIDE; | |
| 247 | |
| 248 protected: | 243 protected: |
| 249 friend class extensions::ExtensionWebstorePrivateApiTest; | 244 friend class extensions::ExtensionWebstorePrivateApiTest; |
| 250 friend class WebstoreInlineInstallUnpackFailureTest; | 245 friend class WebstoreInlineInstallUnpackFailureTest; |
| 251 friend class MockGetAuthTokenFunction; | 246 friend class MockGetAuthTokenFunction; |
| 252 | 247 |
| 253 // Whether or not we should record the oauth2 grant upon successful install. | 248 // Whether or not we should record the oauth2 grant upon successful install. |
| 254 bool record_oauth2_grant_; | 249 bool record_oauth2_grant_; |
| 255 | 250 |
| 256 private: | 251 private: |
| 257 friend class GalleryInstallApiTestObserver; | 252 friend class GalleryInstallApiTestObserver; |
| 258 | 253 |
| 259 // Sets the icon that will be used in any UI. If |icon| is NULL, or contains | 254 // Sets the icon that will be used in any UI. If |icon| is NULL, or contains |
| 260 // an empty bitmap, then a default icon will be used instead. | 255 // an empty bitmap, then a default icon will be used instead. |
| 261 void SetIcon(const SkBitmap* icon); | 256 void SetIcon(const SkBitmap* icon); |
| 262 | 257 |
| 258 // extension_image_utils callback. |
| 259 void OnImageLoaded(const gfx::Image& image); |
| 260 |
| 263 // Starts the process of showing a confirmation UI, which is split into two. | 261 // Starts the process of showing a confirmation UI, which is split into two. |
| 264 // 1) Set off a 'load icon' task. | 262 // 1) Set off a 'load icon' task. |
| 265 // 2) Handle the load icon response and show the UI (OnImageLoaded). | 263 // 2) Handle the load icon response and show the UI (OnImageLoaded). |
| 266 void LoadImageIfNeeded(); | 264 void LoadImageIfNeeded(); |
| 267 | 265 |
| 268 // Starts fetching warnings for OAuth2 scopes, if there are any. | 266 // Starts fetching warnings for OAuth2 scopes, if there are any. |
| 269 void FetchOAuthIssueAdviceIfNeeded(); | 267 void FetchOAuthIssueAdviceIfNeeded(); |
| 270 | 268 |
| 271 // OAuth2MintTokenFlow::Delegate implementation: | 269 // OAuth2MintTokenFlow::Delegate implementation: |
| 272 virtual void OnIssueAdviceSuccess( | 270 virtual void OnIssueAdviceSuccess( |
| (...skipping 27 matching lines...) Expand all Loading... |
| 300 // The delegate we will call Proceed/Abort on after confirmation UI. | 298 // The delegate we will call Proceed/Abort on after confirmation UI. |
| 301 Delegate* delegate_; | 299 Delegate* delegate_; |
| 302 | 300 |
| 303 // A pre-filled prompt. | 301 // A pre-filled prompt. |
| 304 Prompt prompt_; | 302 Prompt prompt_; |
| 305 | 303 |
| 306 // The type of prompt we are going to show. | 304 // The type of prompt we are going to show. |
| 307 PromptType prompt_type_; | 305 PromptType prompt_type_; |
| 308 | 306 |
| 309 scoped_ptr<OAuth2MintTokenFlow> token_flow_; | 307 scoped_ptr<OAuth2MintTokenFlow> token_flow_; |
| 310 | |
| 311 // Keeps track of extension images being loaded on the File thread for the | |
| 312 // purpose of showing the install UI. | |
| 313 ImageLoadingTracker tracker_; | |
| 314 }; | 308 }; |
| 315 | 309 |
| 316 namespace chrome { | 310 namespace chrome { |
| 317 | 311 |
| 318 // Creates an ExtensionInstallPrompt from |browser|. Caller assumes ownership. | 312 // Creates an ExtensionInstallPrompt from |browser|. Caller assumes ownership. |
| 319 // TODO(beng): remove this once various extensions types are weaned from | 313 // TODO(beng): remove this once various extensions types are weaned from |
| 320 // Browser. | 314 // Browser. |
| 321 ExtensionInstallPrompt* CreateExtensionInstallPromptWithBrowser( | 315 ExtensionInstallPrompt* CreateExtensionInstallPromptWithBrowser( |
| 322 Browser* browser); | 316 Browser* browser); |
| 323 | 317 |
| 324 } // namespace chrome | 318 } // namespace chrome |
| 325 | 319 |
| 326 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_INSTALL_PROMPT_H_ | 320 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_INSTALL_PROMPT_H_ |
| OLD | NEW |