OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/origin_chip_view.h" | 5 #include "chrome/browser/ui/views/location_bar/origin_chip_view.h" |
6 | 6 |
7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 fade_in_animation_->SetSlideDuration(300); | 162 fade_in_animation_->SetSlideDuration(300); |
163 } | 163 } |
164 | 164 |
165 OriginChipView::~OriginChipView() { | 165 OriginChipView::~OriginChipView() { |
166 scoped_refptr<SafeBrowsingService> sb_service = | 166 scoped_refptr<SafeBrowsingService> sb_service = |
167 g_browser_process->safe_browsing_service(); | 167 g_browser_process->safe_browsing_service(); |
168 if (sb_service.get() && sb_service->ui_manager()) | 168 if (sb_service.get() && sb_service->ui_manager()) |
169 sb_service->ui_manager()->RemoveObserver(this); | 169 sb_service->ui_manager()->RemoveObserver(this); |
170 } | 170 } |
171 | 171 |
172 bool OriginChipView::ShouldShow() { | |
173 return chrome::ShouldDisplayOriginChipV2() && | |
174 location_bar_view_->GetToolbarModel()->WouldOmitURLDueToOriginChip() && | |
175 location_bar_view_->GetToolbarModel()->origin_chip_enabled(); | |
176 } | |
177 | |
178 void OriginChipView::Update(content::WebContents* web_contents) { | 172 void OriginChipView::Update(content::WebContents* web_contents) { |
179 if (!web_contents) | 173 if (!web_contents) |
180 return; | 174 return; |
181 | 175 |
182 // Note: security level can change async as the connection is made. | 176 // Note: security level can change async as the connection is made. |
183 GURL url = location_bar_view_->GetToolbarModel()->GetURL(); | 177 GURL url = location_bar_view_->GetToolbarModel()->GetURL(); |
184 const ToolbarModel::SecurityLevel security_level = | 178 const ToolbarModel::SecurityLevel security_level = |
185 location_bar_view_->GetToolbarModel()->GetSecurityLevel(true); | 179 location_bar_view_->GetToolbarModel()->GetSecurityLevel(true); |
186 | 180 |
187 bool url_malware = OriginChip::IsMalware(url, web_contents); | 181 bool url_malware = OriginChip::IsMalware(url, web_contents); |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
387 | 381 |
388 // Note: When OnSafeBrowsingHit would be called, OnSafeBrowsingMatch will | 382 // Note: When OnSafeBrowsingHit would be called, OnSafeBrowsingMatch will |
389 // have already been called. | 383 // have already been called. |
390 void OriginChipView::OnSafeBrowsingHit( | 384 void OriginChipView::OnSafeBrowsingHit( |
391 const SafeBrowsingUIManager::UnsafeResource& resource) {} | 385 const SafeBrowsingUIManager::UnsafeResource& resource) {} |
392 | 386 |
393 void OriginChipView::OnSafeBrowsingMatch( | 387 void OriginChipView::OnSafeBrowsingMatch( |
394 const SafeBrowsingUIManager::UnsafeResource& resource) { | 388 const SafeBrowsingUIManager::UnsafeResource& resource) { |
395 OnChanged(); | 389 OnChanged(); |
396 } | 390 } |
OLD | NEW |