Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(484)

Side by Side Diff: chrome/browser/extensions/dev_mode_bubble_controller.h

Issue 134103002: Refactor the extension message bubbles. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix compile errors on non-Win platform Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_DEV_MODE_BUBBLE_CONTROLLER_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_DEV_MODE_BUBBLE_CONTROLLER_H_
6 #define CHROME_BROWSER_EXTENSIONS_DEV_MODE_BUBBLE_CONTROLLER_H_ 6 #define CHROME_BROWSER_EXTENSIONS_DEV_MODE_BUBBLE_CONTROLLER_H_
7 7
8 #include <string> 8 #include <string>
9 #include "chrome/browser/extensions/api/profile_keyed_api_factory.h"
10 #include "chrome/browser/extensions/extension_message_bubble_controller.h" 9 #include "chrome/browser/extensions/extension_message_bubble_controller.h"
11 #include "content/public/browser/notification_observer.h" 10 #include "content/public/browser/notification_observer.h"
12 #include "content/public/browser/notification_registrar.h" 11 #include "content/public/browser/notification_registrar.h"
13 #include "extensions/common/extension.h" 12 #include "extensions/common/extension.h"
14 13
15 class Browser; 14 class Browser;
16 class ExtensionService; 15 class ExtensionService;
17 16
18 namespace extensions { 17 namespace extensions {
19 18
20 class DevModeBubble; 19 class DevModeBubble;
21 20
22 class DevModeBubbleController 21 class DevModeBubbleDelegate
not at google - send to devlin 2014/01/10 21:28:43 you could move this entire class into an anonymous
Finnur 2014/01/13 15:36:32 Done.
23 : public ProfileKeyedAPI, 22 : public ExtensionMessageBubbleController::Delegate {
24 public ExtensionMessageBubbleController,
25 public ExtensionMessageBubbleController::Delegate {
26 public: 23 public:
27 explicit DevModeBubbleController(Profile* profile); 24 // Returns true if the extension is considered a Developer Mode extension.
28 virtual ~DevModeBubbleController(); 25 static bool IsDevModeExtension(const Extension* extension);
29 26
30 // ProfileKeyedAPI implementation. 27 explicit DevModeBubbleDelegate(Profile* profile);
31 static ProfileKeyedAPIFactory< 28 virtual ~DevModeBubbleDelegate();
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 29
41 // ExtensionMessageBubbleController::Delegate methods. 30 // ExtensionMessageBubbleController::Delegate methods.
42 virtual bool ShouldIncludeExtension(const std::string& extension_id) OVERRIDE; 31 virtual bool ShouldIncludeExtension(const std::string& extension_id) OVERRIDE;
43 virtual void AcknowledgeExtension( 32 virtual void AcknowledgeExtension(
44 const std::string& extension_id, 33 const std::string& extension_id,
45 ExtensionMessageBubbleController::BubbleAction user_action) OVERRIDE; 34 ExtensionMessageBubbleController::BubbleAction user_action) OVERRIDE;
46 virtual void PerformAction(const ExtensionIdList& list) OVERRIDE; 35 virtual void PerformAction(const ExtensionIdList& list) OVERRIDE;
47 virtual base::string16 GetTitle() const OVERRIDE; 36 virtual base::string16 GetTitle() const OVERRIDE;
48 virtual base::string16 GetMessageBody() const OVERRIDE; 37 virtual base::string16 GetMessageBody() const OVERRIDE;
49 virtual base::string16 GetOverflowText( 38 virtual base::string16 GetOverflowText(
50 const base::string16& overflow_count) const OVERRIDE; 39 const base::string16& overflow_count) const OVERRIDE;
51 virtual base::string16 GetLearnMoreLabel() const OVERRIDE; 40 virtual base::string16 GetLearnMoreLabel() const OVERRIDE;
52 virtual GURL GetLearnMoreUrl() const OVERRIDE; 41 virtual GURL GetLearnMoreUrl() const OVERRIDE;
53 virtual base::string16 GetActionButtonLabel() const OVERRIDE; 42 virtual base::string16 GetActionButtonLabel() const OVERRIDE;
54 virtual base::string16 GetDismissButtonLabel() const OVERRIDE; 43 virtual base::string16 GetDismissButtonLabel() const OVERRIDE;
55 virtual bool ShouldShowExtensionList() const OVERRIDE; 44 virtual bool ShouldShowExtensionList() const OVERRIDE;
56 virtual std::vector<base::string16> GetExtensions() OVERRIDE;
57 virtual void LogExtensionCount(size_t count) OVERRIDE; 45 virtual void LogExtensionCount(size_t count) OVERRIDE;
58 virtual void LogAction( 46 virtual void LogAction(
59 ExtensionMessageBubbleController::BubbleAction action) OVERRIDE; 47 ExtensionMessageBubbleController::BubbleAction action) OVERRIDE;
60 48
61 private: 49 private:
62 friend class ProfileKeyedAPIFactory<DevModeBubbleController>;
63
64 // ProfileKeyedAPI implementation.
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. 50 // Our extension service. Weak, not owned by us.
71 ExtensionService* service_; 51 ExtensionService* service_;
72 52
53 DISALLOW_COPY_AND_ASSIGN(DevModeBubbleDelegate);
54 };
55
56 class DevModeBubbleController
57 : public ExtensionMessageBubbleController {
58 public:
59 explicit DevModeBubbleController(Profile* profile);
60 virtual ~DevModeBubbleController();
61
62 // Whether the controller knows of extensions to list in the bubble. Returns
63 // true if so.
64 bool ShouldShow();
65
66 // ExtensionMessageBubbleController methods.
67 virtual void Show(ExtensionMessageBubble* bubble) OVERRIDE;
68
69 private:
70 FRIEND_TEST_ALL_PREFIXES(ExtensionMessageBubbleTest, DevModeControllerTest);
71
72 // Clears the list of profiles the bubble has been shown for. Should only be
73 // used during testing.
74 void ClearProfileListForTesting();
not at google - send to devlin 2014/01/10 21:28:43 this can be static? it may seem a little arbitrary
Finnur 2014/01/13 15:36:32 Done.
75
73 // A weak pointer to the profile we are associated with. Not owned by us. 76 // A weak pointer to the profile we are associated with. Not owned by us.
74 Profile* profile_; 77 Profile* profile_;
75 78
76
77 DISALLOW_COPY_AND_ASSIGN(DevModeBubbleController); 79 DISALLOW_COPY_AND_ASSIGN(DevModeBubbleController);
78 }; 80 };
79 81
80 template <>
81 void ProfileKeyedAPIFactory<
82 DevModeBubbleController>::DeclareFactoryDependencies();
83
84 } // namespace extensions 82 } // namespace extensions
85 83
86 #endif // CHROME_BROWSER_EXTENSIONS_DEV_MODE_BUBBLE_CONTROLLER_H_ 84 #endif // CHROME_BROWSER_EXTENSIONS_DEV_MODE_BUBBLE_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698