OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 #include "chrome/browser/extensions/extension_function_dispatcher.h" | 5 #include "chrome/browser/extensions/extension_function_dispatcher.h" |
6 | 6 |
7 #include "base/process_util.h" | 7 #include "base/process_util.h" |
8 #include "base/singleton.h" | 8 #include "base/singleton.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "chrome/browser/extensions/extension_bookmarks_module.h" | 10 #include "chrome/browser/extensions/extension_bookmarks_module.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 } | 61 } |
62 | 62 |
63 void FactoryRegistry::ResetFunctions() { | 63 void FactoryRegistry::ResetFunctions() { |
64 // Register all functions here. | 64 // Register all functions here. |
65 | 65 |
66 namespace tabs = extension_tabs_module_constants; | 66 namespace tabs = extension_tabs_module_constants; |
67 namespace page_actions = extension_page_actions_module_constants; | 67 namespace page_actions = extension_page_actions_module_constants; |
68 namespace bookmarks = extension_bookmarks_module_constants; | 68 namespace bookmarks = extension_bookmarks_module_constants; |
69 | 69 |
70 // Windows | 70 // Windows |
71 factories_[tabs::kGetWindowFunction] = | 71 factories_[tabs::kGetWindowFunction] = |
72 &NewExtensionFunction<GetWindowFunction>; | 72 &NewExtensionFunction<GetWindowFunction>; |
73 factories_[tabs::kGetCurrentWindowFunction] = | 73 factories_[tabs::kGetCurrentWindowFunction] = |
74 &NewExtensionFunction<GetCurrentWindowFunction>; | 74 &NewExtensionFunction<GetCurrentWindowFunction>; |
75 factories_[tabs::kGetLastFocusedWindowFunction] = | 75 factories_[tabs::kGetLastFocusedWindowFunction] = |
76 &NewExtensionFunction<GetLastFocusedWindowFunction>; | 76 &NewExtensionFunction<GetLastFocusedWindowFunction>; |
77 factories_[tabs::kGetAllWindowsFunction] = | 77 factories_[tabs::kGetAllWindowsFunction] = |
78 &NewExtensionFunction<GetAllWindowsFunction>; | 78 &NewExtensionFunction<GetAllWindowsFunction>; |
79 factories_[tabs::kCreateWindowFunction] = | 79 factories_[tabs::kCreateWindowFunction] = |
80 &NewExtensionFunction<CreateWindowFunction>; | 80 &NewExtensionFunction<CreateWindowFunction>; |
81 factories_[tabs::kUpdateWindowFunction] = | 81 factories_[tabs::kUpdateWindowFunction] = |
82 &NewExtensionFunction<UpdateWindowFunction>; | 82 &NewExtensionFunction<UpdateWindowFunction>; |
83 factories_[tabs::kRemoveWindowFunction] = | 83 factories_[tabs::kRemoveWindowFunction] = |
84 &NewExtensionFunction<RemoveWindowFunction>; | 84 &NewExtensionFunction<RemoveWindowFunction>; |
85 | 85 |
86 // Tabs | 86 // Tabs |
87 factories_[tabs::kGetTabFunction] = | 87 factories_[tabs::kGetTabFunction] = |
88 &NewExtensionFunction<GetTabFunction>; | 88 &NewExtensionFunction<GetTabFunction>; |
89 factories_[tabs::kGetSelectedTabFunction] = | 89 factories_[tabs::kGetSelectedTabFunction] = |
90 &NewExtensionFunction<GetSelectedTabFunction>; | 90 &NewExtensionFunction<GetSelectedTabFunction>; |
91 factories_[tabs::kGetAllTabsInWindowFunction] = | 91 factories_[tabs::kGetAllTabsInWindowFunction] = |
92 &NewExtensionFunction<GetAllTabsInWindowFunction>; | 92 &NewExtensionFunction<GetAllTabsInWindowFunction>; |
93 factories_[tabs::kCreateTabFunction] = | 93 factories_[tabs::kCreateTabFunction] = |
94 &NewExtensionFunction<CreateTabFunction>; | 94 &NewExtensionFunction<CreateTabFunction>; |
95 factories_[tabs::kUpdateTabFunction] = | 95 factories_[tabs::kUpdateTabFunction] = |
96 &NewExtensionFunction<UpdateTabFunction>; | 96 &NewExtensionFunction<UpdateTabFunction>; |
97 factories_[tabs::kMoveTabFunction] = | 97 factories_[tabs::kMoveTabFunction] = |
98 &NewExtensionFunction<MoveTabFunction>; | 98 &NewExtensionFunction<MoveTabFunction>; |
99 factories_[tabs::kRemoveTabFunction] = | 99 factories_[tabs::kRemoveTabFunction] = |
100 &NewExtensionFunction<RemoveTabFunction>; | 100 &NewExtensionFunction<RemoveTabFunction>; |
101 | 101 |
102 // Page Actions. | 102 // Page Actions. |
103 factories_[page_actions::kEnablePageActionFunction] = | 103 factories_[page_actions::kEnablePageActionFunction] = |
104 &NewExtensionFunction<EnablePageActionFunction>; | 104 &NewExtensionFunction<EnablePageActionFunction>; |
105 | 105 |
106 // Bookmarks. | 106 // Bookmarks. |
107 factories_[bookmarks::kGetBookmarksFunction] = | 107 factories_[bookmarks::kGetBookmarksFunction] = |
108 &NewExtensionFunction<GetBookmarksFunction>; | 108 &NewExtensionFunction<GetBookmarksFunction>; |
109 factories_[bookmarks::kGetBookmarkChildrenFunction] = | 109 factories_[bookmarks::kGetBookmarkChildrenFunction] = |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 ExtensionMessageService::GetInstance(profile()->GetRequestContext()); | 178 ExtensionMessageService::GetInstance(profile()->GetRequestContext()); |
179 DCHECK(process); | 179 DCHECK(process); |
180 DCHECK(message_service); | 180 DCHECK(message_service); |
181 message_service->RegisterExtension(extension_id, process->pid()); | 181 message_service->RegisterExtension(extension_id, process->pid()); |
182 } | 182 } |
183 | 183 |
184 Browser* ExtensionFunctionDispatcher::GetBrowser() { | 184 Browser* ExtensionFunctionDispatcher::GetBrowser() { |
185 DCHECK(delegate_); | 185 DCHECK(delegate_); |
186 | 186 |
187 Browser* retval = delegate_->GetBrowser(); | 187 Browser* retval = delegate_->GetBrowser(); |
188 DCHECK(retval); | |
189 return retval; | 188 return retval; |
190 } | 189 } |
191 | 190 |
192 void ExtensionFunctionDispatcher::HandleRequest(const std::string& name, | 191 void ExtensionFunctionDispatcher::HandleRequest(const std::string& name, |
193 const std::string& args, | 192 const std::string& args, |
194 int request_id, | 193 int request_id, |
195 bool has_callback) { | 194 bool has_callback) { |
196 // TODO(aa): This will get a bit more complicated when we support functions | 195 // TODO(aa): This will get a bit more complicated when we support functions |
197 // that live longer than the stack frame. | 196 // that live longer than the stack frame. |
198 scoped_ptr<ExtensionFunction> function( | 197 scoped_ptr<ExtensionFunction> function( |
(...skipping 20 matching lines...) Expand all Loading... |
219 } else { | 218 } else { |
220 NOTREACHED(); | 219 NOTREACHED(); |
221 base::KillProcess(render_view_host_->process()->process().handle(), | 220 base::KillProcess(render_view_host_->process()->process().handle(), |
222 ResultCodes::KILLED_BAD_MESSAGE, false); | 221 ResultCodes::KILLED_BAD_MESSAGE, false); |
223 } | 222 } |
224 } | 223 } |
225 | 224 |
226 Profile* ExtensionFunctionDispatcher::profile() { | 225 Profile* ExtensionFunctionDispatcher::profile() { |
227 return render_view_host_->process()->profile(); | 226 return render_view_host_->process()->profile(); |
228 } | 227 } |
OLD | NEW |