Chromium Code Reviews| Index: chrome/browser/extensions/extension_generic_dialog.h |
| diff --git a/chrome/browser/extensions/extension_generic_dialog.h b/chrome/browser/extensions/extension_generic_dialog.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..235fb86808a965ae0bd1441908ebd0c348478f3b |
| --- /dev/null |
| +++ b/chrome/browser/extensions/extension_generic_dialog.h |
| @@ -0,0 +1,104 @@ |
| +// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_GENERIC_DIALOG_H_ |
| +#define CHROME_BROWSER_EXTENSIONS_EXTENSION_GENERIC_DIALOG_H_ |
| +#pragma once |
| + |
| +#include "base/basictypes.h" |
| +#include "base/compiler_specific.h" |
| +#include "chrome/browser/extensions/image_loading_tracker.h" |
| +#include "third_party/skia/include/core/SkBitmap.h" |
| + |
| +class MessageLoop; |
| +class Profile; |
| + |
| +class ExtensionGenericDialog : public ImageLoadingTracker::Observer { |
| + public: |
| + enum DialogType { |
| + DIALOG_UNSET = -1, |
| + DIALOG_UNINSTALL = 0, |
| + DIALOG_RE_ENABLE, |
| + DIALOG_NUM_TYPES |
| + }; |
| + |
| + // A mapping from DialogType to message ID for various dialog content. |
| + static const int kTitleIds[DIALOG_NUM_TYPES]; |
| + static const int kHeadingIds[DIALOG_NUM_TYPES]; |
| + static const int kButtonIds[DIALOG_NUM_TYPES]; |
| + |
| + class Delegate { |
| + public: |
| + // We call this method after ConfirmUninstall()/ConfirmReenable to signal |
| + // that the uninstallation should continue. |
| + virtual void ExtensionDialogAccepted() = 0; |
| + |
| + // We call this method after ConfirmUninstall()/ConfirmReenable to signal |
| + // that the uninstallation should stop. |
| + virtual void ExtensionDialogCanceled() = 0; |
| + |
| + protected: |
| + virtual ~Delegate() {} |
| + }; |
| + |
| + explicit ExtensionGenericDialog(Profile* profile); |
| + virtual ~ExtensionGenericDialog(); |
| + |
| + // Creates an appropriate ExtensionGenericDialog for the platform. |
| + static void Show(Profile* profile, |
|
Aaron Boodman
2011/03/23 21:06:54
I think this should be private.
|
| + Delegate* delegate, |
| + const Extension* extension, |
| + SkBitmap* icon, |
| + DialogType dialog_type); |
| + |
| + // This is called by the extensions management page to verify whether the |
|
Aaron Boodman
2011/03/23 21:06:54
I think you should collapse these two into just Sh
|
| + // uninstallation should proceed. This is declared virtual for testing. |
| + // |
| + // We *MUST* eventually call either Accepted() or Canceled() on |delegate|. |
| + void ConfirmUninstall(Delegate* delegate, const Extension* extension); |
| + |
| + // This is called by the app handler launcher to verify whether the app |
| + // should be re-enabled. This is declared virtual for testing. |
| + // |
| + // We *MUST* eventually call either Accepted() or Canceled() on |delegate|. |
| + void ConfirmReenable(Delegate* delegate, const Extension* extension); |
| + |
| + private: |
| + // Starts the process of showing a confirmation UI, which is split into two. |
| + // 1) Set off a 'load icon' task. |
| + // 2) Handle the load icon response and show the UI (OnImageLoaded). |
| + void ShowConfirmation(DialogType dialog_type); |
| + |
| + // Sets the icon that will be used in any UI. If |icon| is NULL, or contains |
| + // an empty bitmap, then a default icon will be used instead. |
| + void SetIcon(SkBitmap* icon); |
| + |
| + // ImageLoadingTracker::Observer: |
| + virtual void OnImageLoaded(SkBitmap* image, |
| + const ExtensionResource& resource, |
| + int index) OVERRIDE; |
| + |
| + Profile* profile_; |
| + MessageLoop* ui_loop_; |
| + |
| + // The delegate we will call Accepted/Canceled on after confirmation UI. |
| + Delegate* delegate_; |
| + |
| + // The extension we are showing the UI for. |
| + const Extension* extension_; |
| + |
| + // The type of dialog we are going to show. |
| + DialogType dialog_type_; |
| + |
| + // Keeps track of extension images being loaded on the File thread for the |
| + // purpose of showing the install UI. |
| + ImageLoadingTracker tracker_; |
| + |
| + // The extensions icon. |
| + SkBitmap icon_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(ExtensionGenericDialog); |
| +}; |
| + |
| +#endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_GENERIC_DIALOG_H_ |