| 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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/string16.h" | 14 #include "base/string16.h" |
| 15 #include "chrome/browser/extensions/crx_installer_error.h" | 15 #include "chrome/browser/extensions/crx_installer_error.h" |
| 16 #include "chrome/browser/extensions/image_loading_tracker.h" | 16 #include "chrome/browser/extensions/image_loading_tracker.h" |
| 17 #include "chrome/common/extensions/url_pattern.h" | 17 #include "chrome/common/extensions/url_pattern.h" |
| 18 #include "chrome/common/net/gaia/oauth2_mint_token_flow.h" | 18 #include "chrome/common/net/gaia/oauth2_mint_token_flow.h" |
| 19 #include "third_party/skia/include/core/SkBitmap.h" | 19 #include "third_party/skia/include/core/SkBitmap.h" |
| 20 #include "ui/gfx/image/image.h" | 20 #include "ui/gfx/image/image.h" |
| 21 #include "ui/gfx/image/image_skia.h" | 21 #include "ui/gfx/image/image_skia.h" |
| 22 #include "ui/gfx/native_widget_types.h" | 22 #include "ui/gfx/native_widget_types.h" |
| 23 | 23 |
| 24 class Browser; | 24 class Browser; |
| 25 class ExtensionInstallUI; | 25 class ExtensionInstallUI; |
| 26 class InfoBarDelegate; |
| 26 class MessageLoop; | 27 class MessageLoop; |
| 27 class InfoBarDelegate; | 28 class Profile; |
| 28 | 29 |
| 29 namespace base { | 30 namespace base { |
| 30 class DictionaryValue; | 31 class DictionaryValue; |
| 31 } // namespace base | 32 } // namespace base |
| 32 | 33 |
| 34 namespace content { |
| 35 class PageNavigator; |
| 36 } |
| 37 |
| 33 namespace extensions { | 38 namespace extensions { |
| 34 class BundleInstaller; | 39 class BundleInstaller; |
| 35 class Extension; | 40 class Extension; |
| 36 class ExtensionWebstorePrivateApiTest; | 41 class ExtensionWebstorePrivateApiTest; |
| 37 class PermissionSet; | 42 class PermissionSet; |
| 38 } // namespace extensions | 43 } // namespace extensions |
| 39 | 44 |
| 40 // Displays all the UI around extension installation. | 45 // Displays all the UI around extension installation. |
| 41 class ExtensionInstallPrompt : public ImageLoadingTracker::Observer, | 46 class ExtensionInstallPrompt : public ImageLoadingTracker::Observer, |
| 42 public OAuth2MintTokenFlow::Delegate { | 47 public OAuth2MintTokenFlow::Delegate { |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 | 158 |
| 154 // Creates a dummy extension from the |manifest|, replacing the name and | 159 // Creates a dummy extension from the |manifest|, replacing the name and |
| 155 // description with the localizations if provided. | 160 // description with the localizations if provided. |
| 156 static scoped_refptr<extensions::Extension> GetLocalizedExtensionForDisplay( | 161 static scoped_refptr<extensions::Extension> GetLocalizedExtensionForDisplay( |
| 157 const base::DictionaryValue* manifest, | 162 const base::DictionaryValue* manifest, |
| 158 const std::string& id, | 163 const std::string& id, |
| 159 const std::string& localized_name, | 164 const std::string& localized_name, |
| 160 const std::string& localized_description, | 165 const std::string& localized_description, |
| 161 std::string* error); | 166 std::string* error); |
| 162 | 167 |
| 163 explicit ExtensionInstallPrompt(Browser* browser); | 168 // Creates a prompt with a parent window and a navigator that can be used to |
| 169 // load pages. |
| 170 ExtensionInstallPrompt(gfx::NativeWindow parent, |
| 171 content::PageNavigator* navigator, |
| 172 Profile* profile); |
| 164 virtual ~ExtensionInstallPrompt(); | 173 virtual ~ExtensionInstallPrompt(); |
| 165 | 174 |
| 166 ExtensionInstallUI* install_ui() const { return install_ui_.get(); } | 175 ExtensionInstallUI* install_ui() const { return install_ui_.get(); } |
| 167 | 176 |
| 168 bool record_oauth2_grant() const { return record_oauth2_grant_; } | 177 bool record_oauth2_grant() const { return record_oauth2_grant_; } |
| 169 | 178 |
| 170 // This is called by the bundle installer to verify whether the bundle | 179 // This is called by the bundle installer to verify whether the bundle |
| 171 // should be installed. | 180 // should be installed. |
| 172 // | 181 // |
| 173 // We *MUST* eventually call either Proceed() or Abort() on |delegate|. | 182 // We *MUST* eventually call either Proceed() or Abort() on |delegate|. |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 | 272 |
| 264 // OAuth2MintTokenFlow::Delegate implementation: | 273 // OAuth2MintTokenFlow::Delegate implementation: |
| 265 virtual void OnIssueAdviceSuccess( | 274 virtual void OnIssueAdviceSuccess( |
| 266 const IssueAdviceInfo& issue_advice) OVERRIDE; | 275 const IssueAdviceInfo& issue_advice) OVERRIDE; |
| 267 virtual void OnMintTokenFailure( | 276 virtual void OnMintTokenFailure( |
| 268 const GoogleServiceAuthError& error) OVERRIDE; | 277 const GoogleServiceAuthError& error) OVERRIDE; |
| 269 | 278 |
| 270 // Shows the actual UI (the icon should already be loaded). | 279 // Shows the actual UI (the icon should already be loaded). |
| 271 void ShowConfirmation(); | 280 void ShowConfirmation(); |
| 272 | 281 |
| 273 Browser* browser_; | 282 gfx::NativeWindow parent_; |
| 283 content::PageNavigator* navigator_; |
| 274 MessageLoop* ui_loop_; | 284 MessageLoop* ui_loop_; |
| 275 | 285 |
| 276 // The extensions installation icon. | 286 // The extensions installation icon. |
| 277 SkBitmap icon_; | 287 SkBitmap icon_; |
| 278 | 288 |
| 279 // The extension we are showing the UI for. | 289 // The extension we are showing the UI for. |
| 280 const extensions::Extension* extension_; | 290 const extensions::Extension* extension_; |
| 281 | 291 |
| 282 // The bundle we are showing the UI for, if type BUNDLE_INSTALL_PROMPT. | 292 // The bundle we are showing the UI for, if type BUNDLE_INSTALL_PROMPT. |
| 283 const extensions::BundleInstaller* bundle_; | 293 const extensions::BundleInstaller* bundle_; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 297 // The type of prompt we are going to show. | 307 // The type of prompt we are going to show. |
| 298 PromptType prompt_type_; | 308 PromptType prompt_type_; |
| 299 | 309 |
| 300 scoped_ptr<OAuth2MintTokenFlow> token_flow_; | 310 scoped_ptr<OAuth2MintTokenFlow> token_flow_; |
| 301 | 311 |
| 302 // Keeps track of extension images being loaded on the File thread for the | 312 // Keeps track of extension images being loaded on the File thread for the |
| 303 // purpose of showing the install UI. | 313 // purpose of showing the install UI. |
| 304 ImageLoadingTracker tracker_; | 314 ImageLoadingTracker tracker_; |
| 305 }; | 315 }; |
| 306 | 316 |
| 317 namespace chrome { |
| 318 |
| 319 // Creates an ExtensionInstallPrompt from |browser|. Caller assumes ownership. |
| 320 // TODO(beng): remove this once various extensions types are weaned from |
| 321 // Browser. |
| 322 ExtensionInstallPrompt* CreateExtensionInstallPromptWithBrowser( |
| 323 Browser* browser); |
| 324 |
| 325 } // namespace chrome |
| 326 |
| 307 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_INSTALL_PROMPT_H_ | 327 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_INSTALL_PROMPT_H_ |
| OLD | NEW |