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

Side by Side 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, 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 unified diff | Download patch
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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/searchbox/searchbox_extension.h" 5 #include "chrome/renderer/searchbox/searchbox_extension.h"
6 6
7 #include "base/i18n/rtl.h" 7 #include "base/i18n/rtl.h"
8 #include "base/strings/string_number_conversions.h" 8 #include "base/strings/string_number_conversions.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 const v8::FunctionCallbackInfo<v8::Value>& args); 355 const v8::FunctionCallbackInfo<v8::Value>& args);
356 356
357 // Logs information from the iframes/titles on the NTP. 357 // Logs information from the iframes/titles on the NTP.
358 static void LogEvent(const v8::FunctionCallbackInfo<v8::Value>& args); 358 static void LogEvent(const v8::FunctionCallbackInfo<v8::Value>& args);
359 359
360 // Navigates the window to a URL represented by either a URL string or a 360 // Navigates the window to a URL represented by either a URL string or a
361 // restricted ID. 361 // restricted ID.
362 static void NavigateContentWindow( 362 static void NavigateContentWindow(
363 const v8::FunctionCallbackInfo<v8::Value>& args); 363 const v8::FunctionCallbackInfo<v8::Value>& args);
364 364
365 // Pastes provided value or clipboard's content into the omnibox.
366 static void Paste(const v8::FunctionCallbackInfo<v8::Value>& args);
367
365 // Indicates whether the page supports voice search. 368 // Indicates whether the page supports voice search.
366 static void SetVoiceSearchSupported( 369 static void SetVoiceSearchSupported(
367 const v8::FunctionCallbackInfo<v8::Value>& args); 370 const v8::FunctionCallbackInfo<v8::Value>& args);
368 371
369 // Start capturing user key strokes. 372 // Start capturing user key strokes.
370 static void StartCapturingKeyStrokes( 373 static void StartCapturingKeyStrokes(
371 const v8::FunctionCallbackInfo<v8::Value>& args); 374 const v8::FunctionCallbackInfo<v8::Value>& args);
372 375
373 // Stop capturing user key strokes. 376 // Stop capturing user key strokes.
374 static void StopCapturingKeyStrokes( 377 static void StopCapturingKeyStrokes(
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 if (name->Equals(v8::String::New("IsFocused"))) 481 if (name->Equals(v8::String::New("IsFocused")))
479 return v8::FunctionTemplate::New(IsFocused); 482 return v8::FunctionTemplate::New(IsFocused);
480 if (name->Equals(v8::String::New("IsInputInProgress"))) 483 if (name->Equals(v8::String::New("IsInputInProgress")))
481 return v8::FunctionTemplate::New(IsInputInProgress); 484 return v8::FunctionTemplate::New(IsInputInProgress);
482 if (name->Equals(v8::String::New("IsKeyCaptureEnabled"))) 485 if (name->Equals(v8::String::New("IsKeyCaptureEnabled")))
483 return v8::FunctionTemplate::New(IsKeyCaptureEnabled); 486 return v8::FunctionTemplate::New(IsKeyCaptureEnabled);
484 if (name->Equals(v8::String::New("LogEvent"))) 487 if (name->Equals(v8::String::New("LogEvent")))
485 return v8::FunctionTemplate::New(LogEvent); 488 return v8::FunctionTemplate::New(LogEvent);
486 if (name->Equals(v8::String::New("NavigateContentWindow"))) 489 if (name->Equals(v8::String::New("NavigateContentWindow")))
487 return v8::FunctionTemplate::New(NavigateContentWindow); 490 return v8::FunctionTemplate::New(NavigateContentWindow);
491 if (name->Equals(v8::String::New("Paste")))
492 return v8::FunctionTemplate::New(Paste);
488 if (name->Equals(v8::String::New("SetVoiceSearchSupported"))) 493 if (name->Equals(v8::String::New("SetVoiceSearchSupported")))
489 return v8::FunctionTemplate::New(SetVoiceSearchSupported); 494 return v8::FunctionTemplate::New(SetVoiceSearchSupported);
490 if (name->Equals(v8::String::New("StartCapturingKeyStrokes"))) 495 if (name->Equals(v8::String::New("StartCapturingKeyStrokes")))
491 return v8::FunctionTemplate::New(StartCapturingKeyStrokes); 496 return v8::FunctionTemplate::New(StartCapturingKeyStrokes);
492 if (name->Equals(v8::String::New("StopCapturingKeyStrokes"))) 497 if (name->Equals(v8::String::New("StopCapturingKeyStrokes")))
493 return v8::FunctionTemplate::New(StopCapturingKeyStrokes); 498 return v8::FunctionTemplate::New(StopCapturingKeyStrokes);
494 if (name->Equals(v8::String::New("UndoAllMostVisitedDeletions"))) 499 if (name->Equals(v8::String::New("UndoAllMostVisitedDeletions")))
495 return v8::FunctionTemplate::New(UndoAllMostVisitedDeletions); 500 return v8::FunctionTemplate::New(UndoAllMostVisitedDeletions);
496 if (name->Equals(v8::String::New("UndoMostVisitedDeletion"))) 501 if (name->Equals(v8::String::New("UndoMostVisitedDeletion")))
497 return v8::FunctionTemplate::New(UndoMostVisitedDeletion); 502 return v8::FunctionTemplate::New(UndoMostVisitedDeletion);
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
845 if (destination_url.is_valid()) { 850 if (destination_url.is_valid()) {
846 WindowOpenDisposition disposition = CURRENT_TAB; 851 WindowOpenDisposition disposition = CURRENT_TAB;
847 if (args[1]->Uint32Value() == 2) 852 if (args[1]->Uint32Value() == 2)
848 disposition = NEW_BACKGROUND_TAB; 853 disposition = NEW_BACKGROUND_TAB;
849 SearchBox::Get(render_view)->NavigateToURL( 854 SearchBox::Get(render_view)->NavigateToURL(
850 destination_url, transition, disposition, false); 855 destination_url, transition, disposition, false);
851 } 856 }
852 } 857 }
853 858
854 // static 859 // static
860 void SearchBoxExtensionWrapper::Paste(
861 const v8::FunctionCallbackInfo<v8::Value>& args) {
862 content::RenderView* render_view = GetRenderView();
863 if (!render_view) return;
864
865 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.
866 string16 text;
867
samarth 2013/08/06 18:39:44 nit: remove empty line
jfweitz 2013/08/09 02:37:41 Done.
868 if (!args[0]->IsUndefined())
869 text = V8ValueToUTF16(args[0]);
870
871 SearchBox::Get(render_view)->Paste(text);
872 }
873
874 // static
855 void SearchBoxExtensionWrapper::StartCapturingKeyStrokes( 875 void SearchBoxExtensionWrapper::StartCapturingKeyStrokes(
856 const v8::FunctionCallbackInfo<v8::Value>& args) { 876 const v8::FunctionCallbackInfo<v8::Value>& args) {
857 content::RenderView* render_view = GetRenderView(); 877 content::RenderView* render_view = GetRenderView();
858 if (!render_view) return; 878 if (!render_view) return;
859 879
860 DVLOG(1) << render_view << " StartCapturingKeyStrokes"; 880 DVLOG(1) << render_view << " StartCapturingKeyStrokes";
861 SearchBox::Get(render_view)->StartCapturingKeyStrokes(); 881 SearchBox::Get(render_view)->StartCapturingKeyStrokes();
862 } 882 }
863 883
864 // static 884 // static
(...skipping 30 matching lines...) Expand all
895 void SearchBoxExtensionWrapper::UndoMostVisitedDeletion( 915 void SearchBoxExtensionWrapper::UndoMostVisitedDeletion(
896 const v8::FunctionCallbackInfo<v8::Value>& args) { 916 const v8::FunctionCallbackInfo<v8::Value>& args) {
897 content::RenderView* render_view = GetRenderView(); 917 content::RenderView* render_view = GetRenderView();
898 if (!render_view || !args.Length()) return; 918 if (!render_view || !args.Length()) return;
899 919
900 DVLOG(1) << render_view << " UndoMostVisitedDeletion"; 920 DVLOG(1) << render_view << " UndoMostVisitedDeletion";
901 SearchBox::Get(render_view)->UndoMostVisitedDeletion(args[0]->IntegerValue()); 921 SearchBox::Get(render_view)->UndoMostVisitedDeletion(args[0]->IntegerValue());
902 } 922 }
903 923
904 } // namespace extensions_v8 924 } // namespace extensions_v8
OLDNEW
« 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