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

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

Issue 270153004: Introduce ActiveScriptController; track active extension scripts (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Kalman's Created 6 years, 7 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_LOCATION_BAR_CONTROLLER_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_LOCATION_BAR_CONTROLLER_H_
6 #define CHROME_BROWSER_EXTENSIONS_LOCATION_BAR_CONTROLLER_H_ 6 #define CHROME_BROWSER_EXTENSIONS_LOCATION_BAR_CONTROLLER_H_
7 7
8 #include <set>
9 #include <string>
10 #include <vector> 8 #include <vector>
11 9
10 #include "base/macros.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "content/public/browser/web_contents_observer.h"
13
14 namespace content {
15 class WebContents;
16 }
17
12 class ExtensionAction; 18 class ExtensionAction;
13 19
14 namespace extensions { 20 namespace extensions {
21 class ActiveScriptController;
22 class PageActionController;
15 23
16 // Interface for a class that controls the the extension icons that show up in 24 // Interface for a class that controls the the extension icons that show up in
17 // the location bar. Depending on switches, these icons can have differing 25 // the location bar. Depending on switches, these icons can have differing
not at google - send to devlin 2014/05/08 20:47:09 hey this comment makes sense again!
18 // behavior. 26 // behavior.
19 class LocationBarController { 27 class LocationBarController : public content::WebContentsObserver {
20 public: 28 public:
21 // The reaction that the UI should take after executing |OnClicked|. 29 // The action that the UI should take after executing |OnClicked|.
22 enum Action { 30 enum Action {
23 ACTION_NONE, 31 ACTION_NONE,
24 ACTION_SHOW_POPUP, 32 ACTION_SHOW_POPUP,
25 ACTION_SHOW_CONTEXT_MENU, 33 ACTION_SHOW_CONTEXT_MENU,
26 }; 34 };
27 35
28 virtual ~LocationBarController() {} 36 explicit LocationBarController(content::WebContents* web_contents);
37 virtual ~LocationBarController();
29 38
30 // Gets the action data for all extensions. 39 // Returns the actions which should be displayed in the location bar.
31 virtual std::vector<ExtensionAction*> GetCurrentActions() const = 0; 40 std::vector<ExtensionAction*> GetCurrentActions();
32 41
33 // Notifies this that the badge for an extension has been clicked with some 42 // Notifies this that an ExtensionAction has been clicked, and returns the
34 // mouse button (1 for left, 2 for middle, and 3 for right click), and 43 // action which should be taken in response (if any).
35 // returns the action that should be taken in response (if any). 44 Action OnClicked(const ExtensionAction* action);
36 // TODO(kalman): make mouse_button an enum.
37 virtual Action OnClicked(const std::string& extension_id,
38 int mouse_button) = 0;
39 45
40 // Notifies clients that the icons have changed. 46 // Notifies the window that the actions have changed.
41 virtual void NotifyChange() = 0; 47 static void NotifyChange(content::WebContents* web_contents);
48
49 ActiveScriptController* active_script_controller() {
not at google - send to devlin 2014/05/08 20:47:09 hey if the activity log exposed an observer interf
50 return active_script_controller_.get();
51 }
52
53 PageActionController* page_action_controller() {
54 return page_action_controller_.get();
55 }
not at google - send to devlin 2014/05/08 20:47:09 if you don't need to expose this, don't. the activ
Devlin 2014/05/08 23:01:00 Done.
56
57 private:
58 // content::WebContentsObserver implementation.
59 virtual void DidNavigateMainFrame(
60 const content::LoadCommittedDetails& details,
61 const content::FrameNavigateParams& params) OVERRIDE;
62
63 // The associated WebContents.
64 content::WebContents* web_contents_;
65
66 // The controllers for different sources of actions in the location bar.
67 // Currently, this is only page actions and active script actions, so we
68 // explicitly own and create both. If there are ever more, it will be worth
69 // considering making this class own a list of LocationBarControllerProviders
70 // instead.
71 scoped_ptr<ActiveScriptController> active_script_controller_;
72 scoped_ptr<PageActionController> page_action_controller_;
73
74 DISALLOW_COPY_AND_ASSIGN(LocationBarController);
42 }; 75 };
43 76
44 } // namespace extensions 77 } // namespace extensions
45 78
46 #endif // CHROME_BROWSER_EXTENSIONS_LOCATION_BAR_CONTROLLER_H_ 79 #endif // CHROME_BROWSER_EXTENSIONS_LOCATION_BAR_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698