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

Unified Diff: chrome/renderer/searchbox/searchbox_extension.cc

Issue 20501002: Adds paste function to searchbox api and handles paste event on fakebox (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Nits Created 7 years, 4 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
« no previous file with comments | « chrome/renderer/searchbox/searchbox.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/searchbox/searchbox_extension.cc
diff --git a/chrome/renderer/searchbox/searchbox_extension.cc b/chrome/renderer/searchbox/searchbox_extension.cc
index 3eacc3c6d6db1bbed4433b805dcefcba70538dec..75663b74130405373ccb3920ca8371eca5f4af1a 100644
--- a/chrome/renderer/searchbox/searchbox_extension.cc
+++ b/chrome/renderer/searchbox/searchbox_extension.cc
@@ -362,6 +362,9 @@ class SearchBoxExtensionWrapper : public v8::Extension {
static void NavigateContentWindow(
const v8::FunctionCallbackInfo<v8::Value>& args);
+ // Pastes provided value or clipboard's content into the omnibox.
+ static void Paste(const v8::FunctionCallbackInfo<v8::Value>& args);
+
// Indicates whether the page supports voice search.
static void SetVoiceSearchSupported(
const v8::FunctionCallbackInfo<v8::Value>& args);
@@ -485,6 +488,8 @@ v8::Handle<v8::FunctionTemplate> SearchBoxExtensionWrapper::GetNativeFunction(
return v8::FunctionTemplate::New(LogEvent);
if (name->Equals(v8::String::New("NavigateContentWindow")))
return v8::FunctionTemplate::New(NavigateContentWindow);
+ if (name->Equals(v8::String::New("Paste")))
+ return v8::FunctionTemplate::New(Paste);
if (name->Equals(v8::String::New("SetVoiceSearchSupported")))
return v8::FunctionTemplate::New(SetVoiceSearchSupported);
if (name->Equals(v8::String::New("StartCapturingKeyStrokes")))
@@ -852,6 +857,20 @@ void SearchBoxExtensionWrapper::NavigateContentWindow(
}
// static
+void SearchBoxExtensionWrapper::Paste(
+ const v8::FunctionCallbackInfo<v8::Value>& args) {
+ content::RenderView* render_view = GetRenderView();
+ if (!render_view) return;
+
+ string16 text;
+ if (!args[0]->IsUndefined())
+ text = V8ValueToUTF16(args[0]);
+
+ DVLOG(1) << render_view << " Paste: " << text;
+ SearchBox::Get(render_view)->Paste(text);
+}
+
+// static
void SearchBoxExtensionWrapper::StartCapturingKeyStrokes(
const v8::FunctionCallbackInfo<v8::Value>& args) {
content::RenderView* render_view = GetRenderView();
« no previous file with comments | « chrome/renderer/searchbox/searchbox.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698