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

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

Issue 134103002: Refactor the extension message bubbles. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed review comments 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_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 using extensions::ExtensionMessageBubbleController;
17 17
18 class SuspiciousExtensionBubble; 18 namespace {
19 19
20 class SuspiciousExtensionBubbleController 20 class SuspiciousExtensionBubbleDelegate
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(ExtensionService* service);
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 extensions::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 } // namespace
53
54 namespace extensions {
55
56 class SuspiciousExtensionBubble;
57
58 class SuspiciousExtensionBubbleController
59 : public ExtensionMessageBubbleController {
60 public:
61 // Clears the list of profiles the bubble has been shown for. Should only be
62 // used during testing.
63 static void ClearProfileListForTesting();
64
65 explicit SuspiciousExtensionBubbleController(Profile* profile);
66 virtual ~SuspiciousExtensionBubbleController();
67
68 // Whether the controller knows of extensions to list in the bubble. Returns
69 // true if so.
70 bool ShouldShow();
71
72 // ExtensionMessageBubbleController methods.
73 virtual void Show(ExtensionMessageBubble* bubble) OVERRIDE;
74
75 private:
68 // 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.
69 Profile* profile_; 77 Profile* profile_;
70 78
71 DISALLOW_COPY_AND_ASSIGN(SuspiciousExtensionBubbleController); 79 DISALLOW_COPY_AND_ASSIGN(SuspiciousExtensionBubbleController);
72 }; 80 };
73 81
74 template <>
75 void ProfileKeyedAPIFactory<
76 SuspiciousExtensionBubbleController>::DeclareFactoryDependencies();
77
78 } // namespace extensions 82 } // namespace extensions
79 83
80 #endif // CHROME_BROWSER_EXTENSIONS_SUSPICIOUS_EXTENSION_BUBBLE_CONTROLLER_H_ 84 #endif // CHROME_BROWSER_EXTENSIONS_SUSPICIOUS_EXTENSION_BUBBLE_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698