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, |
| 23 public ExtensionMessageBubbleController::Delegate { |
20 public: | 24 public: |
21 explicit SuspiciousExtensionBubbleController(Profile* profile); | 25 explicit SuspiciousExtensionBubbleController(Profile* profile); |
22 virtual ~SuspiciousExtensionBubbleController(); | 26 virtual ~SuspiciousExtensionBubbleController(); |
23 | 27 |
24 // ProfileKeyedAPI implementation. | 28 // ProfileKeyedAPI implementation. |
25 static ProfileKeyedAPIFactory< | 29 static ProfileKeyedAPIFactory< |
26 SuspiciousExtensionBubbleController>* GetFactoryInstance(); | 30 SuspiciousExtensionBubbleController>* GetFactoryInstance(); |
27 | 31 |
28 // Convenience method to get the SuspiciousExtensionBubbleController for a | 32 // Convenience method to get the SuspiciousExtensionBubbleController |
29 // profile. | 33 // for a profile. |
30 static SuspiciousExtensionBubbleController* Get(Profile* profile); | 34 static SuspiciousExtensionBubbleController* Get(Profile* profile); |
31 | 35 |
32 // Check for suspicious extensions, returns true if found. | 36 // Check for suspicious extensions, returns true if found. |
33 bool HasSuspiciousExtensions(); | 37 bool HasSuspiciousExtensions(); |
34 | 38 |
35 // Sets up the callbacks and shows the bubble. | 39 // Sets up the callbacks and shows the bubble. |
36 void Show(SuspiciousExtensionBubble* bubble); | 40 void Show(SuspiciousExtensionBubble* bubble); |
37 | 41 |
38 // Text for various UI labels shown in the bubble. | 42 // Text for various UI labels shown in the bubble. |
39 base::string16 GetTitle(); | 43 base::string16 GetTitle(); |
40 base::string16 GetMessageBody(); | 44 base::string16 GetMessageBody(); |
41 base::string16 GetOverflowText(const base::string16& overflow_count); | 45 base::string16 GetOverflowText(const base::string16& overflow_count); |
42 base::string16 GetLearnMoreLabel(); | 46 base::string16 GetLearnMoreLabel(); |
43 base::string16 GetDismissButtonLabel(); | 47 base::string16 GetDismissButtonLabel(); |
44 | 48 |
45 // Returns a vector of names of suspicious extensions found. | 49 // Returns a vector of names of suspicious extensions found. |
46 std::vector<base::string16> GetSuspiciousExtensionNames(); | 50 std::vector<base::string16> GetSuspiciousExtensionNames(); |
47 | 51 |
48 // Callbacks from bubble. Declared virtual for testing purposes. | 52 // Callbacks from bubble. Declared virtual for testing purposes. |
49 virtual void OnBubbleDismiss(); | 53 virtual void OnBubbleDismiss(); |
50 virtual void OnLinkClicked(); | 54 virtual void OnLinkClicked(); |
51 | 55 |
52 private: | 56 private: |
53 friend class ProfileKeyedAPIFactory<SuspiciousExtensionBubbleController>; | 57 friend class ProfileKeyedAPIFactory< |
| 58 SuspiciousExtensionBubbleController>; |
54 | 59 |
55 // ProfileKeyedAPI implementation. | 60 // ProfileKeyedAPI implementation. |
56 static const char* service_name() { | 61 static const char* service_name() { |
57 return "SuspiciousExtensionBubbleController"; | 62 return "SuspiciousExtensionBubbleController"; |
58 } | 63 } |
59 static const bool kServiceRedirectedInIncognito = true; | 64 static const bool kServiceRedirectedInIncognito = true; |
60 | 65 |
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. | 66 // Our extension service. Weak, not owned by us. |
70 ExtensionService* service_; | 67 ExtensionService* service_; |
71 | 68 |
72 // A weak pointer to the profile we are associated with. Not owned by us. | 69 // A weak pointer to the profile we are associated with. Not owned by us. |
73 Profile* profile_; | 70 Profile* profile_; |
74 | 71 |
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); | 72 DISALLOW_COPY_AND_ASSIGN(SuspiciousExtensionBubbleController); |
80 }; | 73 }; |
81 | 74 |
82 template <> | 75 template <> |
83 void ProfileKeyedAPIFactory< | 76 void ProfileKeyedAPIFactory< |
84 SuspiciousExtensionBubbleController>::DeclareFactoryDependencies(); | 77 SuspiciousExtensionBubbleController>::DeclareFactoryDependencies(); |
85 | 78 |
86 } // namespace extensions | 79 } // namespace extensions |
87 | 80 |
88 #endif // CHROME_BROWSER_EXTENSIONS_SUSPICIOUS_EXTENSION_BUBBLE_CONTROLLER_H_ | 81 #endif // CHROME_BROWSER_EXTENSIONS_SUSPICIOUS_EXTENSION_BUBBLE_CONTROLLER_H_ |
OLD | NEW |