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

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

Issue 7920023: Fix crashes related to the extension uninstall dialog. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: make Show() pure virtual Created 9 years, 3 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
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 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_UNINSTALL_DIALOG_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_UNINSTALL_DIALOG_H_
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_UNINSTALL_DIALOG_H_ 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_UNINSTALL_DIALOG_H_
7 #pragma once 7 #pragma once
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
11 #include "chrome/browser/extensions/image_loading_tracker.h" 11 #include "chrome/browser/extensions/image_loading_tracker.h"
12 #include "third_party/skia/include/core/SkBitmap.h" 12 #include "third_party/skia/include/core/SkBitmap.h"
13 13
14 class MessageLoop; 14 class MessageLoop;
15 class Profile; 15 class Profile;
16 16
17 class ExtensionUninstallDialog : public ImageLoadingTracker::Observer { 17 class ExtensionUninstallDialog : public ImageLoadingTracker::Observer {
18 public: 18 public:
19 class Delegate { 19 class Delegate {
20 public: 20 public:
21 // We call this method to signal that the uninstallation should continue. 21 // We call this method to signal that the uninstallation should continue.
22 virtual void ExtensionDialogAccepted() = 0; 22 virtual void ExtensionUninstallAccepted() = 0;
23 23
24 // We call this method to signal that the uninstallation should stop. 24 // We call this method to signal that the uninstallation should stop.
25 virtual void ExtensionDialogCanceled() = 0; 25 virtual void ExtensionUninstallCanceled() = 0;
26 26
27 protected: 27 protected:
28 virtual ~Delegate() {} 28 virtual ~Delegate() {}
29 }; 29 };
30 30
31 explicit ExtensionUninstallDialog(Profile* profile); 31 // Creates a platform specific implementation of ExtensionUninstallDialog.
32 static ExtensionUninstallDialog* Create(
33 Profile* profile, Delegate* delegate);
34
32 virtual ~ExtensionUninstallDialog(); 35 virtual ~ExtensionUninstallDialog();
33 36
34 // This is called by the extensions management page to verify whether the 37 // This is called to verify whether the uninstallation should proceed.
35 // uninstallation should proceed.
36 // Starts the process of showing a confirmation UI, which is split into two. 38 // Starts the process of showing a confirmation UI, which is split into two.
37 // 1) Set off a 'load icon' task. 39 // 1) Set off a 'load icon' task.
38 // 2) Handle the load icon response and show the UI (OnImageLoaded). 40 // 2) Handle the load icon response and show the UI (OnImageLoaded).
39 void ConfirmUninstall(Delegate* delegate, const Extension* extension); 41 void ConfirmUninstall(const Extension* extension);
42
43 protected:
44 // Constructor used by the derived classes.
45 explicit ExtensionUninstallDialog(Profile* profile, Delegate* delegate);
46
47 Profile* profile_;
48
49 // The delegate we will call Accepted/Canceled on after confirmation dialog.
50 Delegate* delegate_;
51
52 // The extension we are showing the dialog for.
53 const Extension* extension_;
54
55 // The extensions icon.
56 SkBitmap icon_;
40 57
41 private: 58 private:
42 // Creates an appropriate ExtensionUninstallDialog for the platform. 59 // Sets the icon that will be used in the dialog. If |icon| is NULL, or
43 static void Show(Profile* profile, 60 // contains an empty bitmap, then we use a default icon instead.
44 Delegate* delegate,
45 const Extension* extension,
46 SkBitmap* icon);
47
48 // Sets the icon that will be used in any UI. If |icon| is NULL, or contains
49 // an empty bitmap, then a default icon will be used instead.
50 void SetIcon(SkBitmap* icon); 61 void SetIcon(SkBitmap* icon);
51 62
52 // ImageLoadingTracker::Observer: 63 // ImageLoadingTracker::Observer:
53 virtual void OnImageLoaded(SkBitmap* image, 64 virtual void OnImageLoaded(SkBitmap* image,
54 const ExtensionResource& resource, 65 const ExtensionResource& resource,
55 int index) OVERRIDE; 66 int index) OVERRIDE;
56 67
57 Profile* profile_; 68 // Displays the prompt. This should only be called after loading the icon.
69 // The implementations of this method are platform-specific.
70 virtual void Show() = 0;
71
58 MessageLoop* ui_loop_; 72 MessageLoop* ui_loop_;
59 73
60 // The delegate we will call Accepted/Canceled on after confirmation UI.
61 Delegate* delegate_;
62
63 // The extension we are showing the UI for.
64 const Extension* extension_;
65
66 // Keeps track of extension images being loaded on the File thread for the 74 // Keeps track of extension images being loaded on the File thread for the
67 // purpose of showing the install UI. 75 // purpose of showing the dialog.
68 ImageLoadingTracker tracker_; 76 ImageLoadingTracker tracker_;
69 77
70 // The extensions icon.
71 SkBitmap icon_;
72
73 DISALLOW_COPY_AND_ASSIGN(ExtensionUninstallDialog); 78 DISALLOW_COPY_AND_ASSIGN(ExtensionUninstallDialog);
74 }; 79 };
75 80
76 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_UNINSTALL_DIALOG_H_ 81 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_UNINSTALL_DIALOG_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_install_ui.h ('k') | chrome/browser/extensions/extension_uninstall_dialog.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698