OLD | NEW |
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_BROWSER_EVENT_ROUTER_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_BROWSER_EVENT_ROUTER_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_BROWSER_EVENT_ROUTER_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_BROWSER_EVENT_ROUTER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
13 #include "chrome/browser/extensions/api/tabs/tabs.h" | 13 #include "chrome/browser/extensions/api/tabs/tabs.h" |
| 14 #include "chrome/browser/extensions/event_router.h" |
14 #include "chrome/browser/extensions/extension_toolbar_model.h" | 15 #include "chrome/browser/extensions/extension_toolbar_model.h" |
15 #include "chrome/browser/ui/browser_list_observer.h" | 16 #include "chrome/browser/ui/browser_list_observer.h" |
16 #include "chrome/browser/ui/tabs/tab_strip_model_observer.h" | 17 #include "chrome/browser/ui/tabs/tab_strip_model_observer.h" |
17 #include "content/public/browser/notification_registrar.h" | 18 #include "content/public/browser/notification_registrar.h" |
18 | 19 |
19 namespace content { | 20 namespace content { |
20 class WebContents; | 21 class WebContents; |
21 } | 22 } |
22 | 23 |
23 namespace extensions { | 24 namespace extensions { |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 | 100 |
100 // Internal processing of tab updated events. Is called by both TabChangedAt | 101 // Internal processing of tab updated events. Is called by both TabChangedAt |
101 // and Observe/NAV_ENTRY_COMMITTED. | 102 // and Observe/NAV_ENTRY_COMMITTED. |
102 void TabUpdated(content::WebContents* contents, bool did_navigate); | 103 void TabUpdated(content::WebContents* contents, bool did_navigate); |
103 | 104 |
104 // The DispatchEvent methods forward events to the |profile|'s event router. | 105 // The DispatchEvent methods forward events to the |profile|'s event router. |
105 // The BrowserEventRouter listens to events for all profiles, | 106 // The BrowserEventRouter listens to events for all profiles, |
106 // so we avoid duplication by dropping events destined for other profiles. | 107 // so we avoid duplication by dropping events destined for other profiles. |
107 void DispatchEvent(Profile* profile, | 108 void DispatchEvent(Profile* profile, |
108 const char* event_name, | 109 const char* event_name, |
109 const std::string& json_args); | 110 const std::string& json_args, |
| 111 EventRouter::UserGestureState user_gesture); |
110 | 112 |
111 void DispatchEventToExtension(Profile* profile, | 113 void DispatchEventToExtension(Profile* profile, |
112 const std::string& extension_id, | 114 const std::string& extension_id, |
113 const char* event_name, | 115 const char* event_name, |
114 const std::string& json_args); | 116 const std::string& json_args, |
| 117 EventRouter::UserGestureState user_gesture); |
115 | 118 |
116 void DispatchEventsAcrossIncognito(Profile* profile, | 119 void DispatchEventsAcrossIncognito(Profile* profile, |
117 const char* event_name, | 120 const char* event_name, |
118 const std::string& json_args, | 121 const std::string& json_args, |
119 const std::string& cross_incognito_args); | 122 const std::string& cross_incognito_args); |
120 | 123 |
121 void DispatchEventWithTab(Profile* profile, | 124 void DispatchEventWithTab(Profile* profile, |
122 const std::string& extension_id, | 125 const std::string& extension_id, |
123 const char* event_name, | 126 const char* event_name, |
124 const content::WebContents* web_contents, | 127 const content::WebContents* web_contents, |
125 bool active); | 128 bool active, |
| 129 EventRouter::UserGestureState user_gesture); |
126 | 130 |
127 void DispatchSimpleBrowserEvent(Profile* profile, | 131 void DispatchSimpleBrowserEvent(Profile* profile, |
128 const int window_id, | 132 const int window_id, |
129 const char* event_name); | 133 const char* event_name); |
130 | 134 |
131 // Packages |changed_properties| as a tab updated event for the tab |contents| | 135 // Packages |changed_properties| as a tab updated event for the tab |contents| |
132 // and dispatches the event to the extension. | 136 // and dispatches the event to the extension. |
133 void DispatchTabUpdatedEvent(content::WebContents* contents, | 137 void DispatchTabUpdatedEvent(content::WebContents* contents, |
134 DictionaryValue* changed_properties); | 138 DictionaryValue* changed_properties); |
135 | 139 |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 | 211 |
208 // The main profile that owns this event router. | 212 // The main profile that owns this event router. |
209 Profile* profile_; | 213 Profile* profile_; |
210 | 214 |
211 DISALLOW_COPY_AND_ASSIGN(BrowserEventRouter); | 215 DISALLOW_COPY_AND_ASSIGN(BrowserEventRouter); |
212 }; | 216 }; |
213 | 217 |
214 } // namespace extensions | 218 } // namespace extensions |
215 | 219 |
216 #endif // CHROME_BROWSER_EXTENSIONS_BROWSER_EVENT_ROUTER_H_ | 220 #endif // CHROME_BROWSER_EXTENSIONS_BROWSER_EVENT_ROUTER_H_ |
OLD | NEW |