summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions/extension_install_ui.h
blob: 0267450ecd6978294492e2bb3ea919539909363d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
// Copyright (c) 2009 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_INSTALL_UI_H_
#define CHROME_BROWSER_EXTENSIONS_EXTENSION_INSTALL_UI_H_

#include "app/gfx/native_widget_types.h"
#include "base/file_path.h"
#include "base/ref_counted.h"
#include "base/scoped_ptr.h"
#include "third_party/skia/include/core/SkBitmap.h"

#include <string>

class Extension;
class ExtensionsService;
class MessageLoop;
class Profile;
class InfoBarDelegate;
class SandboxedExtensionUnpacker;
class TabContents;

// Displays all the UI around extension installation and uninstallation.
class ExtensionInstallUI {
 public:
  class Delegate {
   public:
    // We call this method after ConfirmInstall()/ConfirmUninstall() to signal
    // that the installation/uninstallation should continue.
    virtual void InstallUIProceed() = 0;

    // We call this method after ConfirmInstall()/ConfirmUninstall() to signal
    // that the installation/uninstallation should stop.
    virtual void InstallUIAbort() = 0;
  };

  static void ShowExtensionInstallPrompt(Profile* profile,
                                         Delegate* delegate,
                                         Extension* extension,
                                         SkBitmap* install_icon,
                                         const std::wstring& warning_text);
  static void ShowExtensionUninstallPrompt(Profile* profile,
                                           Delegate* delegate,
                                           Extension* extension,
                                           SkBitmap* install_icon,
                                           const std::wstring& warning_text);

  // NOTE: The implementations of this function is platform-specific.
  static void ShowExtensionInstallError(const std::string& error);

  explicit ExtensionInstallUI(Profile* profile);

  // This is called by the installer to verify whether the installation should
  // proceed.
  //
  // We *MUST* eventually call either Proceed() or Abort()
  // on |delegate|.
  void ConfirmInstall(Delegate* delegate, Extension* extension,
                      SkBitmap* icon);

  // This is called by the extensions management page to verify whether the
  // uninstallation should proceed.
  //
  // We *MUST* eventually call either Proceed() or Abort()
  // on |delegate|.
  void ConfirmUninstall(Delegate* delegate, Extension* extension,
                        SkBitmap* icon);

  // Installation was successful.
  void OnInstallSuccess(Extension* extension);

  // Installation failed.
  void OnInstallFailure(const std::string& error);

  // The install was rejected because the same extension/version is already
  // installed.
  void OnOverinstallAttempted(Extension* extension);

 private:
  // When a Theme is downloaded it is applied and an info bar is shown to give
  // the user a choice to keep it or undo the installation.
  void ShowThemeInfoBar(Extension* new_theme);

  // Returns the delegate to control the browser's info bar. This is within its
  // own function due to its platform-specific nature.
  InfoBarDelegate* GetNewInfoBarDelegate(Extension* new_theme,
                                         TabContents* tab_contents);

  // Implements the showing of the install/uninstall dialog prompt.
  // NOTE: The implementations of this function is platform-specific.
  static void ShowExtensionInstallUIPromptImpl(
      Profile* profile, Delegate* delegate, Extension* extension,
      SkBitmap* icon, const std::wstring& warning_text, bool is_uninstall);

  Profile* profile_;
  MessageLoop* ui_loop_;
  std::string previous_theme_id_;  // Used to undo theme installation.
  SkBitmap icon_;  // The extensions installation icon.

#if defined(TOOLKIT_GTK)
  // Also needed to undo theme installation in the linux UI.
  bool previous_use_gtk_theme_;
#endif
};

#endif  // CHROME_BROWSER_EXTENSIONS_EXTENSION_INSTALL_UI_H_