Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(239)

Unified Diff: chrome/renderer/extensions/miscellaneous_bindings.cc

Issue 14301016: Fix a couple of bugs relating to sending Tab info with chrome.runtime.connect and (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add key to app1/manifest.json Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/renderer/extensions/miscellaneous_bindings.cc
diff --git a/chrome/renderer/extensions/miscellaneous_bindings.cc b/chrome/renderer/extensions/miscellaneous_bindings.cc
index d9989721e4914f6c9bfc60270bfeac1a3f7bcae3..cf538c7ad315d108a1bed9538f8b47238b19cb13 100644
--- a/chrome/renderer/extensions/miscellaneous_bindings.cc
+++ b/chrome/renderer/extensions/miscellaneous_bindings.cc
@@ -10,6 +10,7 @@
#include "base/basictypes.h"
#include "base/bind.h"
#include "base/lazy_instance.h"
+#include "base/values.h"
#include "chrome/common/extensions/extension_messages.h"
#include "chrome/common/extensions/message_bundle.h"
#include "chrome/common/url_constants.h"
@@ -21,6 +22,7 @@
#include "chrome/renderer/extensions/scoped_persistent.h"
#include "content/public/renderer/render_thread.h"
#include "content/public/renderer/render_view.h"
+#include "content/public/renderer/v8_value_converter.h"
#include "grit/renderer_resources.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebScopedMicrotaskSuppression.h"
#include "v8/include/v8.h"
@@ -36,6 +38,7 @@
// });
using content::RenderThread;
+using content::V8ValueConverter;
namespace {
@@ -201,13 +204,17 @@ void MiscellaneousBindings::DispatchOnConnect(
const ChromeV8ContextSet::ContextSet& contexts,
int target_port_id,
const std::string& channel_name,
- const std::string& tab_json,
+ const base::DictionaryValue& source_tab,
const std::string& source_extension_id,
const std::string& target_extension_id,
+ const GURL& source_url,
content::RenderView* restrict_to_render_view) {
v8::HandleScope handle_scope;
+ scoped_ptr<V8ValueConverter> converter(V8ValueConverter::create());
+
bool port_created = false;
+ std::string source_url_spec = source_url.spec();
for (ChromeV8ContextSet::ContextSet::const_iterator it = contexts.begin();
it != contexts.end(); ++it) {
@@ -216,20 +223,23 @@ void MiscellaneousBindings::DispatchOnConnect(
continue;
}
- std::vector<v8::Handle<v8::Value> > arguments;
- arguments.push_back(v8::Integer::New(target_port_id));
- arguments.push_back(v8::String::New(channel_name.c_str(),
- channel_name.size()));
- arguments.push_back(v8::String::New(tab_json.c_str(),
- tab_json.size()));
- arguments.push_back(v8::String::New(source_extension_id.c_str(),
- source_extension_id.size()));
- arguments.push_back(v8::String::New(target_extension_id.c_str(),
- target_extension_id.size()));
+ v8::Handle<v8::Value> tab = v8::Null();
+ if (!source_tab.empty())
+ tab = converter->ToV8Value(&source_tab, (*it)->v8_context());
+
+ v8::Handle<v8::Value> arguments[] = {
+ v8::Integer::New(target_port_id),
+ v8::String::New(channel_name.c_str(), channel_name.size()),
+ tab,
+ v8::String::New(source_extension_id.c_str(), source_extension_id.size()),
+ v8::String::New(target_extension_id.c_str(), target_extension_id.size()),
+ v8::String::New(source_url_spec.c_str(), source_url_spec.size())
+ };
+
v8::Handle<v8::Value> retval;
v8::TryCatch try_catch;
if (!(*it)->CallChromeHiddenMethod("Port.dispatchOnConnect",
- arguments.size(), &arguments[0],
+ arraysize(arguments), arguments,
&retval)) {
continue;
}
« no previous file with comments | « chrome/renderer/extensions/miscellaneous_bindings.h ('k') | chrome/renderer/extensions/runtime_custom_bindings.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698