Chromium Code Reviews| 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 "chrome/common/extensions/extension.h" | 10 #include "chrome/common/extensions/extension.h" |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 218 | 218 |
| 219 // Gets the x coordinate (relative to |window|) of the left edge of the | 219 // Gets the x coordinate (relative to |window|) of the left edge of the |
| 220 // region of the search box that overlaps the window. | 220 // region of the search box that overlaps the window. |
| 221 static v8::Handle<v8::Value> GetX(const v8::Arguments& args); | 221 static v8::Handle<v8::Value> GetX(const v8::Arguments& args); |
| 222 | 222 |
| 223 // Gets the y coordinate (relative to |window|) of the right edge of the | 223 // Gets the y coordinate (relative to |window|) of the right edge of the |
| 224 // region of the search box that overlaps the window. | 224 // region of the search box that overlaps the window. |
| 225 static v8::Handle<v8::Value> GetY(const v8::Arguments& args); | 225 static v8::Handle<v8::Value> GetY(const v8::Arguments& args); |
| 226 | 226 |
| 227 // Gets the width of the region of the search box that overlaps the window. | 227 // Gets the width of the region of the search box that overlaps the window. |
| 228 // In extended Instant, this gets the width of the location bar instead. | |
|
sreeram
2013/02/20 15:40:10
These are exactly the same. I.e., the width of the
melevin
2013/02/20 20:11:45
Done.
| |
| 228 static v8::Handle<v8::Value> GetWidth(const v8::Arguments& args); | 229 static v8::Handle<v8::Value> GetWidth(const v8::Arguments& args); |
| 229 | 230 |
| 230 // Gets the height of the region of the search box that overlaps the window. | 231 // Gets the height of the region of the search box that overlaps the window. |
| 231 static v8::Handle<v8::Value> GetHeight(const v8::Arguments& args); | 232 static v8::Handle<v8::Value> GetHeight(const v8::Arguments& args); |
| 232 | 233 |
| 233 // Gets the width of the margin from the start-edge of the page to the start | 234 // Gets the start-edge margin to use with extended Instant. |
| 234 // of the suggestions dropdown. | |
| 235 static v8::Handle<v8::Value> GetStartMargin(const v8::Arguments& args); | 235 static v8::Handle<v8::Value> GetStartMargin(const v8::Arguments& args); |
| 236 | 236 |
| 237 // Gets the width of the margin from the end-edge of the page to the end of | |
| 238 // the suggestions dropdown. | |
| 239 static v8::Handle<v8::Value> GetEndMargin(const v8::Arguments& args); | |
| 240 | |
| 241 // Returns true if the Searchbox itself is oriented right-to-left. | 237 // Returns true if the Searchbox itself is oriented right-to-left. |
| 242 static v8::Handle<v8::Value> GetRightToLeft(const v8::Arguments& args); | 238 static v8::Handle<v8::Value> GetRightToLeft(const v8::Arguments& args); |
| 243 | 239 |
| 244 // Gets the autocomplete results from search box. | 240 // Gets the autocomplete results from search box. |
| 245 static v8::Handle<v8::Value> GetAutocompleteResults( | 241 static v8::Handle<v8::Value> GetAutocompleteResults( |
| 246 const v8::Arguments& args); | 242 const v8::Arguments& args); |
| 247 | 243 |
| 248 // Gets the current session context. | 244 // Gets the current session context. |
| 249 static v8::Handle<v8::Value> GetContext(const v8::Arguments& args); | 245 static v8::Handle<v8::Value> GetContext(const v8::Arguments& args); |
| 250 | 246 |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 327 if (name->Equals(v8::String::New("GetX"))) | 323 if (name->Equals(v8::String::New("GetX"))) |
| 328 return v8::FunctionTemplate::New(GetX); | 324 return v8::FunctionTemplate::New(GetX); |
| 329 if (name->Equals(v8::String::New("GetY"))) | 325 if (name->Equals(v8::String::New("GetY"))) |
| 330 return v8::FunctionTemplate::New(GetY); | 326 return v8::FunctionTemplate::New(GetY); |
| 331 if (name->Equals(v8::String::New("GetWidth"))) | 327 if (name->Equals(v8::String::New("GetWidth"))) |
| 332 return v8::FunctionTemplate::New(GetWidth); | 328 return v8::FunctionTemplate::New(GetWidth); |
| 333 if (name->Equals(v8::String::New("GetHeight"))) | 329 if (name->Equals(v8::String::New("GetHeight"))) |
| 334 return v8::FunctionTemplate::New(GetHeight); | 330 return v8::FunctionTemplate::New(GetHeight); |
| 335 if (name->Equals(v8::String::New("GetStartMargin"))) | 331 if (name->Equals(v8::String::New("GetStartMargin"))) |
| 336 return v8::FunctionTemplate::New(GetStartMargin); | 332 return v8::FunctionTemplate::New(GetStartMargin); |
| 337 if (name->Equals(v8::String::New("GetEndMargin"))) | |
| 338 return v8::FunctionTemplate::New(GetEndMargin); | |
| 339 if (name->Equals(v8::String::New("GetRightToLeft"))) | 333 if (name->Equals(v8::String::New("GetRightToLeft"))) |
| 340 return v8::FunctionTemplate::New(GetRightToLeft); | 334 return v8::FunctionTemplate::New(GetRightToLeft); |
| 341 if (name->Equals(v8::String::New("GetAutocompleteResults"))) | 335 if (name->Equals(v8::String::New("GetAutocompleteResults"))) |
| 342 return v8::FunctionTemplate::New(GetAutocompleteResults); | 336 return v8::FunctionTemplate::New(GetAutocompleteResults); |
| 343 if (name->Equals(v8::String::New("GetContext"))) | 337 if (name->Equals(v8::String::New("GetContext"))) |
| 344 return v8::FunctionTemplate::New(GetContext); | 338 return v8::FunctionTemplate::New(GetContext); |
| 345 if (name->Equals(v8::String::New("GetDisplayInstantResults"))) | 339 if (name->Equals(v8::String::New("GetDisplayInstantResults"))) |
| 346 return v8::FunctionTemplate::New(GetDisplayInstantResults); | 340 return v8::FunctionTemplate::New(GetDisplayInstantResults); |
| 347 if (name->Equals(v8::String::New("GetThemeBackgroundInfo"))) | 341 if (name->Equals(v8::String::New("GetThemeBackgroundInfo"))) |
| 348 return v8::FunctionTemplate::New(GetThemeBackgroundInfo); | 342 return v8::FunctionTemplate::New(GetThemeBackgroundInfo); |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 442 if (!render_view) return v8::Undefined(); | 436 if (!render_view) return v8::Undefined(); |
| 443 | 437 |
| 444 return v8::Int32::New(SearchBox::Get(render_view)->GetPopupBounds().y()); | 438 return v8::Int32::New(SearchBox::Get(render_view)->GetPopupBounds().y()); |
| 445 } | 439 } |
| 446 | 440 |
| 447 // static | 441 // static |
| 448 v8::Handle<v8::Value> SearchBoxExtensionWrapper::GetWidth( | 442 v8::Handle<v8::Value> SearchBoxExtensionWrapper::GetWidth( |
| 449 const v8::Arguments& args) { | 443 const v8::Arguments& args) { |
| 450 content::RenderView* render_view = GetRenderView(); | 444 content::RenderView* render_view = GetRenderView(); |
| 451 if (!render_view) return v8::Undefined(); | 445 if (!render_view) return v8::Undefined(); |
| 452 | |
| 453 return v8::Int32::New(SearchBox::Get(render_view)->GetPopupBounds().width()); | 446 return v8::Int32::New(SearchBox::Get(render_view)->GetPopupBounds().width()); |
| 454 } | 447 } |
| 455 | 448 |
| 456 // static | 449 // static |
| 457 v8::Handle<v8::Value> SearchBoxExtensionWrapper::GetHeight( | 450 v8::Handle<v8::Value> SearchBoxExtensionWrapper::GetHeight( |
| 458 const v8::Arguments& args) { | 451 const v8::Arguments& args) { |
| 459 content::RenderView* render_view = GetRenderView(); | 452 content::RenderView* render_view = GetRenderView(); |
| 460 if (!render_view) return v8::Undefined(); | 453 if (!render_view) return v8::Undefined(); |
| 461 | 454 |
| 462 return v8::Int32::New(SearchBox::Get(render_view)->GetPopupBounds().height()); | 455 return v8::Int32::New(SearchBox::Get(render_view)->GetPopupBounds().height()); |
| 463 } | 456 } |
| 464 | 457 |
| 465 // static | 458 // static |
| 466 v8::Handle<v8::Value> SearchBoxExtensionWrapper::GetStartMargin( | 459 v8::Handle<v8::Value> SearchBoxExtensionWrapper::GetStartMargin( |
| 467 const v8::Arguments& args) { | 460 const v8::Arguments& args) { |
| 468 content::RenderView* render_view = GetRenderView(); | 461 content::RenderView* render_view = GetRenderView(); |
| 469 if (!render_view) return v8::Undefined(); | 462 if (!render_view) return v8::Undefined(); |
| 470 return v8::Int32::New(SearchBox::Get(render_view)->GetStartMargin()); | 463 return v8::Int32::New(SearchBox::Get(render_view)->GetStartMargin()); |
| 471 } | 464 } |
| 472 | 465 |
| 473 // static | 466 // static |
| 474 v8::Handle<v8::Value> SearchBoxExtensionWrapper::GetEndMargin( | |
| 475 const v8::Arguments& args) { | |
| 476 content::RenderView* render_view = GetRenderView(); | |
| 477 if (!render_view) return v8::Undefined(); | |
| 478 return v8::Int32::New(SearchBox::Get(render_view)->GetEndMargin()); | |
| 479 } | |
| 480 | |
| 481 // static | |
| 482 v8::Handle<v8::Value> SearchBoxExtensionWrapper::GetRightToLeft( | 467 v8::Handle<v8::Value> SearchBoxExtensionWrapper::GetRightToLeft( |
| 483 const v8::Arguments& args) { | 468 const v8::Arguments& args) { |
| 484 return v8::Boolean::New(base::i18n::IsRTL()); | 469 return v8::Boolean::New(base::i18n::IsRTL()); |
| 485 } | 470 } |
| 486 | 471 |
| 487 // static | 472 // static |
| 488 v8::Handle<v8::Value> SearchBoxExtensionWrapper::GetAutocompleteResults( | 473 v8::Handle<v8::Value> SearchBoxExtensionWrapper::GetAutocompleteResults( |
| 489 const v8::Arguments& args) { | 474 const v8::Arguments& args) { |
| 490 content::RenderView* render_view = GetRenderView(); | 475 content::RenderView* render_view = GetRenderView(); |
| 491 if (!render_view) return v8::Undefined(); | 476 if (!render_view) return v8::Undefined(); |
| (...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 958 Dispatch(frame, kDispatchThemeAreaHeightChangeEventScript); | 943 Dispatch(frame, kDispatchThemeAreaHeightChangeEventScript); |
| 959 } | 944 } |
| 960 | 945 |
| 961 // static | 946 // static |
| 962 v8::Extension* SearchBoxExtension::Get() { | 947 v8::Extension* SearchBoxExtension::Get() { |
| 963 return new SearchBoxExtensionWrapper(ResourceBundle::GetSharedInstance(). | 948 return new SearchBoxExtensionWrapper(ResourceBundle::GetSharedInstance(). |
| 964 GetRawDataResource(IDR_SEARCHBOX_API)); | 949 GetRawDataResource(IDR_SEARCHBOX_API)); |
| 965 } | 950 } |
| 966 | 951 |
| 967 } // namespace extensions_v8 | 952 } // namespace extensions_v8 |
| OLD | NEW |