| 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 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 // Gets Most Visited Items. | 369 // Gets Most Visited Items. |
| 370 static void GetMostVisitedItems( | 370 static void GetMostVisitedItems( |
| 371 const v8::FunctionCallbackInfo<v8::Value>& args); | 371 const v8::FunctionCallbackInfo<v8::Value>& args); |
| 372 | 372 |
| 373 // Gets the raw data for a most visited item including its raw URL. | 373 // Gets the raw data for a most visited item including its raw URL. |
| 374 // GetRenderFrameWithCheckedOrigin() enforces that only code in the origin | 374 // GetRenderFrameWithCheckedOrigin() enforces that only code in the origin |
| 375 // chrome-search://most-visited can call this function. | 375 // chrome-search://most-visited can call this function. |
| 376 static void GetMostVisitedItemData( | 376 static void GetMostVisitedItemData( |
| 377 const v8::FunctionCallbackInfo<v8::Value>& args); | 377 const v8::FunctionCallbackInfo<v8::Value>& args); |
| 378 | 378 |
| 379 // Gets the submitted value of the user's search query. | |
| 380 static void GetQuery(const v8::FunctionCallbackInfo<v8::Value>& args); | |
| 381 | |
| 382 // Returns true if the Searchbox itself is oriented right-to-left. | |
| 383 static void GetRightToLeft(const v8::FunctionCallbackInfo<v8::Value>& args); | |
| 384 | |
| 385 // Gets the Embedded Search request params. Used for logging purposes. | 379 // Gets the Embedded Search request params. Used for logging purposes. |
| 386 static void GetSearchRequestParams( | 380 static void GetSearchRequestParams( |
| 387 const v8::FunctionCallbackInfo<v8::Value>& args); | 381 const v8::FunctionCallbackInfo<v8::Value>& args); |
| 388 | 382 |
| 389 // Gets the current top suggestion to prefetch search results. | 383 // Gets the current top suggestion to prefetch search results. |
| 390 static void GetSuggestionToPrefetch( | 384 static void GetSuggestionToPrefetch( |
| 391 const v8::FunctionCallbackInfo<v8::Value>& args); | 385 const v8::FunctionCallbackInfo<v8::Value>& args); |
| 392 | 386 |
| 393 // Gets the background info of the theme currently adopted by browser. | 387 // Gets the background info of the theme currently adopted by browser. |
| 394 // Call only when overlay is showing NTP page. | 388 // Call only when overlay is showing NTP page. |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 525 if (name_str == "CheckIsUserSignedInToChromeAs") | 519 if (name_str == "CheckIsUserSignedInToChromeAs") |
| 526 return v8::FunctionTemplate::New(isolate, CheckIsUserSignedInToChromeAs); | 520 return v8::FunctionTemplate::New(isolate, CheckIsUserSignedInToChromeAs); |
| 527 if (name_str == "CheckIsUserSyncingHistory") | 521 if (name_str == "CheckIsUserSyncingHistory") |
| 528 return v8::FunctionTemplate::New(isolate, CheckIsUserSyncingHistory); | 522 return v8::FunctionTemplate::New(isolate, CheckIsUserSyncingHistory); |
| 529 if (name_str == "DeleteMostVisitedItem") | 523 if (name_str == "DeleteMostVisitedItem") |
| 530 return v8::FunctionTemplate::New(isolate, DeleteMostVisitedItem); | 524 return v8::FunctionTemplate::New(isolate, DeleteMostVisitedItem); |
| 531 if (name_str == "GetMostVisitedItems") | 525 if (name_str == "GetMostVisitedItems") |
| 532 return v8::FunctionTemplate::New(isolate, GetMostVisitedItems); | 526 return v8::FunctionTemplate::New(isolate, GetMostVisitedItems); |
| 533 if (name_str == "GetMostVisitedItemData") | 527 if (name_str == "GetMostVisitedItemData") |
| 534 return v8::FunctionTemplate::New(isolate, GetMostVisitedItemData); | 528 return v8::FunctionTemplate::New(isolate, GetMostVisitedItemData); |
| 535 if (name_str == "GetQuery") | |
| 536 return v8::FunctionTemplate::New(isolate, GetQuery); | |
| 537 if (name_str == "GetRightToLeft") | |
| 538 return v8::FunctionTemplate::New(isolate, GetRightToLeft); | |
| 539 if (name_str == "GetSearchRequestParams") | 529 if (name_str == "GetSearchRequestParams") |
| 540 return v8::FunctionTemplate::New(isolate, GetSearchRequestParams); | 530 return v8::FunctionTemplate::New(isolate, GetSearchRequestParams); |
| 541 if (name_str == "GetSuggestionToPrefetch") | 531 if (name_str == "GetSuggestionToPrefetch") |
| 542 return v8::FunctionTemplate::New(isolate, GetSuggestionToPrefetch); | 532 return v8::FunctionTemplate::New(isolate, GetSuggestionToPrefetch); |
| 543 if (name_str == "GetThemeBackgroundInfo") | 533 if (name_str == "GetThemeBackgroundInfo") |
| 544 return v8::FunctionTemplate::New(isolate, GetThemeBackgroundInfo); | 534 return v8::FunctionTemplate::New(isolate, GetThemeBackgroundInfo); |
| 545 if (name_str == "IsFocused") | 535 if (name_str == "IsFocused") |
| 546 return v8::FunctionTemplate::New(isolate, IsFocused); | 536 return v8::FunctionTemplate::New(isolate, IsFocused); |
| 547 if (name_str == "IsInputInProgress") | 537 if (name_str == "IsInputInProgress") |
| 548 return v8::FunctionTemplate::New(isolate, IsInputInProgress); | 538 return v8::FunctionTemplate::New(isolate, IsInputInProgress); |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 673 ->GetMostVisitedItemWithID(restricted_id, &mv_item)) { | 663 ->GetMostVisitedItemWithID(restricted_id, &mv_item)) { |
| 674 return; | 664 return; |
| 675 } | 665 } |
| 676 v8::Isolate* isolate = args.GetIsolate(); | 666 v8::Isolate* isolate = args.GetIsolate(); |
| 677 args.GetReturnValue().Set(GenerateMostVisitedItem( | 667 args.GetReturnValue().Set(GenerateMostVisitedItem( |
| 678 isolate, render_frame->GetRenderView()->GetRoutingID(), restricted_id, | 668 isolate, render_frame->GetRenderView()->GetRoutingID(), restricted_id, |
| 679 mv_item)); | 669 mv_item)); |
| 680 } | 670 } |
| 681 | 671 |
| 682 // static | 672 // static |
| 683 void SearchBoxExtensionWrapper::GetQuery( | |
| 684 const v8::FunctionCallbackInfo<v8::Value>& args) { | |
| 685 content::RenderFrame* render_frame = GetRenderFrame(); | |
| 686 if (!render_frame) | |
| 687 return; | |
| 688 const base::string16& query = SearchBox::Get(render_frame)->query(); | |
| 689 DVLOG(1) << render_frame << " GetQuery: '" << query << "'"; | |
| 690 v8::Isolate* isolate = args.GetIsolate(); | |
| 691 args.GetReturnValue().Set(UTF16ToV8String(isolate, query)); | |
| 692 } | |
| 693 | |
| 694 // static | |
| 695 void SearchBoxExtensionWrapper::GetRightToLeft( | |
| 696 const v8::FunctionCallbackInfo<v8::Value>& args) { | |
| 697 args.GetReturnValue().Set(base::i18n::IsRTL()); | |
| 698 } | |
| 699 | |
| 700 // static | |
| 701 void SearchBoxExtensionWrapper::GetSearchRequestParams( | 673 void SearchBoxExtensionWrapper::GetSearchRequestParams( |
| 702 const v8::FunctionCallbackInfo<v8::Value>& args) { | 674 const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 703 content::RenderFrame* render_frame = GetRenderFrame(); | 675 content::RenderFrame* render_frame = GetRenderFrame(); |
| 704 if (!render_frame) | 676 if (!render_frame) |
| 705 return; | 677 return; |
| 706 | 678 |
| 707 const EmbeddedSearchRequestParams& params = | 679 const EmbeddedSearchRequestParams& params = |
| 708 SearchBox::Get(render_frame)->GetEmbeddedSearchRequestParams(); | 680 SearchBox::Get(render_frame)->GetEmbeddedSearchRequestParams(); |
| 709 v8::Isolate* isolate = args.GetIsolate(); | 681 v8::Isolate* isolate = args.GetIsolate(); |
| 710 v8::Local<v8::Object> data = v8::Object::New(isolate); | 682 v8::Local<v8::Object> data = v8::Object::New(isolate); |
| (...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1077 ThrowInvalidParameters(args); | 1049 ThrowInvalidParameters(args); |
| 1078 return; | 1050 return; |
| 1079 } | 1051 } |
| 1080 | 1052 |
| 1081 DVLOG(1) << render_frame << " UndoMostVisitedDeletion"; | 1053 DVLOG(1) << render_frame << " UndoMostVisitedDeletion"; |
| 1082 SearchBox::Get(render_frame) | 1054 SearchBox::Get(render_frame) |
| 1083 ->UndoMostVisitedDeletion(args[0]->ToInteger()->Value()); | 1055 ->UndoMostVisitedDeletion(args[0]->ToInteger()->Value()); |
| 1084 } | 1056 } |
| 1085 | 1057 |
| 1086 } // namespace extensions_v8 | 1058 } // namespace extensions_v8 |
| OLD | NEW |