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

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: Adds optional text param to paste. Also adds drop behavior to fakebox. Created 7 years, 5 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/searchbox/searchbox_extension.cc
diff --git a/chrome/renderer/searchbox/searchbox_extension.cc b/chrome/renderer/searchbox/searchbox_extension.cc
index 3eacc3c6d6db1bbed4433b805dcefcba70538dec..4b5d81b876c1b096e23d1378fce54137236e088b 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,21 @@ void SearchBoxExtensionWrapper::NavigateContentWindow(
}
// static
+void SearchBoxExtensionWrapper::Paste(
+ const v8::FunctionCallbackInfo<v8::Value>& args) {
+ content::RenderView* render_view = GetRenderView();
+ if (!render_view) return;
+
+ DVLOG(1) << render_view << " Paste";
samarth 2013/08/06 18:39:44 Might as well also output the text here.
jfweitz 2013/08/09 02:37:41 Done.
+ string16 text;
+
samarth 2013/08/06 18:39:44 nit: remove empty line
jfweitz 2013/08/09 02:37:41 Done.
+ if (!args[0]->IsUndefined())
+ text = V8ValueToUTF16(args[0]);
+
+ SearchBox::Get(render_view)->Paste(text);
+}
+
+// static
void SearchBoxExtensionWrapper::StartCapturingKeyStrokes(
const v8::FunctionCallbackInfo<v8::Value>& args) {
content::RenderView* render_view = GetRenderView();
« chrome/renderer/searchbox/searchbox.h ('K') | « chrome/renderer/searchbox/searchbox.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698