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

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

Issue 11027044: Add a class to replace ImageLoadingTracker with a nicer API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix include order Created 8 years, 1 month 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 | Annotate | Revision Log
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 <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/callback.h" 11 #include "base/callback.h"
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"
17 #include "extensions/common/url_pattern.h" 16 #include "extensions/common/url_pattern.h"
18 #include "google_apis/gaia/oauth2_mint_token_flow.h" 17 #include "google_apis/gaia/oauth2_mint_token_flow.h"
19 #include "third_party/skia/include/core/SkBitmap.h" 18 #include "third_party/skia/include/core/SkBitmap.h"
20 #include "ui/gfx/image/image.h" 19 #include "ui/gfx/image/image.h"
21 #include "ui/gfx/image/image_skia.h" 20 #include "ui/gfx/image/image_skia.h"
22 #include "ui/gfx/native_widget_types.h" 21 #include "ui/gfx/native_widget_types.h"
23 22
24 class Browser; 23 class Browser;
25 class ExtensionInstallUI; 24 class ExtensionInstallUI;
26 class InfoBarDelegate; 25 class InfoBarDelegate;
27 class MessageLoop; 26 class MessageLoop;
28 class Profile; 27 class Profile;
29 28
30 namespace base { 29 namespace base {
31 class DictionaryValue; 30 class DictionaryValue;
32 } // namespace base 31 } // namespace base
33 32
34 namespace content { 33 namespace content {
35 class WebContents; 34 class WebContents;
36 } 35 }
37 36
38 namespace extensions { 37 namespace extensions {
39 class BundleInstaller; 38 class BundleInstaller;
40 class Extension; 39 class Extension;
41 class ExtensionWebstorePrivateApiTest; 40 class ExtensionWebstorePrivateApiTest;
42 class PermissionSet; 41 class PermissionSet;
43 } // namespace extensions 42 } // namespace extensions
44 43
45 // Displays all the UI around extension installation. 44 // Displays all the UI around extension installation.
46 class ExtensionInstallPrompt : public ImageLoadingTracker::Observer, 45 class ExtensionInstallPrompt
47 public OAuth2MintTokenFlow::Delegate { 46 : public OAuth2MintTokenFlow::Delegate,
47 public base::SupportsWeakPtr<ExtensionInstallPrompt> {
48 public: 48 public:
49 enum PromptType { 49 enum PromptType {
50 UNSET_PROMPT_TYPE = -1, 50 UNSET_PROMPT_TYPE = -1,
51 INSTALL_PROMPT = 0, 51 INSTALL_PROMPT = 0,
52 INLINE_INSTALL_PROMPT, 52 INLINE_INSTALL_PROMPT,
53 BUNDLE_INSTALL_PROMPT, 53 BUNDLE_INSTALL_PROMPT,
54 RE_ENABLE_PROMPT, 54 RE_ENABLE_PROMPT,
55 PERMISSIONS_PROMPT, 55 PERMISSIONS_PROMPT,
56 EXTERNAL_INSTALL_PROMPT, 56 EXTERNAL_INSTALL_PROMPT,
57 NUM_PROMPT_TYPES 57 NUM_PROMPT_TYPES
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 const extensions::Extension* extension, 253 const extensions::Extension* extension,
254 const IssueAdviceInfo& issue_advice); 254 const IssueAdviceInfo& issue_advice);
255 255
256 // Installation was successful. This is declared virtual for testing. 256 // Installation was successful. This is declared virtual for testing.
257 virtual void OnInstallSuccess(const extensions::Extension* extension, 257 virtual void OnInstallSuccess(const extensions::Extension* extension,
258 SkBitmap* icon); 258 SkBitmap* icon);
259 259
260 // Installation failed. This is declared virtual for testing. 260 // Installation failed. This is declared virtual for testing.
261 virtual void OnInstallFailure(const extensions::CrxInstallerError& error); 261 virtual void OnInstallFailure(const extensions::CrxInstallerError& error);
262 262
263 // ImageLoadingTracker::Observer:
264 virtual void OnImageLoaded(const gfx::Image& image,
265 const std::string& extension_id,
266 int index) OVERRIDE;
267
268 protected: 263 protected:
269 friend class extensions::ExtensionWebstorePrivateApiTest; 264 friend class extensions::ExtensionWebstorePrivateApiTest;
270 friend class WebstoreStandaloneInstallUnpackFailureTest; 265 friend class WebstoreStandaloneInstallUnpackFailureTest;
271 friend class MockGetAuthTokenFunction; 266 friend class MockGetAuthTokenFunction;
272 267
273 // Whether or not we should record the oauth2 grant upon successful install. 268 // Whether or not we should record the oauth2 grant upon successful install.
274 bool record_oauth2_grant_; 269 bool record_oauth2_grant_;
275 270
276 private: 271 private:
277 friend class GalleryInstallApiTestObserver; 272 friend class GalleryInstallApiTestObserver;
278 273
279 // Sets the icon that will be used in any UI. If |icon| is NULL, or contains 274 // Sets the icon that will be used in any UI. If |icon| is NULL, or contains
280 // an empty bitmap, then a default icon will be used instead. 275 // an empty bitmap, then a default icon will be used instead.
281 void SetIcon(const SkBitmap* icon); 276 void SetIcon(const SkBitmap* icon);
282 277
278 // ImageLoader callback.
279 void OnImageLoaded(const gfx::Image& image);
280
283 // Starts the process of showing a confirmation UI, which is split into two. 281 // Starts the process of showing a confirmation UI, which is split into two.
284 // 1) Set off a 'load icon' task. 282 // 1) Set off a 'load icon' task.
285 // 2) Handle the load icon response and show the UI (OnImageLoaded). 283 // 2) Handle the load icon response and show the UI (OnImageLoaded).
286 void LoadImageIfNeeded(); 284 void LoadImageIfNeeded();
287 285
288 // Starts fetching warnings for OAuth2 scopes, if there are any. 286 // Starts fetching warnings for OAuth2 scopes, if there are any.
289 void FetchOAuthIssueAdviceIfNeeded(); 287 void FetchOAuthIssueAdviceIfNeeded();
290 288
291 // OAuth2MintTokenFlow::Delegate implementation: 289 // OAuth2MintTokenFlow::Delegate implementation:
292 virtual void OnIssueAdviceSuccess( 290 virtual void OnIssueAdviceSuccess(
(...skipping 19 matching lines...) Expand all
312 310
313 // The permissions being prompted for. 311 // The permissions being prompted for.
314 scoped_refptr<const extensions::PermissionSet> permissions_; 312 scoped_refptr<const extensions::PermissionSet> permissions_;
315 313
316 // The object responsible for doing the UI specific actions. 314 // The object responsible for doing the UI specific actions.
317 scoped_ptr<ExtensionInstallUI> install_ui_; 315 scoped_ptr<ExtensionInstallUI> install_ui_;
318 316
319 // The delegate we will call Proceed/Abort on after confirmation UI. 317 // The delegate we will call Proceed/Abort on after confirmation UI.
320 Delegate* delegate_; 318 Delegate* delegate_;
321 319
320 Profile* profile_;
321
322 // A pre-filled prompt. 322 // A pre-filled prompt.
323 Prompt prompt_; 323 Prompt prompt_;
324 324
325 // The type of prompt we are going to show. 325 // The type of prompt we are going to show.
326 PromptType prompt_type_; 326 PromptType prompt_type_;
327 327
328 scoped_ptr<OAuth2MintTokenFlow> token_flow_; 328 scoped_ptr<OAuth2MintTokenFlow> token_flow_;
329 329
330 // Keeps track of extension images being loaded on the File thread for the
331 // purpose of showing the install UI.
332 ImageLoadingTracker tracker_;
333
334 // Used to show the confirm dialog. 330 // Used to show the confirm dialog.
335 ShowDialogCallback show_dialog_callback_; 331 ShowDialogCallback show_dialog_callback_;
336 }; 332 };
337 333
338 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_INSTALL_PROMPT_H_ 334 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_INSTALL_PROMPT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698