| 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/string_number_conversions.h" | 8 #include "base/string_number_conversions.h" |
| 9 #include "base/stringprintf.h" | 9 #include "base/stringprintf.h" |
| 10 #include "chrome/common/extensions/extension.h" | 10 #include "chrome/common/extensions/extension.h" |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 static v8::Handle<v8::Value> GetWidth(const v8::Arguments& args); | 228 static v8::Handle<v8::Value> GetWidth(const v8::Arguments& args); |
| 229 | 229 |
| 230 // Gets the height of the region of the search box that overlaps the window. | 230 // 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); | 231 static v8::Handle<v8::Value> GetHeight(const v8::Arguments& args); |
| 232 | 232 |
| 233 // Gets the width of the margin from the start-edge of the page to the start | 233 // Gets the width of the margin from the start-edge of the page to the start |
| 234 // of the suggestions dropdown. | 234 // of the location bar. |
| 235 static v8::Handle<v8::Value> GetStartMargin(const v8::Arguments& args); | 235 static v8::Handle<v8::Value> GetLocationBarMargin(const v8::Arguments& args); |
| 236 | 236 |
| 237 // Gets the width of the margin from the end-edge of the page to the end of | 237 // Gets the width of the location bar. |
| 238 // the suggestions dropdown. | 238 static v8::Handle<v8::Value> GetLocationBarWidth(const v8::Arguments& args); |
| 239 static v8::Handle<v8::Value> GetEndMargin(const v8::Arguments& args); | |
| 240 | 239 |
| 241 // Returns true if the Searchbox itself is oriented right-to-left. | 240 // Returns true if the Searchbox itself is oriented right-to-left. |
| 242 static v8::Handle<v8::Value> GetRightToLeft(const v8::Arguments& args); | 241 static v8::Handle<v8::Value> GetRightToLeft(const v8::Arguments& args); |
| 243 | 242 |
| 244 // Gets the autocomplete results from search box. | 243 // Gets the autocomplete results from search box. |
| 245 static v8::Handle<v8::Value> GetAutocompleteResults( | 244 static v8::Handle<v8::Value> GetAutocompleteResults( |
| 246 const v8::Arguments& args); | 245 const v8::Arguments& args); |
| 247 | 246 |
| 248 // Gets the current session context. | 247 // Gets the current session context. |
| 249 static v8::Handle<v8::Value> GetContext(const v8::Arguments& args); | 248 static v8::Handle<v8::Value> GetContext(const v8::Arguments& args); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 if (name->Equals(v8::String::New("GetSelectionEnd"))) | 324 if (name->Equals(v8::String::New("GetSelectionEnd"))) |
| 326 return v8::FunctionTemplate::New(GetSelectionEnd); | 325 return v8::FunctionTemplate::New(GetSelectionEnd); |
| 327 if (name->Equals(v8::String::New("GetX"))) | 326 if (name->Equals(v8::String::New("GetX"))) |
| 328 return v8::FunctionTemplate::New(GetX); | 327 return v8::FunctionTemplate::New(GetX); |
| 329 if (name->Equals(v8::String::New("GetY"))) | 328 if (name->Equals(v8::String::New("GetY"))) |
| 330 return v8::FunctionTemplate::New(GetY); | 329 return v8::FunctionTemplate::New(GetY); |
| 331 if (name->Equals(v8::String::New("GetWidth"))) | 330 if (name->Equals(v8::String::New("GetWidth"))) |
| 332 return v8::FunctionTemplate::New(GetWidth); | 331 return v8::FunctionTemplate::New(GetWidth); |
| 333 if (name->Equals(v8::String::New("GetHeight"))) | 332 if (name->Equals(v8::String::New("GetHeight"))) |
| 334 return v8::FunctionTemplate::New(GetHeight); | 333 return v8::FunctionTemplate::New(GetHeight); |
| 335 if (name->Equals(v8::String::New("GetStartMargin"))) | 334 if (name->Equals(v8::String::New("GetLocationBarMargin"))) |
| 336 return v8::FunctionTemplate::New(GetStartMargin); | 335 return v8::FunctionTemplate::New(GetLocationBarMargin); |
| 337 if (name->Equals(v8::String::New("GetEndMargin"))) | 336 if (name->Equals(v8::String::New("GetLocationBarWidth"))) |
| 338 return v8::FunctionTemplate::New(GetEndMargin); | 337 return v8::FunctionTemplate::New(GetLocationBarWidth); |
| 339 if (name->Equals(v8::String::New("GetRightToLeft"))) | 338 if (name->Equals(v8::String::New("GetRightToLeft"))) |
| 340 return v8::FunctionTemplate::New(GetRightToLeft); | 339 return v8::FunctionTemplate::New(GetRightToLeft); |
| 341 if (name->Equals(v8::String::New("GetAutocompleteResults"))) | 340 if (name->Equals(v8::String::New("GetAutocompleteResults"))) |
| 342 return v8::FunctionTemplate::New(GetAutocompleteResults); | 341 return v8::FunctionTemplate::New(GetAutocompleteResults); |
| 343 if (name->Equals(v8::String::New("GetContext"))) | 342 if (name->Equals(v8::String::New("GetContext"))) |
| 344 return v8::FunctionTemplate::New(GetContext); | 343 return v8::FunctionTemplate::New(GetContext); |
| 345 if (name->Equals(v8::String::New("GetDisplayInstantResults"))) | 344 if (name->Equals(v8::String::New("GetDisplayInstantResults"))) |
| 346 return v8::FunctionTemplate::New(GetDisplayInstantResults); | 345 return v8::FunctionTemplate::New(GetDisplayInstantResults); |
| 347 if (name->Equals(v8::String::New("GetThemeBackgroundInfo"))) | 346 if (name->Equals(v8::String::New("GetThemeBackgroundInfo"))) |
| 348 return v8::FunctionTemplate::New(GetThemeBackgroundInfo); | 347 return v8::FunctionTemplate::New(GetThemeBackgroundInfo); |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 456 // static | 455 // static |
| 457 v8::Handle<v8::Value> SearchBoxExtensionWrapper::GetHeight( | 456 v8::Handle<v8::Value> SearchBoxExtensionWrapper::GetHeight( |
| 458 const v8::Arguments& args) { | 457 const v8::Arguments& args) { |
| 459 content::RenderView* render_view = GetRenderView(); | 458 content::RenderView* render_view = GetRenderView(); |
| 460 if (!render_view) return v8::Undefined(); | 459 if (!render_view) return v8::Undefined(); |
| 461 | 460 |
| 462 return v8::Int32::New(SearchBox::Get(render_view)->GetPopupBounds().height()); | 461 return v8::Int32::New(SearchBox::Get(render_view)->GetPopupBounds().height()); |
| 463 } | 462 } |
| 464 | 463 |
| 465 // static | 464 // static |
| 466 v8::Handle<v8::Value> SearchBoxExtensionWrapper::GetStartMargin( | 465 v8::Handle<v8::Value> SearchBoxExtensionWrapper::GetLocationBarMargin( |
| 467 const v8::Arguments& args) { | 466 const v8::Arguments& args) { |
| 468 content::RenderView* render_view = GetRenderView(); | 467 content::RenderView* render_view = GetRenderView(); |
| 469 if (!render_view) return v8::Undefined(); | 468 if (!render_view) return v8::Undefined(); |
| 470 return v8::Int32::New(SearchBox::Get(render_view)->GetStartMargin()); | 469 return v8::Int32::New(SearchBox::Get(render_view)->GetLocationBarMargin()); |
| 471 } | 470 } |
| 472 | 471 |
| 473 // static | 472 // static |
| 474 v8::Handle<v8::Value> SearchBoxExtensionWrapper::GetEndMargin( | 473 v8::Handle<v8::Value> SearchBoxExtensionWrapper::GetLocationBarWidth( |
| 475 const v8::Arguments& args) { | 474 const v8::Arguments& args) { |
| 476 content::RenderView* render_view = GetRenderView(); | 475 content::RenderView* render_view = GetRenderView(); |
| 477 if (!render_view) return v8::Undefined(); | 476 if (!render_view) return v8::Undefined(); |
| 478 return v8::Int32::New(SearchBox::Get(render_view)->GetEndMargin()); | 477 return v8::Int32::New(SearchBox::Get(render_view)->GetLocationBarWidth()); |
| 479 } | 478 } |
| 480 | 479 |
| 481 // static | 480 // static |
| 482 v8::Handle<v8::Value> SearchBoxExtensionWrapper::GetRightToLeft( | 481 v8::Handle<v8::Value> SearchBoxExtensionWrapper::GetRightToLeft( |
| 483 const v8::Arguments& args) { | 482 const v8::Arguments& args) { |
| 484 return v8::Boolean::New(base::i18n::IsRTL()); | 483 return v8::Boolean::New(base::i18n::IsRTL()); |
| 485 } | 484 } |
| 486 | 485 |
| 487 // static | 486 // static |
| 488 v8::Handle<v8::Value> SearchBoxExtensionWrapper::GetAutocompleteResults( | 487 v8::Handle<v8::Value> SearchBoxExtensionWrapper::GetAutocompleteResults( |
| (...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 958 Dispatch(frame, kDispatchThemeAreaHeightChangeEventScript); | 957 Dispatch(frame, kDispatchThemeAreaHeightChangeEventScript); |
| 959 } | 958 } |
| 960 | 959 |
| 961 // static | 960 // static |
| 962 v8::Extension* SearchBoxExtension::Get() { | 961 v8::Extension* SearchBoxExtension::Get() { |
| 963 return new SearchBoxExtensionWrapper(ResourceBundle::GetSharedInstance(). | 962 return new SearchBoxExtensionWrapper(ResourceBundle::GetSharedInstance(). |
| 964 GetRawDataResource(IDR_SEARCHBOX_API)); | 963 GetRawDataResource(IDR_SEARCHBOX_API)); |
| 965 } | 964 } |
| 966 | 965 |
| 967 } // namespace extensions_v8 | 966 } // namespace extensions_v8 |
| OLD | NEW |