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_UNINSTALL_DIALOG_H_ 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_UNINSTALL_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 ExtensionUninstallDialog : public ImageLoadingTracker::Observer { 18 public: 19 class Delegate { 20 public: 21 // We call this method to signal that the uninstallation should continue. 22 virtual void ExtensionDialogAccepted() = 0; 23 24 // We call this method to signal that the uninstallation should stop. 25 virtual void ExtensionDialogCanceled() = 0; 26 27 protected: ~Delegate()28 virtual ~Delegate() {} 29 }; 30 31 explicit ExtensionUninstallDialog(Profile* profile); 32 virtual ~ExtensionUninstallDialog(); 33 34 // This is called by the extensions management page to verify whether the 35 // uninstallation should proceed. 36 // Starts the process of showing a confirmation UI, which is split into two. 37 // 1) Set off a 'load icon' task. 38 // 2) Handle the load icon response and show the UI (OnImageLoaded). 39 void ConfirmUninstall(Delegate* delegate, const Extension* extension); 40 41 private: 42 // Creates an appropriate ExtensionUninstallDialog for the platform. 43 static void Show(Profile* profile, 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); 51 52 // ImageLoadingTracker::Observer: 53 virtual void OnImageLoaded(SkBitmap* image, 54 const ExtensionResource& resource, 55 int index) OVERRIDE; 56 57 Profile* profile_; 58 MessageLoop* ui_loop_; 59 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 67 // purpose of showing the install UI. 68 ImageLoadingTracker tracker_; 69 70 // The extensions icon. 71 SkBitmap icon_; 72 73 DISALLOW_COPY_AND_ASSIGN(ExtensionUninstallDialog); 74 }; 75 76 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_UNINSTALL_DIALOG_H_ 77