| 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/miscellaneous_bindings.h" | 5 #include "chrome/renderer/extensions/miscellaneous_bindings.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/lazy_instance.h" | 11 #include "base/lazy_instance.h" |
| 12 #include "chrome/common/extensions/extension_messages.h" | 12 #include "chrome/common/extensions/extension_messages.h" |
| 13 #include "chrome/common/extensions/message_bundle.h" | 13 #include "chrome/common/extensions/message_bundle.h" |
| 14 #include "chrome/common/url_constants.h" | 14 #include "chrome/common/url_constants.h" |
| 15 #include "chrome/renderer/extensions/chrome_v8_context.h" | 15 #include "chrome/renderer/extensions/chrome_v8_context.h" |
| 16 #include "chrome/renderer/extensions/chrome_v8_context_set.h" | 16 #include "chrome/renderer/extensions/chrome_v8_context_set.h" |
| 17 #include "chrome/renderer/extensions/chrome_v8_extension.h" | 17 #include "chrome/renderer/extensions/chrome_v8_extension.h" |
| 18 #include "chrome/renderer/extensions/dispatcher.h" | 18 #include "chrome/renderer/extensions/dispatcher.h" |
| 19 #include "chrome/renderer/extensions/event_bindings.h" | 19 #include "chrome/renderer/extensions/event_bindings.h" |
| 20 #include "content/public/renderer/render_thread.h" | 20 #include "content/public/renderer/render_thread.h" |
| 21 #include "content/public/renderer/render_view.h" | 21 #include "content/public/renderer/render_view.h" |
| 22 #include "grit/renderer_resources.h" | 22 #include "grit/renderer_resources.h" |
| 23 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScopedMicrotaskSup
pression.h" | 23 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScopedMicrotaskSup
pression.h" |
| 24 #include "v8/include/v8.h" | 24 #include "v8/include/v8.h" |
| 25 | 25 |
| 26 // Message passing API example (in a content script): | 26 // Message passing API example (in a content script): |
| 27 // var extension = | 27 // var extension = |
| 28 // new chrome.Extension('00123456789abcdef0123456789abcdef0123456'); | 28 // new chrome.Extension('00123456789abcdef0123456789abcdef0123456'); |
| 29 // var port = extension.connect(); | 29 // var port = runtime.connect(); |
| 30 // port.postMessage('Can you hear me now?'); | 30 // port.postMessage('Can you hear me now?'); |
| 31 // port.onmessage.addListener(function(msg, port) { | 31 // port.onmessage.addListener(function(msg, port) { |
| 32 // alert('response=' + msg); | 32 // alert('response=' + msg); |
| 33 // port.postMessage('I got your reponse'); | 33 // port.postMessage('I got your reponse'); |
| 34 // }); | 34 // }); |
| 35 | 35 |
| 36 using content::RenderThread; | 36 using content::RenderThread; |
| 37 | 37 |
| 38 namespace { | 38 namespace { |
| 39 | 39 |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 std::vector<v8::Handle<v8::Value> > arguments; | 300 std::vector<v8::Handle<v8::Value> > arguments; |
| 301 arguments.push_back(v8::Integer::New(port_id)); | 301 arguments.push_back(v8::Integer::New(port_id)); |
| 302 arguments.push_back(v8::Boolean::New(connection_error)); | 302 arguments.push_back(v8::Boolean::New(connection_error)); |
| 303 (*it)->CallChromeHiddenMethod("Port.dispatchOnDisconnect", | 303 (*it)->CallChromeHiddenMethod("Port.dispatchOnDisconnect", |
| 304 arguments.size(), &arguments[0], | 304 arguments.size(), &arguments[0], |
| 305 NULL); | 305 NULL); |
| 306 } | 306 } |
| 307 } | 307 } |
| 308 | 308 |
| 309 } // namespace extensions | 309 } // namespace extensions |
| OLD | NEW |