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 // 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. | |
| 29 }; | |
| 30 | |
| 31 class Delegate { | |
| 32 public: | |
| 33 virtual bool ShouldIncludeExtension(const std::string& extension_id) = 0; | |
| 34 virtual void AcknowledgeExtension( | |
| 35 const std::string& extension_id, | |
| 36 BubbleAction action) = 0; | |
| 37 virtual void PerformAction(const ExtensionIdList& list) = 0; | |
| 38 | |
| 39 // Text for various UI labels shown in the bubble. | |
| 40 virtual string16 GetTitle() const = 0; | |
| 41 virtual string16 GetMessageBody() const = 0; | |
| 42 virtual string16 GetOverflowText(const string16& overflow_count) const = 0; | |
| 43 virtual string16 GetLearnMoreLabel() const = 0; | |
| 44 virtual GURL GetLearnMoreUrl() const = 0; | |
| 45 virtual string16 GetActionButtonLabel() const = 0; | |
| 46 virtual string16 GetDismissButtonLabel() const = 0; | |
| 47 | |
| 48 // Whether to show a list of extensions in the bubble. | |
| 49 virtual bool ShouldShowExtensionList() const = 0; | |
| 50 // The data to show in the bubble. | |
| 51 virtual std::vector<string16> GetExtensions() = 0; | |
| 52 | |
| 53 // Record, through UMA, how many extensions were found. | |
| 54 virtual void LogExtensionCount(size_t count) = 0; | |
| 55 virtual void LogAction(BubbleAction action) = 0; | |
| 56 }; | |
| 57 | |
| 58 ExtensionMessageBubbleController(Delegate* delegate, Profile* profile); | |
| 59 virtual ~ExtensionMessageBubbleController(); | |
| 60 | |
| 61 // Whether the controller knows of extensions to list in the bubble. Returns | |
| 62 // true if so. | |
| 63 bool ShouldShow(); | |
| 64 | |
| 65 // Obtains a list of all extensions (by name) the controller knows about. | |
| 66 std::vector<string16> GetExtensionList(); | |
| 67 | |
| 68 // Obtains a list of all extensions (by id) the controller knows about. | |
| 69 const ExtensionIdList& extension_id_list() const { | |
|
not at google - send to devlin
2013/12/12 21:17:19
having this method and GetExtensionList is confusi
Finnur
2013/12/13 21:29:48
GetExtensionList is a convenience method to get at
| |
| 70 return extension_list_; | |
| 71 } | |
| 72 | |
| 73 // Sets up the callbacks and shows the bubble. | |
| 74 void Show(ExtensionMessageBubble* bubble); | |
| 75 | |
| 76 // Callbacks from bubble. Declared virtual for testing purposes. | |
| 77 virtual void OnBubbleAction(); | |
| 78 virtual void OnBubbleDismiss(); | |
| 79 virtual void OnLinkClicked(); | |
| 80 | |
| 81 // Iterate over the known extensions and acknowledge each one. | |
| 82 void AcknowledgeExtensions(); | |
| 83 | |
| 84 // Get the data this class needs. | |
| 85 void FetchExtensionList(); | |
| 86 | |
| 87 // Our extension service. Weak, not owned by us. | |
| 88 ExtensionService* service_; | |
| 89 | |
| 90 // A weak pointer to the profile we are associated with. Not owned by us. | |
| 91 Profile* profile_; | |
| 92 | |
| 93 // The list of extensions found. | |
| 94 ExtensionIdList extension_list_; | |
| 95 | |
| 96 // The action the user took in the bubble. | |
| 97 BubbleAction user_action_; | |
| 98 | |
| 99 Delegate* delegate_; | |
| 100 | |
| 101 // Whether this class has initialized. | |
| 102 bool initialized_; | |
| 103 | |
| 104 // This object only checks once for suspicious extensions because the dataset | |
| 105 // doesn't change after startup. | |
| 106 bool has_notified_; | |
| 107 | |
| 108 DISALLOW_COPY_AND_ASSIGN(ExtensionMessageBubbleController); | |
| 109 }; | |
| 110 | |
| 111 } // namespace extensions | |
| 112 | |
| 113 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_MESSAGE_BUBBLE_CONTROLLER_H_ | |
| OLD | NEW |