| 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 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 414 static void CheckIsUserSyncingHistory( | 414 static void CheckIsUserSyncingHistory( |
| 415 const v8::FunctionCallbackInfo<v8::Value>& args); | 415 const v8::FunctionCallbackInfo<v8::Value>& args); |
| 416 | 416 |
| 417 // Deletes a Most Visited item. | 417 // Deletes a Most Visited item. |
| 418 static void DeleteMostVisitedItem( | 418 static void DeleteMostVisitedItem( |
| 419 const v8::FunctionCallbackInfo<v8::Value>& args); | 419 const v8::FunctionCallbackInfo<v8::Value>& args); |
| 420 | 420 |
| 421 // Focuses the omnibox. | 421 // Focuses the omnibox. |
| 422 static void Focus(const v8::FunctionCallbackInfo<v8::Value>& args); | 422 static void Focus(const v8::FunctionCallbackInfo<v8::Value>& args); |
| 423 | 423 |
| 424 // Gets whether or not the app launcher is enabled. | |
| 425 static void GetAppLauncherEnabled( | |
| 426 const v8::FunctionCallbackInfo<v8::Value>& args); | |
| 427 | |
| 428 // Gets Most Visited Items. | 424 // Gets Most Visited Items. |
| 429 static void GetMostVisitedItems( | 425 static void GetMostVisitedItems( |
| 430 const v8::FunctionCallbackInfo<v8::Value>& args); | 426 const v8::FunctionCallbackInfo<v8::Value>& args); |
| 431 | 427 |
| 432 // Gets the raw data for a most visited item including its raw URL. | 428 // Gets the raw data for a most visited item including its raw URL. |
| 433 // GetRenderViewWithCheckedOrigin() enforces that only code in the origin | 429 // GetRenderViewWithCheckedOrigin() enforces that only code in the origin |
| 434 // chrome-search://most-visited can call this function. | 430 // chrome-search://most-visited can call this function. |
| 435 static void GetMostVisitedItemData( | 431 static void GetMostVisitedItemData( |
| 436 const v8::FunctionCallbackInfo<v8::Value>& args); | 432 const v8::FunctionCallbackInfo<v8::Value>& args); |
| 437 | 433 |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 594 if (name->Equals( | 590 if (name->Equals( |
| 595 v8::String::NewFromUtf8(isolate, "CheckIsUserSignedInToChromeAs"))) | 591 v8::String::NewFromUtf8(isolate, "CheckIsUserSignedInToChromeAs"))) |
| 596 return v8::FunctionTemplate::New(isolate, CheckIsUserSignedInToChromeAs); | 592 return v8::FunctionTemplate::New(isolate, CheckIsUserSignedInToChromeAs); |
| 597 if (name->Equals( | 593 if (name->Equals( |
| 598 v8::String::NewFromUtf8(isolate, "CheckIsUserSyncingHistory"))) | 594 v8::String::NewFromUtf8(isolate, "CheckIsUserSyncingHistory"))) |
| 599 return v8::FunctionTemplate::New(isolate, CheckIsUserSyncingHistory); | 595 return v8::FunctionTemplate::New(isolate, CheckIsUserSyncingHistory); |
| 600 if (name->Equals(v8::String::NewFromUtf8(isolate, "DeleteMostVisitedItem"))) | 596 if (name->Equals(v8::String::NewFromUtf8(isolate, "DeleteMostVisitedItem"))) |
| 601 return v8::FunctionTemplate::New(isolate, DeleteMostVisitedItem); | 597 return v8::FunctionTemplate::New(isolate, DeleteMostVisitedItem); |
| 602 if (name->Equals(v8::String::NewFromUtf8(isolate, "Focus"))) | 598 if (name->Equals(v8::String::NewFromUtf8(isolate, "Focus"))) |
| 603 return v8::FunctionTemplate::New(isolate, Focus); | 599 return v8::FunctionTemplate::New(isolate, Focus); |
| 604 if (name->Equals(v8::String::NewFromUtf8(isolate, "GetAppLauncherEnabled"))) | |
| 605 return v8::FunctionTemplate::New(isolate, GetAppLauncherEnabled); | |
| 606 if (name->Equals(v8::String::NewFromUtf8(isolate, "GetMostVisitedItems"))) | 600 if (name->Equals(v8::String::NewFromUtf8(isolate, "GetMostVisitedItems"))) |
| 607 return v8::FunctionTemplate::New(isolate, GetMostVisitedItems); | 601 return v8::FunctionTemplate::New(isolate, GetMostVisitedItems); |
| 608 if (name->Equals(v8::String::NewFromUtf8(isolate, "GetMostVisitedItemData"))) | 602 if (name->Equals(v8::String::NewFromUtf8(isolate, "GetMostVisitedItemData"))) |
| 609 return v8::FunctionTemplate::New(isolate, GetMostVisitedItemData); | 603 return v8::FunctionTemplate::New(isolate, GetMostVisitedItemData); |
| 610 if (name->Equals(v8::String::NewFromUtf8(isolate, "GetQuery"))) | 604 if (name->Equals(v8::String::NewFromUtf8(isolate, "GetQuery"))) |
| 611 return v8::FunctionTemplate::New(isolate, GetQuery); | 605 return v8::FunctionTemplate::New(isolate, GetQuery); |
| 612 if (name->Equals(v8::String::NewFromUtf8(isolate, "GetRightToLeft"))) | 606 if (name->Equals(v8::String::NewFromUtf8(isolate, "GetRightToLeft"))) |
| 613 return v8::FunctionTemplate::New(isolate, GetRightToLeft); | 607 return v8::FunctionTemplate::New(isolate, GetRightToLeft); |
| 614 if (name->Equals(v8::String::NewFromUtf8(isolate, "GetSearchRequestParams"))) | 608 if (name->Equals(v8::String::NewFromUtf8(isolate, "GetSearchRequestParams"))) |
| 615 return v8::FunctionTemplate::New(isolate, GetSearchRequestParams); | 609 return v8::FunctionTemplate::New(isolate, GetSearchRequestParams); |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 711 void SearchBoxExtensionWrapper::Focus( | 705 void SearchBoxExtensionWrapper::Focus( |
| 712 const v8::FunctionCallbackInfo<v8::Value>& args) { | 706 const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 713 content::RenderView* render_view = GetRenderView(); | 707 content::RenderView* render_view = GetRenderView(); |
| 714 if (!render_view) return; | 708 if (!render_view) return; |
| 715 | 709 |
| 716 DVLOG(1) << render_view << " Focus"; | 710 DVLOG(1) << render_view << " Focus"; |
| 717 SearchBox::Get(render_view)->Focus(); | 711 SearchBox::Get(render_view)->Focus(); |
| 718 } | 712 } |
| 719 | 713 |
| 720 // static | 714 // static |
| 721 void SearchBoxExtensionWrapper::GetAppLauncherEnabled( | |
| 722 const v8::FunctionCallbackInfo<v8::Value>& args) { | |
| 723 content::RenderView* render_view = GetRenderView(); | |
| 724 if (!render_view) return; | |
| 725 | |
| 726 args.GetReturnValue().Set( | |
| 727 SearchBox::Get(render_view)->app_launcher_enabled()); | |
| 728 } | |
| 729 | |
| 730 // static | |
| 731 void SearchBoxExtensionWrapper::GetMostVisitedItems( | 715 void SearchBoxExtensionWrapper::GetMostVisitedItems( |
| 732 const v8::FunctionCallbackInfo<v8::Value>& args) { | 716 const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 733 content::RenderView* render_view = GetRenderView(); | 717 content::RenderView* render_view = GetRenderView(); |
| 734 if (!render_view) | 718 if (!render_view) |
| 735 return; | 719 return; |
| 736 DVLOG(1) << render_view << " GetMostVisitedItems"; | 720 DVLOG(1) << render_view << " GetMostVisitedItems"; |
| 737 | 721 |
| 738 const SearchBox* search_box = SearchBox::Get(render_view); | 722 const SearchBox* search_box = SearchBox::Get(render_view); |
| 739 | 723 |
| 740 std::vector<InstantMostVisitedItemIDPair> instant_mv_items; | 724 std::vector<InstantMostVisitedItemIDPair> instant_mv_items; |
| (...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1165 if (!render_view) return; | 1149 if (!render_view) return; |
| 1166 | 1150 |
| 1167 bool display_instant_results = | 1151 bool display_instant_results = |
| 1168 SearchBox::Get(render_view)->display_instant_results(); | 1152 SearchBox::Get(render_view)->display_instant_results(); |
| 1169 DVLOG(1) << render_view << " GetDisplayInstantResults" << | 1153 DVLOG(1) << render_view << " GetDisplayInstantResults" << |
| 1170 display_instant_results; | 1154 display_instant_results; |
| 1171 args.GetReturnValue().Set(display_instant_results); | 1155 args.GetReturnValue().Set(display_instant_results); |
| 1172 } | 1156 } |
| 1173 | 1157 |
| 1174 } // namespace extensions_v8 | 1158 } // namespace extensions_v8 |
| OLD | NEW |