Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_MESSAGE_BUBBLE_CONTROLLER_H_ | |
| 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_MESSAGE_BUBBLE_CONTROLLER_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 #include "chrome/browser/extensions/api/profile_keyed_api_factory.h" | |
| 10 #include "chrome/browser/extensions/extension_message_bubble.h" | |
| 11 #include "extensions/common/extension.h" | |
| 12 | |
| 13 class Browser; | |
| 14 class ExtensionService; | |
| 15 | |
| 16 namespace extensions { | |
| 17 | |
| 18 class ExtensionPrefs; | |
| 19 class SuspiciousExtensionBubble; | |
| 20 | |
| 21 class ExtensionMessageBubbleController { | |
| 22 public: | |
| 23 ExtensionMessageBubbleController(ExtensionListType type, Profile* profile); | |
|
not at google - send to devlin
2013/12/04 17:25:13
Having discrete "list types" like this makes this
| |
| 24 virtual ~ExtensionMessageBubbleController(); | |
| 25 | |
| 26 // Whether the controller knows of extensions to list in the bubble. Returns | |
| 27 // true if so. | |
| 28 bool HasExtensionList(); | |
| 29 | |
| 30 // Obtains a list of all extensions (by name) the controller knows about. | |
| 31 std::vector<string16> GetExtensionList() const; | |
| 32 | |
| 33 // Obtains a list of all extensions (by id) the controller knows about. | |
| 34 const ExtensionIdList& extension_id_list() const { | |
| 35 return extension_list_; | |
| 36 } | |
| 37 | |
| 38 // Sets up the callbacks and shows the bubble. | |
| 39 void Show(ExtensionMessageBubble* bubble); | |
| 40 | |
| 41 // Whether the bubble is currently showing. | |
| 42 bool showing_bubble() { return showing_bubble_; } | |
| 43 | |
| 44 // Text for various UI labels shown in the bubble. | |
| 45 string16 GetTitle() const; | |
| 46 string16 GetMessageBody() const; | |
| 47 string16 GetOverflowText(const string16& overflow_count) const; | |
| 48 string16 GetLearnMoreLabel() const; | |
| 49 string16 GetActionButtonLabel() const; | |
| 50 string16 GetDismissButtonLabel() const; | |
| 51 // Whether to show a list of extensions in the bubble. | |
| 52 bool ShouldShowExtensionList() const; | |
| 53 | |
| 54 virtual bool ShouldIncludeExtension(const std::string& extension_id) = 0; | |
| 55 virtual void AcknowledgeExtension(const std::string& extension_id) = 0; | |
| 56 virtual void PerformAction() = 0; | |
|
not at google - send to devlin
2013/12/04 17:25:13
the more typical idiom is to define a Delegate for
| |
| 57 | |
| 58 // Callbacks from bubble. Declared virtual for testing purposes. | |
| 59 virtual void OnBubbleAction(); | |
| 60 virtual void OnBubbleDismiss(); | |
| 61 virtual void OnLinkClicked(); | |
| 62 | |
| 63 protected: | |
| 64 // UMA histogram constants. | |
| 65 enum UmaExtensionListHistogramOptions { | |
| 66 ACTION_LEARN_MORE = 0, | |
| 67 ACTION_EXECUTE, | |
| 68 ACTION_DISMISS, | |
| 69 ACTION_BOUNDARY, // Must be the last value. | |
| 70 }; | |
| 71 | |
| 72 // Our extension service. Weak, not owned by us. | |
| 73 ExtensionService* service_; | |
| 74 | |
| 75 // A weak pointer to the profile we are associated with. Not owned by us. | |
| 76 Profile* profile_; | |
| 77 | |
| 78 // The list of extensions found. | |
| 79 ExtensionIdList extension_list_; | |
| 80 | |
| 81 // The action the user took in the bubble. | |
| 82 UmaExtensionListHistogramOptions user_action_; | |
| 83 | |
| 84 private: | |
| 85 | |
| 86 // Iterate over the known extensions and acknowledge each one. | |
| 87 void AcknowledgeExtensions(); | |
| 88 | |
| 89 // Record UMA statistic for the action taken by the user. | |
| 90 void RecordAction(UmaExtensionListHistogramOptions action); | |
| 91 | |
| 92 // The type of bubble we are serving data for. | |
| 93 ExtensionListType type_; | |
| 94 | |
| 95 // This object only checks once for suspicious extensions because the dataset | |
| 96 // doesn't change after startup. | |
| 97 bool has_notified_; | |
| 98 | |
| 99 // Whether the bubble is currently showing. | |
| 100 bool showing_bubble_; | |
| 101 | |
| 102 DISALLOW_COPY_AND_ASSIGN(ExtensionMessageBubbleController); | |
| 103 }; | |
| 104 | |
| 105 } // namespace extensions | |
| 106 | |
| 107 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_MESSAGE_BUBBLE_CONTROLLER_H_ | |
| OLD | NEW |