Chromium Code Reviews| 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 "chrome/browser/extensions/extension_message_bubble_controller.h" |
| 11 #include "extensions/common/extension.h" | 11 #include "extensions/common/extension.h" |
| 12 | 12 |
| 13 class Browser; | 13 class Browser; |
| 14 class ExtensionService; | 14 class ExtensionService; |
| 15 | 15 |
| 16 namespace extensions { | 16 namespace extensions { |
| 17 | 17 |
| 18 class SuspiciousExtensionBubble; | 18 class SuspiciousExtensionBubble; |
| 19 | 19 |
| 20 class SuspiciousExtensionBubbleController | 20 class SuspiciousExtensionBubbleDelegate |
|
not at google - send to devlin
2014/01/10 21:28:43
same comments here as in the other file (move this
Finnur
2014/01/13 15:36:32
Done.
| |
| 21 : public ProfileKeyedAPI, | 21 : public ExtensionMessageBubbleController::Delegate { |
| 22 public ExtensionMessageBubbleController, | |
| 23 public ExtensionMessageBubbleController::Delegate { | |
| 24 public: | 22 public: |
| 25 explicit SuspiciousExtensionBubbleController(Profile* profile); | 23 explicit SuspiciousExtensionBubbleDelegate(Profile* profile); |
| 26 virtual ~SuspiciousExtensionBubbleController(); | 24 virtual ~SuspiciousExtensionBubbleDelegate(); |
| 27 | |
| 28 // ProfileKeyedAPI implementation. | |
| 29 static ProfileKeyedAPIFactory< | |
| 30 SuspiciousExtensionBubbleController>* GetFactoryInstance(); | |
| 31 | |
| 32 // Convenience method to get the SuspiciousExtensionBubbleController | |
| 33 // for a profile. | |
| 34 static SuspiciousExtensionBubbleController* Get(Profile* profile); | |
| 35 | 25 |
| 36 // ExtensionMessageBubbleController::Delegate methods. | 26 // ExtensionMessageBubbleController::Delegate methods. |
| 37 virtual bool ShouldIncludeExtension(const std::string& extension_id) OVERRIDE; | 27 virtual bool ShouldIncludeExtension(const std::string& extension_id) OVERRIDE; |
| 38 virtual void AcknowledgeExtension( | 28 virtual void AcknowledgeExtension( |
| 39 const std::string& extension_id, | 29 const std::string& extension_id, |
| 40 ExtensionMessageBubbleController::BubbleAction user_action) OVERRIDE; | 30 ExtensionMessageBubbleController::BubbleAction user_action) OVERRIDE; |
| 41 virtual void PerformAction(const ExtensionIdList& list) OVERRIDE; | 31 virtual void PerformAction(const ExtensionIdList& list) OVERRIDE; |
| 42 virtual base::string16 GetTitle() const OVERRIDE; | 32 virtual base::string16 GetTitle() const OVERRIDE; |
| 43 virtual base::string16 GetMessageBody() const OVERRIDE; | 33 virtual base::string16 GetMessageBody() const OVERRIDE; |
| 44 virtual base::string16 GetOverflowText( | 34 virtual base::string16 GetOverflowText( |
| 45 const base::string16& overflow_count) const OVERRIDE; | 35 const base::string16& overflow_count) const OVERRIDE; |
| 46 virtual base::string16 GetLearnMoreLabel() const OVERRIDE; | 36 virtual base::string16 GetLearnMoreLabel() const OVERRIDE; |
| 47 virtual GURL GetLearnMoreUrl() const OVERRIDE; | 37 virtual GURL GetLearnMoreUrl() const OVERRIDE; |
| 48 virtual base::string16 GetActionButtonLabel() const OVERRIDE; | 38 virtual base::string16 GetActionButtonLabel() const OVERRIDE; |
| 49 virtual base::string16 GetDismissButtonLabel() const OVERRIDE; | 39 virtual base::string16 GetDismissButtonLabel() const OVERRIDE; |
| 50 virtual bool ShouldShowExtensionList() const OVERRIDE; | 40 virtual bool ShouldShowExtensionList() const OVERRIDE; |
| 51 virtual std::vector<base::string16> GetExtensions() OVERRIDE; | |
| 52 virtual void LogExtensionCount(size_t count) OVERRIDE; | 41 virtual void LogExtensionCount(size_t count) OVERRIDE; |
| 53 virtual void LogAction( | 42 virtual void LogAction( |
| 54 ExtensionMessageBubbleController::BubbleAction action) OVERRIDE; | 43 ExtensionMessageBubbleController::BubbleAction action) OVERRIDE; |
| 44 | |
| 55 private: | 45 private: |
| 56 friend class ProfileKeyedAPIFactory< | |
| 57 SuspiciousExtensionBubbleController>; | |
| 58 | |
| 59 // ProfileKeyedAPI implementation. | |
| 60 static const char* service_name() { | |
| 61 return "SuspiciousExtensionBubbleController"; | |
| 62 } | |
| 63 static const bool kServiceRedirectedInIncognito = true; | |
| 64 | |
| 65 // Our extension service. Weak, not owned by us. | 46 // Our extension service. Weak, not owned by us. |
| 66 ExtensionService* service_; | 47 ExtensionService* service_; |
| 67 | 48 |
| 49 DISALLOW_COPY_AND_ASSIGN(SuspiciousExtensionBubbleDelegate); | |
| 50 }; | |
| 51 | |
| 52 class SuspiciousExtensionBubbleController | |
| 53 : public ExtensionMessageBubbleController { | |
| 54 public: | |
| 55 explicit SuspiciousExtensionBubbleController(Profile* profile); | |
| 56 virtual ~SuspiciousExtensionBubbleController(); | |
| 57 | |
| 58 // Whether the controller knows of extensions to list in the bubble. Returns | |
| 59 // true if so. | |
| 60 bool ShouldShow(); | |
| 61 | |
| 62 // ExtensionMessageBubbleController methods. | |
| 63 virtual void Show(ExtensionMessageBubble* bubble) OVERRIDE; | |
| 64 | |
| 65 private: | |
| 66 FRIEND_TEST_ALL_PREFIXES(ExtensionMessageBubbleTest, WipeoutControllerTest); | |
| 67 | |
| 68 // Clears the list of profiles the bubble has been shown for. Should only be | |
| 69 // used during testing. | |
| 70 void ClearProfileListForTesting(); | |
| 71 | |
| 68 // A weak pointer to the profile we are associated with. Not owned by us. | 72 // A weak pointer to the profile we are associated with. Not owned by us. |
| 69 Profile* profile_; | 73 Profile* profile_; |
| 70 | 74 |
| 71 DISALLOW_COPY_AND_ASSIGN(SuspiciousExtensionBubbleController); | 75 DISALLOW_COPY_AND_ASSIGN(SuspiciousExtensionBubbleController); |
| 72 }; | 76 }; |
| 73 | 77 |
| 74 template <> | |
| 75 void ProfileKeyedAPIFactory< | |
| 76 SuspiciousExtensionBubbleController>::DeclareFactoryDependencies(); | |
| 77 | |
| 78 } // namespace extensions | 78 } // namespace extensions |
| 79 | 79 |
| 80 #endif // CHROME_BROWSER_EXTENSIONS_SUSPICIOUS_EXTENSION_BUBBLE_CONTROLLER_H_ | 80 #endif // CHROME_BROWSER_EXTENSIONS_SUSPICIOUS_EXTENSION_BUBBLE_CONTROLLER_H_ |
| OLD | NEW |