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" |
| 11 #include "base/stl_util.h" | 11 #include "base/stl_util.h" |
| 12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
| 13 #include "build/build_config.h" | 13 #include "build/build_config.h" |
| 14 #include "chrome/app/chrome_command_ids.h" | 14 #include "chrome/app/chrome_command_ids.h" |
| 15 #include "chrome/browser/command_updater.h" | 15 #include "chrome/browser/command_updater.h" |
| 16 #include "chrome/browser/defaults.h" | 16 #include "chrome/browser/defaults.h" |
| 17 #include "chrome/browser/extensions/api/omnibox/omnibox_api.h" | 17 #include "chrome/browser/extensions/api/omnibox/omnibox_api.h" |
| 18 #include "chrome/browser/extensions/extension_action.h" | 18 #include "chrome/browser/extensions/extension_action.h" |
| 19 #include "chrome/browser/extensions/extension_action_manager.h" | 19 #include "chrome/browser/extensions/extension_action_manager.h" |
| 20 #include "chrome/browser/extensions/extension_util.h" | 20 #include "chrome/browser/extensions/extension_util.h" |
| 21 #include "chrome/browser/extensions/location_bar_controller.h" | 21 #include "chrome/browser/extensions/location_bar_controller.h" |
| 22 #include "chrome/browser/extensions/tab_helper.h" | 22 #include "chrome/browser/extensions/tab_helper.h" |
| 23 #include "chrome/browser/profiles/profile.h" | 23 #include "chrome/browser/profiles/profile.h" |
| 24 #include "chrome/browser/search_engines/template_url_service_factory.h" | 24 #include "chrome/browser/search_engines/template_url_service_factory.h" |
| 25 #include "chrome/browser/ssl/chrome_security_state_model_client.h" | |
| 25 #include "chrome/browser/themes/theme_properties.h" | 26 #include "chrome/browser/themes/theme_properties.h" |
| 26 #include "chrome/browser/translate/chrome_translate_client.h" | 27 #include "chrome/browser/translate/chrome_translate_client.h" |
| 27 #include "chrome/browser/translate/translate_service.h" | 28 #include "chrome/browser/translate/translate_service.h" |
| 28 #include "chrome/browser/ui/autofill/save_card_bubble_controller_impl.h" | 29 #include "chrome/browser/ui/autofill/save_card_bubble_controller_impl.h" |
| 29 #include "chrome/browser/ui/browser.h" | 30 #include "chrome/browser/ui/browser.h" |
| 30 #include "chrome/browser/ui/browser_finder.h" | 31 #include "chrome/browser/ui/browser_finder.h" |
| 31 #include "chrome/browser/ui/browser_window.h" | 32 #include "chrome/browser/ui/browser_window.h" |
| 32 #include "chrome/browser/ui/content_settings/content_setting_bubble_model.h" | 33 #include "chrome/browser/ui/content_settings/content_setting_bubble_model.h" |
| 33 #include "chrome/browser/ui/layout_constants.h" | 34 #include "chrome/browser/ui/layout_constants.h" |
| 34 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller.h" | 35 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller.h" |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 56 #include "components/favicon/content/content_favicon_driver.h" | 57 #include "components/favicon/content/content_favicon_driver.h" |
| 57 #include "components/omnibox/browser/omnibox_popup_model.h" | 58 #include "components/omnibox/browser/omnibox_popup_model.h" |
| 58 #include "components/omnibox/browser/omnibox_popup_view.h" | 59 #include "components/omnibox/browser/omnibox_popup_view.h" |
| 59 #include "components/prefs/pref_service.h" | 60 #include "components/prefs/pref_service.h" |
| 60 #include "components/search_engines/template_url.h" | 61 #include "components/search_engines/template_url.h" |
| 61 #include "components/search_engines/template_url_service.h" | 62 #include "components/search_engines/template_url_service.h" |
| 62 #include "components/toolbar/toolbar_model.h" | 63 #include "components/toolbar/toolbar_model.h" |
| 63 #include "components/translate/core/browser/language_state.h" | 64 #include "components/translate/core/browser/language_state.h" |
| 64 #include "components/zoom/zoom_controller.h" | 65 #include "components/zoom/zoom_controller.h" |
| 65 #include "components/zoom/zoom_event_manager.h" | 66 #include "components/zoom/zoom_event_manager.h" |
| 67 #include "content/public/browser/navigation_entry.h" | |
| 66 #include "content/public/browser/render_widget_host_view.h" | 68 #include "content/public/browser/render_widget_host_view.h" |
| 67 #include "content/public/browser/web_contents.h" | 69 #include "content/public/browser/web_contents.h" |
| 70 #include "content/public/common/ssl_status.h" | |
| 68 #include "extensions/browser/extension_registry.h" | 71 #include "extensions/browser/extension_registry.h" |
| 69 #include "extensions/common/feature_switch.h" | 72 #include "extensions/common/feature_switch.h" |
| 70 #include "grit/components_scaled_resources.h" | 73 #include "grit/components_scaled_resources.h" |
| 71 #include "grit/theme_resources.h" | 74 #include "grit/theme_resources.h" |
| 75 #include "third_party/re2/src/re2/re2.h" | |
| 72 #include "ui/accessibility/ax_view_state.h" | 76 #include "ui/accessibility/ax_view_state.h" |
| 73 #include "ui/base/dragdrop/drag_drop_types.h" | 77 #include "ui/base/dragdrop/drag_drop_types.h" |
| 74 #include "ui/base/material_design/material_design_controller.h" | 78 #include "ui/base/material_design/material_design_controller.h" |
| 75 #include "ui/base/resource/resource_bundle.h" | 79 #include "ui/base/resource/resource_bundle.h" |
| 76 #include "ui/base/theme_provider.h" | 80 #include "ui/base/theme_provider.h" |
| 77 #include "ui/compositor/paint_recorder.h" | 81 #include "ui/compositor/paint_recorder.h" |
| 78 #include "ui/events/event.h" | 82 #include "ui/events/event.h" |
| 79 #include "ui/gfx/animation/slide_animation.h" | 83 #include "ui/gfx/animation/slide_animation.h" |
| 80 #include "ui/gfx/canvas.h" | 84 #include "ui/gfx/canvas.h" |
| 81 #include "ui/gfx/color_palette.h" | 85 #include "ui/gfx/color_palette.h" |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 130 keyword_hint_view_(nullptr), | 134 keyword_hint_view_(nullptr), |
| 131 zoom_view_(nullptr), | 135 zoom_view_(nullptr), |
| 132 open_pdf_in_reader_view_(nullptr), | 136 open_pdf_in_reader_view_(nullptr), |
| 133 manage_passwords_icon_view_(nullptr), | 137 manage_passwords_icon_view_(nullptr), |
| 134 save_credit_card_icon_view_(nullptr), | 138 save_credit_card_icon_view_(nullptr), |
| 135 translate_icon_view_(nullptr), | 139 translate_icon_view_(nullptr), |
| 136 star_view_(nullptr), | 140 star_view_(nullptr), |
| 137 size_animation_(this), | 141 size_animation_(this), |
| 138 is_popup_mode_(is_popup_mode), | 142 is_popup_mode_(is_popup_mode), |
| 139 show_focus_rect_(false), | 143 show_focus_rect_(false), |
| 144 load_state_(new LoadState()), | |
|
Peter Kasting
2016/08/15 23:29:49
If we always have a non-null |load_state_|, why us
Kevin Bailey
2016/08/16 16:39:36
The scoped_ptr is to free it, and having it a new'
Peter Kasting
2016/08/16 18:15:05
If an object represents an internal cache rather t
| |
| 140 template_url_service_(NULL), | 145 template_url_service_(NULL), |
| 141 web_contents_null_at_last_refresh_(true) { | 146 web_contents_null_at_last_refresh_(true) { |
| 142 edit_bookmarks_enabled_.Init( | 147 edit_bookmarks_enabled_.Init( |
| 143 bookmarks::prefs::kEditBookmarksEnabled, profile->GetPrefs(), | 148 bookmarks::prefs::kEditBookmarksEnabled, profile->GetPrefs(), |
| 144 base::Bind(&LocationBarView::UpdateWithoutTabRestore, | 149 base::Bind(&LocationBarView::UpdateWithoutTabRestore, |
| 145 base::Unretained(this))); | 150 base::Unretained(this))); |
| 146 | 151 |
| 147 zoom::ZoomEventManager::GetForBrowserContext(profile) | 152 zoom::ZoomEventManager::GetForBrowserContext(profile) |
| 148 ->AddZoomEventManagerObserver(this); | 153 ->AddZoomEventManagerObserver(this); |
| 149 } | 154 } |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 322 case SELECTED_TEXT: | 327 case SELECTED_TEXT: |
| 323 return native_theme->GetSystemColor( | 328 return native_theme->GetSystemColor( |
| 324 ui::NativeTheme::kColorId_TextfieldSelectionColor); | 329 ui::NativeTheme::kColorId_TextfieldSelectionColor); |
| 325 | 330 |
| 326 case DEEMPHASIZED_TEXT: | 331 case DEEMPHASIZED_TEXT: |
| 327 return color_utils::AlphaBlend(GetColor(TEXT), GetColor(BACKGROUND), 128); | 332 return color_utils::AlphaBlend(GetColor(TEXT), GetColor(BACKGROUND), 128); |
| 328 | 333 |
| 329 case EV_BUBBLE_TEXT_AND_BORDER: | 334 case EV_BUBBLE_TEXT_AND_BORDER: |
| 330 return ui::MaterialDesignController::IsModeMaterial() | 335 return ui::MaterialDesignController::IsModeMaterial() |
| 331 ? GetSecureTextColor( | 336 ? GetSecureTextColor( |
| 332 security_state::SecurityStateModel::EV_SECURE) | 337 GetToolbarModel()->GetSecurityLevel(false)) |
|
Peter Kasting
2016/08/15 23:29:49
This is necessary only if we use the "EV bubble" f
Kevin Bailey
2016/08/16 16:39:36
Sorry, I'm not understanding the comment. The call
Peter Kasting
2016/08/16 18:15:05
You're changing the meaning of "EV bubble" to "ver
Kevin Bailey
2016/08/17 16:33:30
Ok, all I noticed was this enum.
| |
| 333 : SkColorSetRGB(7, 149, 0); | 338 : SkColorSetRGB(7, 149, 0); |
| 334 } | 339 } |
| 335 NOTREACHED(); | 340 NOTREACHED(); |
| 336 return gfx::kPlaceholderColor; | 341 return gfx::kPlaceholderColor; |
| 337 } | 342 } |
| 338 | 343 |
| 339 SkColor LocationBarView::GetSecureTextColor( | 344 SkColor LocationBarView::GetSecureTextColor( |
| 340 security_state::SecurityStateModel::SecurityLevel security_level) const { | 345 security_state::SecurityStateModel::SecurityLevel security_level) const { |
| 341 if (security_level == | 346 if (security_level == |
| 342 security_state::SecurityStateModel::SECURITY_POLICY_WARNING) { | 347 security_state::SecurityStateModel::SECURITY_POLICY_WARNING) { |
| 343 return GetColor(DEEMPHASIZED_TEXT); | 348 return GetColor(DEEMPHASIZED_TEXT); |
| 344 } | 349 } |
| 345 | 350 |
| 346 SkColor text_color = GetColor(TEXT); | 351 SkColor text_color = GetColor(TEXT); |
| 347 if ((security_level == security_state::SecurityStateModel::EV_SECURE) || | 352 if ((security_level == security_state::SecurityStateModel::NONE) || |
|
Peter Kasting
2016/08/15 23:29:49
Simpler than all the changes you've made here is t
Kevin Bailey
2016/08/16 16:39:36
Done.
| |
| 353 (security_level == security_state::SecurityStateModel::EV_SECURE) || | |
| 348 (security_level == security_state::SecurityStateModel::SECURE) || | 354 (security_level == security_state::SecurityStateModel::SECURE) || |
| 349 (security_level == security_state::SecurityStateModel::SECURITY_ERROR)) { | 355 (security_level == security_state::SecurityStateModel::SECURITY_ERROR)) { |
| 350 if (ui::MaterialDesignController::IsModeMaterial()) { | 356 if (ui::MaterialDesignController::IsModeMaterial()) { |
| 351 if (color_utils::IsDark(GetColor(BACKGROUND))) | 357 if (color_utils::IsDark(GetColor(BACKGROUND))) |
| 352 return text_color; | 358 return text_color; |
| 353 if (security_level == security_state::SecurityStateModel::SECURITY_ERROR) | 359 if ((security_level == security_state::SecurityStateModel::NONE) || |
| 360 (security_level == | |
| 361 security_state::SecurityStateModel::SECURITY_ERROR)) | |
| 354 text_color = gfx::kGoogleRed700; | 362 text_color = gfx::kGoogleRed700; |
| 355 else | 363 else |
| 356 text_color = gfx::kGoogleGreen700; | 364 text_color = gfx::kGoogleGreen700; |
| 357 } else if (security_level == | 365 } else if ((security_level == security_state::SecurityStateModel::NONE) || |
| 358 security_state::SecurityStateModel::SECURITY_ERROR) { | 366 (security_level == |
| 367 security_state::SecurityStateModel::SECURITY_ERROR)) { | |
| 359 text_color = SkColorSetRGB(162, 0, 0); | 368 text_color = SkColorSetRGB(162, 0, 0); |
| 360 } else { | 369 } else { |
| 361 text_color = GetColor(EV_BUBBLE_TEXT_AND_BORDER); | 370 text_color = GetColor(EV_BUBBLE_TEXT_AND_BORDER); |
| 362 } | 371 } |
| 363 } | 372 } |
| 364 return color_utils::GetReadableColor(text_color, GetColor(BACKGROUND)); | 373 return color_utils::GetReadableColor(text_color, GetColor(BACKGROUND)); |
| 365 } | 374 } |
| 366 | 375 |
| 367 void LocationBarView::ZoomChangedForActiveTab(bool can_show_bubble) { | 376 void LocationBarView::ZoomChangedForActiveTab(bool can_show_bubble) { |
| 368 DCHECK(zoom_view_); | 377 DCHECK(zoom_view_); |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 525 | 534 |
| 526 min_size.set_height(min_size.height() * size_animation_.GetCurrentValue()); | 535 min_size.set_height(min_size.height() * size_animation_.GetCurrentValue()); |
| 527 | 536 |
| 528 const int padding = GetLayoutConstant(LOCATION_BAR_HORIZONTAL_PADDING); | 537 const int padding = GetLayoutConstant(LOCATION_BAR_HORIZONTAL_PADDING); |
| 529 | 538 |
| 530 // Compute width of omnibox-leading content. | 539 // Compute width of omnibox-leading content. |
| 531 const int edge_thickness = GetHorizontalEdgeThickness(); | 540 const int edge_thickness = GetHorizontalEdgeThickness(); |
| 532 int leading_width = edge_thickness; | 541 int leading_width = edge_thickness; |
| 533 if (ShouldShowKeywordBubble()) { | 542 if (ShouldShowKeywordBubble()) { |
| 534 // The selected keyword view can collapse completely. | 543 // The selected keyword view can collapse completely. |
| 535 } else if (ShouldShowEVBubble()) { | 544 } else if (ShouldShowSecurityChip()) { |
| 536 leading_width += GetLayoutConstant(LOCATION_BAR_BUBBLE_HORIZONTAL_PADDING) + | 545 base::string16 label = GetSecurityText(); |
| 537 location_icon_view_->GetMinimumSizeForLabelText( | 546 leading_width += |
| 538 GetToolbarModel()->GetEVCertName()) | 547 GetLayoutConstant(LOCATION_BAR_BUBBLE_HORIZONTAL_PADDING) + |
| 539 .width(); | 548 location_icon_view_->GetMinimumSizeForLabelText(label).width(); |
| 540 } else { | 549 } else { |
| 550 location_icon_view_->StopAnimation(); | |
| 541 leading_width += padding + location_icon_view_->GetMinimumSize().width(); | 551 leading_width += padding + location_icon_view_->GetMinimumSize().width(); |
| 542 } | 552 } |
| 543 | 553 |
| 544 // Compute width of omnibox-trailing content. | 554 // Compute width of omnibox-trailing content. |
| 545 int trailing_width = edge_thickness; | 555 int trailing_width = edge_thickness; |
| 546 trailing_width += IncrementalMinimumWidth(star_view_) + | 556 trailing_width += IncrementalMinimumWidth(star_view_) + |
| 547 IncrementalMinimumWidth(translate_icon_view_) + | 557 IncrementalMinimumWidth(translate_icon_view_) + |
| 548 IncrementalMinimumWidth(open_pdf_in_reader_view_) + | 558 IncrementalMinimumWidth(open_pdf_in_reader_view_) + |
| 549 IncrementalMinimumWidth(save_credit_card_icon_view_) + | 559 IncrementalMinimumWidth(save_credit_card_icon_view_) + |
| 550 IncrementalMinimumWidth(manage_passwords_icon_view_) + | 560 IncrementalMinimumWidth(manage_passwords_icon_view_) + |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 605 (template_url->GetType() == TemplateURL::OMNIBOX_API_EXTENSION)) { | 615 (template_url->GetType() == TemplateURL::OMNIBOX_API_EXTENSION)) { |
| 606 gfx::Image image = extensions::OmniboxAPI::Get(profile())-> | 616 gfx::Image image = extensions::OmniboxAPI::Get(profile())-> |
| 607 GetOmniboxIcon(template_url->GetExtensionId()); | 617 GetOmniboxIcon(template_url->GetExtensionId()); |
| 608 selected_keyword_view_->SetImage(image.AsImageSkia()); | 618 selected_keyword_view_->SetImage(image.AsImageSkia()); |
| 609 selected_keyword_view_->set_is_extension_icon(true); | 619 selected_keyword_view_->set_is_extension_icon(true); |
| 610 } else { | 620 } else { |
| 611 selected_keyword_view_->ResetImage(); | 621 selected_keyword_view_->ResetImage(); |
| 612 selected_keyword_view_->set_is_extension_icon(false); | 622 selected_keyword_view_->set_is_extension_icon(false); |
| 613 } | 623 } |
| 614 } | 624 } |
| 615 } else if (ShouldShowEVBubble()) { | 625 } else if (ShouldShowSecurityChip()) { |
| 616 location_icon_view_->SetLabel(GetToolbarModel()->GetEVCertName()); | 626 location_icon_view_->SetLabel(GetSecurityText()); |
| 617 location_icon_view_->SetBackground(true); | 627 location_icon_view_->SetBackground(true); |
| 628 location_icon_view_->StartAnimation(); | |
|
Peter Kasting
2016/08/15 23:29:49
Don't start and stop animations from Layout(). La
Kevin Bailey
2016/08/16 16:39:36
I had hoped to use this strategy, but, for example
| |
| 618 // The largest fraction of the omnibox that can be taken by the EV bubble. | 629 // The largest fraction of the omnibox that can be taken by the EV bubble. |
| 619 const double kMaxBubbleFraction = 0.5; | 630 const double kMaxBubbleFraction = 0.5; |
| 620 leading_decorations.AddDecoration( | 631 leading_decorations.AddDecoration( |
| 621 vertical_padding, location_height, false, kMaxBubbleFraction, | 632 vertical_padding, location_height, false, kMaxBubbleFraction, |
| 622 bubble_horizontal_padding, item_padding, location_icon_view_); | 633 bubble_horizontal_padding, item_padding, location_icon_view_); |
| 623 } else { | 634 } else { |
| 635 location_icon_view_->StopAnimation(); | |
| 624 leading_decorations.AddDecoration(vertical_padding, location_height, | 636 leading_decorations.AddDecoration(vertical_padding, location_height, |
| 625 location_icon_view_); | 637 location_icon_view_); |
| 626 } | 638 } |
| 627 | 639 |
| 628 if (star_view_->visible()) { | 640 if (star_view_->visible()) { |
| 629 trailing_decorations.AddDecoration(vertical_padding, location_height, | 641 trailing_decorations.AddDecoration(vertical_padding, location_height, |
| 630 star_view_); | 642 star_view_); |
| 631 } | 643 } |
| 632 if (translate_icon_view_->visible()) { | 644 if (translate_icon_view_->visible()) { |
| 633 trailing_decorations.AddDecoration(vertical_padding, location_height, | 645 trailing_decorations.AddDecoration(vertical_padding, location_height, |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 783 } | 795 } |
| 784 } | 796 } |
| 785 | 797 |
| 786 void LocationBarView::Update(const WebContents* contents) { | 798 void LocationBarView::Update(const WebContents* contents) { |
| 787 RefreshContentSettingViews(); | 799 RefreshContentSettingViews(); |
| 788 RefreshZoomView(); | 800 RefreshZoomView(); |
| 789 RefreshPageActionViews(); | 801 RefreshPageActionViews(); |
| 790 RefreshTranslateIcon(); | 802 RefreshTranslateIcon(); |
| 791 RefreshSaveCreditCardIconView(); | 803 RefreshSaveCreditCardIconView(); |
| 792 RefreshManagePasswordsIconView(); | 804 RefreshManagePasswordsIconView(); |
| 793 content::WebContents* web_contents_for_sub_views = | 805 WebContents* web_contents_for_sub_views = |
| 794 GetToolbarModel()->input_in_progress() ? nullptr : GetWebContents(); | 806 GetToolbarModel()->input_in_progress() ? nullptr : GetWebContents(); |
| 795 open_pdf_in_reader_view_->Update(web_contents_for_sub_views); | 807 open_pdf_in_reader_view_->Update(web_contents_for_sub_views); |
| 796 | 808 |
| 797 if (star_view_) | 809 if (star_view_) |
| 798 UpdateBookmarkStarVisibility(); | 810 UpdateBookmarkStarVisibility(); |
| 799 | 811 |
| 800 if (contents) | 812 if (contents) |
| 801 omnibox_view_->OnTabChanged(contents); | 813 omnibox_view_->OnTabChanged(contents); |
| 802 else | 814 else |
| 803 omnibox_view_->Update(); | 815 omnibox_view_->Update(); |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1031 if (browser) | 1043 if (browser) |
| 1032 FirstRunBubble::ShowBubble(browser, location_icon_view_); | 1044 FirstRunBubble::ShowBubble(browser, location_icon_view_); |
| 1033 #endif | 1045 #endif |
| 1034 } | 1046 } |
| 1035 | 1047 |
| 1036 bool LocationBarView::HasValidSuggestText() const { | 1048 bool LocationBarView::HasValidSuggestText() const { |
| 1037 return suggested_text_view_->visible() && | 1049 return suggested_text_view_->visible() && |
| 1038 !suggested_text_view_->size().IsEmpty(); | 1050 !suggested_text_view_->size().IsEmpty(); |
| 1039 } | 1051 } |
| 1040 | 1052 |
| 1053 base::string16 LocationBarView::GetSecurityText() const { | |
| 1054 return ShouldShowEVBubble() ? GetToolbarModel()->GetEVCertName() | |
|
Peter Kasting
2016/08/15 23:29:49
Nit: This is now the only caller of this function,
Kevin Bailey
2016/08/16 16:39:36
The Mac code should use it. That's where I borrowe
| |
| 1055 : GetToolbarModel()->GetSecureVerboseText(); | |
| 1056 } | |
| 1057 | |
| 1041 bool LocationBarView::ShouldShowKeywordBubble() const { | 1058 bool LocationBarView::ShouldShowKeywordBubble() const { |
| 1042 return !omnibox_view_->model()->keyword().empty() && | 1059 return !omnibox_view_->model()->keyword().empty() && |
| 1043 !omnibox_view_->model()->is_keyword_hint(); | 1060 !omnibox_view_->model()->is_keyword_hint(); |
| 1044 } | 1061 } |
| 1045 | 1062 |
| 1046 bool LocationBarView::ShouldShowEVBubble() const { | 1063 bool LocationBarView::ShouldShowEVBubble() const { |
| 1047 return (GetToolbarModel()->GetSecurityLevel(false) == | 1064 return (GetToolbarModel()->GetSecurityLevel(false) == |
| 1048 security_state::SecurityStateModel::EV_SECURE); | 1065 security_state::SecurityStateModel::EV_SECURE); |
| 1049 } | 1066 } |
| 1050 | 1067 |
| 1068 std::string LocationBarView::TrimSite(const std::string& url) const { | |
| 1069 std::string prefix, site; | |
| 1070 if (RE2::FullMatch(url, "http(s?)://([^/]*)((/?).*)", &prefix, &site)) | |
|
Peter Kasting
2016/08/15 23:29:49
Please don't process things with a regex.
What ar
Kevin Bailey
2016/08/16 16:39:36
Done.
| |
| 1071 return site; | |
| 1072 else | |
| 1073 return url; | |
| 1074 } | |
| 1075 | |
| 1076 bool LocationBarView::ShouldShowSecurityChip() const { | |
| 1077 WebContents* web_contents = delegate_->GetWebContents(); | |
| 1078 if (!web_contents) | |
| 1079 return false; | |
| 1080 content::NavigationEntry* entry = | |
| 1081 web_contents->GetController().GetVisibleEntry(); | |
| 1082 if (omnibox_view_->IsEditingOrEmpty()) { | |
| 1083 load_state_->last_returned_ = false; | |
| 1084 return false; | |
| 1085 } | |
| 1086 std::string site(UTF16ToUTF8(omnibox_view_->GetText())); | |
| 1087 site = TrimSite(site); | |
| 1088 // If URL does not have same site. | |
| 1089 if (TrimSite(entry->GetURL().spec()) != site) { | |
| 1090 load_state_->last_returned_ = false; | |
| 1091 return false; | |
| 1092 } | |
| 1093 if (site == load_state_->last_site_) { | |
| 1094 if (load_state_->last_index_ != | |
| 1095 web_contents->GetController().GetLastCommittedEntryIndex()) { | |
| 1096 // New page, same site. | |
| 1097 load_state_->last_index_ = | |
| 1098 web_contents->GetController().GetLastCommittedEntryIndex(); | |
| 1099 // Return false if last was true, so it animates. | |
| 1100 load_state_->last_returned_ = !load_state_->last_returned_; | |
|
Peter Kasting
2016/08/15 23:29:49
I don't understand this logic. It means each time
Kevin Bailey
2016/08/16 16:39:36
btw, it does return the same thing (if other state
| |
| 1101 return load_state_->last_returned_; | |
| 1102 } else { | |
|
Peter Kasting
2016/08/15 23:29:49
Nit: No else after return.
Anyway here you could
Kevin Bailey
2016/08/16 16:39:36
Done, and more.
| |
| 1103 load_state_->last_returned_ = true; | |
| 1104 return true; | |
| 1105 } | |
| 1106 } | |
| 1107 if (load_state_->last_site_ != site && | |
| 1108 load_state_->last_index_ != | |
| 1109 web_contents->GetController().GetLastCommittedEntryIndex()) { | |
|
Peter Kasting
2016/08/15 23:29:49
Nit:
} else if (load_state_->last_index_ !=
Kevin Bailey
2016/08/16 16:39:36
Done.
| |
| 1110 // New page, new site. | |
| 1111 load_state_->last_site_ = site; | |
| 1112 load_state_->last_index_ = | |
| 1113 web_contents->GetController().GetLastCommittedEntryIndex(); | |
| 1114 // Return false if last was true, so it animates. | |
| 1115 load_state_->last_returned_ = !load_state_->last_returned_; | |
| 1116 return load_state_->last_returned_; | |
| 1117 } | |
| 1118 load_state_->last_returned_ = false; | |
| 1119 return false; | |
| 1120 } | |
| 1121 | |
| 1051 //////////////////////////////////////////////////////////////////////////////// | 1122 //////////////////////////////////////////////////////////////////////////////// |
| 1052 // LocationBarView, private LocationBar implementation: | 1123 // LocationBarView, private LocationBar implementation: |
| 1053 | 1124 |
| 1054 void LocationBarView::ShowFirstRunBubble() { | 1125 void LocationBarView::ShowFirstRunBubble() { |
| 1055 // Wait until search engines have loaded to show the first run bubble. | 1126 // Wait until search engines have loaded to show the first run bubble. |
| 1056 TemplateURLService* url_service = | 1127 TemplateURLService* url_service = |
| 1057 TemplateURLServiceFactory::GetForProfile(profile()); | 1128 TemplateURLServiceFactory::GetForProfile(profile()); |
| 1058 if (!url_service->loaded()) { | 1129 if (!url_service->loaded()) { |
| 1059 template_url_service_ = url_service; | 1130 template_url_service_ = url_service; |
| 1060 template_url_service_->AddObserver(this); | 1131 template_url_service_->AddObserver(this); |
| (...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1385 // LocationBarView, private TemplateURLServiceObserver implementation: | 1456 // LocationBarView, private TemplateURLServiceObserver implementation: |
| 1386 | 1457 |
| 1387 void LocationBarView::OnTemplateURLServiceChanged() { | 1458 void LocationBarView::OnTemplateURLServiceChanged() { |
| 1388 template_url_service_->RemoveObserver(this); | 1459 template_url_service_->RemoveObserver(this); |
| 1389 template_url_service_ = nullptr; | 1460 template_url_service_ = nullptr; |
| 1390 // If the browser is no longer active, let's not show the info bubble, as this | 1461 // If the browser is no longer active, let's not show the info bubble, as this |
| 1391 // would make the browser the active window again. | 1462 // would make the browser the active window again. |
| 1392 if (omnibox_view_ && omnibox_view_->GetWidget()->IsActive()) | 1463 if (omnibox_view_ && omnibox_view_->GetWidget()->IsActive()) |
| 1393 ShowFirstRunBubble(); | 1464 ShowFirstRunBubble(); |
| 1394 } | 1465 } |
| OLD | NEW |