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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 content_blocked_view->SetFont(font_); | |
| 294 content_blocked_view->SetFontColor(GetColor(ToolbarModel::NONE, TEXT)); | |
|
Peter Kasting
2012/09/17 20:04:27
Can we just pass the font and color to the constru
Greg Billock
2012/09/17 21:23:18
Done.
| |
| 294 content_setting_views_.push_back(content_blocked_view); | 295 content_setting_views_.push_back(content_blocked_view); |
| 295 AddChildView(content_blocked_view); | 296 AddChildView(content_blocked_view); |
| 296 content_blocked_view->SetVisible(false); | 297 content_blocked_view->SetVisible(false); |
| 297 } | 298 } |
| 298 | 299 |
| 299 zoom_view_ = new ZoomView(model_, delegate_); | 300 zoom_view_ = new ZoomView(model_, delegate_); |
| 300 AddChildView(zoom_view_); | 301 AddChildView(zoom_view_); |
| 301 | 302 |
| 302 web_intents_button_view_ = | 303 web_intents_button_view_ = |
| 303 new WebIntentsButtonView(this, kWIBubbleBackgroundImages); | 304 new WebIntentsButtonView(this, kWIBubbleBackgroundImages); |
| 305 web_intents_button_view_->SetFont(font_); | |
| 306 web_intents_button_view_->SetFontColor(GetColor(ToolbarModel::NONE, TEXT)); | |
| 304 AddChildView(web_intents_button_view_); | 307 AddChildView(web_intents_button_view_); |
| 305 | 308 |
| 306 if (browser_defaults::bookmarks_enabled && (mode_ == NORMAL)) { | 309 if (browser_defaults::bookmarks_enabled && (mode_ == NORMAL)) { |
| 307 // Note: condition above means that the star icon is hidden in popups and in | 310 // Note: condition above means that the star icon is hidden in popups and in |
| 308 // the app launcher. | 311 // the app launcher. |
| 309 star_view_ = new StarView(command_updater_); | 312 star_view_ = new StarView(command_updater_); |
| 310 AddChildView(star_view_); | 313 AddChildView(star_view_); |
| 311 star_view_->SetVisible(true); | 314 star_view_->SetVisible(true); |
| 312 } | 315 } |
| 313 if (extensions::switch_utils::IsActionBoxEnabled() && browser_) { | 316 if (extensions::switch_utils::IsActionBoxEnabled() && browser_) { |
| (...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 708 i != page_action_views_.end(); ++i) { | 711 i != page_action_views_.end(); ++i) { |
| 709 if ((*i)->visible()) | 712 if ((*i)->visible()) |
| 710 entry_width -= ((*i)->GetPreferredSize().width() + GetItemPadding()); | 713 entry_width -= ((*i)->GetPreferredSize().width() + GetItemPadding()); |
| 711 } | 714 } |
| 712 if (zoom_view_->visible()) | 715 if (zoom_view_->visible()) |
| 713 entry_width -= zoom_view_->GetPreferredSize().width() + GetItemPadding(); | 716 entry_width -= zoom_view_->GetPreferredSize().width() + GetItemPadding(); |
| 714 for (ContentSettingViews::const_iterator i(content_setting_views_.begin()); | 717 for (ContentSettingViews::const_iterator i(content_setting_views_.begin()); |
| 715 i != content_setting_views_.end(); ++i) { | 718 i != content_setting_views_.end(); ++i) { |
| 716 if ((*i)->visible()) | 719 if ((*i)->visible()) |
| 717 entry_width -= ((*i)->GetPreferredSize().width() + GetItemPadding()); | 720 entry_width -= ((*i)->GetPreferredSize().width() + GetItemPadding()); |
| 718 } | 721 } |
|
Greg Billock
2012/09/15 14:29:12
Note to self: missing entry_width adjustment here!
Peter Kasting
2012/09/17 20:04:27
Indeed.
| |
| 719 // The gap between the edit and whatever is to its right is shortened. | 722 // The gap between the edit and whatever is to its right is shortened. |
| 720 entry_width += kEditInternalSpace; | 723 entry_width += kEditInternalSpace; |
| 721 | 724 |
| 722 // Size the EV bubble after taking star/page actions/content settings out of | 725 // Size the EV bubble after taking star/page actions/content settings out of |
| 723 // |entry_width| so we won't take too much space. | 726 // |entry_width| so we won't take too much space. |
| 724 if (ev_bubble_width) { | 727 if (ev_bubble_width) { |
| 725 // Try to elide the bubble to be no larger than half the total available | 728 // Try to elide the bubble to be no larger than half the total available |
| 726 // space, but never elide it any smaller than 150 px. | 729 // space, but never elide it any smaller than 150 px. |
| 727 static const int kMinElidedBubbleWidth = 150; | 730 static const int kMinElidedBubbleWidth = 150; |
| 728 static const double kMaxBubbleFraction = 0.5; | 731 static const double kMaxBubbleFraction = 0.5; |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 815 offset -= GetItemPadding() - (*i)->GetBuiltInHorizontalPadding(); | 818 offset -= GetItemPadding() - (*i)->GetBuiltInHorizontalPadding(); |
| 816 } | 819 } |
| 817 } | 820 } |
| 818 | 821 |
| 819 // Now the web intents button | 822 // Now the web intents button |
| 820 if (web_intents_button_view_->visible()) { | 823 if (web_intents_button_view_->visible()) { |
| 821 offset += web_intents_button_view_->GetBuiltInHorizontalPadding(); | 824 offset += web_intents_button_view_->GetBuiltInHorizontalPadding(); |
| 822 int width = web_intents_button_view_->GetPreferredSize().width(); | 825 int width = web_intents_button_view_->GetPreferredSize().width(); |
| 823 offset -= width; | 826 offset -= width; |
| 824 web_intents_button_view_->SetBounds( | 827 web_intents_button_view_->SetBounds( |
| 825 offset, location_y, width, location_height); | 828 offset, location_y + kBubbleVerticalPadding, width, |
| 829 web_intents_button_view_->GetPreferredSize().height()); | |
| 826 offset -= GetItemPadding() - | 830 offset -= GetItemPadding() - |
| 827 web_intents_button_view_->GetBuiltInHorizontalPadding(); | 831 web_intents_button_view_->GetBuiltInHorizontalPadding(); |
| 828 } | 832 } |
| 829 | 833 |
| 830 // Now lay out items to the left of the edit field. | 834 // Now lay out items to the left of the edit field. |
| 831 if (location_icon_view_->visible()) { | 835 if (location_icon_view_->visible()) { |
| 832 location_icon_view_->SetBounds( | 836 location_icon_view_->SetBounds( |
| 833 kEdgeThickness + GetEdgeItemPadding() - | 837 kEdgeThickness + GetEdgeItemPadding() - |
| 834 location_icon_view_->GetBuiltInHorizontalPadding(), | 838 location_icon_view_->GetBuiltInHorizontalPadding(), |
| 835 location_y, location_icon_width, location_height); | 839 location_y, location_icon_width, location_height); |
| (...skipping 715 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1551 } | 1555 } |
| 1552 | 1556 |
| 1553 void LocationBarView::CleanupFadeAnimation() { | 1557 void LocationBarView::CleanupFadeAnimation() { |
| 1554 // Since we're no longer animating we don't need our layer. | 1558 // Since we're no longer animating we don't need our layer. |
| 1555 SetPaintToLayer(false); | 1559 SetPaintToLayer(false); |
| 1556 // Bubble labels don't need a transparent background anymore. | 1560 // Bubble labels don't need a transparent background anymore. |
| 1557 ev_bubble_view_->SetLabelBackgroundColor(SK_ColorWHITE); | 1561 ev_bubble_view_->SetLabelBackgroundColor(SK_ColorWHITE); |
| 1558 selected_keyword_view_->SetLabelBackgroundColor(SK_ColorWHITE); | 1562 selected_keyword_view_->SetLabelBackgroundColor(SK_ColorWHITE); |
| 1559 } | 1563 } |
| 1560 #endif // USE_AURA | 1564 #endif // USE_AURA |
| OLD | NEW |