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 // ExtensionMessageBubbleController::Delegate methods. |
33 bool HasSuspiciousExtensions(); | 37 virtual bool ShouldIncludeExtension(const std::string& extension_id) OVERRIDE; |
34 | 38 virtual void AcknowledgeExtension( |
35 // Sets up the callbacks and shows the bubble. | 39 const std::string& extension_id, |
36 void Show(SuspiciousExtensionBubble* bubble); | 40 ExtensionMessageBubbleController::BubbleAction user_action) OVERRIDE; |
37 | 41 virtual void PerformAction(const ExtensionIdList& list) OVERRIDE; |
38 // Text for various UI labels shown in the bubble. | 42 virtual base::string16 GetTitle() const OVERRIDE; |
39 base::string16 GetTitle(); | 43 virtual base::string16 GetMessageBody() const OVERRIDE; |
40 base::string16 GetMessageBody(); | 44 virtual base::string16 GetOverflowText( |
41 base::string16 GetOverflowText(const base::string16& overflow_count); | 45 const string16& overflow_count) const OVERRIDE; |
42 base::string16 GetLearnMoreLabel(); | 46 virtual base::string16 GetLearnMoreLabel() const OVERRIDE; |
43 base::string16 GetDismissButtonLabel(); | 47 virtual GURL GetLearnMoreUrl() const OVERRIDE; |
44 | 48 virtual base::string16 GetActionButtonLabel() const OVERRIDE; |
45 // Returns a vector of names of suspicious extensions found. | 49 virtual base::string16 GetDismissButtonLabel() const OVERRIDE; |
46 std::vector<base::string16> GetSuspiciousExtensionNames(); | 50 virtual bool ShouldShowExtensionList() const OVERRIDE; |
47 | 51 virtual std::vector<string16> GetExtensions() OVERRIDE; |
48 // Callbacks from bubble. Declared virtual for testing purposes. | 52 virtual void LogExtensionCount(size_t count) OVERRIDE; |
49 virtual void OnBubbleDismiss(); | 53 virtual void LogAction( |
50 virtual void OnLinkClicked(); | 54 ExtensionMessageBubbleController::BubbleAction action) OVERRIDE; |
51 | |
52 private: | 55 private: |
53 friend class ProfileKeyedAPIFactory<SuspiciousExtensionBubbleController>; | 56 friend class ProfileKeyedAPIFactory< |
| 57 SuspiciousExtensionBubbleController>; |
54 | 58 |
55 // ProfileKeyedAPI implementation. | 59 // ProfileKeyedAPI implementation. |
56 static const char* service_name() { | 60 static const char* service_name() { |
57 return "SuspiciousExtensionBubbleController"; | 61 return "SuspiciousExtensionBubbleController"; |
58 } | 62 } |
59 static const bool kServiceRedirectedInIncognito = true; | 63 static const bool kServiceRedirectedInIncognito = true; |
60 | 64 |
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. | 65 // Our extension service. Weak, not owned by us. |
70 ExtensionService* service_; | 66 ExtensionService* service_; |
71 | 67 |
72 // A weak pointer to the profile we are associated with. Not owned by us. | 68 // A weak pointer to the profile we are associated with. Not owned by us. |
73 Profile* profile_; | 69 Profile* profile_; |
74 | 70 |
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); | 71 DISALLOW_COPY_AND_ASSIGN(SuspiciousExtensionBubbleController); |
80 }; | 72 }; |
81 | 73 |
82 template <> | 74 template <> |
83 void ProfileKeyedAPIFactory< | 75 void ProfileKeyedAPIFactory< |
84 SuspiciousExtensionBubbleController>::DeclareFactoryDependencies(); | 76 SuspiciousExtensionBubbleController>::DeclareFactoryDependencies(); |
85 | 77 |
86 } // namespace extensions | 78 } // namespace extensions |
87 | 79 |
88 #endif // CHROME_BROWSER_EXTENSIONS_SUSPICIOUS_EXTENSION_BUBBLE_CONTROLLER_H_ | 80 #endif // CHROME_BROWSER_EXTENSIONS_SUSPICIOUS_EXTENSION_BUBBLE_CONTROLLER_H_ |
OLD | NEW |