Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(430)

Side by Side Diff: chrome/browser/ui/views/certificate_selector.cc

Issue 2277133003: Fixed a crash in Chrome caused by duplicate certificates (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added comments, changed the fix Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/certificate_selector.h" 5 #include "chrome/browser/ui/views/certificate_selector.h"
6 6
7 #include <stddef.h> // For size_t. 7 #include <stddef.h> // For size_t.
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 // The entry at index |i| is the provider name for |certificates_[i]|. 123 // The entry at index |i| is the provider name for |certificates_[i]|.
124 std::vector<std::string> provider_names; 124 std::vector<std::string> provider_names;
125 #if defined(OS_CHROMEOS) 125 #if defined(OS_CHROMEOS)
126 chromeos::CertificateProviderService* service = 126 chromeos::CertificateProviderService* service =
127 chromeos::CertificateProviderServiceFactory::GetForBrowserContext( 127 chromeos::CertificateProviderServiceFactory::GetForBrowserContext(
128 web_contents->GetBrowserContext()); 128 web_contents->GetBrowserContext());
129 extensions::ExtensionRegistry* extension_registry = 129 extensions::ExtensionRegistry* extension_registry =
130 extensions::ExtensionRegistryFactory::GetForBrowserContext( 130 extensions::ExtensionRegistryFactory::GetForBrowserContext(
131 web_contents->GetBrowserContext()); 131 web_contents->GetBrowserContext());
132 132
133 // TODO(isandrk): See crbug.com/641440. A certificate that was previously
emaxx 2016/08/29 14:16:40 nit: I think it makes more sense to move this crbu
Ivan Šandrk 2016/08/29 15:07:49 Done.
134 // provided by *both* the TPM and an extension will get incorrectly
emaxx 2016/08/29 14:16:39 nit: I don't think that the text in comments shoul
emaxx 2016/08/29 14:16:40 nit: s/TPM/platform/ (this is a more generic and c
Ivan Šandrk 2016/08/29 15:07:49 Done.
135 // filtered out if the extension stops providing it (both instances will be
136 // filtered out). Hence the certificates_ array will be empty and an empty
137 // certificate selection dialog will be shown which will cause a crash
emaxx 2016/08/29 14:16:40 nit: I would suggest rephrasing this sentence in a
Ivan Šandrk 2016/08/29 15:07:49 Done.
138 // (temporary workaround added in CertificateSelector::Show to prevent the
139 // crash).
emaxx 2016/08/29 14:16:40 nit: Generally, why not move this text and merge w
Ivan Šandrk 2016/08/29 15:07:49 Done.
133 for (const auto& cert : certificates) { 140 for (const auto& cert : certificates) {
134 std::string provider_name; 141 std::string provider_name;
135 bool has_extension = false; 142 bool has_extension = false;
136 std::string extension_id; 143 std::string extension_id;
137 if (service->LookUpCertificate(*cert, &has_extension, &extension_id)) { 144 if (service->LookUpCertificate(*cert, &has_extension, &extension_id)) {
138 if (!has_extension) { 145 if (!has_extension) {
139 // This certificate was provided by an extension but isn't provided by 146 // This certificate was provided by an extension but isn't provided by
140 // any extension currently. Don't expose it to the user. 147 // any extension currently. Don't expose it to the user.
141 continue; 148 continue;
142 } 149 }
(...skipping 28 matching lines...) Expand all
171 // GetTopLevelWebContents returns |web_contents| if it is not a guest. 178 // GetTopLevelWebContents returns |web_contents| if it is not a guest.
172 content::WebContents* top_level_web_contents = 179 content::WebContents* top_level_web_contents =
173 guest_view::GuestViewBase::GetTopLevelWebContents(web_contents); 180 guest_view::GuestViewBase::GetTopLevelWebContents(web_contents);
174 return web_modal::WebContentsModalDialogManager::FromWebContents( 181 return web_modal::WebContentsModalDialogManager::FromWebContents(
175 top_level_web_contents) != nullptr; 182 top_level_web_contents) != nullptr;
176 } 183 }
177 184
178 void CertificateSelector::Show() { 185 void CertificateSelector::Show() {
179 constrained_window::ShowWebModalDialogViews(this, web_contents_); 186 constrained_window::ShowWebModalDialogViews(this, web_contents_);
180 187
188 // TODO(isandrk): Temporary workaround for crbug.com/641440. certificates_
189 // array may sometimes be empty by mistake.
190 if (certificates_.empty()) {
191 GetWidget()->Close();
192 return;
193 }
194
181 // Select the first row automatically. This must be done after the dialog has 195 // Select the first row automatically. This must be done after the dialog has
182 // been created. 196 // been created.
183 table_->Select(0); 197 table_->Select(0);
184 } 198 }
185 199
186 void CertificateSelector::InitWithText( 200 void CertificateSelector::InitWithText(
187 std::unique_ptr<views::View> text_label) { 201 std::unique_ptr<views::View> text_label) {
188 views::GridLayout* const layout = views::GridLayout::CreatePanel(this); 202 views::GridLayout* const layout = views::GridLayout::CreatePanel(this);
189 SetLayoutManager(layout); 203 SetLayoutManager(layout);
190 204
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 void CertificateSelector::OnSelectionChanged() { 287 void CertificateSelector::OnSelectionChanged() {
274 GetDialogClientView()->ok_button()->SetEnabled(GetSelectedCert() != nullptr); 288 GetDialogClientView()->ok_button()->SetEnabled(GetSelectedCert() != nullptr);
275 } 289 }
276 290
277 void CertificateSelector::OnDoubleClick() { 291 void CertificateSelector::OnDoubleClick() {
278 if (GetSelectedCert()) 292 if (GetSelectedCert())
279 GetDialogClientView()->AcceptWindow(); 293 GetDialogClientView()->AcceptWindow();
280 } 294 }
281 295
282 } // namespace chrome 296 } // namespace chrome
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698