| 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 #include "chrome/renderer/extensions/dispatcher.h" | 5 #include "chrome/renderer/extensions/dispatcher.h" |
| 6 | 6 |
| 7 #include "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/strings/string_piece.h" | 10 #include "base/strings/string_piece.h" |
| 11 #include "base/strings/string_split.h" | 11 #include "base/strings/string_split.h" |
| 12 #include "chrome/common/child_process_logging.h" | 12 #include "chrome/common/child_process_logging.h" |
| 13 #include "chrome/common/chrome_switches.h" | 13 #include "chrome/common/chrome_switches.h" |
| 14 #include "chrome/common/chrome_version_info.h" | 14 #include "chrome/common/chrome_version_info.h" |
| 15 #include "chrome/common/extensions/api/extension_api.h" | 15 #include "chrome/common/extensions/api/extension_api.h" |
| 16 #include "chrome/common/extensions/background_info.h" | 16 #include "chrome/common/extensions/background_info.h" |
| 17 #include "chrome/common/extensions/extension.h" | 17 #include "chrome/common/extensions/extension.h" |
| 18 #include "chrome/common/extensions/extension_messages.h" | 18 #include "chrome/common/extensions/extension_messages.h" |
| 19 #include "chrome/common/extensions/features/feature.h" | 19 #include "chrome/common/extensions/features/feature.h" |
| 20 #include "chrome/common/extensions/manifest.h" | 20 #include "chrome/common/extensions/manifest.h" |
| 21 #include "chrome/common/extensions/message_bundle.h" | 21 #include "chrome/common/extensions/message_bundle.h" |
| 22 #include "chrome/common/extensions/permissions/permission_set.h" | 22 #include "chrome/common/extensions/permissions/permission_set.h" |
| 23 #include "chrome/common/url_constants.h" | 23 #include "chrome/common/url_constants.h" |
| 24 #include "chrome/common/view_type.h" | |
| 25 #include "chrome/renderer/chrome_render_process_observer.h" | 24 #include "chrome/renderer/chrome_render_process_observer.h" |
| 26 #include "chrome/renderer/extensions/api_activity_logger.h" | 25 #include "chrome/renderer/extensions/api_activity_logger.h" |
| 27 #include "chrome/renderer/extensions/api_definitions_natives.h" | 26 #include "chrome/renderer/extensions/api_definitions_natives.h" |
| 28 #include "chrome/renderer/extensions/app_bindings.h" | 27 #include "chrome/renderer/extensions/app_bindings.h" |
| 29 #include "chrome/renderer/extensions/app_runtime_custom_bindings.h" | 28 #include "chrome/renderer/extensions/app_runtime_custom_bindings.h" |
| 30 #include "chrome/renderer/extensions/app_window_custom_bindings.h" | 29 #include "chrome/renderer/extensions/app_window_custom_bindings.h" |
| 31 #include "chrome/renderer/extensions/binding_generating_native_handler.h" | 30 #include "chrome/renderer/extensions/binding_generating_native_handler.h" |
| 32 #include "chrome/renderer/extensions/chrome_v8_context.h" | 31 #include "chrome/renderer/extensions/chrome_v8_context.h" |
| 33 #include "chrome/renderer/extensions/chrome_v8_extension.h" | 32 #include "chrome/renderer/extensions/chrome_v8_extension.h" |
| 34 #include "chrome/renderer/extensions/content_watcher.h" | 33 #include "chrome/renderer/extensions/content_watcher.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 55 #include "chrome/renderer/extensions/sync_file_system_custom_bindings.h" | 54 #include "chrome/renderer/extensions/sync_file_system_custom_bindings.h" |
| 56 #include "chrome/renderer/extensions/tab_finder.h" | 55 #include "chrome/renderer/extensions/tab_finder.h" |
| 57 #include "chrome/renderer/extensions/tabs_custom_bindings.h" | 56 #include "chrome/renderer/extensions/tabs_custom_bindings.h" |
| 58 #include "chrome/renderer/extensions/tts_custom_bindings.h" | 57 #include "chrome/renderer/extensions/tts_custom_bindings.h" |
| 59 #include "chrome/renderer/extensions/user_script_slave.h" | 58 #include "chrome/renderer/extensions/user_script_slave.h" |
| 60 #include "chrome/renderer/extensions/web_request_custom_bindings.h" | 59 #include "chrome/renderer/extensions/web_request_custom_bindings.h" |
| 61 #include "chrome/renderer/extensions/webstore_bindings.h" | 60 #include "chrome/renderer/extensions/webstore_bindings.h" |
| 62 #include "chrome/renderer/resource_bundle_source_map.h" | 61 #include "chrome/renderer/resource_bundle_source_map.h" |
| 63 #include "content/public/renderer/render_thread.h" | 62 #include "content/public/renderer/render_thread.h" |
| 64 #include "content/public/renderer/render_view.h" | 63 #include "content/public/renderer/render_view.h" |
| 64 #include "extensions/common/view_type.h" |
| 65 #include "grit/renderer_resources.h" | 65 #include "grit/renderer_resources.h" |
| 66 | |
| 67 #include "third_party/WebKit/Source/Platform/chromium/public/WebString.h" | 66 #include "third_party/WebKit/Source/Platform/chromium/public/WebString.h" |
| 68 #include "third_party/WebKit/Source/Platform/chromium/public/WebURLRequest.h" | 67 #include "third_party/WebKit/Source/Platform/chromium/public/WebURLRequest.h" |
| 69 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDataSource.h" | 68 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDataSource.h" |
| 70 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" | 69 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" |
| 71 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" | 70 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
| 72 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScopedUserGesture.
h" | 71 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScopedUserGesture.
h" |
| 73 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityPolicy.h" | 72 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityPolicy.h" |
| 74 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" | 73 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" |
| 75 #include "ui/base/layout.h" | 74 #include "ui/base/layout.h" |
| 76 #include "ui/base/resource/resource_bundle.h" | 75 #include "ui/base/resource/resource_bundle.h" |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 } | 245 } |
| 247 | 246 |
| 248 private: | 247 private: |
| 249 bool IsContextLazyBackgroundPage(RenderView* render_view, | 248 bool IsContextLazyBackgroundPage(RenderView* render_view, |
| 250 const Extension* extension) { | 249 const Extension* extension) { |
| 251 if (!render_view) | 250 if (!render_view) |
| 252 return false; | 251 return false; |
| 253 | 252 |
| 254 ExtensionHelper* helper = ExtensionHelper::Get(render_view); | 253 ExtensionHelper* helper = ExtensionHelper::Get(render_view); |
| 255 return (extension && BackgroundInfo::HasLazyBackgroundPage(extension) && | 254 return (extension && BackgroundInfo::HasLazyBackgroundPage(extension) && |
| 256 helper->view_type() == chrome::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE); | 255 helper->view_type() == VIEW_TYPE_EXTENSION_BACKGROUND_PAGE); |
| 257 } | 256 } |
| 258 }; | 257 }; |
| 259 | 258 |
| 260 class ProcessInfoNativeHandler : public ChromeV8Extension { | 259 class ProcessInfoNativeHandler : public ChromeV8Extension { |
| 261 public: | 260 public: |
| 262 ProcessInfoNativeHandler(Dispatcher* dispatcher, | 261 ProcessInfoNativeHandler(Dispatcher* dispatcher, |
| 263 v8::Handle<v8::Context> context, | 262 v8::Handle<v8::Context> context, |
| 264 const std::string& extension_id, | 263 const std::string& extension_id, |
| 265 const std::string& context_type, | 264 const std::string& context_type, |
| 266 bool is_incognito_context, | 265 bool is_incognito_context, |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 497 } | 496 } |
| 498 | 497 |
| 499 void Dispatcher::OnSetFunctionNames( | 498 void Dispatcher::OnSetFunctionNames( |
| 500 const std::vector<std::string>& names) { | 499 const std::vector<std::string>& names) { |
| 501 function_names_.clear(); | 500 function_names_.clear(); |
| 502 for (size_t i = 0; i < names.size(); ++i) | 501 for (size_t i = 0; i < names.size(); ++i) |
| 503 function_names_.insert(names[i]); | 502 function_names_.insert(names[i]); |
| 504 } | 503 } |
| 505 | 504 |
| 506 void Dispatcher::OnSetChannel(int channel) { | 505 void Dispatcher::OnSetChannel(int channel) { |
| 507 extensions::Feature::SetCurrentChannel( | 506 Feature::SetCurrentChannel( |
| 508 static_cast<chrome::VersionInfo::Channel>(channel)); | 507 static_cast<chrome::VersionInfo::Channel>(channel)); |
| 509 } | 508 } |
| 510 | 509 |
| 511 void Dispatcher::OnMessageInvoke(const std::string& extension_id, | 510 void Dispatcher::OnMessageInvoke(const std::string& extension_id, |
| 512 const std::string& function_name, | 511 const std::string& function_name, |
| 513 const base::ListValue& args, | 512 const base::ListValue& args, |
| 514 const GURL& event_url, | 513 const GURL& event_url, |
| 515 bool user_gesture) { | 514 bool user_gesture) { |
| 516 scoped_ptr<WebScopedUserGesture> web_user_gesture; | 515 scoped_ptr<WebScopedUserGesture> web_user_gesture; |
| 517 if (user_gesture) { | 516 if (user_gesture) { |
| (...skipping 851 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1369 std::string error_msg = base::StringPrintf(kMessage, function_name.c_str()); | 1368 std::string error_msg = base::StringPrintf(kMessage, function_name.c_str()); |
| 1370 v8::ThrowException( | 1369 v8::ThrowException( |
| 1371 v8::Exception::Error(v8::String::New(error_msg.c_str()))); | 1370 v8::Exception::Error(v8::String::New(error_msg.c_str()))); |
| 1372 return false; | 1371 return false; |
| 1373 } | 1372 } |
| 1374 | 1373 |
| 1375 return true; | 1374 return true; |
| 1376 } | 1375 } |
| 1377 | 1376 |
| 1378 } // namespace extensions | 1377 } // namespace extensions |
| OLD | NEW |