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

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

Issue 10917280: Fix up views web intents location bar decoration. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add period Created 8 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 | Annotate | Revision Log
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/command_line.h" 10 #include "base/command_line.h"
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 IDR_OMNIBOX_EV_BUBBLE_BACKGROUND_C, 152 IDR_OMNIBOX_EV_BUBBLE_BACKGROUND_C,
153 IDR_OMNIBOX_EV_BUBBLE_BACKGROUND_R, 153 IDR_OMNIBOX_EV_BUBBLE_BACKGROUND_R,
154 }; 154 };
155 155
156 static const int kSelectedKeywordBackgroundImages[] = { 156 static const int kSelectedKeywordBackgroundImages[] = {
157 IDR_LOCATION_BAR_SELECTED_KEYWORD_BACKGROUND_L, 157 IDR_LOCATION_BAR_SELECTED_KEYWORD_BACKGROUND_L,
158 IDR_LOCATION_BAR_SELECTED_KEYWORD_BACKGROUND_C, 158 IDR_LOCATION_BAR_SELECTED_KEYWORD_BACKGROUND_C,
159 IDR_LOCATION_BAR_SELECTED_KEYWORD_BACKGROUND_R, 159 IDR_LOCATION_BAR_SELECTED_KEYWORD_BACKGROUND_R,
160 }; 160 };
161 161
162 // TODO(gbillock): replace these with web-intents images when available.
163 static const int kWIBubbleBackgroundImages[] = { 162 static const int kWIBubbleBackgroundImages[] = {
164 IDR_OMNIBOX_WI_BUBBLE_BACKGROUND_L, 163 IDR_OMNIBOX_WI_BUBBLE_BACKGROUND_L,
165 IDR_OMNIBOX_WI_BUBBLE_BACKGROUND_C, 164 IDR_OMNIBOX_WI_BUBBLE_BACKGROUND_C,
166 IDR_OMNIBOX_WI_BUBBLE_BACKGROUND_R, 165 IDR_OMNIBOX_WI_BUBBLE_BACKGROUND_R,
167 }; 166 };
168 167
169 #if defined(USE_AURA) 168 #if defined(USE_AURA)
170 LocationBarView::FadeAnimationObserver::FadeAnimationObserver( 169 LocationBarView::FadeAnimationObserver::FadeAnimationObserver(
171 LocationBarView* location_bar_view) 170 LocationBarView* location_bar_view)
172 : location_bar_view_(location_bar_view) { 171 : location_bar_view_(location_bar_view) {
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 selected_keyword_view_->SetVisible(false); 284 selected_keyword_view_->SetVisible(false);
286 285
287 keyword_hint_view_ = new KeywordHintView(profile_); 286 keyword_hint_view_ = new KeywordHintView(profile_);
288 AddChildView(keyword_hint_view_); 287 AddChildView(keyword_hint_view_);
289 keyword_hint_view_->SetVisible(false); 288 keyword_hint_view_->SetVisible(false);
290 keyword_hint_view_->SetFont(font_); 289 keyword_hint_view_->SetFont(font_);
291 290
292 for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) { 291 for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) {
293 ContentSettingImageView* content_blocked_view = 292 ContentSettingImageView* content_blocked_view =
294 new ContentSettingImageView(static_cast<ContentSettingsType>(i), 293 new ContentSettingImageView(static_cast<ContentSettingsType>(i),
295 kCSBubbleBackgroundImages, this); 294 kCSBubbleBackgroundImages, this,
295 font_, GetColor(ToolbarModel::NONE, TEXT));
296 content_setting_views_.push_back(content_blocked_view); 296 content_setting_views_.push_back(content_blocked_view);
297 AddChildView(content_blocked_view); 297 AddChildView(content_blocked_view);
298 content_blocked_view->SetVisible(false); 298 content_blocked_view->SetVisible(false);
299 } 299 }
300 300
301 zoom_view_ = new ZoomView(model_, delegate_); 301 zoom_view_ = new ZoomView(model_, delegate_);
302 AddChildView(zoom_view_); 302 AddChildView(zoom_view_);
303 303
304 web_intents_button_view_ = 304 web_intents_button_view_ =
305 new WebIntentsButtonView(this, kWIBubbleBackgroundImages); 305 new WebIntentsButtonView(this, kWIBubbleBackgroundImages,
306 font_, GetColor(ToolbarModel::NONE, TEXT));
306 AddChildView(web_intents_button_view_); 307 AddChildView(web_intents_button_view_);
307 308
308 open_pdf_in_reader_view_ = new OpenPDFInReaderView(this); 309 open_pdf_in_reader_view_ = new OpenPDFInReaderView(this);
309 AddChildView(open_pdf_in_reader_view_); 310 AddChildView(open_pdf_in_reader_view_);
310 311
311 if (browser_defaults::bookmarks_enabled && (mode_ == NORMAL)) { 312 if (browser_defaults::bookmarks_enabled && (mode_ == NORMAL)) {
312 // Note: condition above means that the star icon is hidden in popups and in 313 // Note: condition above means that the star icon is hidden in popups and in
313 // the app launcher. 314 // the app launcher.
314 star_view_ = new StarView(command_updater_); 315 star_view_ = new StarView(command_updater_);
315 AddChildView(star_view_); 316 AddChildView(star_view_);
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after
731 if ((*i)->visible()) 732 if ((*i)->visible())
732 entry_width -= ((*i)->GetPreferredSize().width() + GetItemPadding()); 733 entry_width -= ((*i)->GetPreferredSize().width() + GetItemPadding());
733 } 734 }
734 if (zoom_view_->visible()) 735 if (zoom_view_->visible())
735 entry_width -= zoom_view_->GetPreferredSize().width() + GetItemPadding(); 736 entry_width -= zoom_view_->GetPreferredSize().width() + GetItemPadding();
736 for (ContentSettingViews::const_iterator i(content_setting_views_.begin()); 737 for (ContentSettingViews::const_iterator i(content_setting_views_.begin());
737 i != content_setting_views_.end(); ++i) { 738 i != content_setting_views_.end(); ++i) {
738 if ((*i)->visible()) 739 if ((*i)->visible())
739 entry_width -= ((*i)->GetPreferredSize().width() + GetItemPadding()); 740 entry_width -= ((*i)->GetPreferredSize().width() + GetItemPadding());
740 } 741 }
742 if (web_intents_button_view_->visible()) {
743 entry_width -= web_intents_button_view_->GetPreferredSize().width() +
744 GetItemPadding();
745 }
741 // The gap between the edit and whatever is to its right is shortened. 746 // The gap between the edit and whatever is to its right is shortened.
742 entry_width += kEditInternalSpace; 747 entry_width += kEditInternalSpace;
743 748
744 // Size the EV bubble after taking star/page actions/content settings out of 749 // Size the EV bubble after taking star/page actions/content settings out of
745 // |entry_width| so we won't take too much space. 750 // |entry_width| so we won't take too much space.
746 if (ev_bubble_width) { 751 if (ev_bubble_width) {
747 // Try to elide the bubble to be no larger than half the total available 752 // Try to elide the bubble to be no larger than half the total available
748 // space, but never elide it any smaller than 150 px. 753 // space, but never elide it any smaller than 150 px.
749 static const int kMinElidedBubbleWidth = 150; 754 static const int kMinElidedBubbleWidth = 150;
750 static const double kMaxBubbleFraction = 0.5; 755 static const double kMaxBubbleFraction = 0.5;
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
841 if ((*i)->visible()) { 846 if ((*i)->visible()) {
842 offset += (*i)->GetBuiltInHorizontalPadding(); 847 offset += (*i)->GetBuiltInHorizontalPadding();
843 int content_blocked_width = (*i)->GetPreferredSize().width(); 848 int content_blocked_width = (*i)->GetPreferredSize().width();
844 offset -= content_blocked_width; 849 offset -= content_blocked_width;
845 (*i)->SetBounds(offset, location_y + kBubbleVerticalPadding, 850 (*i)->SetBounds(offset, location_y + kBubbleVerticalPadding,
846 content_blocked_width, (*i)->GetPreferredSize().height()); 851 content_blocked_width, (*i)->GetPreferredSize().height());
847 offset -= GetItemPadding() - (*i)->GetBuiltInHorizontalPadding(); 852 offset -= GetItemPadding() - (*i)->GetBuiltInHorizontalPadding();
848 } 853 }
849 } 854 }
850 855
851 // Now the web intents button 856 // Now the web intents button.
852 if (web_intents_button_view_->visible()) { 857 if (web_intents_button_view_->visible()) {
853 offset += web_intents_button_view_->GetBuiltInHorizontalPadding(); 858 offset += web_intents_button_view_->GetBuiltInHorizontalPadding();
854 int width = web_intents_button_view_->GetPreferredSize().width(); 859 int width = web_intents_button_view_->GetPreferredSize().width();
855 offset -= width; 860 offset -= width;
856 web_intents_button_view_->SetBounds( 861 web_intents_button_view_->SetBounds(
857 offset, location_y, width, location_height); 862 offset, location_y + kBubbleVerticalPadding, width,
863 web_intents_button_view_->GetPreferredSize().height());
858 offset -= GetItemPadding() - 864 offset -= GetItemPadding() -
859 web_intents_button_view_->GetBuiltInHorizontalPadding(); 865 web_intents_button_view_->GetBuiltInHorizontalPadding();
860 } 866 }
861 867
862 // Now lay out items to the left of the edit field. 868 // Now lay out items to the left of the edit field.
863 if (location_icon_view_->visible()) { 869 if (location_icon_view_->visible()) {
864 location_icon_view_->SetBounds( 870 location_icon_view_->SetBounds(
865 kEdgeThickness + GetEdgeItemPadding() - 871 kEdgeThickness + GetEdgeItemPadding() -
866 location_icon_view_->GetBuiltInHorizontalPadding(), 872 location_icon_view_->GetBuiltInHorizontalPadding(),
867 location_y, location_icon_width, location_height); 873 location_y, location_icon_width, location_height);
(...skipping 717 matching lines...) Expand 10 before | Expand all | Expand 10 after
1585 } 1591 }
1586 1592
1587 void LocationBarView::CleanupFadeAnimation() { 1593 void LocationBarView::CleanupFadeAnimation() {
1588 // Since we're no longer animating we don't need our layer. 1594 // Since we're no longer animating we don't need our layer.
1589 SetPaintToLayer(false); 1595 SetPaintToLayer(false);
1590 // Bubble labels don't need a transparent background anymore. 1596 // Bubble labels don't need a transparent background anymore.
1591 ev_bubble_view_->SetLabelBackgroundColor(SK_ColorWHITE); 1597 ev_bubble_view_->SetLabelBackgroundColor(SK_ColorWHITE);
1592 selected_keyword_view_->SetLabelBackgroundColor(SK_ColorWHITE); 1598 selected_keyword_view_->SetLabelBackgroundColor(SK_ColorWHITE);
1593 } 1599 }
1594 #endif // USE_AURA 1600 #endif // USE_AURA
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698