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

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

Issue 10544185: Order the script badges in the location bar consistently (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: revert scoped_ptr change, rebase Created 8 years, 6 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
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/compiler_specific.h" 13 #include "base/compiler_specific.h"
14 #include "base/memory/linked_ptr.h" 14 #include "base/memory/linked_ptr.h"
15 #include "base/memory/ref_counted.h" 15 #include "base/memory/ref_counted.h"
16 #include "chrome/browser/extensions/location_bar_controller.h" 16 #include "chrome/browser/extensions/location_bar_controller.h"
17 #include "chrome/browser/extensions/script_executor.h" 17 #include "chrome/browser/extensions/script_executor.h"
18 #include "chrome/browser/extensions/script_executor_impl.h" 18 #include "chrome/browser/extensions/script_executor_impl.h"
19 #include "content/public/browser/notification_observer.h"
20 #include "content/public/browser/notification_registrar.h"
19 #include "content/public/browser/web_contents_observer.h" 21 #include "content/public/browser/web_contents_observer.h"
20 22
21 class ExtensionAction; 23 class ExtensionAction;
22 class ExtensionService; 24 class ExtensionService;
23 class TabContents; 25 class TabContents;
24 26
25 namespace IPC { 27 namespace IPC {
26 class Message; 28 class Message;
27 } 29 }
28 30
(...skipping 12 matching lines...) Expand all
41 // 43 //
42 // When extension IDs are recorded a NOTIFICATION_EXTENSION_LOCATION_BAR_UPDATED 44 // When extension IDs are recorded a NOTIFICATION_EXTENSION_LOCATION_BAR_UPDATED
43 // is sent, and those extensions will be returned from GetCurrentActions until 45 // is sent, and those extensions will be returned from GetCurrentActions until
44 // the next page navigation. 46 // the next page navigation.
45 // 47 //
46 // Ref-counted so that it can be safely bound in a base::Bind. 48 // Ref-counted so that it can be safely bound in a base::Bind.
47 class ScriptBadgeController 49 class ScriptBadgeController
48 : public base::RefCountedThreadSafe<ScriptBadgeController>, 50 : public base::RefCountedThreadSafe<ScriptBadgeController>,
49 public LocationBarController, 51 public LocationBarController,
50 public ScriptExecutor, 52 public ScriptExecutor,
51 public content::WebContentsObserver { 53 public content::WebContentsObserver,
54 public content::NotificationObserver {
52 public: 55 public:
53 explicit ScriptBadgeController(TabContents* tab_contents); 56 explicit ScriptBadgeController(TabContents* tab_contents);
54 57
55 // LocationBarController implementation. 58 // LocationBarController implementation.
56 virtual scoped_ptr<std::vector<ExtensionAction*> > GetCurrentActions() 59 virtual std::vector<ExtensionAction*> GetCurrentActions() OVERRIDE;
57 OVERRIDE;
58 virtual Action OnClicked(const std::string& extension_id, 60 virtual Action OnClicked(const std::string& extension_id,
59 int mouse_button) OVERRIDE; 61 int mouse_button) OVERRIDE;
60 62
61 // ScriptExecutor implementation. 63 // ScriptExecutor implementation.
62 virtual void ExecuteScript(const std::string& extension_id, 64 virtual void ExecuteScript(const std::string& extension_id,
63 ScriptType script_type, 65 ScriptType script_type,
64 const std::string& code, 66 const std::string& code,
65 FrameScope frame_scope, 67 FrameScope frame_scope,
66 UserScript::RunLocation run_at, 68 UserScript::RunLocation run_at,
67 WorldType world_type, 69 WorldType world_type,
(...skipping 19 matching lines...) Expand all
87 89
88 // Sends a LOCATION_BAR_UPDATED notification. 90 // Sends a LOCATION_BAR_UPDATED notification.
89 void Notify(); 91 void Notify();
90 92
91 // content::WebContentsObserver implementation. 93 // content::WebContentsObserver implementation.
92 virtual void DidNavigateMainFrame( 94 virtual void DidNavigateMainFrame(
93 const content::LoadCommittedDetails& details, 95 const content::LoadCommittedDetails& details,
94 const content::FrameNavigateParams& params) OVERRIDE; 96 const content::FrameNavigateParams& params) OVERRIDE;
95 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; 97 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
96 98
99 // content::NotificationObserver implementation.
100 virtual void Observe(int type,
101 const content::NotificationSource& source,
102 const content::NotificationDetails& details) OVERRIDE;
103
97 // IPC::Message handlers. 104 // IPC::Message handlers.
98 void OnContentScriptsExecuting(const std::set<std::string>& extension_ids, 105 void OnContentScriptsExecuting(const std::set<std::string>& extension_ids,
99 int32 page_id); 106 int32 page_id);
100 107
108 // Tries to insert an extension into the relevant collections, and returns
109 // whether any change was made.
110 bool InsertExtension(const std::string& extension_id);
111
112 // Tries to erase an extension from the relevant collections, and returns
113 // whether any change was made.
114 bool EraseExtension(const Extension* extension);
115
101 // Delegate ScriptExecutorImpl for running ExecuteScript. 116 // Delegate ScriptExecutorImpl for running ExecuteScript.
102 ScriptExecutorImpl script_executor_; 117 ScriptExecutorImpl script_executor_;
103 118
104 // Our parent TabContents. 119 // Our parent TabContents.
105 TabContents* tab_contents_; 120 TabContents* tab_contents_;
106 121
122 // The current extension actions in the order they appeared.
123 std::vector<ExtensionAction*> current_actions_;
124
107 // The extensions that have called ExecuteScript on the current frame. 125 // The extensions that have called ExecuteScript on the current frame.
108 std::set<std::string> extensions_executing_scripts_; 126 std::set<std::string> extensions_executing_scripts_;
109 127
128 // Listen to extension unloaded notifications.
129 content::NotificationRegistrar registrar_;
130
110 DISALLOW_COPY_AND_ASSIGN(ScriptBadgeController); 131 DISALLOW_COPY_AND_ASSIGN(ScriptBadgeController);
111 }; 132 };
112 133
113 } // namespace extensions 134 } // namespace extensions
114 135
115 #endif // CHROME_BROWSER_EXTENSIONS_SCRIPT_BADGE_CONTROLLER_H_ 136 #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