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 : public OAuth2MintTokenFlow::Delegate, |
46 public OAuth2MintTokenFlow::Delegate { | 45 public base::SupportsWeakPtr<ExtensionInstallPrompt> { |
Finnur
2012/10/05 14:41:33
If the second doesn't fit within 80 cols when alig
Marijn Kruisselbrink
2012/10/05 18:00:08
Done.
| |
47 public: | 46 public: |
48 enum PromptType { | 47 enum PromptType { |
49 UNSET_PROMPT_TYPE = -1, | 48 UNSET_PROMPT_TYPE = -1, |
50 INSTALL_PROMPT = 0, | 49 INSTALL_PROMPT = 0, |
51 INLINE_INSTALL_PROMPT, | 50 INLINE_INSTALL_PROMPT, |
52 BUNDLE_INSTALL_PROMPT, | 51 BUNDLE_INSTALL_PROMPT, |
53 RE_ENABLE_PROMPT, | 52 RE_ENABLE_PROMPT, |
54 PERMISSIONS_PROMPT, | 53 PERMISSIONS_PROMPT, |
55 NUM_PROMPT_TYPES | 54 NUM_PROMPT_TYPES |
56 }; | 55 }; |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
233 const extensions::Extension* extension, | 232 const extensions::Extension* extension, |
234 const IssueAdviceInfo& issue_advice); | 233 const IssueAdviceInfo& issue_advice); |
235 | 234 |
236 // Installation was successful. This is declared virtual for testing. | 235 // Installation was successful. This is declared virtual for testing. |
237 virtual void OnInstallSuccess(const extensions::Extension* extension, | 236 virtual void OnInstallSuccess(const extensions::Extension* extension, |
238 SkBitmap* icon); | 237 SkBitmap* icon); |
239 | 238 |
240 // Installation failed. This is declared virtual for testing. | 239 // Installation failed. This is declared virtual for testing. |
241 virtual void OnInstallFailure(const extensions::CrxInstallerError& error); | 240 virtual void OnInstallFailure(const extensions::CrxInstallerError& error); |
242 | 241 |
243 // ImageLoadingTracker::Observer: | 242 // extension_image_utils callback. |
244 virtual void OnImageLoaded(const gfx::Image& image, | 243 void OnImageLoaded(const gfx::Image& image); |
Finnur
2012/10/05 14:41:33
Is there a reason to keep these public? Can you no
Aaron Boodman
2012/10/05 16:46:03
I did not know about that rule. I very frequently
Marijn Kruisselbrink
2012/10/05 18:00:08
Done.
| |
245 const std::string& extension_id, | |
246 int index) OVERRIDE; | |
247 | 244 |
248 protected: | 245 protected: |
249 friend class extensions::ExtensionWebstorePrivateApiTest; | 246 friend class extensions::ExtensionWebstorePrivateApiTest; |
250 friend class WebstoreInlineInstallUnpackFailureTest; | 247 friend class WebstoreInlineInstallUnpackFailureTest; |
251 friend class MockGetAuthTokenFunction; | 248 friend class MockGetAuthTokenFunction; |
252 | 249 |
253 // Whether or not we should record the oauth2 grant upon successful install. | 250 // Whether or not we should record the oauth2 grant upon successful install. |
254 bool record_oauth2_grant_; | 251 bool record_oauth2_grant_; |
255 | 252 |
256 private: | 253 private: |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
300 // The delegate we will call Proceed/Abort on after confirmation UI. | 297 // The delegate we will call Proceed/Abort on after confirmation UI. |
301 Delegate* delegate_; | 298 Delegate* delegate_; |
302 | 299 |
303 // A pre-filled prompt. | 300 // A pre-filled prompt. |
304 Prompt prompt_; | 301 Prompt prompt_; |
305 | 302 |
306 // The type of prompt we are going to show. | 303 // The type of prompt we are going to show. |
307 PromptType prompt_type_; | 304 PromptType prompt_type_; |
308 | 305 |
309 scoped_ptr<OAuth2MintTokenFlow> token_flow_; | 306 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 }; | 307 }; |
315 | 308 |
316 namespace chrome { | 309 namespace chrome { |
317 | 310 |
318 // Creates an ExtensionInstallPrompt from |browser|. Caller assumes ownership. | 311 // Creates an ExtensionInstallPrompt from |browser|. Caller assumes ownership. |
319 // TODO(beng): remove this once various extensions types are weaned from | 312 // TODO(beng): remove this once various extensions types are weaned from |
320 // Browser. | 313 // Browser. |
321 ExtensionInstallPrompt* CreateExtensionInstallPromptWithBrowser( | 314 ExtensionInstallPrompt* CreateExtensionInstallPromptWithBrowser( |
322 Browser* browser); | 315 Browser* browser); |
323 | 316 |
324 } // namespace chrome | 317 } // namespace chrome |
325 | 318 |
326 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_INSTALL_PROMPT_H_ | 319 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_INSTALL_PROMPT_H_ |
OLD | NEW |