Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(413)

Side by Side Diff: chrome/renderer/searchbox/searchbox_extension.cc

Issue 12047107: Change the SearchBox API from using the start/end margins of the location bar to using the start ma… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 static v8::Handle<v8::Value> GetSelectionEnd(const v8::Arguments& args); 229 static v8::Handle<v8::Value> GetSelectionEnd(const v8::Arguments& args);
230 230
231 // Gets the x coordinate (relative to |window|) of the left edge of the 231 // Gets the x coordinate (relative to |window|) of the left edge of the
232 // region of the search box that overlaps the window. 232 // region of the search box that overlaps the window.
233 static v8::Handle<v8::Value> GetX(const v8::Arguments& args); 233 static v8::Handle<v8::Value> GetX(const v8::Arguments& args);
234 234
235 // Gets the y coordinate (relative to |window|) of the right edge of the 235 // Gets the y coordinate (relative to |window|) of the right edge of the
236 // region of the search box that overlaps the window. 236 // region of the search box that overlaps the window.
237 static v8::Handle<v8::Value> GetY(const v8::Arguments& args); 237 static v8::Handle<v8::Value> GetY(const v8::Arguments& args);
238 238
239 // Gets the width of the region of the search box that overlaps the window. 239 // Gets the width of the region of the search box that overlaps the window,
240 // i.e., the width of the omnibox.
240 static v8::Handle<v8::Value> GetWidth(const v8::Arguments& args); 241 static v8::Handle<v8::Value> GetWidth(const v8::Arguments& args);
241 242
242 // Gets the height of the region of the search box that overlaps the window. 243 // Gets the height of the region of the search box that overlaps the window.
243 static v8::Handle<v8::Value> GetHeight(const v8::Arguments& args); 244 static v8::Handle<v8::Value> GetHeight(const v8::Arguments& args);
244 245
245 // Gets the width of the margin from the start-edge of the page to the start 246 // Gets the start-edge margin to use with extended Instant.
246 // of the suggestions dropdown.
247 static v8::Handle<v8::Value> GetStartMargin(const v8::Arguments& args); 247 static v8::Handle<v8::Value> GetStartMargin(const v8::Arguments& args);
248 248
249 // Gets the width of the margin from the end-edge of the page to the end of
250 // the suggestions dropdown.
251 static v8::Handle<v8::Value> GetEndMargin(const v8::Arguments& args);
252
253 // Returns true if the Searchbox itself is oriented right-to-left. 249 // Returns true if the Searchbox itself is oriented right-to-left.
254 static v8::Handle<v8::Value> GetRightToLeft(const v8::Arguments& args); 250 static v8::Handle<v8::Value> GetRightToLeft(const v8::Arguments& args);
255 251
256 // Gets the autocomplete results from search box. 252 // Gets the autocomplete results from search box.
257 static v8::Handle<v8::Value> GetAutocompleteResults( 253 static v8::Handle<v8::Value> GetAutocompleteResults(
258 const v8::Arguments& args); 254 const v8::Arguments& args);
259 255
260 // Gets whether to display Instant results. 256 // Gets whether to display Instant results.
261 static v8::Handle<v8::Value> GetDisplayInstantResults( 257 static v8::Handle<v8::Value> GetDisplayInstantResults(
262 const v8::Arguments& args); 258 const v8::Arguments& args);
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 if (name->Equals(v8::String::New("GetX"))) 325 if (name->Equals(v8::String::New("GetX")))
330 return v8::FunctionTemplate::New(GetX); 326 return v8::FunctionTemplate::New(GetX);
331 if (name->Equals(v8::String::New("GetY"))) 327 if (name->Equals(v8::String::New("GetY")))
332 return v8::FunctionTemplate::New(GetY); 328 return v8::FunctionTemplate::New(GetY);
333 if (name->Equals(v8::String::New("GetWidth"))) 329 if (name->Equals(v8::String::New("GetWidth")))
334 return v8::FunctionTemplate::New(GetWidth); 330 return v8::FunctionTemplate::New(GetWidth);
335 if (name->Equals(v8::String::New("GetHeight"))) 331 if (name->Equals(v8::String::New("GetHeight")))
336 return v8::FunctionTemplate::New(GetHeight); 332 return v8::FunctionTemplate::New(GetHeight);
337 if (name->Equals(v8::String::New("GetStartMargin"))) 333 if (name->Equals(v8::String::New("GetStartMargin")))
338 return v8::FunctionTemplate::New(GetStartMargin); 334 return v8::FunctionTemplate::New(GetStartMargin);
339 if (name->Equals(v8::String::New("GetEndMargin")))
340 return v8::FunctionTemplate::New(GetEndMargin);
341 if (name->Equals(v8::String::New("GetRightToLeft"))) 335 if (name->Equals(v8::String::New("GetRightToLeft")))
342 return v8::FunctionTemplate::New(GetRightToLeft); 336 return v8::FunctionTemplate::New(GetRightToLeft);
343 if (name->Equals(v8::String::New("GetAutocompleteResults"))) 337 if (name->Equals(v8::String::New("GetAutocompleteResults")))
344 return v8::FunctionTemplate::New(GetAutocompleteResults); 338 return v8::FunctionTemplate::New(GetAutocompleteResults);
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);
349 if (name->Equals(v8::String::New("IsKeyCaptureEnabled"))) 343 if (name->Equals(v8::String::New("IsKeyCaptureEnabled")))
350 return v8::FunctionTemplate::New(IsKeyCaptureEnabled); 344 return v8::FunctionTemplate::New(IsKeyCaptureEnabled);
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 if (!render_view) return v8::Undefined(); 434 if (!render_view) return v8::Undefined();
441 435
442 return v8::Int32::New(SearchBox::Get(render_view)->GetPopupBounds().y()); 436 return v8::Int32::New(SearchBox::Get(render_view)->GetPopupBounds().y());
443 } 437 }
444 438
445 // static 439 // static
446 v8::Handle<v8::Value> SearchBoxExtensionWrapper::GetWidth( 440 v8::Handle<v8::Value> SearchBoxExtensionWrapper::GetWidth(
447 const v8::Arguments& args) { 441 const v8::Arguments& args) {
448 content::RenderView* render_view = GetRenderView(); 442 content::RenderView* render_view = GetRenderView();
449 if (!render_view) return v8::Undefined(); 443 if (!render_view) return v8::Undefined();
450
451 return v8::Int32::New(SearchBox::Get(render_view)->GetPopupBounds().width()); 444 return v8::Int32::New(SearchBox::Get(render_view)->GetPopupBounds().width());
452 } 445 }
453 446
454 // static 447 // static
455 v8::Handle<v8::Value> SearchBoxExtensionWrapper::GetHeight( 448 v8::Handle<v8::Value> SearchBoxExtensionWrapper::GetHeight(
456 const v8::Arguments& args) { 449 const v8::Arguments& args) {
457 content::RenderView* render_view = GetRenderView(); 450 content::RenderView* render_view = GetRenderView();
458 if (!render_view) return v8::Undefined(); 451 if (!render_view) return v8::Undefined();
459 452
460 return v8::Int32::New(SearchBox::Get(render_view)->GetPopupBounds().height()); 453 return v8::Int32::New(SearchBox::Get(render_view)->GetPopupBounds().height());
461 } 454 }
462 455
463 // static 456 // static
464 v8::Handle<v8::Value> SearchBoxExtensionWrapper::GetStartMargin( 457 v8::Handle<v8::Value> SearchBoxExtensionWrapper::GetStartMargin(
465 const v8::Arguments& args) { 458 const v8::Arguments& args) {
466 content::RenderView* render_view = GetRenderView(); 459 content::RenderView* render_view = GetRenderView();
467 if (!render_view) return v8::Undefined(); 460 if (!render_view) return v8::Undefined();
468 return v8::Int32::New(SearchBox::Get(render_view)->GetStartMargin()); 461 return v8::Int32::New(SearchBox::Get(render_view)->GetStartMargin());
469 } 462 }
470 463
471 // static 464 // static
472 v8::Handle<v8::Value> SearchBoxExtensionWrapper::GetEndMargin(
473 const v8::Arguments& args) {
474 content::RenderView* render_view = GetRenderView();
475 if (!render_view) return v8::Undefined();
476 return v8::Int32::New(SearchBox::Get(render_view)->GetEndMargin());
477 }
478
479 // static
480 v8::Handle<v8::Value> SearchBoxExtensionWrapper::GetRightToLeft( 465 v8::Handle<v8::Value> SearchBoxExtensionWrapper::GetRightToLeft(
481 const v8::Arguments& args) { 466 const v8::Arguments& args) {
482 return v8::Boolean::New(base::i18n::IsRTL()); 467 return v8::Boolean::New(base::i18n::IsRTL());
483 } 468 }
484 469
485 // static 470 // static
486 v8::Handle<v8::Value> SearchBoxExtensionWrapper::GetAutocompleteResults( 471 v8::Handle<v8::Value> SearchBoxExtensionWrapper::GetAutocompleteResults(
487 const v8::Arguments& args) { 472 const v8::Arguments& args) {
488 content::RenderView* render_view = GetRenderView(); 473 content::RenderView* render_view = GetRenderView();
489 if (!render_view) return v8::Undefined(); 474 if (!render_view) return v8::Undefined();
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after
930 void SearchBoxExtension::DispatchMarginChange(WebKit::WebFrame* frame) { 915 void SearchBoxExtension::DispatchMarginChange(WebKit::WebFrame* frame) {
931 Dispatch(frame, kDispatchMarginChangeEventScript); 916 Dispatch(frame, kDispatchMarginChangeEventScript);
932 } 917 }
933 918
934 // static 919 // static
935 void SearchBoxExtension::DispatchThemeChange(WebKit::WebFrame* frame) { 920 void SearchBoxExtension::DispatchThemeChange(WebKit::WebFrame* frame) {
936 Dispatch(frame, kDispatchThemeChangeEventScript); 921 Dispatch(frame, kDispatchThemeChangeEventScript);
937 } 922 }
938 923
939 } // namespace extensions_v8 924 } // namespace extensions_v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698