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

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

Issue 1520543004: Add method for identifying different InfoBars (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebasing Created 5 years 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
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/basictypes.h" 7 #include "base/basictypes.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 "chrome/browser/certificate_viewer.h" 10 #include "chrome/browser/certificate_viewer.h"
(...skipping 26 matching lines...) Expand all
37 // the infobar to |infobar_service|. 37 // the infobar to |infobar_service|.
38 static void Create(InfoBarService* infobar_service, 38 static void Create(InfoBarService* infobar_service,
39 net::X509Certificate* cert); 39 net::X509Certificate* cert);
40 40
41 private: 41 private:
42 explicit SSLAddCertificateInfoBarDelegate(net::X509Certificate* cert); 42 explicit SSLAddCertificateInfoBarDelegate(net::X509Certificate* cert);
43 ~SSLAddCertificateInfoBarDelegate() override; 43 ~SSLAddCertificateInfoBarDelegate() override;
44 44
45 // ConfirmInfoBarDelegate: 45 // ConfirmInfoBarDelegate:
46 Type GetInfoBarType() const override; 46 Type GetInfoBarType() const override;
47 std::string GetIdentifier() const override;
47 int GetIconId() const override; 48 int GetIconId() const override;
48 gfx::VectorIconId GetVectorIconId() const override; 49 gfx::VectorIconId GetVectorIconId() const override;
49 base::string16 GetMessageText() const override; 50 base::string16 GetMessageText() const override;
50 int GetButtons() const override; 51 int GetButtons() const override;
51 base::string16 GetButtonLabel(InfoBarButton button) const override; 52 base::string16 GetButtonLabel(InfoBarButton button) const override;
52 bool Accept() override; 53 bool Accept() override;
53 54
54 // The certificate that was added. 55 // The certificate that was added.
55 scoped_refptr<net::X509Certificate> cert_; 56 scoped_refptr<net::X509Certificate> cert_;
56 57
(...skipping 14 matching lines...) Expand all
71 } 72 }
72 73
73 SSLAddCertificateInfoBarDelegate::~SSLAddCertificateInfoBarDelegate() { 74 SSLAddCertificateInfoBarDelegate::~SSLAddCertificateInfoBarDelegate() {
74 } 75 }
75 76
76 infobars::InfoBarDelegate::Type 77 infobars::InfoBarDelegate::Type
77 SSLAddCertificateInfoBarDelegate::GetInfoBarType() const { 78 SSLAddCertificateInfoBarDelegate::GetInfoBarType() const {
78 return PAGE_ACTION_TYPE; 79 return PAGE_ACTION_TYPE;
79 } 80 }
80 81
82 std::string SSLAddCertificateInfoBarDelegate::GetIdentifier() const {
83 return "SSLAddCertificateInfoBarDelegate";
84 }
85
81 int SSLAddCertificateInfoBarDelegate::GetIconId() const { 86 int SSLAddCertificateInfoBarDelegate::GetIconId() const {
82 // TODO(davidben): Use a more appropriate icon. 87 // TODO(davidben): Use a more appropriate icon.
83 return IDR_INFOBAR_SAVE_PASSWORD; 88 return IDR_INFOBAR_SAVE_PASSWORD;
84 } 89 }
85 90
86 gfx::VectorIconId SSLAddCertificateInfoBarDelegate::GetVectorIconId() const { 91 gfx::VectorIconId SSLAddCertificateInfoBarDelegate::GetVectorIconId() const {
87 #if !defined(OS_MACOSX) 92 #if !defined(OS_MACOSX)
88 return gfx::VectorIconId::AUTOLOGIN; 93 return gfx::VectorIconId::AUTOLOGIN;
89 #else 94 #else
90 return gfx::VectorIconId::VECTOR_ICON_NONE; 95 return gfx::VectorIconId::VECTOR_ICON_NONE;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 int render_frame_id, 128 int render_frame_id,
124 int cert_error) { 129 int cert_error) {
125 WebContents* web_contents = WebContents::FromRenderFrameHost( 130 WebContents* web_contents = WebContents::FromRenderFrameHost(
126 RenderFrameHost::FromID(render_process_id, render_frame_id)); 131 RenderFrameHost::FromID(render_process_id, render_frame_id));
127 if (!web_contents) 132 if (!web_contents)
128 return; 133 return;
129 134
130 // TODO(davidben): Use a more appropriate icon. 135 // TODO(davidben): Use a more appropriate icon.
131 // TODO(davidben): Display a more user-friendly error string. 136 // TODO(davidben): Display a more user-friendly error string.
132 SimpleAlertInfoBarDelegate::Create( 137 SimpleAlertInfoBarDelegate::Create(
133 InfoBarService::FromWebContents(web_contents), IDR_INFOBAR_SAVE_PASSWORD, 138 InfoBarService::FromWebContents(web_contents),
139 "SSLAddCertificate",
140 IDR_INFOBAR_SAVE_PASSWORD,
134 #if !defined(OS_MACOSX) 141 #if !defined(OS_MACOSX)
135 gfx::VectorIconId::AUTOLOGIN, 142 gfx::VectorIconId::AUTOLOGIN,
136 #else 143 #else
137 gfx::VectorIconId::VECTOR_ICON_NONE, 144 gfx::VectorIconId::VECTOR_ICON_NONE,
138 #endif 145 #endif
139 l10n_util::GetStringFUTF16( 146 l10n_util::GetStringFUTF16(
140 IDS_ADD_CERT_ERR_INVALID_CERT, base::IntToString16(-cert_error), 147 IDS_ADD_CERT_ERR_INVALID_CERT, base::IntToString16(-cert_error),
141 base::ASCIIToUTF16(net::ErrorToString(cert_error))), 148 base::ASCIIToUTF16(net::ErrorToString(cert_error))),
142 true); 149 true);
143 } 150 }
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 render_process_id, render_frame_id, cert_error)); 208 render_process_id, render_frame_id, cert_error));
202 } else { 209 } else {
203 BrowserThread::PostTask( 210 BrowserThread::PostTask(
204 BrowserThread::UI, FROM_HERE, 211 BrowserThread::UI, FROM_HERE,
205 base::Bind(&ShowSuccessInfoBar, 212 base::Bind(&ShowSuccessInfoBar,
206 render_process_id, render_frame_id, cert)); 213 render_process_id, render_frame_id, cert));
207 } 214 }
208 } 215 }
209 216
210 } // namespace chrome 217 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698