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