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

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

Issue 2351003003: [omnibox] Support new flags for security chip (Closed)
Patch Set: Simplify class field definitions Created 4 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
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/i18n/rtl.h" 11 #include "base/i18n/rtl.h"
11 #include "base/stl_util.h" 12 #include "base/stl_util.h"
12 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
13 #include "build/build_config.h" 14 #include "build/build_config.h"
14 #include "chrome/app/chrome_command_ids.h" 15 #include "chrome/app/chrome_command_ids.h"
15 #include "chrome/browser/command_updater.h" 16 #include "chrome/browser/command_updater.h"
16 #include "chrome/browser/defaults.h" 17 #include "chrome/browser/defaults.h"
17 #include "chrome/browser/extensions/api/omnibox/omnibox_api.h" 18 #include "chrome/browser/extensions/api/omnibox/omnibox_api.h"
18 #include "chrome/browser/extensions/extension_action.h" 19 #include "chrome/browser/extensions/extension_action.h"
19 #include "chrome/browser/extensions/extension_action_manager.h" 20 #include "chrome/browser/extensions/extension_action_manager.h"
(...skipping 24 matching lines...) Expand all
44 #include "chrome/browser/ui/views/location_bar/page_action_image_view.h" 45 #include "chrome/browser/ui/views/location_bar/page_action_image_view.h"
45 #include "chrome/browser/ui/views/location_bar/page_action_with_badge_view.h" 46 #include "chrome/browser/ui/views/location_bar/page_action_with_badge_view.h"
46 #include "chrome/browser/ui/views/location_bar/selected_keyword_view.h" 47 #include "chrome/browser/ui/views/location_bar/selected_keyword_view.h"
47 #include "chrome/browser/ui/views/location_bar/star_view.h" 48 #include "chrome/browser/ui/views/location_bar/star_view.h"
48 #include "chrome/browser/ui/views/location_bar/zoom_bubble_view.h" 49 #include "chrome/browser/ui/views/location_bar/zoom_bubble_view.h"
49 #include "chrome/browser/ui/views/location_bar/zoom_view.h" 50 #include "chrome/browser/ui/views/location_bar/zoom_view.h"
50 #include "chrome/browser/ui/views/passwords/manage_passwords_bubble_view.h" 51 #include "chrome/browser/ui/views/passwords/manage_passwords_bubble_view.h"
51 #include "chrome/browser/ui/views/passwords/manage_passwords_icon_views.h" 52 #include "chrome/browser/ui/views/passwords/manage_passwords_icon_views.h"
52 #include "chrome/browser/ui/views/translate/translate_bubble_view.h" 53 #include "chrome/browser/ui/views/translate/translate_bubble_view.h"
53 #include "chrome/browser/ui/views/translate/translate_icon_view.h" 54 #include "chrome/browser/ui/views/translate/translate_icon_view.h"
55 #include "chrome/common/chrome_switches.h"
54 #include "chrome/grit/generated_resources.h" 56 #include "chrome/grit/generated_resources.h"
55 #include "chrome/grit/theme_resources.h" 57 #include "chrome/grit/theme_resources.h"
56 #include "components/bookmarks/common/bookmark_pref_names.h" 58 #include "components/bookmarks/common/bookmark_pref_names.h"
57 #include "components/favicon/content/content_favicon_driver.h" 59 #include "components/favicon/content/content_favicon_driver.h"
58 #include "components/grit/components_scaled_resources.h" 60 #include "components/grit/components_scaled_resources.h"
59 #include "components/omnibox/browser/omnibox_popup_model.h" 61 #include "components/omnibox/browser/omnibox_popup_model.h"
60 #include "components/omnibox/browser/omnibox_popup_view.h" 62 #include "components/omnibox/browser/omnibox_popup_view.h"
61 #include "components/prefs/pref_service.h" 63 #include "components/prefs/pref_service.h"
62 #include "components/search_engines/template_url.h" 64 #include "components/search_engines/template_url.h"
63 #include "components/search_engines/template_url_service.h" 65 #include "components/search_engines/template_url_service.h"
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 zoom_view_(nullptr), 133 zoom_view_(nullptr),
132 open_pdf_in_reader_view_(nullptr), 134 open_pdf_in_reader_view_(nullptr),
133 manage_passwords_icon_view_(nullptr), 135 manage_passwords_icon_view_(nullptr),
134 save_credit_card_icon_view_(nullptr), 136 save_credit_card_icon_view_(nullptr),
135 translate_icon_view_(nullptr), 137 translate_icon_view_(nullptr),
136 star_view_(nullptr), 138 star_view_(nullptr),
137 size_animation_(this), 139 size_animation_(this),
138 is_popup_mode_(is_popup_mode), 140 is_popup_mode_(is_popup_mode),
139 show_focus_rect_(false), 141 show_focus_rect_(false),
140 template_url_service_(NULL), 142 template_url_service_(NULL),
141 web_contents_null_at_last_refresh_(true) { 143 web_contents_null_at_last_refresh_(true),
144 should_show_secure_state_(true),
145 should_animate_secure_state_(true) {
142 edit_bookmarks_enabled_.Init( 146 edit_bookmarks_enabled_.Init(
143 bookmarks::prefs::kEditBookmarksEnabled, profile->GetPrefs(), 147 bookmarks::prefs::kEditBookmarksEnabled, profile->GetPrefs(),
144 base::Bind(&LocationBarView::UpdateWithoutTabRestore, 148 base::Bind(&LocationBarView::UpdateWithoutTabRestore,
145 base::Unretained(this))); 149 base::Unretained(this)));
146 150
147 zoom::ZoomEventManager::GetForBrowserContext(profile) 151 zoom::ZoomEventManager::GetForBrowserContext(profile)
148 ->AddZoomEventManagerObserver(this); 152 ->AddZoomEventManagerObserver(this);
153
154 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
155 if (command_line->HasSwitch(switches::kMaterialSecurityVerbose)) {
156 std::string security_verbose_flag =
157 command_line->GetSwitchValueASCII(switches::kMaterialSecurityVerbose);
158
159 should_show_secure_state_ =
160 security_verbose_flag ==
161 switches::kMaterialSecurityVerboseShowAllAnimated ||
162 security_verbose_flag ==
163 switches::kMaterialSecurityVerboseShowAllNonAnimated;
164
165 should_animate_secure_state_ =
166 security_verbose_flag ==
167 switches::kMaterialSecurityVerboseShowAllAnimated ||
168 security_verbose_flag ==
169 switches::kMaterialSecurityVerboseShowNonSecureAnimated;
170 }
149 } 171 }
150 172
151 LocationBarView::~LocationBarView() { 173 LocationBarView::~LocationBarView() {
152 if (template_url_service_) 174 if (template_url_service_)
153 template_url_service_->RemoveObserver(this); 175 template_url_service_->RemoveObserver(this);
154 176
155 zoom::ZoomEventManager::GetForBrowserContext(profile()) 177 zoom::ZoomEventManager::GetForBrowserContext(profile())
156 ->RemoveZoomEventManagerObserver(this); 178 ->RemoveZoomEventManagerObserver(this);
157 } 179 }
158 180
(...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after
796 818
797 if (star_view_) 819 if (star_view_)
798 UpdateBookmarkStarVisibility(); 820 UpdateBookmarkStarVisibility();
799 821
800 if (contents) 822 if (contents)
801 omnibox_view_->OnTabChanged(contents); 823 omnibox_view_->OnTabChanged(contents);
802 else 824 else
803 omnibox_view_->Update(); 825 omnibox_view_->Update();
804 826
805 bool should_show = ShouldShowSecurityChip(); 827 bool should_show = ShouldShowSecurityChip();
806 location_icon_view_->SetSecurityState(should_show, should_show && !contents); 828 location_icon_view_->SetSecurityState(
829 should_show, should_show && !contents && should_animate_secure_state_);
807 830
808 OnChanged(); // NOTE: Calls Layout(). 831 OnChanged(); // NOTE: Calls Layout().
809 } 832 }
810 833
811 void LocationBarView::ResetTabState(WebContents* contents) { 834 void LocationBarView::ResetTabState(WebContents* contents) {
812 omnibox_view_->ResetTabState(contents); 835 omnibox_view_->ResetTabState(contents);
813 } 836 }
814 837
815 //////////////////////////////////////////////////////////////////////////////// 838 ////////////////////////////////////////////////////////////////////////////////
816 // LocationBarView, public OmniboxEditController implementation: 839 // LocationBarView, public OmniboxEditController implementation:
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
1042 : GetToolbarModel()->GetSecureVerboseText(); 1065 : GetToolbarModel()->GetSecureVerboseText();
1043 } 1066 }
1044 1067
1045 bool LocationBarView::ShouldShowKeywordBubble() const { 1068 bool LocationBarView::ShouldShowKeywordBubble() const {
1046 return !omnibox_view_->model()->keyword().empty() && 1069 return !omnibox_view_->model()->keyword().empty() &&
1047 !omnibox_view_->model()->is_keyword_hint(); 1070 !omnibox_view_->model()->is_keyword_hint();
1048 } 1071 }
1049 1072
1050 bool LocationBarView::ShouldShowEVBubble() const { 1073 bool LocationBarView::ShouldShowEVBubble() const {
1051 return (GetToolbarModel()->GetSecurityLevel(false) == 1074 return (GetToolbarModel()->GetSecurityLevel(false) ==
1052 security_state::SecurityStateModel::EV_SECURE); 1075 security_state::SecurityStateModel::EV_SECURE) &&
1076 should_show_secure_state_;
1053 } 1077 }
1054 1078
1055 bool LocationBarView::ShouldShowSecurityChip() const { 1079 bool LocationBarView::ShouldShowSecurityChip() const {
1056 using SecurityLevel = security_state::SecurityStateModel::SecurityLevel; 1080 using SecurityLevel = security_state::SecurityStateModel::SecurityLevel;
1057 SecurityLevel level = GetToolbarModel()->GetSecurityLevel(false); 1081 SecurityLevel level = GetToolbarModel()->GetSecurityLevel(false);
1058 return level == SecurityLevel::SECURE || level == SecurityLevel::EV_SECURE || 1082 return ((level == SecurityLevel::SECURE ||
1083 level == SecurityLevel::EV_SECURE) &&
1084 should_show_secure_state_) ||
1059 level == SecurityLevel::SECURITY_ERROR; 1085 level == SecurityLevel::SECURITY_ERROR;
1060 } 1086 }
1061 1087
1062 //////////////////////////////////////////////////////////////////////////////// 1088 ////////////////////////////////////////////////////////////////////////////////
1063 // LocationBarView, private LocationBar implementation: 1089 // LocationBarView, private LocationBar implementation:
1064 1090
1065 void LocationBarView::ShowFirstRunBubble() { 1091 void LocationBarView::ShowFirstRunBubble() {
1066 // Wait until search engines have loaded to show the first run bubble. 1092 // Wait until search engines have loaded to show the first run bubble.
1067 TemplateURLService* url_service = 1093 TemplateURLService* url_service =
1068 TemplateURLServiceFactory::GetForProfile(profile()); 1094 TemplateURLServiceFactory::GetForProfile(profile());
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
1397 // LocationBarView, private TemplateURLServiceObserver implementation: 1423 // LocationBarView, private TemplateURLServiceObserver implementation:
1398 1424
1399 void LocationBarView::OnTemplateURLServiceChanged() { 1425 void LocationBarView::OnTemplateURLServiceChanged() {
1400 template_url_service_->RemoveObserver(this); 1426 template_url_service_->RemoveObserver(this);
1401 template_url_service_ = nullptr; 1427 template_url_service_ = nullptr;
1402 // If the browser is no longer active, let's not show the info bubble, as this 1428 // If the browser is no longer active, let's not show the info bubble, as this
1403 // would make the browser the active window again. 1429 // would make the browser the active window again.
1404 if (omnibox_view_ && omnibox_view_->GetWidget()->IsActive()) 1430 if (omnibox_view_ && omnibox_view_->GetWidget()->IsActive())
1405 ShowFirstRunBubble(); 1431 ShowFirstRunBubble();
1406 } 1432 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/location_bar/location_bar_view.h ('k') | chrome/common/chrome_switches.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698