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 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 virtual v8::Handle<v8::FunctionTemplate> GetNativeFunction( | 314 virtual v8::Handle<v8::FunctionTemplate> GetNativeFunction( |
315 v8::Handle<v8::String> name) OVERRIDE; | 315 v8::Handle<v8::String> name) OVERRIDE; |
316 | 316 |
317 // Helper function to find the RenderView. May return NULL. | 317 // Helper function to find the RenderView. May return NULL. |
318 static content::RenderView* GetRenderView(); | 318 static content::RenderView* GetRenderView(); |
319 | 319 |
320 // Deletes a Most Visited item. | 320 // Deletes a Most Visited item. |
321 static void DeleteMostVisitedItem( | 321 static void DeleteMostVisitedItem( |
322 const v8::FunctionCallbackInfo<v8::Value>& args); | 322 const v8::FunctionCallbackInfo<v8::Value>& args); |
323 | 323 |
| 324 // Focuses the omnibox. |
| 325 static void Focus(const v8::FunctionCallbackInfo<v8::Value>& args); |
| 326 |
324 // Gets whether or not the app launcher is enabled. | 327 // Gets whether or not the app launcher is enabled. |
325 static void GetAppLauncherEnabled( | 328 static void GetAppLauncherEnabled( |
326 const v8::FunctionCallbackInfo<v8::Value>& args); | 329 const v8::FunctionCallbackInfo<v8::Value>& args); |
327 | 330 |
328 // Gets the font family of the text in the omnibox. | 331 // Gets the font family of the text in the omnibox. |
329 static void GetFont(const v8::FunctionCallbackInfo<v8::Value>& args); | 332 static void GetFont(const v8::FunctionCallbackInfo<v8::Value>& args); |
330 | 333 |
331 // Gets the font size of the text in the omnibox. | 334 // Gets the font size of the text in the omnibox. |
332 static void GetFontSize(const v8::FunctionCallbackInfo<v8::Value>& args); | 335 static void GetFontSize(const v8::FunctionCallbackInfo<v8::Value>& args); |
333 | 336 |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
478 | 481 |
479 SearchBoxExtensionWrapper::SearchBoxExtensionWrapper( | 482 SearchBoxExtensionWrapper::SearchBoxExtensionWrapper( |
480 const base::StringPiece& code) | 483 const base::StringPiece& code) |
481 : v8::Extension(kSearchBoxExtensionName, code.data(), 0, 0, code.size()) { | 484 : v8::Extension(kSearchBoxExtensionName, code.data(), 0, 0, code.size()) { |
482 } | 485 } |
483 | 486 |
484 v8::Handle<v8::FunctionTemplate> SearchBoxExtensionWrapper::GetNativeFunction( | 487 v8::Handle<v8::FunctionTemplate> SearchBoxExtensionWrapper::GetNativeFunction( |
485 v8::Handle<v8::String> name) { | 488 v8::Handle<v8::String> name) { |
486 if (name->Equals(v8::String::New("DeleteMostVisitedItem"))) | 489 if (name->Equals(v8::String::New("DeleteMostVisitedItem"))) |
487 return v8::FunctionTemplate::New(DeleteMostVisitedItem); | 490 return v8::FunctionTemplate::New(DeleteMostVisitedItem); |
| 491 if (name->Equals(v8::String::New("Focus"))) |
| 492 return v8::FunctionTemplate::New(Focus); |
488 if (name->Equals(v8::String::New("GetAppLauncherEnabled"))) | 493 if (name->Equals(v8::String::New("GetAppLauncherEnabled"))) |
489 return v8::FunctionTemplate::New(GetAppLauncherEnabled); | 494 return v8::FunctionTemplate::New(GetAppLauncherEnabled); |
490 if (name->Equals(v8::String::New("GetFont"))) | 495 if (name->Equals(v8::String::New("GetFont"))) |
491 return v8::FunctionTemplate::New(GetFont); | 496 return v8::FunctionTemplate::New(GetFont); |
492 if (name->Equals(v8::String::New("GetFontSize"))) | 497 if (name->Equals(v8::String::New("GetFontSize"))) |
493 return v8::FunctionTemplate::New(GetFontSize); | 498 return v8::FunctionTemplate::New(GetFontSize); |
494 if (name->Equals(v8::String::New("GetMostVisitedItems"))) | 499 if (name->Equals(v8::String::New("GetMostVisitedItems"))) |
495 return v8::FunctionTemplate::New(GetMostVisitedItems); | 500 return v8::FunctionTemplate::New(GetMostVisitedItems); |
496 if (name->Equals(v8::String::New("GetMostVisitedItemData"))) | 501 if (name->Equals(v8::String::New("GetMostVisitedItemData"))) |
497 return v8::FunctionTemplate::New(GetMostVisitedItemData); | 502 return v8::FunctionTemplate::New(GetMostVisitedItemData); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
547 void SearchBoxExtensionWrapper::DeleteMostVisitedItem( | 552 void SearchBoxExtensionWrapper::DeleteMostVisitedItem( |
548 const v8::FunctionCallbackInfo<v8::Value>& args) { | 553 const v8::FunctionCallbackInfo<v8::Value>& args) { |
549 content::RenderView* render_view = GetRenderView(); | 554 content::RenderView* render_view = GetRenderView(); |
550 if (!render_view || !args.Length()) return; | 555 if (!render_view || !args.Length()) return; |
551 | 556 |
552 DVLOG(1) << render_view << " DeleteMostVisitedItem"; | 557 DVLOG(1) << render_view << " DeleteMostVisitedItem"; |
553 SearchBox::Get(render_view)->DeleteMostVisitedItem(args[0]->IntegerValue()); | 558 SearchBox::Get(render_view)->DeleteMostVisitedItem(args[0]->IntegerValue()); |
554 } | 559 } |
555 | 560 |
556 // static | 561 // static |
| 562 void SearchBoxExtensionWrapper::Focus( |
| 563 const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 564 content::RenderView* render_view = GetRenderView(); |
| 565 if (!render_view) return; |
| 566 |
| 567 DVLOG(1) << render_view << " Focus"; |
| 568 SearchBox::Get(render_view)->Focus(); |
| 569 } |
| 570 |
| 571 // static |
557 void SearchBoxExtensionWrapper::GetAppLauncherEnabled( | 572 void SearchBoxExtensionWrapper::GetAppLauncherEnabled( |
558 const v8::FunctionCallbackInfo<v8::Value>& args) { | 573 const v8::FunctionCallbackInfo<v8::Value>& args) { |
559 content::RenderView* render_view = GetRenderView(); | 574 content::RenderView* render_view = GetRenderView(); |
560 if (!render_view) return; | 575 if (!render_view) return; |
561 | 576 |
562 args.GetReturnValue().Set( | 577 args.GetReturnValue().Set( |
563 SearchBox::Get(render_view)->app_launcher_enabled()); | 578 SearchBox::Get(render_view)->app_launcher_enabled()); |
564 } | 579 } |
565 | 580 |
566 // static | 581 // static |
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
969 if (!render_view) return; | 984 if (!render_view) return; |
970 | 985 |
971 bool display_instant_results = | 986 bool display_instant_results = |
972 SearchBox::Get(render_view)->display_instant_results(); | 987 SearchBox::Get(render_view)->display_instant_results(); |
973 DVLOG(1) << render_view << " GetDisplayInstantResults" << | 988 DVLOG(1) << render_view << " GetDisplayInstantResults" << |
974 display_instant_results; | 989 display_instant_results; |
975 args.GetReturnValue().Set(display_instant_results); | 990 args.GetReturnValue().Set(display_instant_results); |
976 } | 991 } |
977 | 992 |
978 } // namespace extensions_v8 | 993 } // namespace extensions_v8 |
OLD | NEW |