1 // Copyright (c) 2012 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.
5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_ERROR_UI_H_
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_ERROR_UI_H_
8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h"
10 #include "chrome/browser/ui/global_error/global_error.h"
11 #include "extensions/common/extension.h"
14 class ExtensionService
;
16 // This class encapsulates the UI we want to show users when certain events
17 // occur related to installed extensions.
18 class ExtensionErrorUI
{
20 static ExtensionErrorUI
* Create(ExtensionService
* extension_service
);
22 virtual ~ExtensionErrorUI();
24 // Inform us that a given extension is of a certain type that the user
25 // hasn't yet acknowledged.
26 void AddExternalExtension(const std::string
& id
);
27 void AddBlacklistedExtension(const std::string
& id
);
29 // Returns sets replaying the IDs that have been added with the
30 // Add[...]Extension methods.
31 const extensions::ExtensionIdSet
* get_external_extension_ids() const {
32 return external_extension_ids_
.get();
35 const extensions::ExtensionIdSet
* get_blacklisted_extension_ids() const {
36 return blacklisted_extension_ids_
.get();
39 // Shows the installation error in a bubble view. Should return true if a
40 // bubble is shown, false if one could not be shown.
41 virtual bool ShowErrorInBubbleView() = 0;
43 // Shows the extension page. Called as a result of the user clicking more
44 // info and should be only called from the context of a callback
45 // (BubbleViewDidClose or BubbleViewAccept/CancelButtonPressed).
46 // It should use the same browser as where the bubble was shown.
47 virtual void ShowExtensions() = 0;
49 // Closes the error UI. This will end up calling BubbleViewDidClose, possibly
51 virtual void Close() = 0;
54 explicit ExtensionErrorUI(ExtensionService
* extension_service
);
56 ExtensionService
* extension_service() const { return extension_service_
; }
58 // Model methods for the bubble view.
59 base::string16
GetBubbleViewTitle();
60 std::vector
<base::string16
> GetBubbleViewMessages();
61 base::string16
GetBubbleViewAcceptButtonLabel();
62 base::string16
GetBubbleViewCancelButtonLabel();
64 // Sub-classes should call this methods based on the actions taken by the user
65 // in the error bubble.
66 void BubbleViewDidClose(); // destroys |this|
67 void BubbleViewAcceptButtonPressed();
68 void BubbleViewCancelButtonPressed();
71 bool should_delete_self_on_close_
;
72 ExtensionService
* extension_service_
;
73 scoped_ptr
<extensions::ExtensionIdSet
> external_extension_ids_
;
74 scoped_ptr
<extensions::ExtensionIdSet
> blacklisted_extension_ids_
;
75 base::string16 message_
; // Displayed in the body of the alert.
77 // For a given set of extension IDs, generates appropriate text
78 // describing what the user needs to know about them.
79 base::string16
GenerateMessageSection(
80 const extensions::ExtensionIdSet
* extensions
,
81 int extension_template_message_id
,
82 int app_template_message_id
);
84 // Generates the message displayed in the body of the alert.
85 base::string16
GenerateMessage();
87 DISALLOW_COPY_AND_ASSIGN(ExtensionErrorUI
);
90 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_ERROR_UI_H_