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 "chrome/browser/extensions/extension_message_bubble_controller.h" 11 #include "extensions/common/extension.h" 12 13 class Browser; 14 class ExtensionService; 15 16 namespace extensions { 17 18 class SuspiciousExtensionBubble; 19 20 class SuspiciousExtensionBubbleController 21 : public ProfileKeyedAPI, 22 public ExtensionMessageBubbleController, 23 public ExtensionMessageBubbleController::Delegate { 24 public: 25 explicit SuspiciousExtensionBubbleController(Profile* profile); 26 virtual ~SuspiciousExtensionBubbleController(); 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 36 // ExtensionMessageBubbleController::Delegate methods. 37 virtual bool ShouldIncludeExtension(const std::string& extension_id) OVERRIDE; 38 virtual void AcknowledgeExtension( 39 const std::string& extension_id, 40 ExtensionMessageBubbleController::BubbleAction user_action) OVERRIDE; 41 virtual void PerformAction(const ExtensionIdList& list) OVERRIDE; 42 virtual base::string16 GetTitle() const OVERRIDE; 43 virtual base::string16 GetMessageBody() const OVERRIDE; 44 virtual base::string16 GetOverflowText( 45 const string16& overflow_count) const OVERRIDE; 46 virtual base::string16 GetLearnMoreLabel() const OVERRIDE; 47 virtual GURL GetLearnMoreUrl() const OVERRIDE; 48 virtual base::string16 GetActionButtonLabel() const OVERRIDE; 49 virtual base::string16 GetDismissButtonLabel() const OVERRIDE; 50 virtual bool ShouldShowExtensionList() const OVERRIDE; 51 virtual std::vector<string16> GetExtensions() OVERRIDE; 52 virtual void LogExtensionCount(size_t count) OVERRIDE; 53 virtual void LogAction( 54 ExtensionMessageBubbleController::BubbleAction action) OVERRIDE; 55 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. 66 ExtensionService* service_; 67 68 // A weak pointer to the profile we are associated with. Not owned by us. 69 Profile* profile_; 70 71 DISALLOW_COPY_AND_ASSIGN(SuspiciousExtensionBubbleController); 72 }; 73 74 template <> 75 void ProfileKeyedAPIFactory< 76 SuspiciousExtensionBubbleController>::DeclareFactoryDependencies(); 77 78 } // namespace extensions 79 80 #endif // CHROME_BROWSER_EXTENSIONS_SUSPICIOUS_EXTENSION_BUBBLE_CONTROLLER_H_ 81