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_DEV_MODE_BUBBLE_CONTROLLER_H_ 6 #define CHROME_BROWSER_EXTENSIONS_DEV_MODE_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 "content/public/browser/notification_observer.h" 12 #include "content/public/browser/notification_registrar.h" 13 #include "extensions/common/extension.h" 14 15 class Browser; 16 class ExtensionService; 17 18 namespace extensions { 19 20 class DevModeBubble; 21 22 class DevModeBubbleController 23 : public ProfileKeyedAPI, 24 public ExtensionMessageBubbleController, 25 public ExtensionMessageBubbleController::Delegate { 26 public: 27 explicit DevModeBubbleController(Profile* profile); 28 virtual ~DevModeBubbleController(); 29 30 // ProfileKeyedAPI implementation. 31 static ProfileKeyedAPIFactory< 32 DevModeBubbleController>* GetFactoryInstance(); 33 34 // Convenience method to get the DevModeBubbleController for a 35 // profile. 36 static DevModeBubbleController* Get(Profile* profile); 37 38 // Returns true if the extension is considered a Developer Mode extension. 39 bool IsDevModeExtension(const Extension* extension) const; 40 41 // ExtensionMessageBubbleController::Delegate methods. 42 virtual bool ShouldIncludeExtension(const std::string& extension_id) OVERRIDE; 43 virtual void AcknowledgeExtension( 44 const std::string& extension_id, 45 ExtensionMessageBubbleController::BubbleAction user_action) OVERRIDE; 46 virtual void PerformAction(const ExtensionIdList& list) OVERRIDE; 47 virtual string16 GetTitle() const OVERRIDE; 48 virtual string16 GetMessageBody() const OVERRIDE; 49 virtual string16 GetOverflowText( 50 const string16& overflow_count) const OVERRIDE; 51 virtual string16 GetLearnMoreLabel() const OVERRIDE; 52 virtual GURL GetLearnMoreUrl() const OVERRIDE; 53 virtual string16 GetActionButtonLabel() const OVERRIDE; 54 virtual string16 GetDismissButtonLabel() const OVERRIDE; 55 virtual bool ShouldShowExtensionList() const OVERRIDE; 56 virtual std::vector<string16> GetExtensions() OVERRIDE; 57 virtual void LogExtensionCount(size_t count) OVERRIDE; 58 virtual void LogAction( 59 ExtensionMessageBubbleController::BubbleAction action) OVERRIDE; 60 61 private: 62 friend class ProfileKeyedAPIFactory<DevModeBubbleController>; 63 64 // ProfileKeyedAPI implementation. service_name()65 static const char* service_name() { 66 return "DevModeBubbleController"; 67 } 68 static const bool kServiceRedirectedInIncognito = true; 69 70 // Our extension service. Weak, not owned by us. 71 ExtensionService* service_; 72 73 // A weak pointer to the profile we are associated with. Not owned by us. 74 Profile* profile_; 75 76 77 DISALLOW_COPY_AND_ASSIGN(DevModeBubbleController); 78 }; 79 80 template <> 81 void ProfileKeyedAPIFactory< 82 DevModeBubbleController>::DeclareFactoryDependencies(); 83 84 } // namespace extensions 85 86 #endif // CHROME_BROWSER_EXTENSIONS_DEV_MODE_BUBBLE_CONTROLLER_H_ 87