| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 484 const v8::FunctionCallbackInfo<v8::Value>& args); | 484 const v8::FunctionCallbackInfo<v8::Value>& args); |
| 485 | 485 |
| 486 // Undoes the deletion of all Most Visited itens. | 486 // Undoes the deletion of all Most Visited itens. |
| 487 static void UndoAllMostVisitedDeletions( | 487 static void UndoAllMostVisitedDeletions( |
| 488 const v8::FunctionCallbackInfo<v8::Value>& args); | 488 const v8::FunctionCallbackInfo<v8::Value>& args); |
| 489 | 489 |
| 490 // Undoes the deletion of a Most Visited item. | 490 // Undoes the deletion of a Most Visited item. |
| 491 static void UndoMostVisitedDeletion( | 491 static void UndoMostVisitedDeletion( |
| 492 const v8::FunctionCallbackInfo<v8::Value>& args); | 492 const v8::FunctionCallbackInfo<v8::Value>& args); |
| 493 | 493 |
| 494 // Indicates whether the page supports Instant. | |
| 495 static void GetDisplayInstantResults( | |
| 496 const v8::FunctionCallbackInfo<v8::Value>& args); | |
| 497 | |
| 498 private: | 494 private: |
| 499 DISALLOW_COPY_AND_ASSIGN(SearchBoxExtensionWrapper); | 495 DISALLOW_COPY_AND_ASSIGN(SearchBoxExtensionWrapper); |
| 500 }; | 496 }; |
| 501 | 497 |
| 502 // static | 498 // static |
| 503 v8::Extension* SearchBoxExtension::Get() { | 499 v8::Extension* SearchBoxExtension::Get() { |
| 504 return new SearchBoxExtensionWrapper(ResourceBundle::GetSharedInstance(). | 500 return new SearchBoxExtensionWrapper(ResourceBundle::GetSharedInstance(). |
| 505 GetRawDataResource(IDR_SEARCHBOX_API)); | 501 GetRawDataResource(IDR_SEARCHBOX_API)); |
| 506 } | 502 } |
| 507 | 503 |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 632 if (name->Equals( | 628 if (name->Equals( |
| 633 v8::String::NewFromUtf8(isolate, "StartCapturingKeyStrokes"))) | 629 v8::String::NewFromUtf8(isolate, "StartCapturingKeyStrokes"))) |
| 634 return v8::FunctionTemplate::New(isolate, StartCapturingKeyStrokes); | 630 return v8::FunctionTemplate::New(isolate, StartCapturingKeyStrokes); |
| 635 if (name->Equals(v8::String::NewFromUtf8(isolate, "StopCapturingKeyStrokes"))) | 631 if (name->Equals(v8::String::NewFromUtf8(isolate, "StopCapturingKeyStrokes"))) |
| 636 return v8::FunctionTemplate::New(isolate, StopCapturingKeyStrokes); | 632 return v8::FunctionTemplate::New(isolate, StopCapturingKeyStrokes); |
| 637 if (name->Equals( | 633 if (name->Equals( |
| 638 v8::String::NewFromUtf8(isolate, "UndoAllMostVisitedDeletions"))) | 634 v8::String::NewFromUtf8(isolate, "UndoAllMostVisitedDeletions"))) |
| 639 return v8::FunctionTemplate::New(isolate, UndoAllMostVisitedDeletions); | 635 return v8::FunctionTemplate::New(isolate, UndoAllMostVisitedDeletions); |
| 640 if (name->Equals(v8::String::NewFromUtf8(isolate, "UndoMostVisitedDeletion"))) | 636 if (name->Equals(v8::String::NewFromUtf8(isolate, "UndoMostVisitedDeletion"))) |
| 641 return v8::FunctionTemplate::New(isolate, UndoMostVisitedDeletion); | 637 return v8::FunctionTemplate::New(isolate, UndoMostVisitedDeletion); |
| 642 if (name->Equals( | |
| 643 v8::String::NewFromUtf8(isolate, "GetDisplayInstantResults"))) | |
| 644 return v8::FunctionTemplate::New(isolate, GetDisplayInstantResults); | |
| 645 return v8::Local<v8::FunctionTemplate>(); | 638 return v8::Local<v8::FunctionTemplate>(); |
| 646 } | 639 } |
| 647 | 640 |
| 648 // static | 641 // static |
| 649 content::RenderView* SearchBoxExtensionWrapper::GetRenderView() { | 642 content::RenderView* SearchBoxExtensionWrapper::GetRenderView() { |
| 650 blink::WebLocalFrame* webframe = | 643 blink::WebLocalFrame* webframe = |
| 651 blink::WebLocalFrame::frameForCurrentContext(); | 644 blink::WebLocalFrame::frameForCurrentContext(); |
| 652 if (!webframe) return NULL; | 645 if (!webframe) return NULL; |
| 653 | 646 |
| 654 blink::WebView* webview = webframe->view(); | 647 blink::WebView* webview = webframe->view(); |
| (...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1135 if (!args.Length()) { | 1128 if (!args.Length()) { |
| 1136 ThrowInvalidParameters(args); | 1129 ThrowInvalidParameters(args); |
| 1137 return; | 1130 return; |
| 1138 } | 1131 } |
| 1139 | 1132 |
| 1140 DVLOG(1) << render_view << " UndoMostVisitedDeletion"; | 1133 DVLOG(1) << render_view << " UndoMostVisitedDeletion"; |
| 1141 SearchBox::Get(render_view) | 1134 SearchBox::Get(render_view) |
| 1142 ->UndoMostVisitedDeletion(args[0]->ToInteger()->Value()); | 1135 ->UndoMostVisitedDeletion(args[0]->ToInteger()->Value()); |
| 1143 } | 1136 } |
| 1144 | 1137 |
| 1145 // static | |
| 1146 void SearchBoxExtensionWrapper::GetDisplayInstantResults( | |
| 1147 const v8::FunctionCallbackInfo<v8::Value>& args) { | |
| 1148 content::RenderView* render_view = GetRenderView(); | |
| 1149 if (!render_view) return; | |
| 1150 | |
| 1151 bool display_instant_results = | |
| 1152 SearchBox::Get(render_view)->display_instant_results(); | |
| 1153 DVLOG(1) << render_view << " GetDisplayInstantResults" << | |
| 1154 display_instant_results; | |
| 1155 args.GetReturnValue().Set(display_instant_results); | |
| 1156 } | |
| 1157 | |
| 1158 } // namespace extensions_v8 | 1138 } // namespace extensions_v8 |
| OLD | NEW |