Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 151 IDR_OMNIBOX_EV_BUBBLE_BACKGROUND_C, | 151 IDR_OMNIBOX_EV_BUBBLE_BACKGROUND_C, |
| 152 IDR_OMNIBOX_EV_BUBBLE_BACKGROUND_R, | 152 IDR_OMNIBOX_EV_BUBBLE_BACKGROUND_R, |
| 153 }; | 153 }; |
| 154 | 154 |
| 155 static const int kSelectedKeywordBackgroundImages[] = { | 155 static const int kSelectedKeywordBackgroundImages[] = { |
| 156 IDR_LOCATION_BAR_SELECTED_KEYWORD_BACKGROUND_L, | 156 IDR_LOCATION_BAR_SELECTED_KEYWORD_BACKGROUND_L, |
| 157 IDR_LOCATION_BAR_SELECTED_KEYWORD_BACKGROUND_C, | 157 IDR_LOCATION_BAR_SELECTED_KEYWORD_BACKGROUND_C, |
| 158 IDR_LOCATION_BAR_SELECTED_KEYWORD_BACKGROUND_R, | 158 IDR_LOCATION_BAR_SELECTED_KEYWORD_BACKGROUND_R, |
| 159 }; | 159 }; |
| 160 | 160 |
| 161 // TODO(gbillock): replace these with web-intents images when available. | |
| 162 static const int kWIBubbleBackgroundImages[] = { | 161 static const int kWIBubbleBackgroundImages[] = { |
| 163 IDR_OMNIBOX_WI_BUBBLE_BACKGROUND_L, | 162 IDR_OMNIBOX_WI_BUBBLE_BACKGROUND_L, |
| 164 IDR_OMNIBOX_WI_BUBBLE_BACKGROUND_C, | 163 IDR_OMNIBOX_WI_BUBBLE_BACKGROUND_C, |
| 165 IDR_OMNIBOX_WI_BUBBLE_BACKGROUND_R, | 164 IDR_OMNIBOX_WI_BUBBLE_BACKGROUND_R, |
| 166 }; | 165 }; |
| 167 | 166 |
| 168 #if defined(USE_AURA) | 167 #if defined(USE_AURA) |
| 169 LocationBarView::FadeAnimationObserver::FadeAnimationObserver( | 168 LocationBarView::FadeAnimationObserver::FadeAnimationObserver( |
| 170 LocationBarView* location_bar_view) | 169 LocationBarView* location_bar_view) |
| 171 : location_bar_view_(location_bar_view) { | 170 : location_bar_view_(location_bar_view) { |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 283 selected_keyword_view_->SetVisible(false); | 282 selected_keyword_view_->SetVisible(false); |
| 284 | 283 |
| 285 keyword_hint_view_ = new KeywordHintView(profile_); | 284 keyword_hint_view_ = new KeywordHintView(profile_); |
| 286 AddChildView(keyword_hint_view_); | 285 AddChildView(keyword_hint_view_); |
| 287 keyword_hint_view_->SetVisible(false); | 286 keyword_hint_view_->SetVisible(false); |
| 288 keyword_hint_view_->SetFont(font_); | 287 keyword_hint_view_->SetFont(font_); |
| 289 | 288 |
| 290 for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) { | 289 for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) { |
| 291 ContentSettingImageView* content_blocked_view = | 290 ContentSettingImageView* content_blocked_view = |
| 292 new ContentSettingImageView(static_cast<ContentSettingsType>(i), | 291 new ContentSettingImageView(static_cast<ContentSettingsType>(i), |
| 293 kCSBubbleBackgroundImages, this); | 292 kCSBubbleBackgroundImages, this, |
| 293 font_, GetColor(ToolbarModel::NONE, TEXT)); | |
| 294 content_setting_views_.push_back(content_blocked_view); | 294 content_setting_views_.push_back(content_blocked_view); |
| 295 AddChildView(content_blocked_view); | 295 AddChildView(content_blocked_view); |
| 296 content_blocked_view->SetVisible(false); | 296 content_blocked_view->SetVisible(false); |
| 297 } | 297 } |
| 298 | 298 |
| 299 zoom_view_ = new ZoomView(model_, delegate_); | 299 zoom_view_ = new ZoomView(model_, delegate_); |
| 300 AddChildView(zoom_view_); | 300 AddChildView(zoom_view_); |
| 301 | 301 |
| 302 web_intents_button_view_ = | 302 web_intents_button_view_ = |
| 303 new WebIntentsButtonView(this, kWIBubbleBackgroundImages); | 303 new WebIntentsButtonView(this, kWIBubbleBackgroundImages, |
| 304 font_, GetColor(ToolbarModel::NONE, TEXT)); | |
| 304 AddChildView(web_intents_button_view_); | 305 AddChildView(web_intents_button_view_); |
| 305 | 306 |
| 306 if (browser_defaults::bookmarks_enabled && (mode_ == NORMAL)) { | 307 if (browser_defaults::bookmarks_enabled && (mode_ == NORMAL)) { |
| 307 // Note: condition above means that the star icon is hidden in popups and in | 308 // Note: condition above means that the star icon is hidden in popups and in |
| 308 // the app launcher. | 309 // the app launcher. |
| 309 star_view_ = new StarView(command_updater_); | 310 star_view_ = new StarView(command_updater_); |
| 310 AddChildView(star_view_); | 311 AddChildView(star_view_); |
| 311 star_view_->SetVisible(true); | 312 star_view_->SetVisible(true); |
| 312 } | 313 } |
| 313 if (extensions::switch_utils::IsActionBoxEnabled() && browser_) { | 314 if (extensions::switch_utils::IsActionBoxEnabled() && browser_) { |
| (...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 713 if ((*i)->visible()) | 714 if ((*i)->visible()) |
| 714 entry_width -= ((*i)->GetPreferredSize().width() + GetItemPadding()); | 715 entry_width -= ((*i)->GetPreferredSize().width() + GetItemPadding()); |
| 715 } | 716 } |
| 716 if (zoom_view_->visible()) | 717 if (zoom_view_->visible()) |
| 717 entry_width -= zoom_view_->GetPreferredSize().width() + GetItemPadding(); | 718 entry_width -= zoom_view_->GetPreferredSize().width() + GetItemPadding(); |
| 718 for (ContentSettingViews::const_iterator i(content_setting_views_.begin()); | 719 for (ContentSettingViews::const_iterator i(content_setting_views_.begin()); |
| 719 i != content_setting_views_.end(); ++i) { | 720 i != content_setting_views_.end(); ++i) { |
| 720 if ((*i)->visible()) | 721 if ((*i)->visible()) |
| 721 entry_width -= ((*i)->GetPreferredSize().width() + GetItemPadding()); | 722 entry_width -= ((*i)->GetPreferredSize().width() + GetItemPadding()); |
| 722 } | 723 } |
| 724 if (web_intents_button_view_->visible()) { | |
| 725 entry_width -= web_intents_button_view_->GetPreferredSize().width() + | |
| 726 GetItemPadding(); | |
| 727 } | |
| 723 // The gap between the edit and whatever is to its right is shortened. | 728 // The gap between the edit and whatever is to its right is shortened. |
| 724 entry_width += kEditInternalSpace; | 729 entry_width += kEditInternalSpace; |
| 725 | 730 |
| 726 // Size the EV bubble after taking star/page actions/content settings out of | 731 // Size the EV bubble after taking star/page actions/content settings out of |
| 727 // |entry_width| so we won't take too much space. | 732 // |entry_width| so we won't take too much space. |
| 728 if (ev_bubble_width) { | 733 if (ev_bubble_width) { |
| 729 // Try to elide the bubble to be no larger than half the total available | 734 // Try to elide the bubble to be no larger than half the total available |
| 730 // space, but never elide it any smaller than 150 px. | 735 // space, but never elide it any smaller than 150 px. |
| 731 static const int kMinElidedBubbleWidth = 150; | 736 static const int kMinElidedBubbleWidth = 150; |
| 732 static const double kMaxBubbleFraction = 0.5; | 737 static const double kMaxBubbleFraction = 0.5; |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 813 if ((*i)->visible()) { | 818 if ((*i)->visible()) { |
| 814 offset += (*i)->GetBuiltInHorizontalPadding(); | 819 offset += (*i)->GetBuiltInHorizontalPadding(); |
| 815 int content_blocked_width = (*i)->GetPreferredSize().width(); | 820 int content_blocked_width = (*i)->GetPreferredSize().width(); |
| 816 offset -= content_blocked_width; | 821 offset -= content_blocked_width; |
| 817 (*i)->SetBounds(offset, location_y + kBubbleVerticalPadding, | 822 (*i)->SetBounds(offset, location_y + kBubbleVerticalPadding, |
| 818 content_blocked_width, (*i)->GetPreferredSize().height()); | 823 content_blocked_width, (*i)->GetPreferredSize().height()); |
| 819 offset -= GetItemPadding() - (*i)->GetBuiltInHorizontalPadding(); | 824 offset -= GetItemPadding() - (*i)->GetBuiltInHorizontalPadding(); |
| 820 } | 825 } |
| 821 } | 826 } |
| 822 | 827 |
| 823 // Now the web intents button | 828 // Now the web intents button |
|
Peter Kasting
2012/09/17 22:13:35
Nit: While here, can you add a trailing period?
Greg Billock
2012/09/18 02:03:51
CQ kicked this back, so done.
| |
| 824 if (web_intents_button_view_->visible()) { | 829 if (web_intents_button_view_->visible()) { |
| 825 offset += web_intents_button_view_->GetBuiltInHorizontalPadding(); | 830 offset += web_intents_button_view_->GetBuiltInHorizontalPadding(); |
| 826 int width = web_intents_button_view_->GetPreferredSize().width(); | 831 int width = web_intents_button_view_->GetPreferredSize().width(); |
| 827 offset -= width; | 832 offset -= width; |
| 828 web_intents_button_view_->SetBounds( | 833 web_intents_button_view_->SetBounds( |
| 829 offset, location_y, width, location_height); | 834 offset, location_y + kBubbleVerticalPadding, width, |
| 835 web_intents_button_view_->GetPreferredSize().height()); | |
| 830 offset -= GetItemPadding() - | 836 offset -= GetItemPadding() - |
| 831 web_intents_button_view_->GetBuiltInHorizontalPadding(); | 837 web_intents_button_view_->GetBuiltInHorizontalPadding(); |
| 832 } | 838 } |
| 833 | 839 |
| 834 // Now lay out items to the left of the edit field. | 840 // Now lay out items to the left of the edit field. |
| 835 if (location_icon_view_->visible()) { | 841 if (location_icon_view_->visible()) { |
| 836 location_icon_view_->SetBounds( | 842 location_icon_view_->SetBounds( |
| 837 kEdgeThickness + GetEdgeItemPadding() - | 843 kEdgeThickness + GetEdgeItemPadding() - |
| 838 location_icon_view_->GetBuiltInHorizontalPadding(), | 844 location_icon_view_->GetBuiltInHorizontalPadding(), |
| 839 location_y, location_icon_width, location_height); | 845 location_y, location_icon_width, location_height); |
| (...skipping 715 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1555 } | 1561 } |
| 1556 | 1562 |
| 1557 void LocationBarView::CleanupFadeAnimation() { | 1563 void LocationBarView::CleanupFadeAnimation() { |
| 1558 // Since we're no longer animating we don't need our layer. | 1564 // Since we're no longer animating we don't need our layer. |
| 1559 SetPaintToLayer(false); | 1565 SetPaintToLayer(false); |
| 1560 // Bubble labels don't need a transparent background anymore. | 1566 // Bubble labels don't need a transparent background anymore. |
| 1561 ev_bubble_view_->SetLabelBackgroundColor(SK_ColorWHITE); | 1567 ev_bubble_view_->SetLabelBackgroundColor(SK_ColorWHITE); |
| 1562 selected_keyword_view_->SetLabelBackgroundColor(SK_ColorWHITE); | 1568 selected_keyword_view_->SetLabelBackgroundColor(SK_ColorWHITE); |
| 1563 } | 1569 } |
| 1564 #endif // USE_AURA | 1570 #endif // USE_AURA |
| OLD | NEW |