| 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_SUSPICIOUS_EXTENSION_BUBBLE_CONTROLLER_H_ | |
| 6 #define CHROME_BROWSER_EXTENSIONS_SUSPICIOUS_EXTENSION_BUBBLE_CONTROLLER_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 #include "chrome/browser/extensions/api/profile_keyed_api_factory.h" | |
| 10 #include "extensions/common/extension.h" | |
| 11 | |
| 12 class Browser; | |
| 13 class ExtensionService; | |
| 14 | |
| 15 namespace extensions { | |
| 16 | |
| 17 class SuspiciousExtensionBubble; | |
| 18 | |
| 19 class SuspiciousExtensionBubbleController : public ProfileKeyedAPI { | |
| 20 public: | |
| 21 explicit SuspiciousExtensionBubbleController(Profile* profile); | |
| 22 virtual ~SuspiciousExtensionBubbleController(); | |
| 23 | |
| 24 // ProfileKeyedAPI implementation. | |
| 25 static ProfileKeyedAPIFactory< | |
| 26 SuspiciousExtensionBubbleController>* GetFactoryInstance(); | |
| 27 | |
| 28 // Convenience method to get the SuspiciousExtensionBubbleController for a | |
| 29 // profile. | |
| 30 static SuspiciousExtensionBubbleController* Get(Profile* profile); | |
| 31 | |
| 32 // Check for suspicious extensions, returns true if found. | |
| 33 bool HasSuspiciousExtensions(); | |
| 34 | |
| 35 // Sets up the callbacks and shows the bubble. | |
| 36 void Show(SuspiciousExtensionBubble* bubble); | |
| 37 | |
| 38 // Text for various UI labels shown in the bubble. | |
| 39 string16 GetTitle(); | |
| 40 string16 GetMessageBody(); | |
| 41 string16 GetOverflowText(const string16& overflow_count); | |
| 42 string16 GetLearnMoreLabel(); | |
| 43 string16 GetDismissButtonLabel(); | |
| 44 | |
| 45 // Returns a vector of names of suspicious extensions found. | |
| 46 std::vector<string16> GetSuspiciousExtensionNames(); | |
| 47 | |
| 48 // Callbacks from bubble. Declared virtual for testing purposes. | |
| 49 virtual void OnBubbleDismiss(); | |
| 50 virtual void OnLinkClicked(); | |
| 51 | |
| 52 private: | |
| 53 friend class ProfileKeyedAPIFactory<SuspiciousExtensionBubbleController>; | |
| 54 | |
| 55 // ProfileKeyedAPI implementation. | |
| 56 static const char* service_name() { | |
| 57 return "SuspiciousExtensionBubbleController"; | |
| 58 } | |
| 59 static const bool kServiceRedirectedInIncognito = true; | |
| 60 | |
| 61 // Mark all extensions found as acknowledged (don't need to warn about them | |
| 62 // again). | |
| 63 void AcknowledgeWipeout(); | |
| 64 | |
| 65 // The list of suspicious extensions found. Reset at the beginning of each | |
| 66 // call to FoundSuspiciousExtensions. | |
| 67 ExtensionIdList suspicious_extensions_; | |
| 68 | |
| 69 // Our extension service. Weak, not owned by us. | |
| 70 ExtensionService* service_; | |
| 71 | |
| 72 // A weak pointer to the profile we are associated with. Not owned by us. | |
| 73 Profile* profile_; | |
| 74 | |
| 75 // This object only checks once for suspicious extensions because the dataset | |
| 76 // doesn't change after startup. | |
| 77 bool has_notified_; | |
| 78 | |
| 79 DISALLOW_COPY_AND_ASSIGN(SuspiciousExtensionBubbleController); | |
| 80 }; | |
| 81 | |
| 82 template <> | |
| 83 void ProfileKeyedAPIFactory< | |
| 84 SuspiciousExtensionBubbleController>::DeclareFactoryDependencies(); | |
| 85 | |
| 86 } // namespace extensions | |
| 87 | |
| 88 #endif // CHROME_BROWSER_EXTENSIONS_SUSPICIOUS_EXTENSION_BUBBLE_CONTROLLER_H_ | |
| OLD | NEW |