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/browser.h" |
| 11 #include "chrome/browser/browser_window.h" |
10 #include "chrome/browser/extensions/execute_code_in_tab_function.h" | 12 #include "chrome/browser/extensions/execute_code_in_tab_function.h" |
11 #include "chrome/browser/extensions/extension_bookmarks_module.h" | 13 #include "chrome/browser/extensions/extension_bookmarks_module.h" |
12 #include "chrome/browser/extensions/extension_bookmarks_module_constants.h" | 14 #include "chrome/browser/extensions/extension_bookmarks_module_constants.h" |
13 #include "chrome/browser/extensions/extension_browser_actions_api.h" | 15 #include "chrome/browser/extensions/extension_browser_actions_api.h" |
14 #include "chrome/browser/extensions/extension_dom_ui.h" | 16 #include "chrome/browser/extensions/extension_dom_ui.h" |
15 #include "chrome/browser/extensions/extension_function.h" | 17 #include "chrome/browser/extensions/extension_function.h" |
16 #include "chrome/browser/extensions/extension_history_api.h" | 18 #include "chrome/browser/extensions/extension_history_api.h" |
17 #include "chrome/browser/extensions/extension_i18n_api.h" | 19 #include "chrome/browser/extensions/extension_i18n_api.h" |
18 #include "chrome/browser/extensions/extension_message_service.h" | 20 #include "chrome/browser/extensions/extension_message_service.h" |
19 #include "chrome/browser/extensions/extension_page_actions_module.h" | 21 #include "chrome/browser/extensions/extension_page_actions_module.h" |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 ExtensionFunction* FactoryRegistry::NewFunction(const std::string& name) { | 176 ExtensionFunction* FactoryRegistry::NewFunction(const std::string& name) { |
175 FactoryMap::iterator iter = factories_.find(name); | 177 FactoryMap::iterator iter = factories_.find(name); |
176 DCHECK(iter != factories_.end()); | 178 DCHECK(iter != factories_.end()); |
177 ExtensionFunction* function = iter->second(); | 179 ExtensionFunction* function = iter->second(); |
178 function->set_name(name); | 180 function->set_name(name); |
179 return function; | 181 return function; |
180 } | 182 } |
181 | 183 |
182 }; // namespace | 184 }; // namespace |
183 | 185 |
| 186 // ExtensionFunctionDispatcher::Delegate --------------------------------------- |
| 187 |
| 188 gfx::NativeWindow ExtensionFunctionDispatcher::Delegate:: |
| 189 GetFrameNativeWindow() { |
| 190 Browser* browser = GetBrowser(); |
| 191 // If a browser is bound to this dispatcher, then return the widget hosting |
| 192 // the window. Extensions hosted in ExternalTabContainer objects may not |
| 193 // have a running browser instance. |
| 194 if (browser) |
| 195 return browser->window()->GetNativeHandle(); |
| 196 |
| 197 return NULL; |
| 198 } |
| 199 |
184 // ExtensionFunctionDispatcher ------------------------------------------------- | 200 // ExtensionFunctionDispatcher ------------------------------------------------- |
185 | 201 |
186 void ExtensionFunctionDispatcher::GetAllFunctionNames( | 202 void ExtensionFunctionDispatcher::GetAllFunctionNames( |
187 std::vector<std::string>* names) { | 203 std::vector<std::string>* names) { |
188 FactoryRegistry::instance()->GetAllNames(names); | 204 FactoryRegistry::instance()->GetAllNames(names); |
189 } | 205 } |
190 | 206 |
191 bool ExtensionFunctionDispatcher::OverrideFunction( | 207 bool ExtensionFunctionDispatcher::OverrideFunction( |
192 const std::string& name, ExtensionFunctionFactory factory) { | 208 const std::string& name, ExtensionFunctionFactory factory) { |
193 return FactoryRegistry::instance()->OverrideFunction(name, factory); | 209 return FactoryRegistry::instance()->OverrideFunction(name, factory); |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 } else { | 327 } else { |
312 NOTREACHED(); | 328 NOTREACHED(); |
313 base::KillProcess(render_view_host_->process()->GetHandle(), | 329 base::KillProcess(render_view_host_->process()->GetHandle(), |
314 ResultCodes::KILLED_BAD_MESSAGE, false); | 330 ResultCodes::KILLED_BAD_MESSAGE, false); |
315 } | 331 } |
316 } | 332 } |
317 | 333 |
318 Profile* ExtensionFunctionDispatcher::profile() { | 334 Profile* ExtensionFunctionDispatcher::profile() { |
319 return render_view_host_->process()->profile(); | 335 return render_view_host_->process()->profile(); |
320 } | 336 } |
| 337 |
| 338 gfx::NativeWindow ExtensionFunctionDispatcher::GetFrameNativeWindow() { |
| 339 return delegate_ ? delegate_->GetFrameNativeWindow() : NULL; |
| 340 } |
OLD | NEW |