Enable Enterprise enrollment on desktop builds.
[chromium-blink-merge.git] / chrome / browser / extensions / extension_message_bubble_controller.h
blobe2a64fd82575e83639a9cdc159c91c447557b186
1 // Copyright (c) 2013 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_MESSAGE_BUBBLE_CONTROLLER_H_
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_MESSAGE_BUBBLE_CONTROLLER_H_
8 #include <string>
9 #include "chrome/browser/extensions/extension_message_bubble.h"
10 #include "extensions/browser/browser_context_keyed_api_factory.h"
11 #include "extensions/common/extension.h"
13 class Browser;
14 class Profile;
16 namespace extensions {
18 class ExtensionPrefs;
19 class SuspiciousExtensionBubble;
21 class ExtensionMessageBubbleController {
22 public:
23 // UMA histogram constants.
24 enum BubbleAction {
25 ACTION_LEARN_MORE = 0,
26 ACTION_EXECUTE,
27 ACTION_DISMISS,
28 ACTION_BOUNDARY, // Must be the last value.
31 class Delegate {
32 public:
33 Delegate();
34 virtual ~Delegate();
36 virtual bool ShouldIncludeExtension(const std::string& extension_id) = 0;
37 virtual void AcknowledgeExtension(
38 const std::string& extension_id,
39 BubbleAction action) = 0;
40 virtual void PerformAction(const ExtensionIdList& list) = 0;
41 virtual void OnClose() {}
43 // Text for various UI labels shown in the bubble.
44 virtual base::string16 GetTitle() const = 0;
45 virtual base::string16 GetMessageBody() const = 0;
46 virtual base::string16 GetOverflowText(
47 const base::string16& overflow_count) const = 0;
48 virtual base::string16 GetLearnMoreLabel() const = 0;
49 virtual GURL GetLearnMoreUrl() const = 0;
50 virtual base::string16 GetActionButtonLabel() const = 0;
51 virtual base::string16 GetDismissButtonLabel() const = 0;
53 // Whether to show a list of extensions in the bubble.
54 virtual bool ShouldShowExtensionList() const = 0;
56 // In some cases, we want the delegate only to handle a single extension
57 // and this sets which extension.
58 virtual void RestrictToSingleExtension(const std::string& extension_id);
60 // Record, through UMA, how many extensions were found.
61 virtual void LogExtensionCount(size_t count) = 0;
62 virtual void LogAction(BubbleAction action) = 0;
65 ExtensionMessageBubbleController(Delegate* delegate, Profile* profile);
66 virtual ~ExtensionMessageBubbleController();
68 Delegate* delegate() const { return delegate_.get(); }
70 // Obtains a list of all extensions (by name) the controller knows about.
71 std::vector<base::string16> GetExtensionList();
73 // Obtains a list of all extensions (by id) the controller knows about.
74 const ExtensionIdList& GetExtensionIdList();
76 // Whether to close the bubble when it loses focus.
77 virtual bool CloseOnDeactivate();
79 // Sets up the callbacks and shows the bubble.
80 virtual void Show(ExtensionMessageBubble* bubble);
82 // Callbacks from bubble. Declared virtual for testing purposes.
83 virtual void OnBubbleAction();
84 virtual void OnBubbleDismiss();
85 virtual void OnLinkClicked();
87 private:
88 // Iterate over the known extensions and acknowledge each one.
89 void AcknowledgeExtensions();
91 // Get the data this class needs.
92 ExtensionIdList* GetOrCreateExtensionList();
94 // A weak pointer to the profile we are associated with. Not owned by us.
95 Profile* profile_;
97 // The list of extensions found.
98 ExtensionIdList extension_list_;
100 // The action the user took in the bubble.
101 BubbleAction user_action_;
103 // Our delegate supplying information about what to show in the dialog.
104 scoped_ptr<Delegate> delegate_;
106 // Whether this class has initialized.
107 bool initialized_;
109 DISALLOW_COPY_AND_ASSIGN(ExtensionMessageBubbleController);
112 } // namespace extensions
114 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_MESSAGE_BUBBLE_CONTROLLER_H_