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

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

Issue 10446034: Rename ActionBoxController -> LocationBarController. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: blah Created 8 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_SCRIPT_BADGE_CONTROLLER_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_SCRIPT_BADGE_CONTROLLER_H_
6 #define CHROME_BROWSER_EXTENSIONS_SCRIPT_BADGE_CONTROLLER_H_ 6 #define CHROME_BROWSER_EXTENSIONS_SCRIPT_BADGE_CONTROLLER_H_
7 #pragma once 7 #pragma once
8 8
9 #include <map> 9 #include <map>
10 #include <set> 10 #include <set>
11 #include <string> 11 #include <string>
12 12
13 #include "base/memory/linked_ptr.h" 13 #include "base/memory/linked_ptr.h"
14 #include "chrome/browser/extensions/action_box_controller.h" 14 #include "chrome/browser/extensions/location_bar_controller.h"
15 #include "chrome/browser/extensions/script_executor.h" 15 #include "chrome/browser/extensions/script_executor.h"
16 #include "chrome/browser/extensions/script_executor_impl.h" 16 #include "chrome/browser/extensions/script_executor_impl.h"
17 #include "content/public/browser/web_contents_observer.h" 17 #include "content/public/browser/web_contents_observer.h"
18 18
19 class ExtensionAction; 19 class ExtensionAction;
20 class ExtensionService; 20 class ExtensionService;
21 class TabContentsWrapper; 21 class TabContentsWrapper;
22 22
23 namespace extensions { 23 namespace extensions {
24 24
25 class Extension; 25 class Extension;
26 26
27 // An ActionBoxController which corresponds to script badges, and implements 27 // An LocationBarController which displays icons whenever a script is executing
28 // ScriptExecutor in order to show those scripts in the action box too. 28 // in a tab. It accomplishes this two different ways:
29 class ScriptBadgeController : public ActionBoxController, 29 //
30 // - For content_script declarations, the current URL in the tab is compared to
31 // registered content scripts when GetCurrentActions() is called.
32 // - An interface is exposed for programmatically executing scripts. Executed
33 // scripts are recorded and used later to populate GetCurrentActions().
34 //
35 // TODO(aa): There are some edge cases that need to be thought-through here:
36 //
37 // - Redirects. In this case, I think we may flicker the icons in the url bar
38 // as we bounce from URL to URL, without any script actually being executed.
39 // - Frames. This won't show icons for content_scripts running in frames. Should
40 // it?
41 // - Possibly other weirdness where the state here doesn't match the state in
42 // the renderer for whatever reason.
43 class ScriptBadgeController : public LocationBarController,
30 public ScriptExecutor, 44 public ScriptExecutor,
31 public content::WebContentsObserver { 45 public content::WebContentsObserver {
32 public: 46 public:
33 explicit ScriptBadgeController(TabContentsWrapper* tab_contents); 47 explicit ScriptBadgeController(TabContentsWrapper* tab_contents);
34 virtual ~ScriptBadgeController(); 48 virtual ~ScriptBadgeController();
35 49
36 // ActionBoxController implementation. 50 // LocationBarController implementation.
37 virtual scoped_ptr<std::vector<ExtensionAction*> > GetCurrentActions() 51 virtual scoped_ptr<std::vector<ExtensionAction*> > GetCurrentActions()
38 OVERRIDE; 52 OVERRIDE;
39 virtual Action OnClicked(const std::string& extension_id, 53 virtual Action OnClicked(const std::string& extension_id,
40 int mouse_button) OVERRIDE; 54 int mouse_button) OVERRIDE;
41 55
42 // ScriptExecutor implementation. 56 // ScriptExecutor implementation.
43 virtual void ExecuteScript(const std::string& extension_id, 57 virtual void ExecuteScript(const std::string& extension_id,
44 ScriptType script_type, 58 ScriptType script_type,
45 const std::string& code, 59 const std::string& code,
46 FrameScope frame_scope, 60 FrameScope frame_scope,
(...skipping 27 matching lines...) Expand all
74 // that get generated for extensions that haven't declared anything. 88 // that get generated for extensions that haven't declared anything.
75 typedef std::map<std::string, linked_ptr<ExtensionAction> > ScriptBadgeMap; 89 typedef std::map<std::string, linked_ptr<ExtensionAction> > ScriptBadgeMap;
76 ScriptBadgeMap script_badges_; 90 ScriptBadgeMap script_badges_;
77 91
78 DISALLOW_COPY_AND_ASSIGN(ScriptBadgeController); 92 DISALLOW_COPY_AND_ASSIGN(ScriptBadgeController);
79 }; 93 };
80 94
81 } // namespace extensions 95 } // namespace extensions
82 96
83 #endif // CHROME_BROWSER_EXTENSIONS_SCRIPT_BADGE_CONTROLLER_H_ 97 #endif // CHROME_BROWSER_EXTENSIONS_SCRIPT_BADGE_CONTROLLER_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/page_action_controller.cc ('k') | chrome/browser/extensions/script_badge_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698