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

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

Issue 1338103002: Create c/b/ui/views/layout_constants.*. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review comments Created 5 years, 3 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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/browser/ui/views/location_bar/location_bar_view.h" 5 #include "chrome/browser/ui/views/location_bar/location_bar_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 9
10 #include "base/i18n/rtl.h" 10 #include "base/i18n/rtl.h"
11 #include "base/prefs/pref_service.h" 11 #include "base/prefs/pref_service.h"
12 #include "base/stl_util.h" 12 #include "base/stl_util.h"
13 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
14 #include "chrome/app/chrome_command_ids.h" 14 #include "chrome/app/chrome_command_ids.h"
15 #include "chrome/browser/command_updater.h" 15 #include "chrome/browser/command_updater.h"
16 #include "chrome/browser/defaults.h" 16 #include "chrome/browser/defaults.h"
17 #include "chrome/browser/extensions/api/omnibox/omnibox_api.h" 17 #include "chrome/browser/extensions/api/omnibox/omnibox_api.h"
18 #include "chrome/browser/extensions/extension_action.h" 18 #include "chrome/browser/extensions/extension_action.h"
19 #include "chrome/browser/extensions/extension_action_manager.h" 19 #include "chrome/browser/extensions/extension_action_manager.h"
20 #include "chrome/browser/extensions/extension_util.h" 20 #include "chrome/browser/extensions/extension_util.h"
21 #include "chrome/browser/extensions/location_bar_controller.h" 21 #include "chrome/browser/extensions/location_bar_controller.h"
22 #include "chrome/browser/extensions/tab_helper.h" 22 #include "chrome/browser/extensions/tab_helper.h"
23 #include "chrome/browser/profiles/profile.h" 23 #include "chrome/browser/profiles/profile.h"
24 #include "chrome/browser/search/instant_service.h" 24 #include "chrome/browser/search/instant_service.h"
25 #include "chrome/browser/search/instant_service_factory.h" 25 #include "chrome/browser/search/instant_service_factory.h"
26 #include "chrome/browser/search/search.h" 26 #include "chrome/browser/search/search.h"
27 #include "chrome/browser/search_engines/template_url_service_factory.h" 27 #include "chrome/browser/search_engines/template_url_service_factory.h"
28 #include "chrome/browser/themes/theme_properties.h"
29 #include "chrome/browser/translate/chrome_translate_client.h" 28 #include "chrome/browser/translate/chrome_translate_client.h"
30 #include "chrome/browser/translate/translate_service.h" 29 #include "chrome/browser/translate/translate_service.h"
31 #include "chrome/browser/ui/browser.h" 30 #include "chrome/browser/ui/browser.h"
32 #include "chrome/browser/ui/browser_finder.h" 31 #include "chrome/browser/ui/browser_finder.h"
33 #include "chrome/browser/ui/browser_instant_controller.h" 32 #include "chrome/browser/ui/browser_instant_controller.h"
34 #include "chrome/browser/ui/browser_window.h" 33 #include "chrome/browser/ui/browser_window.h"
35 #include "chrome/browser/ui/content_settings/content_setting_bubble_model.h" 34 #include "chrome/browser/ui/content_settings/content_setting_bubble_model.h"
36 #include "chrome/browser/ui/passwords/manage_passwords_icon.h" 35 #include "chrome/browser/ui/passwords/manage_passwords_icon.h"
37 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller.h" 36 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller.h"
38 #include "chrome/browser/ui/tabs/tab_strip_model.h" 37 #include "chrome/browser/ui/tabs/tab_strip_model.h"
39 #include "chrome/browser/ui/view_ids.h" 38 #include "chrome/browser/ui/view_ids.h"
40 #include "chrome/browser/ui/views/browser_dialogs.h" 39 #include "chrome/browser/ui/views/browser_dialogs.h"
40 #include "chrome/browser/ui/views/layout_constants.h"
41 #include "chrome/browser/ui/views/location_bar/content_setting_image_view.h" 41 #include "chrome/browser/ui/views/location_bar/content_setting_image_view.h"
42 #include "chrome/browser/ui/views/location_bar/ev_bubble_view.h" 42 #include "chrome/browser/ui/views/location_bar/ev_bubble_view.h"
43 #include "chrome/browser/ui/views/location_bar/keyword_hint_view.h" 43 #include "chrome/browser/ui/views/location_bar/keyword_hint_view.h"
44 #include "chrome/browser/ui/views/location_bar/location_bar_layout.h" 44 #include "chrome/browser/ui/views/location_bar/location_bar_layout.h"
45 #include "chrome/browser/ui/views/location_bar/location_icon_view.h" 45 #include "chrome/browser/ui/views/location_bar/location_icon_view.h"
46 #include "chrome/browser/ui/views/location_bar/open_pdf_in_reader_view.h" 46 #include "chrome/browser/ui/views/location_bar/open_pdf_in_reader_view.h"
47 #include "chrome/browser/ui/views/location_bar/page_action_image_view.h" 47 #include "chrome/browser/ui/views/location_bar/page_action_image_view.h"
48 #include "chrome/browser/ui/views/location_bar/page_action_with_badge_view.h" 48 #include "chrome/browser/ui/views/location_bar/page_action_with_badge_view.h"
49 #include "chrome/browser/ui/views/location_bar/selected_keyword_view.h" 49 #include "chrome/browser/ui/views/location_bar/selected_keyword_view.h"
50 #include "chrome/browser/ui/views/location_bar/star_view.h" 50 #include "chrome/browser/ui/views/location_bar/star_view.h"
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 font_list.DeriveWithSizeDelta(desired_font_size - current_font_size); 208 font_list.DeriveWithSizeDelta(desired_font_size - current_font_size);
209 } 209 }
210 // Shrink large fonts to make them fit. 210 // Shrink large fonts to make them fit.
211 // TODO(pkasting): Stretch the location bar instead in this case. 211 // TODO(pkasting): Stretch the location bar instead in this case.
212 const int location_height = GetInternalHeight(true); 212 const int location_height = GetInternalHeight(true);
213 font_list = font_list.DeriveWithHeightUpperBound(location_height); 213 font_list = font_list.DeriveWithHeightUpperBound(location_height);
214 214
215 // Determine the font for use inside the bubbles. The bubble background 215 // Determine the font for use inside the bubbles. The bubble background
216 // images have 1 px thick edges, which we don't want to overlap. 216 // images have 1 px thick edges, which we don't want to overlap.
217 const int kBubbleInteriorVerticalPadding = 1; 217 const int kBubbleInteriorVerticalPadding = 1;
218 const int bubble_padding = GetThemeProvider()->GetDisplayProperty(
219 ThemeProperties::PROPERTY_LOCATION_BAR_BUBBLE_VERTICAL_PADDING);
220 const int bubble_vertical_padding = 218 const int bubble_vertical_padding =
221 (bubble_padding + kBubbleInteriorVerticalPadding) * 2; 219 (GetLayoutConstant(LOCATION_BAR_BUBBLE_VERTICAL_PADDING) +
220 kBubbleInteriorVerticalPadding) * 2;
222 const gfx::FontList bubble_font_list(font_list.DeriveWithHeightUpperBound( 221 const gfx::FontList bubble_font_list(font_list.DeriveWithHeightUpperBound(
223 location_height - bubble_vertical_padding)); 222 location_height - bubble_vertical_padding));
224 223
225 const SkColor background_color = 224 const SkColor background_color =
226 GetColor(connection_security::NONE, LocationBarView::BACKGROUND); 225 GetColor(connection_security::NONE, LocationBarView::BACKGROUND);
227 ev_bubble_view_ = new EVBubbleView( 226 ev_bubble_view_ = new EVBubbleView(
228 bubble_font_list, GetColor(connection_security::EV_SECURE, SECURITY_TEXT), 227 bubble_font_list, GetColor(connection_security::EV_SECURE, SECURITY_TEXT),
229 background_color, this); 228 background_color, this);
230 ev_bubble_view_->set_drag_controller(this); 229 ev_bubble_view_->set_drag_controller(this);
231 AddChildView(ev_bubble_view_); 230 AddChildView(ev_bubble_view_);
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 show_focus_rect_ = show; 460 show_focus_rect_ = show;
462 SchedulePaint(); 461 SchedulePaint();
463 } 462 }
464 463
465 void LocationBarView::SelectAll() { 464 void LocationBarView::SelectAll() {
466 omnibox_view_->SelectAll(true); 465 omnibox_view_->SelectAll(true);
467 } 466 }
468 467
469 gfx::Point LocationBarView::GetLocationBarAnchorPoint() const { 468 gfx::Point LocationBarView::GetLocationBarAnchorPoint() const {
470 // The +1 in the next line creates a 1-px gap between icon and arrow tip. 469 // The +1 in the next line creates a 1-px gap between icon and arrow tip.
471 const int icon_internal_padding = GetThemeProvider()->GetDisplayProperty( 470 const int icon_padding = GetLayoutConstant(ICON_LABEL_VIEW_TRAILING_PADDING);
472 ThemeProperties::PROPERTY_ICON_LABEL_VIEW_TRAILING_PADDING); 471 gfx::Point icon_bottom(
473 gfx::Point icon_bottom(0, location_icon_view_->GetImageBounds().bottom() - 472 0, location_icon_view_->GetImageBounds().bottom() - icon_padding + 1);
474 icon_internal_padding + 1);
475 gfx::Point icon_center(location_icon_view_->GetImageBounds().CenterPoint()); 473 gfx::Point icon_center(location_icon_view_->GetImageBounds().CenterPoint());
476 gfx::Point point(icon_center.x(), icon_bottom.y()); 474 gfx::Point point(icon_center.x(), icon_bottom.y());
477 ConvertPointToTarget(location_icon_view_, this, &point); 475 ConvertPointToTarget(location_icon_view_, this, &point);
478 return point; 476 return point;
479 } 477 }
480 478
481 int LocationBarView::GetInternalHeight(bool use_preferred_size) { 479 int LocationBarView::GetInternalHeight(bool use_preferred_size) {
482 int total_height = 480 int total_height =
483 use_preferred_size ? GetPreferredSize().height() : height(); 481 use_preferred_size ? GetPreferredSize().height() : height();
484 return std::max(total_height - (VerticalPadding() * 2), 0); 482 return std::max(total_height - (VerticalPadding() * 2), 0);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 } 523 }
526 524
527 void LocationBarView::GetAccessibleState(ui::AXViewState* state) { 525 void LocationBarView::GetAccessibleState(ui::AXViewState* state) {
528 state->role = ui::AX_ROLE_GROUP; 526 state->role = ui::AX_ROLE_GROUP;
529 } 527 }
530 528
531 gfx::Size LocationBarView::GetPreferredSize() const { 529 gfx::Size LocationBarView::GetPreferredSize() const {
532 // Compute minimum height. 530 // Compute minimum height.
533 gfx::Size min_size(border_painter_->GetMinimumSize()); 531 gfx::Size min_size(border_painter_->GetMinimumSize());
534 // For non-material the size of the asset determines the size of the 532 // For non-material the size of the asset determines the size of the
535 // LocationBarView. For Material Design the height is encoded as a constant in 533 // LocationBarView.
536 // ThemeProperties. 534 if (ui::MaterialDesignController::IsModeMaterial())
537 ui::ThemeProvider* theme_provider = GetThemeProvider(); 535 min_size.set_height(GetLayoutConstant(LOCATION_BAR_HEIGHT));
538 if (ui::MaterialDesignController::IsModeMaterial()) {
539 min_size.set_height(theme_provider->GetDisplayProperty(
540 ThemeProperties::PROPERTY_LOCATION_BAR_HEIGHT));
541 }
542 536
543 if (!IsInitialized()) 537 if (!IsInitialized())
544 return min_size; 538 return min_size;
545 539
546 min_size.set_height(min_size.height() * size_animation_.GetCurrentValue()); 540 min_size.set_height(min_size.height() * size_animation_.GetCurrentValue());
547 541
548 const int horizontal_item_padding = theme_provider->GetDisplayProperty( 542 const int padding = GetLayoutConstant(LOCATION_BAR_HORIZONTAL_PADDING);
549 ThemeProperties::PROPERTY_LOCATION_BAR_HORIZONTAL_PADDING);
550 const int bubble_horizontal_padding = theme_provider->GetDisplayProperty(
551 ThemeProperties::PROPERTY_LOCATION_BAR_BUBBLE_HORIZONTAL_PADDING);
552 543
553 // Compute width of omnibox-leading content. 544 // Compute width of omnibox-leading content.
554 const int horizontal_edge_thickness = GetHorizontalEdgeThickness(); 545 const int horizontal_edge_thickness = GetHorizontalEdgeThickness();
555 int leading_width = horizontal_edge_thickness; 546 int leading_width = horizontal_edge_thickness;
556 if (ShouldShowKeywordBubble()) { 547 if (ShouldShowKeywordBubble()) {
557 // The selected keyword view can collapse completely. 548 // The selected keyword view can collapse completely.
558 } else if (ShouldShowEVBubble()) { 549 } else if (ShouldShowEVBubble()) {
559 leading_width += bubble_horizontal_padding + 550 leading_width += GetLayoutConstant(LOCATION_BAR_BUBBLE_HORIZONTAL_PADDING) +
560 ev_bubble_view_->GetMinimumSizeForLabelText( 551 ev_bubble_view_->GetMinimumSizeForLabelText(
561 GetToolbarModel()->GetEVCertName()) 552 GetToolbarModel()->GetEVCertName()).width();
562 .width();
563 } else { 553 } else {
564 leading_width += 554 leading_width += padding + location_icon_view_->GetMinimumSize().width();
565 horizontal_item_padding + location_icon_view_->GetMinimumSize().width();
566 } 555 }
567 556
568 // Compute width of omnibox-trailing content. 557 // Compute width of omnibox-trailing content.
569 int trailing_width = horizontal_edge_thickness; 558 int trailing_width = horizontal_edge_thickness;
570 trailing_width += IncrementalMinimumWidth(star_view_) + 559 trailing_width += IncrementalMinimumWidth(star_view_) +
571 IncrementalMinimumWidth(translate_icon_view_) + 560 IncrementalMinimumWidth(translate_icon_view_) +
572 IncrementalMinimumWidth(open_pdf_in_reader_view_) + 561 IncrementalMinimumWidth(open_pdf_in_reader_view_) +
573 IncrementalMinimumWidth(manage_passwords_icon_view_) + 562 IncrementalMinimumWidth(manage_passwords_icon_view_) +
574 IncrementalMinimumWidth(zoom_view_) + 563 IncrementalMinimumWidth(zoom_view_) +
575 IncrementalMinimumWidth(mic_search_view_); 564 IncrementalMinimumWidth(mic_search_view_);
576 for (PageActionViews::const_iterator i(page_action_views_.begin()); 565 for (PageActionViews::const_iterator i(page_action_views_.begin());
577 i != page_action_views_.end(); ++i) 566 i != page_action_views_.end(); ++i)
578 trailing_width += IncrementalMinimumWidth((*i)); 567 trailing_width += IncrementalMinimumWidth((*i));
579 for (ContentSettingViews::const_iterator i(content_setting_views_.begin()); 568 for (ContentSettingViews::const_iterator i(content_setting_views_.begin());
580 i != content_setting_views_.end(); ++i) 569 i != content_setting_views_.end(); ++i)
581 trailing_width += IncrementalMinimumWidth((*i)); 570 trailing_width += IncrementalMinimumWidth((*i));
582 571
583 min_size.set_width(leading_width + omnibox_view_->GetMinimumSize().width() + 572 min_size.set_width(leading_width + omnibox_view_->GetMinimumSize().width() +
584 2 * horizontal_item_padding - 573 2 * padding - omnibox_view_->GetInsets().width() +
585 omnibox_view_->GetInsets().width() + trailing_width); 574 trailing_width);
586 return min_size; 575 return min_size;
587 } 576 }
588 577
589 void LocationBarView::Layout() { 578 void LocationBarView::Layout() {
590 if (!IsInitialized()) 579 if (!IsInitialized())
591 return; 580 return;
592 581
593 selected_keyword_view_->SetVisible(false); 582 selected_keyword_view_->SetVisible(false);
594 location_icon_view_->SetVisible(false); 583 location_icon_view_->SetVisible(false);
595 ev_bubble_view_->SetVisible(false); 584 ev_bubble_view_->SetVisible(false);
596 keyword_hint_view_->SetVisible(false); 585 keyword_hint_view_->SetVisible(false);
597 586
598 ui::ThemeProvider* theme_provider = GetThemeProvider(); 587 const int item_padding = GetLayoutConstant(LOCATION_BAR_HORIZONTAL_PADDING);
599 const int horizontal_item_padding = theme_provider->GetDisplayProperty(
600 ThemeProperties::PROPERTY_LOCATION_BAR_HORIZONTAL_PADDING);
601 int trailing_edge_item_padding = 0; 588 int trailing_edge_item_padding = 0;
602 if (!ui::MaterialDesignController::IsModeMaterial()) { 589 if (!ui::MaterialDesignController::IsModeMaterial()) {
603 trailing_edge_item_padding = horizontal_item_padding - 590 trailing_edge_item_padding = item_padding - GetHorizontalEdgeThickness() -
604 GetHorizontalEdgeThickness() - 591 omnibox_view_->GetInsets().right();
605 omnibox_view_->GetInsets().right();
606 } 592 }
607 593
608 LocationBarLayout leading_decorations( 594 LocationBarLayout leading_decorations(
609 LocationBarLayout::LEFT_EDGE, horizontal_item_padding, 595 LocationBarLayout::LEFT_EDGE, item_padding,
610 horizontal_item_padding - omnibox_view_->GetInsets().left() - 596 item_padding - omnibox_view_->GetInsets().left() -
611 GetEditLeadingInternalSpace()); 597 GetEditLeadingInternalSpace());
612 LocationBarLayout trailing_decorations(LocationBarLayout::RIGHT_EDGE, 598 LocationBarLayout trailing_decorations(
613 horizontal_item_padding, 599 LocationBarLayout::RIGHT_EDGE, item_padding, trailing_edge_item_padding);
614 trailing_edge_item_padding);
615 600
616 const base::string16 keyword(omnibox_view_->model()->keyword()); 601 const base::string16 keyword(omnibox_view_->model()->keyword());
617 // In some cases (e.g. fullscreen mode) we may have 0 height. We still want 602 // In some cases (e.g. fullscreen mode) we may have 0 height. We still want
618 // to position our child views in this case, because other things may be 603 // to position our child views in this case, because other things may be
619 // positioned relative to them (e.g. the "bookmark added" bubble if the user 604 // positioned relative to them (e.g. the "bookmark added" bubble if the user
620 // hits ctrl-d). 605 // hits ctrl-d).
621 const int bubble_vertical_padding = 606 const int bubble_vertical_padding =
622 GetVerticalEdgeThickness() + 607 GetVerticalEdgeThickness() +
623 theme_provider->GetDisplayProperty( 608 GetLayoutConstant(LOCATION_BAR_BUBBLE_VERTICAL_PADDING);
624 ThemeProperties::PROPERTY_LOCATION_BAR_BUBBLE_VERTICAL_PADDING);
625 const int bubble_height = 609 const int bubble_height =
626 std::max(height() - (bubble_vertical_padding * 2), 0); 610 std::max(height() - (bubble_vertical_padding * 2), 0);
627 const int bubble_horizontal_padding = theme_provider->GetDisplayProperty( 611 const int bubble_horizontal_padding =
628 ThemeProperties::PROPERTY_LOCATION_BAR_BUBBLE_HORIZONTAL_PADDING); 612 GetLayoutConstant(LOCATION_BAR_BUBBLE_HORIZONTAL_PADDING);
629 const int location_height = GetInternalHeight(false); 613 const int location_height = GetInternalHeight(false);
630 const int vertical_padding = VerticalPadding(); 614 const int vertical_padding = VerticalPadding();
631 if (ShouldShowKeywordBubble()) { 615 if (ShouldShowKeywordBubble()) {
632 leading_decorations.AddDecoration(bubble_vertical_padding, bubble_height, 616 leading_decorations.AddDecoration(bubble_vertical_padding, bubble_height,
633 true, 0, bubble_horizontal_padding, 617 true, 0, bubble_horizontal_padding,
634 horizontal_item_padding, 618 item_padding, selected_keyword_view_);
635 selected_keyword_view_);
636 if (selected_keyword_view_->keyword() != keyword) { 619 if (selected_keyword_view_->keyword() != keyword) {
637 selected_keyword_view_->SetKeyword(keyword); 620 selected_keyword_view_->SetKeyword(keyword);
638 const TemplateURL* template_url = 621 const TemplateURL* template_url =
639 TemplateURLServiceFactory::GetForProfile(profile())-> 622 TemplateURLServiceFactory::GetForProfile(profile())->
640 GetTemplateURLForKeyword(keyword); 623 GetTemplateURLForKeyword(keyword);
641 if (template_url && 624 if (template_url &&
642 (template_url->GetType() == TemplateURL::OMNIBOX_API_EXTENSION)) { 625 (template_url->GetType() == TemplateURL::OMNIBOX_API_EXTENSION)) {
643 gfx::Image image = extensions::OmniboxAPI::Get(profile())-> 626 gfx::Image image = extensions::OmniboxAPI::Get(profile())->
644 GetOmniboxIcon(template_url->GetExtensionId()); 627 GetOmniboxIcon(template_url->GetExtensionId());
645 selected_keyword_view_->SetImage(image.AsImageSkia()); 628 selected_keyword_view_->SetImage(image.AsImageSkia());
646 selected_keyword_view_->set_is_extension_icon(true); 629 selected_keyword_view_->set_is_extension_icon(true);
647 } else { 630 } else {
648 selected_keyword_view_->SetImage( 631 selected_keyword_view_->SetImage(
649 *(GetThemeProvider()->GetImageSkiaNamed(IDR_OMNIBOX_SEARCH))); 632 *(GetThemeProvider()->GetImageSkiaNamed(IDR_OMNIBOX_SEARCH)));
650 selected_keyword_view_->set_is_extension_icon(false); 633 selected_keyword_view_->set_is_extension_icon(false);
651 } 634 }
652 } 635 }
653 } else if (ShouldShowEVBubble()) { 636 } else if (ShouldShowEVBubble()) {
654 ev_bubble_view_->SetLabel(GetToolbarModel()->GetEVCertName()); 637 ev_bubble_view_->SetLabel(GetToolbarModel()->GetEVCertName());
655 // The largest fraction of the omnibox that can be taken by the EV bubble. 638 // The largest fraction of the omnibox that can be taken by the EV bubble.
656 const double kMaxBubbleFraction = 0.5; 639 const double kMaxBubbleFraction = 0.5;
657 leading_decorations.AddDecoration( 640 leading_decorations.AddDecoration(
658 bubble_vertical_padding, bubble_height, false, kMaxBubbleFraction, 641 bubble_vertical_padding, bubble_height, false, kMaxBubbleFraction,
659 bubble_horizontal_padding, horizontal_item_padding, ev_bubble_view_); 642 bubble_horizontal_padding, item_padding, ev_bubble_view_);
660 } else { 643 } else {
661 leading_decorations.AddDecoration(vertical_padding, location_height, 644 leading_decorations.AddDecoration(vertical_padding, location_height,
662 location_icon_view_); 645 location_icon_view_);
663 } 646 }
664 647
665 if (star_view_->visible()) { 648 if (star_view_->visible()) {
666 trailing_decorations.AddDecoration(vertical_padding, location_height, 649 trailing_decorations.AddDecoration(vertical_padding, location_height,
667 star_view_); 650 star_view_);
668 } 651 }
669 if (translate_icon_view_->visible()) { 652 if (translate_icon_view_->visible()) {
(...skipping 17 matching lines...) Expand all
687 } 670 }
688 if (zoom_view_->visible()) { 671 if (zoom_view_->visible()) {
689 trailing_decorations.AddDecoration(vertical_padding, location_height, 672 trailing_decorations.AddDecoration(vertical_padding, location_height,
690 zoom_view_); 673 zoom_view_);
691 } 674 }
692 for (ContentSettingViews::const_reverse_iterator i( 675 for (ContentSettingViews::const_reverse_iterator i(
693 content_setting_views_.rbegin()); i != content_setting_views_.rend(); 676 content_setting_views_.rbegin()); i != content_setting_views_.rend();
694 ++i) { 677 ++i) {
695 if ((*i)->visible()) { 678 if ((*i)->visible()) {
696 trailing_decorations.AddDecoration(bubble_vertical_padding, bubble_height, 679 trailing_decorations.AddDecoration(bubble_vertical_padding, bubble_height,
697 false, 0, horizontal_item_padding, 680 false, 0, item_padding, item_padding,
698 horizontal_item_padding, (*i)); 681 *i);
699 } 682 }
700 } 683 }
701 if (mic_search_view_->visible()) { 684 if (mic_search_view_->visible()) {
702 trailing_decorations.AddDecoration(vertical_padding, location_height, 685 trailing_decorations.AddDecoration(vertical_padding, location_height,
703 mic_search_view_); 686 mic_search_view_);
704 } 687 }
705 // Because IMEs may eat the tab key, we don't show "press tab to search" while 688 // Because IMEs may eat the tab key, we don't show "press tab to search" while
706 // IME composition is in progress. 689 // IME composition is in progress.
707 if (!keyword.empty() && omnibox_view_->model()->is_keyword_hint() && 690 if (!keyword.empty() && omnibox_view_->model()->is_keyword_hint() &&
708 !omnibox_view_->IsImeComposing()) { 691 !omnibox_view_->IsImeComposing()) {
709 trailing_decorations.AddDecoration( 692 trailing_decorations.AddDecoration(vertical_padding, location_height, true,
710 vertical_padding, location_height, true, 0, horizontal_item_padding, 693 0, item_padding, item_padding,
711 horizontal_item_padding, keyword_hint_view_); 694 keyword_hint_view_);
712 if (keyword_hint_view_->keyword() != keyword) 695 if (keyword_hint_view_->keyword() != keyword)
713 keyword_hint_view_->SetKeyword(keyword); 696 keyword_hint_view_->SetKeyword(keyword);
714 } 697 }
715 698
716 // Perform layout. 699 // Perform layout.
717 const int horizontal_edge_thickness = GetHorizontalEdgeThickness(); 700 const int horizontal_edge_thickness = GetHorizontalEdgeThickness();
718 int full_width = width() - (2 * horizontal_edge_thickness); 701 int full_width = width() - (2 * horizontal_edge_thickness);
719 702
720 int entry_width = full_width; 703 int entry_width = full_width;
721 leading_decorations.LayoutPass1(&entry_width); 704 leading_decorations.LayoutPass1(&entry_width);
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
855 } 838 }
856 839
857 WebContents* LocationBarView::GetWebContents() { 840 WebContents* LocationBarView::GetWebContents() {
858 return delegate_->GetWebContents(); 841 return delegate_->GetWebContents();
859 } 842 }
860 843
861 //////////////////////////////////////////////////////////////////////////////// 844 ////////////////////////////////////////////////////////////////////////////////
862 // LocationBarView, private: 845 // LocationBarView, private:
863 846
864 int LocationBarView::IncrementalMinimumWidth(views::View* view) const { 847 int LocationBarView::IncrementalMinimumWidth(views::View* view) const {
865 const int horizontal_item_padding = GetThemeProvider()->GetDisplayProperty( 848 return view->visible() ?
866 ThemeProperties::PROPERTY_LOCATION_BAR_HORIZONTAL_PADDING); 849 (GetLayoutConstant(LOCATION_BAR_HORIZONTAL_PADDING) +
867 return view->visible() 850 view->GetMinimumSize().width()) : 0;
868 ? (horizontal_item_padding + view->GetMinimumSize().width())
869 : 0;
870 } 851 }
871 852
872 int LocationBarView::GetHorizontalEdgeThickness() const { 853 int LocationBarView::GetHorizontalEdgeThickness() const {
873 // In maximized popup mode, there isn't any edge. 854 // In maximized popup mode, there isn't any edge.
874 return (is_popup_mode_ && browser_ && browser_->window() && 855 return (is_popup_mode_ && browser_ && browser_->window() &&
875 browser_->window()->IsMaximized()) 856 browser_->window()->IsMaximized()) ?
876 ? 0 857 0 : GetVerticalEdgeThickness();
877 : GetVerticalEdgeThickness();
878 } 858 }
879 859
880 int LocationBarView::GetVerticalEdgeThickness() const { 860 int LocationBarView::GetVerticalEdgeThickness() const {
881 return is_popup_mode_ ? kPopupEdgeThickness : kNormalEdgeThickness; 861 return is_popup_mode_ ? kPopupEdgeThickness : kNormalEdgeThickness;
882 } 862 }
883 863
884 int LocationBarView::VerticalPadding() const { 864 int LocationBarView::VerticalPadding() const {
885 return is_popup_mode_ 865 return is_popup_mode_ ?
886 ? kPopupEdgeThickness 866 kPopupEdgeThickness : GetLayoutConstant(LOCATION_BAR_VERTICAL_PADDING);
887 : GetThemeProvider()->GetDisplayProperty(
888 ThemeProperties::PROPERTY_LOCATION_BAR_VERTICAL_PADDING);
889 } 867 }
890 868
891 bool LocationBarView::RefreshContentSettingViews() { 869 bool LocationBarView::RefreshContentSettingViews() {
892 bool visibility_changed = false; 870 bool visibility_changed = false;
893 for (ContentSettingViews::const_iterator i(content_setting_views_.begin()); 871 for (ContentSettingViews::const_iterator i(content_setting_views_.begin());
894 i != content_setting_views_.end(); ++i) { 872 i != content_setting_views_.end(); ++i) {
895 const bool was_visible = (*i)->visible(); 873 const bool was_visible = (*i)->visible();
896 (*i)->Update(GetToolbarModel()->input_in_progress() ? 874 (*i)->Update(GetToolbarModel()->input_in_progress() ?
897 NULL : GetWebContents()); 875 NULL : GetWebContents());
898 if (was_visible != (*i)->visible()) 876 if (was_visible != (*i)->visible())
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after
1403 1381
1404 void LocationBarView::ModelChanged(const SearchModel::State& old_state, 1382 void LocationBarView::ModelChanged(const SearchModel::State& old_state,
1405 const SearchModel::State& new_state) { 1383 const SearchModel::State& new_state) {
1406 const bool visible = !GetToolbarModel()->input_in_progress() && 1384 const bool visible = !GetToolbarModel()->input_in_progress() &&
1407 new_state.voice_search_supported; 1385 new_state.voice_search_supported;
1408 if (mic_search_view_->visible() != visible) { 1386 if (mic_search_view_->visible() != visible) {
1409 mic_search_view_->SetVisible(visible); 1387 mic_search_view_->SetVisible(visible);
1410 Layout(); 1388 Layout();
1411 } 1389 }
1412 } 1390 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698