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

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

Issue 6721013: extensions: Refactor ExtensionInstallUI class. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add SetIcon and call it Created 9 years, 9 months 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
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_GENERIC_DIALOG_H_
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_GENERIC_DIALOG_H_
7 #pragma once
8
9 #include "base/basictypes.h"
10 #include "base/compiler_specific.h"
11 #include "chrome/browser/extensions/image_loading_tracker.h"
12 #include "third_party/skia/include/core/SkBitmap.h"
13
14 class MessageLoop;
15 class Profile;
16
17 class ExtensionGenericDialog : public ImageLoadingTracker::Observer {
18 public:
19 enum DialogType {
20 DIALOG_UNSET = -1,
21 DIALOG_UNINSTALL = 0,
22 DIALOG_RE_ENABLE,
23 DIALOG_NUM_TYPES
24 };
25
26 class Delegate {
27 public:
28 // We call this method after ConfirmUninstall()/ConfirmReenable to signal
29 // that the uninstallation should continue.
30 virtual void ExtensionDialogAccepted() = 0;
31
32 // We call this method after ConfirmUninstall()/ConfirmReenable to signal
33 // that the uninstallation should stop.
34 virtual void ExtensionDialogCanceled() = 0;
35
36 protected:
37 virtual ~Delegate() {}
38 };
39
40 explicit ExtensionGenericDialog(Profile* profile);
41 virtual ~ExtensionGenericDialog();
42
43 // This is called by the extensions management page to verify whether the
44 // uninstallation should proceed. This is declared virtual for testing.
45 //
46 // We *MUST* eventually call either Accepted() or Canceled() on |delegate|.
47 void ConfirmUninstall(Delegate* delegate, const Extension* extension);
48
49 // This is called by the app handler launcher to verify whether the app
50 // should be re-enabled. This is declared virtual for testing.
51 //
52 // We *MUST* eventually call either Accepted() or Canceled() on |delegate|.
53 void ConfirmReenable(Delegate* delegate, const Extension* extension);
54
55 private:
56 // Starts the process of showing a confirmation UI, which is split into two.
57 // 1) Set off a 'load icon' task.
58 // 2) Handle the load icon response and show the UI (OnImageLoaded).
59 void ShowConfirmation(DialogType dialog_type);
60
61 // Sets the icon that will be used in any UI. If |icon| is NULL, or contains
62 // an empty bitmap, then a default icon will be used instead.
63 void SetIcon(SkBitmap* icon);
64
65 // ImageLoadingTracker::Observer:
66 virtual void OnImageLoaded(SkBitmap* image,
67 const ExtensionResource& resource,
68 int index) OVERRIDE;
69
70 Profile* profile_;
71 MessageLoop* ui_loop_;
72
73 // The delegate we will call Accepted/Canceled on after confirmation UI.
74 Delegate* delegate_;
75
76 // The extension we are showing the UI for.
77 const Extension* extension_;
78
79 // The type of dialog we are going to show.
80 DialogType dialog_type_;
81
82 // Keeps track of extension images being loaded on the File thread for the
83 // purpose of showing the install UI.
84 ImageLoadingTracker tracker_;
85
86 // The extensions icon.
87 SkBitmap icon_;
88
89 DISALLOW_COPY_AND_ASSIGN(ExtensionGenericDialog);
90 };
91
92 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_GENERIC_DIALOG_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698