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/i18n/rtl.h" | 10 #include "base/i18n/rtl.h" |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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_vertical_padding = | 218 const int bubble_height = |
| 219 GetPreferredSize().height() - | |
| 219 (GetLayoutConstant(LOCATION_BAR_BUBBLE_VERTICAL_PADDING) + | 220 (GetLayoutConstant(LOCATION_BAR_BUBBLE_VERTICAL_PADDING) + |
| 220 kBubbleInteriorVerticalPadding) * 2; | 221 kBubbleInteriorVerticalPadding + GetVerticalEdgeThickness()) * |
| 221 const gfx::FontList bubble_font_list(font_list.DeriveWithHeightUpperBound( | 222 2; |
|
Peter Kasting
2015/10/05 21:53:14
It's not really clear to me why you moved away fro
jonross
2015/10/06 18:00:14
Before MD bubbles were inset further than other it
Peter Kasting
2015/10/06 19:15:41
OK. Just make sure that the lock in a non-EV case
| |
| 222 location_height - bubble_vertical_padding)); | 223 const int desired_bubble_font_size = |
| 224 GetLayoutConstant(LOCATION_BAR_BUBBLE_FONT_PIXEL_SIZE); | |
|
Peter Kasting
2015/10/05 21:53:14
I still think we should eliminate this and just le
jonross
2015/10/06 18:00:14
I agree with removing this. Current calculations r
| |
| 225 gfx::FontList bubble_font_list = font_list; | |
| 226 if (bubble_font_list.GetFontSize() != desired_bubble_font_size) { | |
| 227 bubble_font_list = bubble_font_list.DeriveWithSizeDelta( | |
| 228 desired_bubble_font_size - bubble_font_list.GetFontSize()); | |
| 229 } | |
| 230 bubble_font_list = bubble_font_list.DeriveWithHeightUpperBound(bubble_height); | |
| 223 | 231 |
| 224 const SkColor background_color = | 232 const SkColor background_color = |
| 225 GetColor(SecurityStateModel::NONE, LocationBarView::BACKGROUND); | 233 GetColor(SecurityStateModel::NONE, LocationBarView::BACKGROUND); |
| 226 ev_bubble_view_ = new EVBubbleView( | 234 const SkColor ev_text_color = |
| 227 bubble_font_list, GetColor(SecurityStateModel::EV_SECURE, SECURITY_TEXT), | 235 GetColor(SecurityStateModel::EV_SECURE, SECURITY_TEXT); |
| 228 background_color, this); | 236 ev_bubble_view_ = |
| 237 new EVBubbleView(bubble_font_list, ev_text_color, background_color, this); | |
| 229 ev_bubble_view_->set_drag_controller(this); | 238 ev_bubble_view_->set_drag_controller(this); |
| 230 AddChildView(ev_bubble_view_); | 239 AddChildView(ev_bubble_view_); |
| 231 | 240 |
| 232 // Initialize the Omnibox view. | 241 // Initialize the Omnibox view. |
| 233 omnibox_view_ = new OmniboxViewViews( | 242 omnibox_view_ = new OmniboxViewViews( |
| 234 this, profile(), command_updater(), is_popup_mode_, this, font_list); | 243 this, profile(), command_updater(), is_popup_mode_, this, font_list); |
| 235 omnibox_view_->Init(); | 244 omnibox_view_->Init(); |
| 236 omnibox_view_->SetFocusable(true); | 245 omnibox_view_->SetFocusable(true); |
| 237 AddChildView(omnibox_view_); | 246 AddChildView(omnibox_view_); |
| 238 | 247 |
| 239 // Initialize the inline autocomplete view which is visible only when IME is | 248 // Initialize the inline autocomplete view which is visible only when IME is |
| 240 // turned on. Use the same font with the omnibox and highlighted background. | 249 // turned on. Use the same font with the omnibox and highlighted background. |
| 241 ime_inline_autocomplete_view_ = new views::Label(base::string16(), font_list); | 250 ime_inline_autocomplete_view_ = new views::Label(base::string16(), font_list); |
| 242 ime_inline_autocomplete_view_->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 251 ime_inline_autocomplete_view_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 243 ime_inline_autocomplete_view_->SetAutoColorReadabilityEnabled(false); | 252 ime_inline_autocomplete_view_->SetAutoColorReadabilityEnabled(false); |
| 244 ime_inline_autocomplete_view_->set_background( | 253 ime_inline_autocomplete_view_->set_background( |
| 245 views::Background::CreateSolidBackground(GetNativeTheme()->GetSystemColor( | 254 views::Background::CreateSolidBackground(GetNativeTheme()->GetSystemColor( |
| 246 ui::NativeTheme::kColorId_TextfieldSelectionBackgroundFocused))); | 255 ui::NativeTheme::kColorId_TextfieldSelectionBackgroundFocused))); |
| 247 ime_inline_autocomplete_view_->SetEnabledColor( | 256 ime_inline_autocomplete_view_->SetEnabledColor( |
| 248 GetNativeTheme()->GetSystemColor( | 257 GetNativeTheme()->GetSystemColor( |
| 249 ui::NativeTheme::kColorId_TextfieldSelectionColor)); | 258 ui::NativeTheme::kColorId_TextfieldSelectionColor)); |
| 250 ime_inline_autocomplete_view_->SetVisible(false); | 259 ime_inline_autocomplete_view_->SetVisible(false); |
| 251 AddChildView(ime_inline_autocomplete_view_); | 260 AddChildView(ime_inline_autocomplete_view_); |
| 252 | 261 |
| 253 const SkColor text_color = GetColor(SecurityStateModel::NONE, TEXT); | 262 const SkColor selected_text_color = GetColor( |
| 263 SecurityStateModel::NONE, | |
| 264 ui::MaterialDesignController::IsModeMaterial() ? BUBBLE_TEXT : TEXT); | |
| 254 selected_keyword_view_ = new SelectedKeywordView( | 265 selected_keyword_view_ = new SelectedKeywordView( |
| 255 bubble_font_list, text_color, background_color, profile()); | 266 bubble_font_list, selected_text_color, background_color, profile()); |
| 256 AddChildView(selected_keyword_view_); | 267 AddChildView(selected_keyword_view_); |
| 257 | 268 |
| 258 suggested_text_view_ = new views::Label(base::string16(), font_list); | 269 suggested_text_view_ = new views::Label(base::string16(), font_list); |
| 259 suggested_text_view_->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 270 suggested_text_view_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 260 suggested_text_view_->SetAutoColorReadabilityEnabled(false); | 271 suggested_text_view_->SetAutoColorReadabilityEnabled(false); |
| 261 suggested_text_view_->SetEnabledColor( | 272 suggested_text_view_->SetEnabledColor( |
| 262 GetColor(SecurityStateModel::NONE, LocationBarView::DEEMPHASIZED_TEXT)); | 273 GetColor(SecurityStateModel::NONE, LocationBarView::DEEMPHASIZED_TEXT)); |
| 263 suggested_text_view_->SetVisible(false); | 274 suggested_text_view_->SetVisible(false); |
| 264 AddChildView(suggested_text_view_); | 275 AddChildView(suggested_text_view_); |
| 265 | 276 |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 276 l10n_util::GetStringUTF16(IDS_TOOLTIP_MIC_SEARCH)); | 287 l10n_util::GetStringUTF16(IDS_TOOLTIP_MIC_SEARCH)); |
| 277 mic_search_view_->SetImage( | 288 mic_search_view_->SetImage( |
| 278 views::Button::STATE_NORMAL, | 289 views::Button::STATE_NORMAL, |
| 279 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( | 290 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( |
| 280 IDR_OMNIBOX_MIC_SEARCH)); | 291 IDR_OMNIBOX_MIC_SEARCH)); |
| 281 mic_search_view_->SetImageAlignment(views::ImageButton::ALIGN_CENTER, | 292 mic_search_view_->SetImageAlignment(views::ImageButton::ALIGN_CENTER, |
| 282 views::ImageButton::ALIGN_MIDDLE); | 293 views::ImageButton::ALIGN_MIDDLE); |
| 283 mic_search_view_->SetVisible(false); | 294 mic_search_view_->SetVisible(false); |
| 284 AddChildView(mic_search_view_); | 295 AddChildView(mic_search_view_); |
| 285 | 296 |
| 297 const SkColor text_color = GetColor(SecurityStateModel::NONE, TEXT); | |
| 286 for (ContentSettingsType type : | 298 for (ContentSettingsType type : |
| 287 ContentSettingBubbleModel::GetSupportedBubbleTypes()) { | 299 ContentSettingBubbleModel::GetSupportedBubbleTypes()) { |
| 288 ContentSettingImageView* content_blocked_view = new ContentSettingImageView( | 300 ContentSettingImageView* content_blocked_view = new ContentSettingImageView( |
| 289 type, this, bubble_font_list, text_color, background_color); | 301 type, this, bubble_font_list, text_color, background_color); |
| 290 content_setting_views_.push_back(content_blocked_view); | 302 content_setting_views_.push_back(content_blocked_view); |
| 291 content_blocked_view->SetVisible(false); | 303 content_blocked_view->SetVisible(false); |
| 292 AddChildView(content_blocked_view); | 304 AddChildView(content_blocked_view); |
| 293 } | 305 } |
| 294 | 306 |
| 295 zoom_view_ = new ZoomView(delegate_); | 307 zoom_view_ = new ZoomView(delegate_); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 341 return color_utils::AlphaBlend( | 353 return color_utils::AlphaBlend( |
| 342 GetColor(security_level, TEXT), | 354 GetColor(security_level, TEXT), |
| 343 GetColor(security_level, BACKGROUND), | 355 GetColor(security_level, BACKGROUND), |
| 344 128); | 356 128); |
| 345 | 357 |
| 346 case SECURITY_TEXT: { | 358 case SECURITY_TEXT: { |
| 347 SkColor color; | 359 SkColor color; |
| 348 switch (security_level) { | 360 switch (security_level) { |
| 349 case SecurityStateModel::EV_SECURE: | 361 case SecurityStateModel::EV_SECURE: |
| 350 case SecurityStateModel::SECURE: | 362 case SecurityStateModel::SECURE: |
| 351 color = SkColorSetRGB(7, 149, 0); | 363 if (ui::MaterialDesignController::IsModeMaterial()) |
| 364 color = SkColorSetRGB(11, 128, 67); | |
| 365 else | |
| 366 color = SkColorSetRGB(7, 149, 0); | |
| 352 break; | 367 break; |
| 353 | 368 |
| 354 case SecurityStateModel::SECURITY_POLICY_WARNING: | 369 case SecurityStateModel::SECURITY_POLICY_WARNING: |
| 355 return GetColor(security_level, DEEMPHASIZED_TEXT); | 370 return GetColor(security_level, DEEMPHASIZED_TEXT); |
| 356 break; | 371 break; |
| 357 | 372 |
| 358 case SecurityStateModel::SECURITY_ERROR: | 373 case SecurityStateModel::SECURITY_ERROR: |
| 359 color = SkColorSetRGB(162, 0, 0); | 374 color = SkColorSetRGB(162, 0, 0); |
| 360 break; | 375 break; |
| 361 | 376 |
| 362 case SecurityStateModel::SECURITY_WARNING: | 377 case SecurityStateModel::SECURITY_WARNING: |
| 363 return GetColor(security_level, TEXT); | 378 return GetColor(security_level, TEXT); |
| 364 break; | 379 break; |
| 365 | 380 |
| 366 default: | 381 default: |
| 367 NOTREACHED(); | 382 NOTREACHED(); |
| 368 return GetColor(security_level, TEXT); | 383 return GetColor(security_level, TEXT); |
| 369 } | 384 } |
| 370 return color_utils::GetReadableColor( | 385 return color_utils::GetReadableColor( |
| 371 color, GetColor(security_level, BACKGROUND)); | 386 color, GetColor(security_level, BACKGROUND)); |
| 372 } | 387 } |
| 373 | 388 |
| 389 case BUBBLE_TEXT: | |
|
Peter Kasting
2015/10/05 21:53:14
If this is now only used for the search chit, we s
jonross
2015/10/06 18:00:14
Done.
| |
| 390 return SkColorSetRGB(51, 103, 214); | |
| 391 | |
| 374 default: | 392 default: |
| 375 NOTREACHED(); | 393 NOTREACHED(); |
| 376 return GetColor(security_level, TEXT); | 394 return GetColor(security_level, TEXT); |
| 377 } | 395 } |
| 378 } | 396 } |
| 379 | 397 |
| 380 void LocationBarView::ZoomChangedForActiveTab(bool can_show_bubble) { | 398 void LocationBarView::ZoomChangedForActiveTab(bool can_show_bubble) { |
| 381 DCHECK(zoom_view_); | 399 DCHECK(zoom_view_); |
| 382 if (RefreshZoomView()) { | 400 if (RefreshZoomView()) { |
| 383 Layout(); | 401 Layout(); |
| (...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 853 } | 871 } |
| 854 | 872 |
| 855 int LocationBarView::GetHorizontalEdgeThickness() const { | 873 int LocationBarView::GetHorizontalEdgeThickness() const { |
| 856 // In maximized popup mode, there isn't any edge. | 874 // In maximized popup mode, there isn't any edge. |
| 857 return (is_popup_mode_ && browser_ && browser_->window() && | 875 return (is_popup_mode_ && browser_ && browser_->window() && |
| 858 browser_->window()->IsMaximized()) ? | 876 browser_->window()->IsMaximized()) ? |
| 859 0 : GetVerticalEdgeThickness(); | 877 0 : GetVerticalEdgeThickness(); |
| 860 } | 878 } |
| 861 | 879 |
| 862 int LocationBarView::GetVerticalEdgeThickness() const { | 880 int LocationBarView::GetVerticalEdgeThickness() const { |
| 881 // In Material Design horizontal layout disregards the border. | |
|
Peter Kasting
2015/10/05 21:53:13
Nit: Remove "horizontal"?
jonross
2015/10/06 18:00:14
Done.
| |
| 882 if (ui::MaterialDesignController::IsModeMaterial()) | |
| 883 return 0; | |
|
Peter Kasting
2015/10/05 21:53:14
This will change the following besides the bubble
jonross
2015/10/06 18:00:13
This improves the background color for both modes.
| |
| 863 return is_popup_mode_ ? kPopupEdgeThickness : kNormalEdgeThickness; | 884 return is_popup_mode_ ? kPopupEdgeThickness : kNormalEdgeThickness; |
| 864 } | 885 } |
| 865 | 886 |
| 866 int LocationBarView::VerticalPadding() const { | 887 int LocationBarView::VerticalPadding() const { |
| 867 return is_popup_mode_ ? | 888 return is_popup_mode_ ? |
| 868 kPopupEdgeThickness : GetLayoutConstant(LOCATION_BAR_VERTICAL_PADDING); | 889 kPopupEdgeThickness : GetLayoutConstant(LOCATION_BAR_VERTICAL_PADDING); |
| 869 } | 890 } |
| 870 | 891 |
| 871 bool LocationBarView::RefreshContentSettingViews() { | 892 bool LocationBarView::RefreshContentSettingViews() { |
| 872 bool visibility_changed = false; | 893 bool visibility_changed = false; |
| (...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1409 | 1430 |
| 1410 void LocationBarView::ModelChanged(const SearchModel::State& old_state, | 1431 void LocationBarView::ModelChanged(const SearchModel::State& old_state, |
| 1411 const SearchModel::State& new_state) { | 1432 const SearchModel::State& new_state) { |
| 1412 const bool visible = !GetToolbarModel()->input_in_progress() && | 1433 const bool visible = !GetToolbarModel()->input_in_progress() && |
| 1413 new_state.voice_search_supported; | 1434 new_state.voice_search_supported; |
| 1414 if (mic_search_view_->visible() != visible) { | 1435 if (mic_search_view_->visible() != visible) { |
| 1415 mic_search_view_->SetVisible(visible); | 1436 mic_search_view_->SetVisible(visible); |
| 1416 Layout(); | 1437 Layout(); |
| 1417 } | 1438 } |
| 1418 } | 1439 } |
| OLD | NEW |