| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 Loading... |
| 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 string16 text; |
| 866 if (!args[0]->IsUndefined()) |
| 867 text = V8ValueToUTF16(args[0]); |
| 868 |
| 869 DVLOG(1) << render_view << " Paste: " << text; |
| 870 SearchBox::Get(render_view)->Paste(text); |
| 871 } |
| 872 |
| 873 // static |
| 855 void SearchBoxExtensionWrapper::StartCapturingKeyStrokes( | 874 void SearchBoxExtensionWrapper::StartCapturingKeyStrokes( |
| 856 const v8::FunctionCallbackInfo<v8::Value>& args) { | 875 const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 857 content::RenderView* render_view = GetRenderView(); | 876 content::RenderView* render_view = GetRenderView(); |
| 858 if (!render_view) return; | 877 if (!render_view) return; |
| 859 | 878 |
| 860 DVLOG(1) << render_view << " StartCapturingKeyStrokes"; | 879 DVLOG(1) << render_view << " StartCapturingKeyStrokes"; |
| 861 SearchBox::Get(render_view)->StartCapturingKeyStrokes(); | 880 SearchBox::Get(render_view)->StartCapturingKeyStrokes(); |
| 862 } | 881 } |
| 863 | 882 |
| 864 // static | 883 // static |
| (...skipping 30 matching lines...) Expand all Loading... |
| 895 void SearchBoxExtensionWrapper::UndoMostVisitedDeletion( | 914 void SearchBoxExtensionWrapper::UndoMostVisitedDeletion( |
| 896 const v8::FunctionCallbackInfo<v8::Value>& args) { | 915 const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 897 content::RenderView* render_view = GetRenderView(); | 916 content::RenderView* render_view = GetRenderView(); |
| 898 if (!render_view || !args.Length()) return; | 917 if (!render_view || !args.Length()) return; |
| 899 | 918 |
| 900 DVLOG(1) << render_view << " UndoMostVisitedDeletion"; | 919 DVLOG(1) << render_view << " UndoMostVisitedDeletion"; |
| 901 SearchBox::Get(render_view)->UndoMostVisitedDeletion(args[0]->IntegerValue()); | 920 SearchBox::Get(render_view)->UndoMostVisitedDeletion(args[0]->IntegerValue()); |
| 902 } | 921 } |
| 903 | 922 |
| 904 } // namespace extensions_v8 | 923 } // namespace extensions_v8 |
| OLD | NEW |