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/chrome_security_state_model_client.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/cert_store.h" | |
18 #include "content/public/browser/navigation_controller.h" | 17 #include "content/public/browser/navigation_controller.h" |
19 #include "content/public/browser/navigation_entry.h" | 18 #include "content/public/browser/navigation_entry.h" |
20 #include "content/public/browser/web_contents.h" | 19 #include "content/public/browser/web_contents.h" |
21 #include "content/public/common/ssl_status.h" | 20 #include "content/public/common/ssl_status.h" |
22 | 21 |
23 ChromeToolbarModelDelegate::ChromeToolbarModelDelegate() {} | 22 ChromeToolbarModelDelegate::ChromeToolbarModelDelegate() {} |
24 | 23 |
25 ChromeToolbarModelDelegate::~ChromeToolbarModelDelegate() {} | 24 ChromeToolbarModelDelegate::~ChromeToolbarModelDelegate() {} |
26 | 25 |
27 base::string16 ChromeToolbarModelDelegate::FormattedStringWithEquivalentMeaning( | 26 base::string16 ChromeToolbarModelDelegate::FormattedStringWithEquivalentMeaning( |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 // If there is no active WebContents (which can happen during toolbar | 74 // If there is no active WebContents (which can happen during toolbar |
76 // initialization), assume no security style. | 75 // initialization), assume no security style. |
77 if (!web_contents) | 76 if (!web_contents) |
78 return security_state::SecurityStateModel::NONE; | 77 return security_state::SecurityStateModel::NONE; |
79 auto* client = ChromeSecurityStateModelClient::FromWebContents(web_contents); | 78 auto* client = ChromeSecurityStateModelClient::FromWebContents(web_contents); |
80 return client->GetSecurityInfo().security_level; | 79 return client->GetSecurityInfo().security_level; |
81 } | 80 } |
82 | 81 |
83 scoped_refptr<net::X509Certificate> ChromeToolbarModelDelegate::GetCertificate() | 82 scoped_refptr<net::X509Certificate> ChromeToolbarModelDelegate::GetCertificate() |
84 const { | 83 const { |
85 scoped_refptr<net::X509Certificate> cert; | |
86 content::NavigationEntry* entry = GetNavigationEntry(); | 84 content::NavigationEntry* entry = GetNavigationEntry(); |
87 if (entry) { | 85 if (!entry) |
88 content::CertStore::GetInstance()->RetrieveCert(entry->GetSSL().cert_id, | 86 return scoped_refptr<net::X509Certificate>(); |
89 &cert); | 87 return entry->GetSSL().certificate; |
90 } | |
91 return cert; | |
92 } | 88 } |
93 | 89 |
94 content::NavigationController* | 90 content::NavigationController* |
95 ChromeToolbarModelDelegate::GetNavigationController() const { | 91 ChromeToolbarModelDelegate::GetNavigationController() const { |
96 // This |current_tab| can be null during the initialization of the toolbar | 92 // 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 | 93 // during window creation (i.e. before any tabs have been added to the |
98 // window). | 94 // window). |
99 content::WebContents* current_tab = GetActiveWebContents(); | 95 content::WebContents* current_tab = GetActiveWebContents(); |
100 return current_tab ? ¤t_tab->GetController() : nullptr; | 96 return current_tab ? ¤t_tab->GetController() : nullptr; |
101 } | 97 } |
102 | 98 |
103 content::NavigationEntry* ChromeToolbarModelDelegate::GetNavigationEntry() | 99 content::NavigationEntry* ChromeToolbarModelDelegate::GetNavigationEntry() |
104 const { | 100 const { |
105 content::NavigationController* controller = GetNavigationController(); | 101 content::NavigationController* controller = GetNavigationController(); |
106 return controller ? controller->GetVisibleEntry() : nullptr; | 102 return controller ? controller->GetVisibleEntry() : nullptr; |
107 } | 103 } |
108 | 104 |
109 Profile* ChromeToolbarModelDelegate::GetProfile() const { | 105 Profile* ChromeToolbarModelDelegate::GetProfile() const { |
110 content::NavigationController* controller = GetNavigationController(); | 106 content::NavigationController* controller = GetNavigationController(); |
111 return controller | 107 return controller |
112 ? Profile::FromBrowserContext(controller->GetBrowserContext()) | 108 ? Profile::FromBrowserContext(controller->GetBrowserContext()) |
113 : nullptr; | 109 : nullptr; |
114 } | 110 } |
OLD | NEW |