| 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/stringprintf.h" | 8 #include "base/stringprintf.h" |
| 9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 static v8::Handle<v8::Value> GetSelectionEnd(const v8::Arguments& args); | 245 static v8::Handle<v8::Value> GetSelectionEnd(const v8::Arguments& args); |
| 246 | 246 |
| 247 // Gets the x coordinate (relative to |window|) of the left edge of the | 247 // Gets the x coordinate (relative to |window|) of the left edge of the |
| 248 // region of the search box that overlaps the window. | 248 // region of the search box that overlaps the window. |
| 249 static v8::Handle<v8::Value> GetX(const v8::Arguments& args); | 249 static v8::Handle<v8::Value> GetX(const v8::Arguments& args); |
| 250 | 250 |
| 251 // Gets the y coordinate (relative to |window|) of the right edge of the | 251 // Gets the y coordinate (relative to |window|) of the right edge of the |
| 252 // region of the search box that overlaps the window. | 252 // region of the search box that overlaps the window. |
| 253 static v8::Handle<v8::Value> GetY(const v8::Arguments& args); | 253 static v8::Handle<v8::Value> GetY(const v8::Arguments& args); |
| 254 | 254 |
| 255 // Gets the width of the region of the search box that overlaps the window. | 255 // Gets the width of the region of the search box that overlaps the window, |
| 256 // i.e., the width of the omnibox. |
| 256 static v8::Handle<v8::Value> GetWidth(const v8::Arguments& args); | 257 static v8::Handle<v8::Value> GetWidth(const v8::Arguments& args); |
| 257 | 258 |
| 258 // Gets the height of the region of the search box that overlaps the window. | 259 // Gets the height of the region of the search box that overlaps the window. |
| 259 static v8::Handle<v8::Value> GetHeight(const v8::Arguments& args); | 260 static v8::Handle<v8::Value> GetHeight(const v8::Arguments& args); |
| 260 | 261 |
| 261 // Gets Most Visited Items. | 262 // Gets Most Visited Items. |
| 262 static v8::Handle<v8::Value> GetMostVisitedItems(const v8::Arguments& args); | 263 static v8::Handle<v8::Value> GetMostVisitedItems(const v8::Arguments& args); |
| 263 | 264 |
| 264 // Gets the width of the margin from the start-edge of the page to the start | 265 // Gets the start-edge margin to use with extended Instant. |
| 265 // of the suggestions dropdown. | |
| 266 static v8::Handle<v8::Value> GetStartMargin(const v8::Arguments& args); | 266 static v8::Handle<v8::Value> GetStartMargin(const v8::Arguments& args); |
| 267 | 267 |
| 268 // Gets the width of the margin from the end-edge of the page to the end of | |
| 269 // the suggestions dropdown. | |
| 270 static v8::Handle<v8::Value> GetEndMargin(const v8::Arguments& args); | |
| 271 | |
| 272 // Returns true if the Searchbox itself is oriented right-to-left. | 268 // Returns true if the Searchbox itself is oriented right-to-left. |
| 273 static v8::Handle<v8::Value> GetRightToLeft(const v8::Arguments& args); | 269 static v8::Handle<v8::Value> GetRightToLeft(const v8::Arguments& args); |
| 274 | 270 |
| 275 // Gets the autocomplete results from search box. | 271 // Gets the autocomplete results from search box. |
| 276 static v8::Handle<v8::Value> GetAutocompleteResults( | 272 static v8::Handle<v8::Value> GetAutocompleteResults( |
| 277 const v8::Arguments& args); | 273 const v8::Arguments& args); |
| 278 | 274 |
| 279 // Gets whether to display Instant results. | 275 // Gets whether to display Instant results. |
| 280 static v8::Handle<v8::Value> GetDisplayInstantResults( | 276 static v8::Handle<v8::Value> GetDisplayInstantResults( |
| 281 const v8::Arguments& args); | 277 const v8::Arguments& args); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 if (name->Equals(v8::String::New("GetY"))) | 356 if (name->Equals(v8::String::New("GetY"))) |
| 361 return v8::FunctionTemplate::New(GetY); | 357 return v8::FunctionTemplate::New(GetY); |
| 362 if (name->Equals(v8::String::New("GetWidth"))) | 358 if (name->Equals(v8::String::New("GetWidth"))) |
| 363 return v8::FunctionTemplate::New(GetWidth); | 359 return v8::FunctionTemplate::New(GetWidth); |
| 364 if (name->Equals(v8::String::New("GetHeight"))) | 360 if (name->Equals(v8::String::New("GetHeight"))) |
| 365 return v8::FunctionTemplate::New(GetHeight); | 361 return v8::FunctionTemplate::New(GetHeight); |
| 366 if (name->Equals(v8::String::New("GetMostVisitedItems"))) | 362 if (name->Equals(v8::String::New("GetMostVisitedItems"))) |
| 367 return v8::FunctionTemplate::New(GetMostVisitedItems); | 363 return v8::FunctionTemplate::New(GetMostVisitedItems); |
| 368 if (name->Equals(v8::String::New("GetStartMargin"))) | 364 if (name->Equals(v8::String::New("GetStartMargin"))) |
| 369 return v8::FunctionTemplate::New(GetStartMargin); | 365 return v8::FunctionTemplate::New(GetStartMargin); |
| 370 if (name->Equals(v8::String::New("GetEndMargin"))) | |
| 371 return v8::FunctionTemplate::New(GetEndMargin); | |
| 372 if (name->Equals(v8::String::New("GetRightToLeft"))) | 366 if (name->Equals(v8::String::New("GetRightToLeft"))) |
| 373 return v8::FunctionTemplate::New(GetRightToLeft); | 367 return v8::FunctionTemplate::New(GetRightToLeft); |
| 374 if (name->Equals(v8::String::New("GetAutocompleteResults"))) | 368 if (name->Equals(v8::String::New("GetAutocompleteResults"))) |
| 375 return v8::FunctionTemplate::New(GetAutocompleteResults); | 369 return v8::FunctionTemplate::New(GetAutocompleteResults); |
| 376 if (name->Equals(v8::String::New("GetDisplayInstantResults"))) | 370 if (name->Equals(v8::String::New("GetDisplayInstantResults"))) |
| 377 return v8::FunctionTemplate::New(GetDisplayInstantResults); | 371 return v8::FunctionTemplate::New(GetDisplayInstantResults); |
| 378 if (name->Equals(v8::String::New("GetThemeBackgroundInfo"))) | 372 if (name->Equals(v8::String::New("GetThemeBackgroundInfo"))) |
| 379 return v8::FunctionTemplate::New(GetThemeBackgroundInfo); | 373 return v8::FunctionTemplate::New(GetThemeBackgroundInfo); |
| 380 if (name->Equals(v8::String::New("IsKeyCaptureEnabled"))) | 374 if (name->Equals(v8::String::New("IsKeyCaptureEnabled"))) |
| 381 return v8::FunctionTemplate::New(IsKeyCaptureEnabled); | 375 return v8::FunctionTemplate::New(IsKeyCaptureEnabled); |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 475 if (!render_view) return v8::Undefined(); | 469 if (!render_view) return v8::Undefined(); |
| 476 | 470 |
| 477 return v8::Int32::New(SearchBox::Get(render_view)->GetPopupBounds().y()); | 471 return v8::Int32::New(SearchBox::Get(render_view)->GetPopupBounds().y()); |
| 478 } | 472 } |
| 479 | 473 |
| 480 // static | 474 // static |
| 481 v8::Handle<v8::Value> SearchBoxExtensionWrapper::GetWidth( | 475 v8::Handle<v8::Value> SearchBoxExtensionWrapper::GetWidth( |
| 482 const v8::Arguments& args) { | 476 const v8::Arguments& args) { |
| 483 content::RenderView* render_view = GetRenderView(); | 477 content::RenderView* render_view = GetRenderView(); |
| 484 if (!render_view) return v8::Undefined(); | 478 if (!render_view) return v8::Undefined(); |
| 485 | |
| 486 return v8::Int32::New(SearchBox::Get(render_view)->GetPopupBounds().width()); | 479 return v8::Int32::New(SearchBox::Get(render_view)->GetPopupBounds().width()); |
| 487 } | 480 } |
| 488 | 481 |
| 489 // static | 482 // static |
| 490 v8::Handle<v8::Value> SearchBoxExtensionWrapper::GetHeight( | 483 v8::Handle<v8::Value> SearchBoxExtensionWrapper::GetHeight( |
| 491 const v8::Arguments& args) { | 484 const v8::Arguments& args) { |
| 492 content::RenderView* render_view = GetRenderView(); | 485 content::RenderView* render_view = GetRenderView(); |
| 493 if (!render_view) return v8::Undefined(); | 486 if (!render_view) return v8::Undefined(); |
| 494 | 487 |
| 495 return v8::Int32::New(SearchBox::Get(render_view)->GetPopupBounds().height()); | 488 return v8::Int32::New(SearchBox::Get(render_view)->GetPopupBounds().height()); |
| 496 } | 489 } |
| 497 | 490 |
| 498 // static | 491 // static |
| 499 v8::Handle<v8::Value> SearchBoxExtensionWrapper::GetStartMargin( | 492 v8::Handle<v8::Value> SearchBoxExtensionWrapper::GetStartMargin( |
| 500 const v8::Arguments& args) { | 493 const v8::Arguments& args) { |
| 501 content::RenderView* render_view = GetRenderView(); | 494 content::RenderView* render_view = GetRenderView(); |
| 502 if (!render_view) return v8::Undefined(); | 495 if (!render_view) return v8::Undefined(); |
| 503 return v8::Int32::New(SearchBox::Get(render_view)->GetStartMargin()); | 496 return v8::Int32::New(SearchBox::Get(render_view)->GetStartMargin()); |
| 504 } | 497 } |
| 505 | 498 |
| 506 // static | 499 // static |
| 507 v8::Handle<v8::Value> SearchBoxExtensionWrapper::GetEndMargin( | |
| 508 const v8::Arguments& args) { | |
| 509 content::RenderView* render_view = GetRenderView(); | |
| 510 if (!render_view) return v8::Undefined(); | |
| 511 return v8::Int32::New(SearchBox::Get(render_view)->GetEndMargin()); | |
| 512 } | |
| 513 | |
| 514 // static | |
| 515 v8::Handle<v8::Value> SearchBoxExtensionWrapper::GetRightToLeft( | 500 v8::Handle<v8::Value> SearchBoxExtensionWrapper::GetRightToLeft( |
| 516 const v8::Arguments& args) { | 501 const v8::Arguments& args) { |
| 517 return v8::Boolean::New(base::i18n::IsRTL()); | 502 return v8::Boolean::New(base::i18n::IsRTL()); |
| 518 } | 503 } |
| 519 | 504 |
| 520 // static | 505 // static |
| 521 v8::Handle<v8::Value> SearchBoxExtensionWrapper::GetAutocompleteResults( | 506 v8::Handle<v8::Value> SearchBoxExtensionWrapper::GetAutocompleteResults( |
| 522 const v8::Arguments& args) { | 507 const v8::Arguments& args) { |
| 523 content::RenderView* render_view = GetRenderView(); | 508 content::RenderView* render_view = GetRenderView(); |
| 524 if (!render_view) return v8::Undefined(); | 509 if (!render_view) return v8::Undefined(); |
| (...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1043 void SearchBoxExtension::DispatchThemeChange(WebKit::WebFrame* frame) { | 1028 void SearchBoxExtension::DispatchThemeChange(WebKit::WebFrame* frame) { |
| 1044 Dispatch(frame, kDispatchThemeChangeEventScript); | 1029 Dispatch(frame, kDispatchThemeChangeEventScript); |
| 1045 } | 1030 } |
| 1046 | 1031 |
| 1047 // static | 1032 // static |
| 1048 void SearchBoxExtension::DispatchMostVisitedChanged( | 1033 void SearchBoxExtension::DispatchMostVisitedChanged( |
| 1049 WebKit::WebFrame* frame) { | 1034 WebKit::WebFrame* frame) { |
| 1050 Dispatch(frame, kDispatchMostVisitedChangedScript); | 1035 Dispatch(frame, kDispatchMostVisitedChangedScript); |
| 1051 } | 1036 } |
| 1052 } // namespace extensions_v8 | 1037 } // namespace extensions_v8 |
| OLD | NEW |