Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/toolbar/chrome_toolbar_model_delegate.h" | 5 #include "chrome/browser/ui/toolbar/chrome_toolbar_model_delegate.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h" | 8 #include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/search/search.h" | 10 #include "chrome/browser/search/search.h" |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 84 const { | 84 const { |
| 85 scoped_refptr<net::X509Certificate> cert; | 85 scoped_refptr<net::X509Certificate> cert; |
| 86 content::NavigationEntry* entry = GetNavigationEntry(); | 86 content::NavigationEntry* entry = GetNavigationEntry(); |
| 87 if (entry) { | 87 if (entry) { |
| 88 content::CertStore::GetInstance()->RetrieveCert(entry->GetSSL().cert_id, | 88 content::CertStore::GetInstance()->RetrieveCert(entry->GetSSL().cert_id, |
| 89 &cert); | 89 &cert); |
| 90 } | 90 } |
| 91 return cert; | 91 return cert; |
| 92 } | 92 } |
| 93 | 93 |
| 94 bool ChromeToolbarModelDelegate::GetFailsMalwareCheck() const { | |
| 95 content::WebContents* web_contents = GetActiveWebContents(); | |
| 96 // If there is no active WebContents (which can happen during toolbar | |
| 97 // initialization), assume it did not failed. | |
|
Peter Kasting
2016/09/13 05:55:59
Nit: If there's no WebContents, there's no current
spqchan
2016/09/13 21:23:41
Done.
| |
| 98 if (!web_contents) | |
| 99 return false; | |
| 100 | |
| 101 auto* client = ChromeSecurityStateModelClient::FromWebContents(web_contents); | |
| 102 return client->GetSecurityInfo().fails_malware_check; | |
| 103 } | |
| 104 | |
| 94 content::NavigationController* | 105 content::NavigationController* |
| 95 ChromeToolbarModelDelegate::GetNavigationController() const { | 106 ChromeToolbarModelDelegate::GetNavigationController() const { |
| 96 // This |current_tab| can be null during the initialization of the toolbar | 107 // This |current_tab| can be null during the initialization of the toolbar |
| 97 // during window creation (i.e. before any tabs have been added to the | 108 // during window creation (i.e. before any tabs have been added to the |
| 98 // window). | 109 // window). |
| 99 content::WebContents* current_tab = GetActiveWebContents(); | 110 content::WebContents* current_tab = GetActiveWebContents(); |
| 100 return current_tab ? ¤t_tab->GetController() : nullptr; | 111 return current_tab ? ¤t_tab->GetController() : nullptr; |
| 101 } | 112 } |
| 102 | 113 |
| 103 content::NavigationEntry* ChromeToolbarModelDelegate::GetNavigationEntry() | 114 content::NavigationEntry* ChromeToolbarModelDelegate::GetNavigationEntry() |
| 104 const { | 115 const { |
| 105 content::NavigationController* controller = GetNavigationController(); | 116 content::NavigationController* controller = GetNavigationController(); |
| 106 return controller ? controller->GetVisibleEntry() : nullptr; | 117 return controller ? controller->GetVisibleEntry() : nullptr; |
| 107 } | 118 } |
| 108 | 119 |
| 109 Profile* ChromeToolbarModelDelegate::GetProfile() const { | 120 Profile* ChromeToolbarModelDelegate::GetProfile() const { |
| 110 content::NavigationController* controller = GetNavigationController(); | 121 content::NavigationController* controller = GetNavigationController(); |
| 111 return controller | 122 return controller |
| 112 ? Profile::FromBrowserContext(controller->GetBrowserContext()) | 123 ? Profile::FromBrowserContext(controller->GetBrowserContext()) |
| 113 : nullptr; | 124 : nullptr; |
| 114 } | 125 } |
| OLD | NEW |