OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_EXTENSIONS_SUSPICIOUS_EXTENSION_BUBBLE_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_SUSPICIOUS_EXTENSION_BUBBLE_CONTROLLER_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_SUSPICIOUS_EXTENSION_BUBBLE_CONTROLLER_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_SUSPICIOUS_EXTENSION_BUBBLE_CONTROLLER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include "chrome/browser/extensions/api/profile_keyed_api_factory.h" | 9 #include "chrome/browser/extensions/api/profile_keyed_api_factory.h" |
| 10 #include "chrome/browser/extensions/extension_message_bubble_controller.h" |
10 #include "extensions/common/extension.h" | 11 #include "extensions/common/extension.h" |
11 | 12 |
12 class Browser; | 13 class Browser; |
13 class ExtensionService; | 14 class ExtensionService; |
14 | 15 |
15 namespace extensions { | 16 namespace extensions { |
16 | 17 |
17 class SuspiciousExtensionBubble; | 18 class SuspiciousExtensionBubble; |
18 | 19 |
19 class SuspiciousExtensionBubbleController : public ProfileKeyedAPI { | 20 class SuspiciousExtensionBubbleController |
| 21 : public ProfileKeyedAPI, |
| 22 public ExtensionMessageBubbleController { |
20 public: | 23 public: |
21 explicit SuspiciousExtensionBubbleController(Profile* profile); | 24 explicit SuspiciousExtensionBubbleController(Profile* profile); |
22 virtual ~SuspiciousExtensionBubbleController(); | 25 virtual ~SuspiciousExtensionBubbleController(); |
23 | 26 |
24 // ProfileKeyedAPI implementation. | 27 // ProfileKeyedAPI implementation. |
25 static ProfileKeyedAPIFactory< | 28 static ProfileKeyedAPIFactory< |
26 SuspiciousExtensionBubbleController>* GetFactoryInstance(); | 29 SuspiciousExtensionBubbleController>* GetFactoryInstance(); |
27 | 30 |
28 // Convenience method to get the SuspiciousExtensionBubbleController for a | 31 // Convenience method to get the SuspiciousExtensionBubbleController for a |
29 // profile. | 32 // profile. |
30 static SuspiciousExtensionBubbleController* Get(Profile* profile); | 33 static SuspiciousExtensionBubbleController* Get(Profile* profile); |
31 | 34 |
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: | 35 private: |
53 friend class ProfileKeyedAPIFactory<SuspiciousExtensionBubbleController>; | 36 friend class ProfileKeyedAPIFactory<SuspiciousExtensionBubbleController>; |
54 | 37 |
55 // ProfileKeyedAPI implementation. | 38 // ProfileKeyedAPI implementation. |
56 static const char* service_name() { | 39 static const char* service_name() { |
57 return "SuspiciousExtensionBubbleController"; | 40 return "SuspiciousExtensionBubbleController"; |
58 } | 41 } |
59 static const bool kServiceRedirectedInIncognito = true; | 42 static const bool kServiceRedirectedInIncognito = true; |
60 | 43 |
61 // Mark all extensions found as acknowledged (don't need to warn about them | 44 // ExtensionMessageBubbleController methods. |
62 // again). | 45 virtual bool ShouldIncludeExtension(const std::string& extension_id) OVERRIDE; |
63 void AcknowledgeWipeout(); | 46 virtual void AcknowledgeExtension(const std::string& extension_id) OVERRIDE; |
64 | 47 virtual void PerformAction() OVERRIDE; |
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 | 48 |
79 DISALLOW_COPY_AND_ASSIGN(SuspiciousExtensionBubbleController); | 49 DISALLOW_COPY_AND_ASSIGN(SuspiciousExtensionBubbleController); |
80 }; | 50 }; |
81 | 51 |
82 template <> | 52 template <> |
83 void ProfileKeyedAPIFactory< | 53 void ProfileKeyedAPIFactory< |
84 SuspiciousExtensionBubbleController>::DeclareFactoryDependencies(); | 54 SuspiciousExtensionBubbleController>::DeclareFactoryDependencies(); |
85 | 55 |
86 } // namespace extensions | 56 } // namespace extensions |
87 | 57 |
88 #endif // CHROME_BROWSER_EXTENSIONS_SUSPICIOUS_EXTENSION_BUBBLE_CONTROLLER_H_ | 58 #endif // CHROME_BROWSER_EXTENSIONS_SUSPICIOUS_EXTENSION_BUBBLE_CONTROLLER_H_ |
OLD | NEW |