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" |
11 #include "chrome/browser/ssl/chrome_security_state_model_client.h" | 11 #include "chrome/browser/ssl/security_state_tab_helper.h" |
12 #include "chrome/common/pref_names.h" | 12 #include "chrome/common/pref_names.h" |
13 #include "chrome/common/url_constants.h" | 13 #include "chrome/common/url_constants.h" |
14 #include "components/google/core/browser/google_util.h" | 14 #include "components/google/core/browser/google_util.h" |
15 #include "components/omnibox/browser/autocomplete_input.h" | 15 #include "components/omnibox/browser/autocomplete_input.h" |
16 #include "components/prefs/pref_service.h" | 16 #include "components/prefs/pref_service.h" |
17 #include "content/public/browser/navigation_controller.h" | 17 #include "content/public/browser/navigation_controller.h" |
18 #include "content/public/browser/navigation_entry.h" | 18 #include "content/public/browser/navigation_entry.h" |
19 #include "content/public/browser/ssl_status.h" | 19 #include "content/public/browser/ssl_status.h" |
20 #include "content/public/browser/web_contents.h" | 20 #include "content/public/browser/web_contents.h" |
21 | 21 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 return !search::IsInstantNTP(GetActiveWebContents()); | 68 return !search::IsInstantNTP(GetActiveWebContents()); |
69 } | 69 } |
70 | 70 |
71 security_state::SecurityStateModel::SecurityLevel | 71 security_state::SecurityStateModel::SecurityLevel |
72 ChromeToolbarModelDelegate::GetSecurityLevel() const { | 72 ChromeToolbarModelDelegate::GetSecurityLevel() const { |
73 content::WebContents* web_contents = GetActiveWebContents(); | 73 content::WebContents* web_contents = GetActiveWebContents(); |
74 // If there is no active WebContents (which can happen during toolbar | 74 // If there is no active WebContents (which can happen during toolbar |
75 // initialization), assume no security style. | 75 // initialization), assume no security style. |
76 if (!web_contents) | 76 if (!web_contents) |
77 return security_state::SecurityStateModel::NONE; | 77 return security_state::SecurityStateModel::NONE; |
78 auto* client = ChromeSecurityStateModelClient::FromWebContents(web_contents); | 78 auto* helper = SecurityStateTabHelper::FromWebContents(web_contents); |
79 security_state::SecurityStateModel::SecurityInfo security_info; | 79 security_state::SecurityStateModel::SecurityInfo security_info; |
80 client->GetSecurityInfo(&security_info); | 80 helper->GetSecurityInfo(&security_info); |
81 return security_info.security_level; | 81 return security_info.security_level; |
82 } | 82 } |
83 | 83 |
84 scoped_refptr<net::X509Certificate> ChromeToolbarModelDelegate::GetCertificate() | 84 scoped_refptr<net::X509Certificate> ChromeToolbarModelDelegate::GetCertificate() |
85 const { | 85 const { |
86 content::NavigationEntry* entry = GetNavigationEntry(); | 86 content::NavigationEntry* entry = GetNavigationEntry(); |
87 if (!entry) | 87 if (!entry) |
88 return scoped_refptr<net::X509Certificate>(); | 88 return scoped_refptr<net::X509Certificate>(); |
89 return entry->GetSSL().certificate; | 89 return entry->GetSSL().certificate; |
90 } | 90 } |
91 | 91 |
92 bool ChromeToolbarModelDelegate::FailsMalwareCheck() const { | 92 bool ChromeToolbarModelDelegate::FailsMalwareCheck() const { |
93 content::WebContents* web_contents = GetActiveWebContents(); | 93 content::WebContents* web_contents = GetActiveWebContents(); |
94 // If there is no active WebContents (which can happen during toolbar | 94 // If there is no active WebContents (which can happen during toolbar |
95 // initialization), so nothing can fail. | 95 // initialization), so nothing can fail. |
96 if (!web_contents) | 96 if (!web_contents) |
97 return false; | 97 return false; |
98 security_state::SecurityStateModel::SecurityInfo security_info; | 98 security_state::SecurityStateModel::SecurityInfo security_info; |
99 ChromeSecurityStateModelClient::FromWebContents(web_contents) | 99 SecurityStateTabHelper::FromWebContents(web_contents) |
100 ->GetSecurityInfo(&security_info); | 100 ->GetSecurityInfo(&security_info); |
101 return security_info.fails_malware_check; | 101 return security_info.fails_malware_check; |
102 } | 102 } |
103 | 103 |
104 content::NavigationController* | 104 content::NavigationController* |
105 ChromeToolbarModelDelegate::GetNavigationController() const { | 105 ChromeToolbarModelDelegate::GetNavigationController() const { |
106 // This |current_tab| can be null during the initialization of the toolbar | 106 // This |current_tab| can be null during the initialization of the toolbar |
107 // during window creation (i.e. before any tabs have been added to the | 107 // during window creation (i.e. before any tabs have been added to the |
108 // window). | 108 // window). |
109 content::WebContents* current_tab = GetActiveWebContents(); | 109 content::WebContents* current_tab = GetActiveWebContents(); |
110 return current_tab ? ¤t_tab->GetController() : nullptr; | 110 return current_tab ? ¤t_tab->GetController() : nullptr; |
111 } | 111 } |
112 | 112 |
113 content::NavigationEntry* ChromeToolbarModelDelegate::GetNavigationEntry() | 113 content::NavigationEntry* ChromeToolbarModelDelegate::GetNavigationEntry() |
114 const { | 114 const { |
115 content::NavigationController* controller = GetNavigationController(); | 115 content::NavigationController* controller = GetNavigationController(); |
116 return controller ? controller->GetVisibleEntry() : nullptr; | 116 return controller ? controller->GetVisibleEntry() : nullptr; |
117 } | 117 } |
118 | 118 |
119 Profile* ChromeToolbarModelDelegate::GetProfile() const { | 119 Profile* ChromeToolbarModelDelegate::GetProfile() const { |
120 content::NavigationController* controller = GetNavigationController(); | 120 content::NavigationController* controller = GetNavigationController(); |
121 return controller | 121 return controller |
122 ? Profile::FromBrowserContext(controller->GetBrowserContext()) | 122 ? Profile::FromBrowserContext(controller->GetBrowserContext()) |
123 : nullptr; | 123 : nullptr; |
124 } | 124 } |
OLD | NEW |