| 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_padding = |
| 219 (GetLayoutConstant(LOCATION_BAR_BUBBLE_VERTICAL_PADDING) + | 219 GetVerticalEdgeThickness() + |
| 220 kBubbleInteriorVerticalPadding) * 2; | 220 GetLayoutConstant(LOCATION_BAR_BUBBLE_VERTICAL_PADDING) + |
| 221 const gfx::FontList bubble_font_list(font_list.DeriveWithHeightUpperBound( | 221 kBubbleInteriorVerticalPadding; |
| 222 location_height - bubble_vertical_padding)); | 222 const int bubble_height = GetPreferredSize().height() - (bubble_padding * 2); |
| 223 gfx::FontList bubble_font_list = |
| 224 font_list.DeriveWithHeightUpperBound(bubble_height); |
| 223 | 225 |
| 224 const SkColor background_color = | 226 const SkColor background_color = |
| 225 GetColor(SecurityStateModel::NONE, LocationBarView::BACKGROUND); | 227 GetColor(SecurityStateModel::NONE, LocationBarView::BACKGROUND); |
| 226 ev_bubble_view_ = new EVBubbleView( | 228 const SkColor ev_text_color = |
| 227 bubble_font_list, GetColor(SecurityStateModel::EV_SECURE, SECURITY_TEXT), | 229 GetColor(SecurityStateModel::EV_SECURE, SECURITY_TEXT); |
| 228 background_color, this); | 230 ev_bubble_view_ = |
| 231 new EVBubbleView(bubble_font_list, ev_text_color, background_color, this); |
| 229 ev_bubble_view_->set_drag_controller(this); | 232 ev_bubble_view_->set_drag_controller(this); |
| 230 AddChildView(ev_bubble_view_); | 233 AddChildView(ev_bubble_view_); |
| 231 | 234 |
| 232 // Initialize the Omnibox view. | 235 // Initialize the Omnibox view. |
| 233 omnibox_view_ = new OmniboxViewViews( | 236 omnibox_view_ = new OmniboxViewViews( |
| 234 this, profile(), command_updater(), is_popup_mode_, this, font_list); | 237 this, profile(), command_updater(), is_popup_mode_, this, font_list); |
| 235 omnibox_view_->Init(); | 238 omnibox_view_->Init(); |
| 236 omnibox_view_->SetFocusable(true); | 239 omnibox_view_->SetFocusable(true); |
| 237 AddChildView(omnibox_view_); | 240 AddChildView(omnibox_view_); |
| 238 | 241 |
| 239 // Initialize the inline autocomplete view which is visible only when IME is | 242 // 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. | 243 // turned on. Use the same font with the omnibox and highlighted background. |
| 241 ime_inline_autocomplete_view_ = new views::Label(base::string16(), font_list); | 244 ime_inline_autocomplete_view_ = new views::Label(base::string16(), font_list); |
| 242 ime_inline_autocomplete_view_->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 245 ime_inline_autocomplete_view_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 243 ime_inline_autocomplete_view_->SetAutoColorReadabilityEnabled(false); | 246 ime_inline_autocomplete_view_->SetAutoColorReadabilityEnabled(false); |
| 244 ime_inline_autocomplete_view_->set_background( | 247 ime_inline_autocomplete_view_->set_background( |
| 245 views::Background::CreateSolidBackground(GetNativeTheme()->GetSystemColor( | 248 views::Background::CreateSolidBackground(GetNativeTheme()->GetSystemColor( |
| 246 ui::NativeTheme::kColorId_TextfieldSelectionBackgroundFocused))); | 249 ui::NativeTheme::kColorId_TextfieldSelectionBackgroundFocused))); |
| 247 ime_inline_autocomplete_view_->SetEnabledColor( | 250 ime_inline_autocomplete_view_->SetEnabledColor( |
| 248 GetNativeTheme()->GetSystemColor( | 251 GetNativeTheme()->GetSystemColor( |
| 249 ui::NativeTheme::kColorId_TextfieldSelectionColor)); | 252 ui::NativeTheme::kColorId_TextfieldSelectionColor)); |
| 250 ime_inline_autocomplete_view_->SetVisible(false); | 253 ime_inline_autocomplete_view_->SetVisible(false); |
| 251 AddChildView(ime_inline_autocomplete_view_); | 254 AddChildView(ime_inline_autocomplete_view_); |
| 252 | 255 |
| 253 const SkColor text_color = GetColor(SecurityStateModel::NONE, TEXT); | 256 const SkColor selected_text_color = GetColor( |
| 257 SecurityStateModel::NONE, ui::MaterialDesignController::IsModeMaterial() |
| 258 ? KEYWORD_SEARCH_TEXT |
| 259 : TEXT); |
| 254 selected_keyword_view_ = new SelectedKeywordView( | 260 selected_keyword_view_ = new SelectedKeywordView( |
| 255 bubble_font_list, text_color, background_color, profile()); | 261 bubble_font_list, selected_text_color, background_color, profile()); |
| 256 AddChildView(selected_keyword_view_); | 262 AddChildView(selected_keyword_view_); |
| 257 | 263 |
| 258 suggested_text_view_ = new views::Label(base::string16(), font_list); | 264 suggested_text_view_ = new views::Label(base::string16(), font_list); |
| 259 suggested_text_view_->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 265 suggested_text_view_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 260 suggested_text_view_->SetAutoColorReadabilityEnabled(false); | 266 suggested_text_view_->SetAutoColorReadabilityEnabled(false); |
| 261 suggested_text_view_->SetEnabledColor( | 267 suggested_text_view_->SetEnabledColor( |
| 262 GetColor(SecurityStateModel::NONE, LocationBarView::DEEMPHASIZED_TEXT)); | 268 GetColor(SecurityStateModel::NONE, LocationBarView::DEEMPHASIZED_TEXT)); |
| 263 suggested_text_view_->SetVisible(false); | 269 suggested_text_view_->SetVisible(false); |
| 264 AddChildView(suggested_text_view_); | 270 AddChildView(suggested_text_view_); |
| 265 | 271 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 276 l10n_util::GetStringUTF16(IDS_TOOLTIP_MIC_SEARCH)); | 282 l10n_util::GetStringUTF16(IDS_TOOLTIP_MIC_SEARCH)); |
| 277 mic_search_view_->SetImage( | 283 mic_search_view_->SetImage( |
| 278 views::Button::STATE_NORMAL, | 284 views::Button::STATE_NORMAL, |
| 279 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( | 285 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( |
| 280 IDR_OMNIBOX_MIC_SEARCH)); | 286 IDR_OMNIBOX_MIC_SEARCH)); |
| 281 mic_search_view_->SetImageAlignment(views::ImageButton::ALIGN_CENTER, | 287 mic_search_view_->SetImageAlignment(views::ImageButton::ALIGN_CENTER, |
| 282 views::ImageButton::ALIGN_MIDDLE); | 288 views::ImageButton::ALIGN_MIDDLE); |
| 283 mic_search_view_->SetVisible(false); | 289 mic_search_view_->SetVisible(false); |
| 284 AddChildView(mic_search_view_); | 290 AddChildView(mic_search_view_); |
| 285 | 291 |
| 292 const SkColor text_color = GetColor(SecurityStateModel::NONE, TEXT); |
| 286 for (ContentSettingsType type : | 293 for (ContentSettingsType type : |
| 287 ContentSettingBubbleModel::GetSupportedBubbleTypes()) { | 294 ContentSettingBubbleModel::GetSupportedBubbleTypes()) { |
| 288 ContentSettingImageView* content_blocked_view = new ContentSettingImageView( | 295 ContentSettingImageView* content_blocked_view = new ContentSettingImageView( |
| 289 type, this, bubble_font_list, text_color, background_color); | 296 type, this, bubble_font_list, text_color, background_color); |
| 290 content_setting_views_.push_back(content_blocked_view); | 297 content_setting_views_.push_back(content_blocked_view); |
| 291 content_blocked_view->SetVisible(false); | 298 content_blocked_view->SetVisible(false); |
| 292 AddChildView(content_blocked_view); | 299 AddChildView(content_blocked_view); |
| 293 } | 300 } |
| 294 | 301 |
| 295 zoom_view_ = new ZoomView(delegate_); | 302 zoom_view_ = new ZoomView(delegate_); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 return color_utils::AlphaBlend( | 348 return color_utils::AlphaBlend( |
| 342 GetColor(security_level, TEXT), | 349 GetColor(security_level, TEXT), |
| 343 GetColor(security_level, BACKGROUND), | 350 GetColor(security_level, BACKGROUND), |
| 344 128); | 351 128); |
| 345 | 352 |
| 346 case SECURITY_TEXT: { | 353 case SECURITY_TEXT: { |
| 347 SkColor color; | 354 SkColor color; |
| 348 switch (security_level) { | 355 switch (security_level) { |
| 349 case SecurityStateModel::EV_SECURE: | 356 case SecurityStateModel::EV_SECURE: |
| 350 case SecurityStateModel::SECURE: | 357 case SecurityStateModel::SECURE: |
| 351 color = SkColorSetRGB(7, 149, 0); | 358 if (ui::MaterialDesignController::IsModeMaterial()) |
| 359 color = SkColorSetRGB(11, 128, 67); |
| 360 else |
| 361 color = SkColorSetRGB(7, 149, 0); |
| 352 break; | 362 break; |
| 353 | 363 |
| 354 case SecurityStateModel::SECURITY_POLICY_WARNING: | 364 case SecurityStateModel::SECURITY_POLICY_WARNING: |
| 355 return GetColor(security_level, DEEMPHASIZED_TEXT); | 365 return GetColor(security_level, DEEMPHASIZED_TEXT); |
| 356 break; | 366 break; |
| 357 | 367 |
| 358 case SecurityStateModel::SECURITY_ERROR: | 368 case SecurityStateModel::SECURITY_ERROR: |
| 359 color = SkColorSetRGB(162, 0, 0); | 369 color = SkColorSetRGB(162, 0, 0); |
| 360 break; | 370 break; |
| 361 | 371 |
| 362 case SecurityStateModel::SECURITY_WARNING: | 372 case SecurityStateModel::SECURITY_WARNING: |
| 363 return GetColor(security_level, TEXT); | 373 return GetColor(security_level, TEXT); |
| 364 break; | 374 break; |
| 365 | 375 |
| 366 default: | 376 default: |
| 367 NOTREACHED(); | 377 NOTREACHED(); |
| 368 return GetColor(security_level, TEXT); | 378 return GetColor(security_level, TEXT); |
| 369 } | 379 } |
| 370 return color_utils::GetReadableColor( | 380 return color_utils::GetReadableColor( |
| 371 color, GetColor(security_level, BACKGROUND)); | 381 color, GetColor(security_level, BACKGROUND)); |
| 372 } | 382 } |
| 373 | 383 |
| 384 case KEYWORD_SEARCH_TEXT: |
| 385 return SkColorSetRGB(51, 103, 214); |
| 386 |
| 374 default: | 387 default: |
| 375 NOTREACHED(); | 388 NOTREACHED(); |
| 376 return GetColor(security_level, TEXT); | 389 return GetColor(security_level, TEXT); |
| 377 } | 390 } |
| 378 } | 391 } |
| 379 | 392 |
| 380 void LocationBarView::ZoomChangedForActiveTab(bool can_show_bubble) { | 393 void LocationBarView::ZoomChangedForActiveTab(bool can_show_bubble) { |
| 381 DCHECK(zoom_view_); | 394 DCHECK(zoom_view_); |
| 382 if (RefreshZoomView()) { | 395 if (RefreshZoomView()) { |
| 383 Layout(); | 396 Layout(); |
| (...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 853 } | 866 } |
| 854 | 867 |
| 855 int LocationBarView::GetHorizontalEdgeThickness() const { | 868 int LocationBarView::GetHorizontalEdgeThickness() const { |
| 856 // In maximized popup mode, there isn't any edge. | 869 // In maximized popup mode, there isn't any edge. |
| 857 return (is_popup_mode_ && browser_ && browser_->window() && | 870 return (is_popup_mode_ && browser_ && browser_->window() && |
| 858 browser_->window()->IsMaximized()) ? | 871 browser_->window()->IsMaximized()) ? |
| 859 0 : GetVerticalEdgeThickness(); | 872 0 : GetVerticalEdgeThickness(); |
| 860 } | 873 } |
| 861 | 874 |
| 862 int LocationBarView::GetVerticalEdgeThickness() const { | 875 int LocationBarView::GetVerticalEdgeThickness() const { |
| 876 // In Material Design vertical layout disregards the border. |
| 877 if (ui::MaterialDesignController::IsModeMaterial()) |
| 878 return 0; |
| 863 return is_popup_mode_ ? kPopupEdgeThickness : kNormalEdgeThickness; | 879 return is_popup_mode_ ? kPopupEdgeThickness : kNormalEdgeThickness; |
| 864 } | 880 } |
| 865 | 881 |
| 866 int LocationBarView::VerticalPadding() const { | 882 int LocationBarView::VerticalPadding() const { |
| 867 return is_popup_mode_ ? | 883 return is_popup_mode_ ? |
| 868 kPopupEdgeThickness : GetLayoutConstant(LOCATION_BAR_VERTICAL_PADDING); | 884 kPopupEdgeThickness : GetLayoutConstant(LOCATION_BAR_VERTICAL_PADDING); |
| 869 } | 885 } |
| 870 | 886 |
| 871 bool LocationBarView::RefreshContentSettingViews() { | 887 bool LocationBarView::RefreshContentSettingViews() { |
| 872 bool visibility_changed = false; | 888 bool visibility_changed = false; |
| (...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1409 | 1425 |
| 1410 void LocationBarView::ModelChanged(const SearchModel::State& old_state, | 1426 void LocationBarView::ModelChanged(const SearchModel::State& old_state, |
| 1411 const SearchModel::State& new_state) { | 1427 const SearchModel::State& new_state) { |
| 1412 const bool visible = !GetToolbarModel()->input_in_progress() && | 1428 const bool visible = !GetToolbarModel()->input_in_progress() && |
| 1413 new_state.voice_search_supported; | 1429 new_state.voice_search_supported; |
| 1414 if (mic_search_view_->visible() != visible) { | 1430 if (mic_search_view_->visible() != visible) { |
| 1415 mic_search_view_->SetVisible(visible); | 1431 mic_search_view_->SetVisible(visible); |
| 1416 Layout(); | 1432 Layout(); |
| 1417 } | 1433 } |
| 1418 } | 1434 } |
| OLD | NEW |