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

Side by Side Diff: chrome/browser/views/location_bar/location_bar_view.cc

Issue 2721009: Fix up the Windows omnibox after the recent endcap removal. This fixes most ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 6 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
« no previous file with comments | « chrome/browser/views/location_bar/location_bar_view.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/browser/views/location_bar/location_bar_view.h" 5 #include "chrome/browser/views/location_bar/location_bar_view.h"
6 6
7 #if defined(OS_LINUX) 7 #if defined(OS_LINUX)
8 #include <gtk/gtk.h> 8 #include <gtk/gtk.h>
9 #endif 9 #endif
10 10
(...skipping 10 matching lines...) Expand all
21 #include "chrome/browser/views/location_bar/content_setting_image_view.h" 21 #include "chrome/browser/views/location_bar/content_setting_image_view.h"
22 #include "chrome/browser/views/location_bar/ev_bubble_view.h" 22 #include "chrome/browser/views/location_bar/ev_bubble_view.h"
23 #include "chrome/browser/views/location_bar/keyword_hint_view.h" 23 #include "chrome/browser/views/location_bar/keyword_hint_view.h"
24 #include "chrome/browser/views/location_bar/location_icon_view.h" 24 #include "chrome/browser/views/location_bar/location_icon_view.h"
25 #include "chrome/browser/views/location_bar/page_action_image_view.h" 25 #include "chrome/browser/views/location_bar/page_action_image_view.h"
26 #include "chrome/browser/views/location_bar/page_action_with_badge_view.h" 26 #include "chrome/browser/views/location_bar/page_action_with_badge_view.h"
27 #include "chrome/browser/views/location_bar/selected_keyword_view.h" 27 #include "chrome/browser/views/location_bar/selected_keyword_view.h"
28 #include "chrome/browser/views/location_bar/star_view.h" 28 #include "chrome/browser/views/location_bar/star_view.h"
29 #include "gfx/canvas.h" 29 #include "gfx/canvas.h"
30 #include "gfx/color_utils.h" 30 #include "gfx/color_utils.h"
31 #include "gfx/skia_util.h"
31 #include "grit/theme_resources.h" 32 #include "grit/theme_resources.h"
32 #include "views/drag_utils.h" 33 #include "views/drag_utils.h"
33 34
34 #if defined(OS_WIN) 35 #if defined(OS_WIN)
35 #include "chrome/browser/views/first_run_bubble.h" 36 #include "chrome/browser/views/first_run_bubble.h"
36 #endif 37 #endif
37 38
38 using views::View; 39 using views::View;
39 40
40 // static 41 // static
41 const int LocationBarView::kVertMargin = 2; 42 const int LocationBarView::kVertMargin = 2;
43 const int LocationBarView::kEdgeThickness = 2;
44 const int LocationBarView::kItemPadding = 3;
42 45
43 // Padding between items in the location bar. 46 // Convenience: Total space at the edges of the bar.
44 static const int kViewPadding = 3; 47 const int kEdgePadding =
48 LocationBarView::kEdgeThickness + LocationBarView::kItemPadding;
45 49
46 // Padding before the start of a bubble. 50 // Padding before the start of a bubble.
47 static const int kBubblePadding = kViewPadding - 1; 51 static const int kBubblePadding = kEdgePadding - 1;
48 52
49 // Padding between the location icon and the edit, if they're adjacent. 53 // Padding between the location icon and the edit, if they're adjacent.
50 static const int kLocationIconEditPadding = kViewPadding - 1; 54 static const int kLocationIconEditPadding = LocationBarView::kItemPadding - 1;
55
56 // Padding after the star.
57 static const int kStarPadding = kEdgePadding + 1;
51 58
52 static const int kEVBubbleBackgroundImages[] = { 59 static const int kEVBubbleBackgroundImages[] = {
53 IDR_OMNIBOX_EV_BUBBLE_BACKGROUND_L, 60 IDR_OMNIBOX_EV_BUBBLE_BACKGROUND_L,
54 IDR_OMNIBOX_EV_BUBBLE_BACKGROUND_C, 61 IDR_OMNIBOX_EV_BUBBLE_BACKGROUND_C,
55 IDR_OMNIBOX_EV_BUBBLE_BACKGROUND_R, 62 IDR_OMNIBOX_EV_BUBBLE_BACKGROUND_R,
56 }; 63 };
57 64
58 static const int kSelectedKeywordBackgroundImages[] = { 65 static const int kSelectedKeywordBackgroundImages[] = {
59 IDR_LOCATION_BAR_SELECTED_KEYWORD_BACKGROUND_L, 66 IDR_LOCATION_BAR_SELECTED_KEYWORD_BACKGROUND_L,
60 IDR_LOCATION_BAR_SELECTED_KEYWORD_BACKGROUND_C, 67 IDR_LOCATION_BAR_SELECTED_KEYWORD_BACKGROUND_C,
61 IDR_LOCATION_BAR_SELECTED_KEYWORD_BACKGROUND_R, 68 IDR_LOCATION_BAR_SELECTED_KEYWORD_BACKGROUND_R,
62 }; 69 };
63 70
64 static const SkBitmap* kBackground = NULL; 71 static const int kNormalModeBackgroundImages[] = {
65 72 IDR_LOCATIONBG_L,
66 static const SkBitmap* kPopupBackground = NULL; 73 IDR_LOCATIONBG_C,
74 IDR_LOCATIONBG_R,
75 };
67 76
68 // LocationBarView ----------------------------------------------------------- 77 // LocationBarView -----------------------------------------------------------
69 78
70 LocationBarView::LocationBarView(Profile* profile, 79 LocationBarView::LocationBarView(Profile* profile,
71 CommandUpdater* command_updater, 80 CommandUpdater* command_updater,
72 ToolbarModel* model, 81 ToolbarModel* model,
73 Delegate* delegate, 82 Delegate* delegate,
74 Mode mode) 83 Mode mode)
75 : profile_(profile), 84 : profile_(profile),
76 command_updater_(command_updater), 85 command_updater_(command_updater),
77 model_(model), 86 model_(model),
78 delegate_(delegate), 87 delegate_(delegate),
79 disposition_(CURRENT_TAB), 88 disposition_(CURRENT_TAB),
80 location_icon_view_(NULL), 89 location_icon_view_(NULL),
81 ev_bubble_view_(NULL), 90 ev_bubble_view_(NULL),
82 location_entry_view_(NULL), 91 location_entry_view_(NULL),
83 selected_keyword_view_(NULL), 92 selected_keyword_view_(NULL),
84 keyword_hint_view_(NULL), 93 keyword_hint_view_(NULL),
85 star_view_(NULL), 94 star_view_(NULL),
86 mode_(mode), 95 mode_(mode),
87 force_hidden_count_(0), 96 force_hidden_count_(0),
88 ALLOW_THIS_IN_INITIALIZER_LIST(first_run_bubble_(this)) { 97 ALLOW_THIS_IN_INITIALIZER_LIST(first_run_bubble_(this)) {
89 DCHECK(profile_); 98 DCHECK(profile_);
90 SetID(VIEW_ID_LOCATION_BAR); 99 SetID(VIEW_ID_LOCATION_BAR);
91 SetFocusable(true); 100 SetFocusable(true);
92 101
93 if (!kBackground) { 102 if (mode_ == NORMAL)
94 ResourceBundle &rb = ResourceBundle::GetSharedInstance(); 103 painter_.reset(new views::HorizontalPainter(kNormalModeBackgroundImages));
95 kBackground = rb.GetBitmapNamed(IDR_LOCATIONBG);
96 kPopupBackground = rb.GetBitmapNamed(IDR_LOCATIONBG_POPUPMODE_CENTER);
97 }
98 } 104 }
99 105
100 LocationBarView::~LocationBarView() { 106 LocationBarView::~LocationBarView() {
101 } 107 }
102 108
103 void LocationBarView::Init() { 109 void LocationBarView::Init() {
104 if (mode_ == POPUP) { 110 if (mode_ == POPUP) {
105 font_ = ResourceBundle::GetSharedInstance().GetFont( 111 font_ = ResourceBundle::GetSharedInstance().GetFont(
106 ResourceBundle::BaseFont); 112 ResourceBundle::BaseFont);
107 } else { 113 } else {
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 // Compensate for some built-in padding in the Star image. 357 // Compensate for some built-in padding in the Star image.
352 screen_bounds.Inset(1, 1, 1, 2); 358 screen_bounds.Inset(1, 1, 1, 2);
353 gfx::Point origin(screen_bounds.origin()); 359 gfx::Point origin(screen_bounds.origin());
354 views::View::ConvertPointToScreen(star_view_, &origin); 360 views::View::ConvertPointToScreen(star_view_, &origin);
355 screen_bounds.set_origin(origin); 361 screen_bounds.set_origin(origin);
356 browser::ShowBookmarkBubbleView(GetWindow(), screen_bounds, star_view_, 362 browser::ShowBookmarkBubbleView(GetWindow(), screen_bounds, star_view_,
357 profile_, url, newly_bookmarked); 363 profile_, url, newly_bookmarked);
358 } 364 }
359 365
360 gfx::Size LocationBarView::GetPreferredSize() { 366 gfx::Size LocationBarView::GetPreferredSize() {
361 return gfx::Size(0, 367 return gfx::Size(0, GetThemeProvider()->GetBitmapNamed(mode_ == POPUP ?
362 (mode_ == POPUP ? kPopupBackground : kBackground)->height()); 368 IDR_LOCATIONBG_POPUPMODE_CENTER : IDR_LOCATIONBG_C)->height());
363 } 369 }
364 370
365 void LocationBarView::Layout() { 371 void LocationBarView::Layout() {
366 if (!location_entry_.get()) 372 if (!location_entry_.get())
367 return; 373 return;
368 374
369 int entry_width = width() - kViewPadding; 375 int entry_width = width() - (star_view_ ? kStarPadding : kEdgePadding);
370 376
371 // |location_icon_view_| is visible except when |ev_bubble_view_| or 377 // |location_icon_view_| is visible except when |ev_bubble_view_| or
372 // |selected_keyword_view_| are visible. 378 // |selected_keyword_view_| are visible.
373 int location_icon_width = 0; 379 int location_icon_width = 0;
374 int ev_bubble_width = 0; 380 int ev_bubble_width = 0;
375 location_icon_view_->SetVisible(false); 381 location_icon_view_->SetVisible(false);
376 ev_bubble_view_->SetVisible(false); 382 ev_bubble_view_->SetVisible(false);
377 const std::wstring keyword(location_entry_->model()->keyword()); 383 const std::wstring keyword(location_entry_->model()->keyword());
378 const bool is_keyword_hint(location_entry_->model()->is_keyword_hint()); 384 const bool is_keyword_hint(location_entry_->model()->is_keyword_hint());
379 const bool show_selected_keyword = !keyword.empty() && !is_keyword_hint; 385 const bool show_selected_keyword = !keyword.empty() && !is_keyword_hint;
380 if (show_selected_keyword) { 386 if (show_selected_keyword) {
381 entry_width -= kViewPadding; // Assume the keyword might be hidden. 387 entry_width -= kEdgePadding; // Assume the keyword might be hidden.
382 } else if (model_->GetSecurityLevel() == ToolbarModel::EV_SECURE) { 388 } else if (model_->GetSecurityLevel() == ToolbarModel::EV_SECURE) {
383 ev_bubble_view_->SetVisible(true); 389 ev_bubble_view_->SetVisible(true);
384 ev_bubble_view_->SetLabel(model_->GetEVCertName()); 390 ev_bubble_view_->SetLabel(model_->GetEVCertName());
385 ev_bubble_width = ev_bubble_view_->GetPreferredSize().width(); 391 ev_bubble_width = ev_bubble_view_->GetPreferredSize().width();
386 // We'll adjust this width and take it out of |entry_width| below. 392 // We'll adjust this width and take it out of |entry_width| below.
387 } else { 393 } else {
388 location_icon_view_->SetVisible(true); 394 location_icon_view_->SetVisible(true);
389 location_icon_width = location_icon_view_->GetPreferredSize().width(); 395 location_icon_width = location_icon_view_->GetPreferredSize().width();
390 entry_width -= 396 entry_width -=
391 kViewPadding + location_icon_width + kLocationIconEditPadding; 397 kEdgePadding + location_icon_width + kLocationIconEditPadding;
392 } 398 }
393 399
394 if (star_view_) 400 if (star_view_)
395 entry_width -= star_view_->GetPreferredSize().width() + kViewPadding; 401 entry_width -= star_view_->GetPreferredSize().width() + kItemPadding;
396 for (PageActionViews::const_iterator i(page_action_views_.begin()); 402 for (PageActionViews::const_iterator i(page_action_views_.begin());
397 i != page_action_views_.end(); ++i) { 403 i != page_action_views_.end(); ++i) {
398 if ((*i)->IsVisible()) 404 if ((*i)->IsVisible())
399 entry_width -= (*i)->GetPreferredSize().width() + kViewPadding; 405 entry_width -= (*i)->GetPreferredSize().width() + kItemPadding;
400 } 406 }
401 for (ContentSettingViews::const_iterator i(content_setting_views_.begin()); 407 for (ContentSettingViews::const_iterator i(content_setting_views_.begin());
402 i != content_setting_views_.end(); ++i) { 408 i != content_setting_views_.end(); ++i) {
403 if ((*i)->IsVisible()) 409 if ((*i)->IsVisible())
404 entry_width -= (*i)->GetPreferredSize().width() + kViewPadding; 410 entry_width -= (*i)->GetPreferredSize().width() + kItemPadding;
405 } 411 }
406 412
407 // Size the EV bubble. We do this after taking the star/page actions/content 413 // Size the EV bubble. We do this after taking the star/page actions/content
408 // settings out of |entry_width| so we won't take too much space. 414 // settings out of |entry_width| so we won't take too much space.
409 if (ev_bubble_width) { 415 if (ev_bubble_width) {
410 // Try to elide the bubble to be no larger than half the total available 416 // Try to elide the bubble to be no larger than half the total available
411 // space, but never elide it any smaller than 150 px. 417 // space, but never elide it any smaller than 150 px.
412 static const int kMinElidedBubbleWidth = 150; 418 static const int kMinElidedBubbleWidth = 150;
413 static const double kMaxBubbleFraction = 0.5; 419 static const double kMaxBubbleFraction = 0.5;
414 ev_bubble_width = std::min(ev_bubble_width, std::max(kMinElidedBubbleWidth, 420 ev_bubble_width = std::min(ev_bubble_width, std::max(kMinElidedBubbleWidth,
415 static_cast<int>((entry_width - kBubblePadding - kViewPadding) * 421 static_cast<int>((entry_width - kBubblePadding - kItemPadding) *
416 kMaxBubbleFraction))); 422 kMaxBubbleFraction)));
417 423
418 entry_width -= kBubblePadding + ev_bubble_width + kViewPadding; 424 entry_width -= kBubblePadding + ev_bubble_width + kItemPadding;
419 } 425 }
420 426
421 #if defined(OS_WIN) 427 #if defined(OS_WIN)
422 RECT formatting_rect; 428 RECT formatting_rect;
423 location_entry_->GetRect(&formatting_rect); 429 location_entry_->GetRect(&formatting_rect);
424 RECT edit_bounds; 430 RECT edit_bounds;
425 location_entry_->GetClientRect(&edit_bounds); 431 location_entry_->GetClientRect(&edit_bounds);
426 int max_edit_width = entry_width - formatting_rect.left - 432 int max_edit_width = entry_width - formatting_rect.left -
427 (edit_bounds.right - formatting_rect.right); 433 (edit_bounds.right - formatting_rect.right);
428 #else 434 #else
(...skipping 13 matching lines...) Expand all
442 } else if (show_keyword_hint) { 448 } else if (show_keyword_hint) {
443 if (keyword_hint_view_->keyword() != keyword) 449 if (keyword_hint_view_->keyword() != keyword)
444 keyword_hint_view_->SetKeyword(keyword); 450 keyword_hint_view_->SetKeyword(keyword);
445 } 451 }
446 452
447 // TODO(sky): baseline layout. 453 // TODO(sky): baseline layout.
448 int location_y = TopMargin(); 454 int location_y = TopMargin();
449 int location_height = std::max(height() - location_y - kVertMargin, 0); 455 int location_height = std::max(height() - location_y - kVertMargin, 0);
450 456
451 // Lay out items to the right of the edit field. 457 // Lay out items to the right of the edit field.
452 int offset = width() - kViewPadding; 458 int offset = width();
453 if (star_view_) { 459 if (star_view_) {
460 offset -= kStarPadding;
454 int star_width = star_view_->GetPreferredSize().width(); 461 int star_width = star_view_->GetPreferredSize().width();
455 offset -= star_width; 462 offset -= star_width;
456 star_view_->SetBounds(offset, location_y, star_width, location_height); 463 star_view_->SetBounds(offset, location_y, star_width, location_height);
457 offset -= kViewPadding; 464 offset -= kItemPadding;
465 } else {
466 offset -= kEdgePadding;
458 } 467 }
459 468
460 for (PageActionViews::const_iterator i(page_action_views_.begin()); 469 for (PageActionViews::const_iterator i(page_action_views_.begin());
461 i != page_action_views_.end(); ++i) { 470 i != page_action_views_.end(); ++i) {
462 if ((*i)->IsVisible()) { 471 if ((*i)->IsVisible()) {
463 int page_action_width = (*i)->GetPreferredSize().width(); 472 int page_action_width = (*i)->GetPreferredSize().width();
464 offset -= page_action_width; 473 offset -= page_action_width;
465 (*i)->SetBounds(offset, location_y, page_action_width, location_height); 474 (*i)->SetBounds(offset, location_y, page_action_width, location_height);
466 offset -= kViewPadding; 475 offset -= kItemPadding;
467 } 476 }
468 } 477 }
469 // We use a reverse_iterator here because we're laying out the views from 478 // We use a reverse_iterator here because we're laying out the views from
470 // right to left but in the vector they're ordered left to right. 479 // right to left but in the vector they're ordered left to right.
471 for (ContentSettingViews::const_reverse_iterator 480 for (ContentSettingViews::const_reverse_iterator
472 i(content_setting_views_.rbegin()); i != content_setting_views_.rend(); 481 i(content_setting_views_.rbegin()); i != content_setting_views_.rend();
473 ++i) { 482 ++i) {
474 if ((*i)->IsVisible()) { 483 if ((*i)->IsVisible()) {
475 int content_blocked_width = (*i)->GetPreferredSize().width(); 484 int content_blocked_width = (*i)->GetPreferredSize().width();
476 offset -= content_blocked_width; 485 offset -= content_blocked_width;
477 (*i)->SetBounds(offset, location_y, content_blocked_width, 486 (*i)->SetBounds(offset, location_y, content_blocked_width,
478 location_height); 487 location_height);
479 offset -= kViewPadding; 488 offset -= kItemPadding;
480 } 489 }
481 } 490 }
482 491
483 // Now lay out items to the left of the edit field. 492 // Now lay out items to the left of the edit field.
484 if (location_icon_view_->IsVisible()) { 493 if (location_icon_view_->IsVisible()) {
485 location_icon_view_->SetBounds(kViewPadding, location_y, 494 location_icon_view_->SetBounds(kEdgePadding, location_y,
486 location_icon_width, location_height); 495 location_icon_width, location_height);
487 offset = location_icon_view_->bounds().right() + kLocationIconEditPadding; 496 offset = location_icon_view_->bounds().right() + kLocationIconEditPadding;
488 } else if (ev_bubble_view_->IsVisible()) { 497 } else if (ev_bubble_view_->IsVisible()) {
489 ev_bubble_view_->SetBounds(kBubblePadding, location_y, ev_bubble_width, 498 ev_bubble_view_->SetBounds(kBubblePadding, location_y, ev_bubble_width,
490 location_height); 499 location_height);
491 offset = ev_bubble_view_->bounds().right() + kViewPadding; 500 offset = ev_bubble_view_->bounds().right() + kItemPadding;
492 } else { 501 } else {
493 offset = show_selected_keyword ? kBubblePadding : kViewPadding; 502 offset = show_selected_keyword ? kBubblePadding : kEdgePadding;
494 } 503 }
495 504
496 // Now lay out the edit field and views that autocollapse to give it more 505 // Now lay out the edit field and views that autocollapse to give it more
497 // room. 506 // room.
498 gfx::Rect location_bounds(offset, location_y, entry_width, location_height); 507 gfx::Rect location_bounds(offset, location_y, entry_width, location_height);
499 if (show_selected_keyword) { 508 if (show_selected_keyword) {
500 LayoutView(true, selected_keyword_view_, available_width, &location_bounds); 509 LayoutView(true, selected_keyword_view_, available_width, &location_bounds);
501 if (!selected_keyword_view_->IsVisible()) { 510 if (!selected_keyword_view_->IsVisible()) {
502 location_bounds.set_x( 511 location_bounds.set_x(
503 location_bounds.x() + kViewPadding - kBubblePadding); 512 location_bounds.x() + kEdgePadding - kBubblePadding);
504 } 513 }
505 } else if (show_keyword_hint) { 514 } else if (show_keyword_hint) {
506 LayoutView(false, keyword_hint_view_, available_width, &location_bounds); 515 LayoutView(false, keyword_hint_view_, available_width, &location_bounds);
507 } 516 }
508 517
509 location_entry_view_->SetBounds(location_bounds); 518 location_entry_view_->SetBounds(location_bounds);
510 } 519 }
511 520
512 void LocationBarView::Paint(gfx::Canvas* canvas) { 521 void LocationBarView::Paint(gfx::Canvas* canvas) {
513 View::Paint(canvas); 522 View::Paint(canvas);
523
524 if (painter_.get()) {
525 painter_->Paint(width(), height(), canvas);
526 } else if (mode_ == POPUP) {
527 canvas->TileImageInt(*GetThemeProvider()->GetBitmapNamed(
528 IDR_LOCATIONBG_POPUPMODE_CENTER), 0, 0, 0, 0, width(), height());
529 }
514 // When used in the app launcher, don't draw a border, the LocationBarView has 530 // When used in the app launcher, don't draw a border, the LocationBarView has
515 // its own views::Border. 531 // its own views::Border.
516 if (mode_ != APP_LAUNCHER) {
517 const SkBitmap* background =
518 mode_ == POPUP ?
519 kPopupBackground :
520 GetThemeProvider()->GetBitmapNamed(IDR_LOCATIONBG);
521 532
522 canvas->TileImageInt(*background, 0, 0, 0, 0, width(), height()); 533 // Draw the background color so that the graphical elements at the edges
534 // appear over the correct color. (The edit draws its own background, so this
535 // isn't important for that.)
536 // TODO(pkasting): We need images that are transparent in the middle, so we
537 // can draw the border images over the background color instead of the
538 // reverse; this antialiases better (see comments in
539 // AutocompletePopupContentsView::Paint()).
540 gfx::Rect bounds(GetLocalBounds(false));
541 bounds.Inset(0, TopMargin(), 0, kVertMargin);
542 SkColor color(GetColor(ToolbarModel::NONE, BACKGROUND));
543 if (mode_ == NORMAL) {
544 SkPaint paint;
545 paint.setColor(color);
546 paint.setStyle(SkPaint::kFill_Style);
547 paint.setAntiAlias(true);
548 // The round corners of the omnibox match the round corners of the dropdown
549 // below, and all our other bubbles.
550 static const SkScalar radius(
sky 2010/06/14 20:20:51 Is it really worth making this static?
Peter Kasting 2010/06/14 20:22:16 Oops, I didn't mean to do that.
551 SkIntToScalar(BubbleBorder::GetCornerRadius()));
552 bounds.Inset(kEdgeThickness, 0);
553 canvas->drawRoundRect(gfx::RectToSkRect(bounds), radius, radius, paint);
554 } else {
555 canvas->FillRectInt(color, bounds.x(), bounds.y(), bounds.width(),
556 bounds.height());
523 } 557 }
524 gfx::Rect bounds = GetLocalBounds(false);
525 int top_margin = TopMargin();
526 canvas->FillRectInt(GetColor(ToolbarModel::NONE, BACKGROUND), bounds.x(),
527 top_margin, bounds.width(),
528 std::max(height() - top_margin - kVertMargin, 0));
529 } 558 }
530 559
531 void LocationBarView::VisibleBoundsInRootChanged() { 560 void LocationBarView::VisibleBoundsInRootChanged() {
532 location_entry_->ClosePopup(); 561 location_entry_->ClosePopup();
533 } 562 }
534 563
535 #if defined(OS_WIN) 564 #if defined(OS_WIN)
536 bool LocationBarView::OnMousePressed(const views::MouseEvent& event) { 565 bool LocationBarView::OnMousePressed(const views::MouseEvent& event) {
537 UINT msg; 566 UINT msg;
538 if (event.IsLeftMouseButton()) { 567 if (event.IsLeftMouseButton()) {
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
658 // apparently buggy. In both LTR UI and RTL UI with left-to-right layout, 687 // apparently buggy. In both LTR UI and RTL UI with left-to-right layout,
659 // PosFromChar(i) might return 0 when i is greater than 1. 688 // PosFromChar(i) might return 0 when i is greater than 1.
660 return std::max( 689 return std::max(
661 location_bar_width - font_.GetStringWidth(location_entry_->GetText()), 0); 690 location_bar_width - font_.GetStringWidth(location_entry_->GetText()), 0);
662 #else 691 #else
663 return location_bar_width - location_entry_->TextWidth(); 692 return location_bar_width - location_entry_->TextWidth();
664 #endif 693 #endif
665 } 694 }
666 695
667 bool LocationBarView::UsePref(int pref_width, int available_width) { 696 bool LocationBarView::UsePref(int pref_width, int available_width) {
668 return (pref_width + kViewPadding <= available_width); 697 return (pref_width + kItemPadding <= available_width);
669 } 698 }
670 699
671 void LocationBarView::LayoutView(bool leading, 700 void LocationBarView::LayoutView(bool leading,
672 views::View* view, 701 views::View* view,
673 int available_width, 702 int available_width,
674 gfx::Rect* bounds) { 703 gfx::Rect* bounds) {
675 DCHECK(view && bounds); 704 DCHECK(view && bounds);
676 gfx::Size view_size = view->GetPreferredSize(); 705 gfx::Size view_size = view->GetPreferredSize();
677 if (!UsePref(view_size.width(), available_width)) 706 if (!UsePref(view_size.width(), available_width))
678 view_size = view->GetMinimumSize(); 707 view_size = view->GetMinimumSize();
679 if (view_size.width() + kViewPadding >= bounds->width()) { 708 if (view_size.width() + kItemPadding >= bounds->width()) {
680 view->SetVisible(false); 709 view->SetVisible(false);
681 return; 710 return;
682 } 711 }
683 if (leading) { 712 if (leading) {
684 view->SetBounds(bounds->x(), bounds->y(), view_size.width(), 713 view->SetBounds(bounds->x(), bounds->y(), view_size.width(),
685 bounds->height()); 714 bounds->height());
686 bounds->Offset(view_size.width() + kViewPadding, 0); 715 bounds->Offset(view_size.width() + kItemPadding, 0);
687 } else { 716 } else {
688 view->SetBounds(bounds->right() - view_size.width(), bounds->y(), 717 view->SetBounds(bounds->right() - view_size.width(), bounds->y(),
689 view_size.width(), bounds->height()); 718 view_size.width(), bounds->height());
690 } 719 }
691 bounds->set_width(bounds->width() - view_size.width() - kViewPadding); 720 bounds->set_width(bounds->width() - view_size.width() - kItemPadding);
692 view->SetVisible(true); 721 view->SetVisible(true);
693 } 722 }
694 723
695 void LocationBarView::RefreshContentSettingViews() { 724 void LocationBarView::RefreshContentSettingViews() {
696 const TabContents* tab_contents = delegate_->GetTabContents(); 725 const TabContents* tab_contents = delegate_->GetTabContents();
697 for (ContentSettingViews::const_iterator i(content_setting_views_.begin()); 726 for (ContentSettingViews::const_iterator i(content_setting_views_.begin());
698 i != content_setting_views_.end(); ++i) { 727 i != content_setting_views_.end(); ++i) {
699 (*i)->UpdateFromTabContents( 728 (*i)->UpdateFromTabContents(
700 model_->input_in_progress() ? NULL : tab_contents); 729 model_->input_in_progress() ? NULL : tab_contents);
701 } 730 }
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
974 page_action_views_[i]->image_view()->ExecuteAction(kLeftMouseButton, 1003 page_action_views_[i]->image_view()->ExecuteAction(kLeftMouseButton,
975 false); // inspect_with_devtools 1004 false); // inspect_with_devtools
976 return; 1005 return;
977 } 1006 }
978 ++current; 1007 ++current;
979 } 1008 }
980 } 1009 }
981 1010
982 NOTREACHED(); 1011 NOTREACHED();
983 } 1012 }
OLDNEW
« no previous file with comments | « chrome/browser/views/location_bar/location_bar_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698