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

Side by Side Diff: chrome/browser/ssl/ssl_add_certificate.cc

Issue 2361843003: Always use vector icons for desktop infobars (when one is defined). (Closed)
Patch Set: make patch match description 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 | « chrome/app/theme/theme_resources.grd ('k') | components/infobars/core/infobar_delegate.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/ssl/ssl_add_certificate.h" 5 #include "chrome/browser/ssl/ssl_add_certificate.h"
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "base/strings/string_number_conversions.h" 8 #include "base/strings/string_number_conversions.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "build/build_config.h" 10 #include "build/build_config.h"
11 #include "chrome/browser/certificate_viewer.h" 11 #include "chrome/browser/certificate_viewer.h"
12 #include "chrome/browser/infobars/infobar_service.h" 12 #include "chrome/browser/infobars/infobar_service.h"
13 #include "chrome/grit/generated_resources.h" 13 #include "chrome/grit/generated_resources.h"
14 #include "chrome/grit/theme_resources.h"
15 #include "components/infobars/core/confirm_infobar_delegate.h" 14 #include "components/infobars/core/confirm_infobar_delegate.h"
16 #include "components/infobars/core/infobar.h" 15 #include "components/infobars/core/infobar.h"
17 #include "components/infobars/core/infobar_delegate.h" 16 #include "components/infobars/core/infobar_delegate.h"
18 #include "components/infobars/core/simple_alert_infobar_delegate.h" 17 #include "components/infobars/core/simple_alert_infobar_delegate.h"
19 #include "content/public/browser/browser_thread.h" 18 #include "content/public/browser/browser_thread.h"
20 #include "content/public/browser/render_frame_host.h" 19 #include "content/public/browser/render_frame_host.h"
21 #include "content/public/browser/web_contents.h" 20 #include "content/public/browser/web_contents.h"
22 #include "net/base/net_errors.h" 21 #include "net/base/net_errors.h"
23 #include "net/cert/cert_database.h" 22 #include "net/cert/cert_database.h"
24 #include "net/cert/x509_certificate.h" 23 #include "net/cert/x509_certificate.h"
(...skipping 15 matching lines...) Expand all
40 static void Create(InfoBarService* infobar_service, 39 static void Create(InfoBarService* infobar_service,
41 net::X509Certificate* cert); 40 net::X509Certificate* cert);
42 41
43 private: 42 private:
44 explicit SSLAddCertificateInfoBarDelegate(net::X509Certificate* cert); 43 explicit SSLAddCertificateInfoBarDelegate(net::X509Certificate* cert);
45 ~SSLAddCertificateInfoBarDelegate() override; 44 ~SSLAddCertificateInfoBarDelegate() override;
46 45
47 // ConfirmInfoBarDelegate: 46 // ConfirmInfoBarDelegate:
48 Type GetInfoBarType() const override; 47 Type GetInfoBarType() const override;
49 infobars::InfoBarDelegate::InfoBarIdentifier GetIdentifier() const override; 48 infobars::InfoBarDelegate::InfoBarIdentifier GetIdentifier() const override;
50 int GetIconId() const override;
51 gfx::VectorIconId GetVectorIconId() const override; 49 gfx::VectorIconId GetVectorIconId() const override;
52 base::string16 GetMessageText() const override; 50 base::string16 GetMessageText() const override;
53 int GetButtons() const override; 51 int GetButtons() const override;
54 base::string16 GetButtonLabel(InfoBarButton button) const override; 52 base::string16 GetButtonLabel(InfoBarButton button) const override;
55 bool Accept() override; 53 bool Accept() override;
56 54
57 // The certificate that was added. 55 // The certificate that was added.
58 scoped_refptr<net::X509Certificate> cert_; 56 scoped_refptr<net::X509Certificate> cert_;
59 57
60 DISALLOW_COPY_AND_ASSIGN(SSLAddCertificateInfoBarDelegate); 58 DISALLOW_COPY_AND_ASSIGN(SSLAddCertificateInfoBarDelegate);
(...skipping 18 matching lines...) Expand all
79 infobars::InfoBarDelegate::Type 77 infobars::InfoBarDelegate::Type
80 SSLAddCertificateInfoBarDelegate::GetInfoBarType() const { 78 SSLAddCertificateInfoBarDelegate::GetInfoBarType() const {
81 return PAGE_ACTION_TYPE; 79 return PAGE_ACTION_TYPE;
82 } 80 }
83 81
84 infobars::InfoBarDelegate::InfoBarIdentifier 82 infobars::InfoBarDelegate::InfoBarIdentifier
85 SSLAddCertificateInfoBarDelegate::GetIdentifier() const { 83 SSLAddCertificateInfoBarDelegate::GetIdentifier() const {
86 return SSL_ADD_CERTIFICATE_INFOBAR_DELEGATE; 84 return SSL_ADD_CERTIFICATE_INFOBAR_DELEGATE;
87 } 85 }
88 86
89 int SSLAddCertificateInfoBarDelegate::GetIconId() const { 87 gfx::VectorIconId SSLAddCertificateInfoBarDelegate::GetVectorIconId() const {
90 // TODO(davidben): Use a more appropriate icon. 88 // TODO(davidben): Use a more appropriate icon.
91 return IDR_INFOBAR_SAVE_PASSWORD;
Peter Kasting 2016/09/23 00:45:10 So, this is safe to remove because this infobar is
92 }
93
94 gfx::VectorIconId SSLAddCertificateInfoBarDelegate::GetVectorIconId() const {
95 #if !defined(OS_MACOSX)
96 return gfx::VectorIconId::AUTOLOGIN; 89 return gfx::VectorIconId::AUTOLOGIN;
97 #else
98 return gfx::VectorIconId::VECTOR_ICON_NONE;
99 #endif
100 } 90 }
101 91
102 base::string16 SSLAddCertificateInfoBarDelegate::GetMessageText() const { 92 base::string16 SSLAddCertificateInfoBarDelegate::GetMessageText() const {
103 // TODO(evanm): GetDisplayName should return UTF-16. 93 // TODO(evanm): GetDisplayName should return UTF-16.
104 return l10n_util::GetStringFUTF16(IDS_ADD_CERT_SUCCESS_INFOBAR_LABEL, 94 return l10n_util::GetStringFUTF16(IDS_ADD_CERT_SUCCESS_INFOBAR_LABEL,
105 base::UTF8ToUTF16( 95 base::UTF8ToUTF16(
106 cert_->issuer().GetDisplayName())); 96 cert_->issuer().GetDisplayName()));
107 } 97 }
108 98
109 int SSLAddCertificateInfoBarDelegate::GetButtons() const { 99 int SSLAddCertificateInfoBarDelegate::GetButtons() const {
(...skipping 23 matching lines...) Expand all
133 WebContents* web_contents = WebContents::FromRenderFrameHost( 123 WebContents* web_contents = WebContents::FromRenderFrameHost(
134 RenderFrameHost::FromID(render_process_id, render_frame_id)); 124 RenderFrameHost::FromID(render_process_id, render_frame_id));
135 if (!web_contents) 125 if (!web_contents)
136 return; 126 return;
137 127
138 // TODO(davidben): Use a more appropriate icon. 128 // TODO(davidben): Use a more appropriate icon.
139 // TODO(davidben): Display a more user-friendly error string. 129 // TODO(davidben): Display a more user-friendly error string.
140 SimpleAlertInfoBarDelegate::Create( 130 SimpleAlertInfoBarDelegate::Create(
141 InfoBarService::FromWebContents(web_contents), 131 InfoBarService::FromWebContents(web_contents),
142 infobars::InfoBarDelegate::SSL_ADD_CERTIFICATE, 132 infobars::InfoBarDelegate::SSL_ADD_CERTIFICATE,
143 IDR_INFOBAR_SAVE_PASSWORD, 133 0,
Peter Kasting 2016/09/23 00:45:09 (and similarly)
Evan Stade 2016/09/23 01:24:39 yes, this file isn't compiled on mobile.
144 #if !defined(OS_MACOSX)
145 gfx::VectorIconId::AUTOLOGIN, 134 gfx::VectorIconId::AUTOLOGIN,
146 #else
147 gfx::VectorIconId::VECTOR_ICON_NONE,
148 #endif
149 l10n_util::GetStringFUTF16( 135 l10n_util::GetStringFUTF16(
150 IDS_ADD_CERT_ERR_INVALID_CERT, base::IntToString16(-cert_error), 136 IDS_ADD_CERT_ERR_INVALID_CERT, base::IntToString16(-cert_error),
151 base::ASCIIToUTF16(net::ErrorToString(cert_error))), 137 base::ASCIIToUTF16(net::ErrorToString(cert_error))),
152 true); 138 true);
153 } 139 }
154 140
155 void ShowSuccessInfoBar(int render_process_id, 141 void ShowSuccessInfoBar(int render_process_id,
156 int render_frame_id, 142 int render_frame_id,
157 net::X509Certificate* cert) { 143 net::X509Certificate* cert) {
158 WebContents* web_contents = WebContents::FromRenderFrameHost( 144 WebContents* web_contents = WebContents::FromRenderFrameHost(
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 render_process_id, render_frame_id, cert_error)); 197 render_process_id, render_frame_id, cert_error));
212 } else { 198 } else {
213 BrowserThread::PostTask( 199 BrowserThread::PostTask(
214 BrowserThread::UI, FROM_HERE, 200 BrowserThread::UI, FROM_HERE,
215 base::Bind(&ShowSuccessInfoBar, render_process_id, render_frame_id, 201 base::Bind(&ShowSuccessInfoBar, render_process_id, render_frame_id,
216 base::RetainedRef(cert))); 202 base::RetainedRef(cert)));
217 } 203 }
218 } 204 }
219 205
220 } // namespace chrome 206 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/app/theme/theme_resources.grd ('k') | components/infobars/core/infobar_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698