| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/toolbar/site_chip_view.h" | 5 #include "chrome/browser/ui/views/toolbar/site_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/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 if (host == chrome::kChromeUISettingsHost) | 165 if (host == chrome::kChromeUISettingsHost) |
| 166 return IDS_SETTINGS_TITLE; | 166 return IDS_SETTINGS_TITLE; |
| 167 if (host == chrome::kChromeUIVersionHost) | 167 if (host == chrome::kChromeUIVersionHost) |
| 168 return IDS_ABOUT_VERSION_TITLE; | 168 return IDS_ABOUT_VERSION_TITLE; |
| 169 | 169 |
| 170 return -1; | 170 return -1; |
| 171 } | 171 } |
| 172 | 172 |
| 173 } // namespace | 173 } // namespace |
| 174 | 174 |
| 175 string16 SiteChipView::SiteLabelFromURL(const GURL& provided_url) { | 175 base::string16 SiteChipView::SiteLabelFromURL(const GURL& provided_url) { |
| 176 // First, strip view-source: if it appears. Note that GetContent removes | 176 // First, strip view-source: if it appears. Note that GetContent removes |
| 177 // "view-source:" but leaves the http, https or ftp scheme. | 177 // "view-source:" but leaves the http, https or ftp scheme. |
| 178 GURL url(provided_url); | 178 GURL url(provided_url); |
| 179 if (url.SchemeIs(content::kViewSourceScheme)) | 179 if (url.SchemeIs(content::kViewSourceScheme)) |
| 180 url = GURL(url.GetContent()); | 180 url = GURL(url.GetContent()); |
| 181 | 181 |
| 182 // Chrome built-in pages. | 182 // Chrome built-in pages. |
| 183 if (url.is_empty() || | 183 if (url.is_empty() || |
| 184 url.SchemeIs(chrome::kChromeUIScheme) || | 184 url.SchemeIs(chrome::kChromeUIScheme) || |
| 185 url.SchemeIs(chrome::kAboutScheme)) { | 185 url.SchemeIs(chrome::kAboutScheme)) { |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 } else if (security_level_ == ToolbarModel::SECURITY_ERROR) { | 342 } else if (security_level_ == ToolbarModel::SECURITY_ERROR) { |
| 343 painter_ = broken_ssl_background_painter_.get(); | 343 painter_ = broken_ssl_background_painter_.get(); |
| 344 label_background = kBrokenSSLBackgroundColor; | 344 label_background = kBrokenSSLBackgroundColor; |
| 345 } else if (security_level_ == ToolbarModel::EV_SECURE) { | 345 } else if (security_level_ == ToolbarModel::EV_SECURE) { |
| 346 painter_ = ev_background_painter_.get(); | 346 painter_ = ev_background_painter_.get(); |
| 347 label_background = kEVBackgroundColor; | 347 label_background = kEVBackgroundColor; |
| 348 } else { | 348 } else { |
| 349 painter_ = NULL; | 349 painter_ = NULL; |
| 350 } | 350 } |
| 351 | 351 |
| 352 string16 host = SiteLabelFromURL(url_displayed_); | 352 base::string16 host = SiteLabelFromURL(url_displayed_); |
| 353 if (security_level_ == ToolbarModel::EV_SECURE) { | 353 if (security_level_ == ToolbarModel::EV_SECURE) { |
| 354 host = l10n_util::GetStringFUTF16(IDS_SITE_CHIP_EV_SSL_LABEL, | 354 host = l10n_util::GetStringFUTF16(IDS_SITE_CHIP_EV_SSL_LABEL, |
| 355 toolbar_view_->GetToolbarModel()->GetEVCertName(), | 355 toolbar_view_->GetToolbarModel()->GetEVCertName(), |
| 356 host); | 356 host); |
| 357 } | 357 } |
| 358 | 358 |
| 359 host_label_->SetText(host); | 359 host_label_->SetText(host); |
| 360 host_label_->SetTooltipText(host); | 360 host_label_->SetTooltipText(host); |
| 361 host_label_->SetBackgroundColor(label_background); | 361 host_label_->SetBackgroundColor(label_background); |
| 362 | 362 |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 486 // Note: When OnSafeBrowsingHit would be called, OnSafeBrowsingMatch will | 486 // Note: When OnSafeBrowsingHit would be called, OnSafeBrowsingMatch will |
| 487 // have already been called. | 487 // have already been called. |
| 488 void SiteChipView::OnSafeBrowsingHit( | 488 void SiteChipView::OnSafeBrowsingHit( |
| 489 const SafeBrowsingUIManager::UnsafeResource& resource) {} | 489 const SafeBrowsingUIManager::UnsafeResource& resource) {} |
| 490 | 490 |
| 491 void SiteChipView::OnSafeBrowsingMatch( | 491 void SiteChipView::OnSafeBrowsingMatch( |
| 492 const SafeBrowsingUIManager::UnsafeResource& resource) { | 492 const SafeBrowsingUIManager::UnsafeResource& resource) { |
| 493 OnChanged(); | 493 OnChanged(); |
| 494 } | 494 } |
| 495 | 495 |
| OLD | NEW |