OLD | NEW |
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 25 matching lines...) Expand all Loading... |
36 static void Create(InfoBarService* infobar_service, | 36 static void Create(InfoBarService* infobar_service, |
37 net::X509Certificate* cert) { | 37 net::X509Certificate* cert) { |
38 infobar_service->AddInfoBar(ConfirmInfoBarDelegate::CreateInfoBar( | 38 infobar_service->AddInfoBar(ConfirmInfoBarDelegate::CreateInfoBar( |
39 scoped_ptr<ConfirmInfoBarDelegate>( | 39 scoped_ptr<ConfirmInfoBarDelegate>( |
40 new SSLAddCertificateInfoBarDelegate(cert)))); | 40 new SSLAddCertificateInfoBarDelegate(cert)))); |
41 } | 41 } |
42 | 42 |
43 private: | 43 private: |
44 explicit SSLAddCertificateInfoBarDelegate(net::X509Certificate* cert) | 44 explicit SSLAddCertificateInfoBarDelegate(net::X509Certificate* cert) |
45 : cert_(cert) {} | 45 : cert_(cert) {} |
46 virtual ~SSLAddCertificateInfoBarDelegate() {} | 46 ~SSLAddCertificateInfoBarDelegate() override {} |
47 | 47 |
48 // ConfirmInfoBarDelegate implementation: | 48 // ConfirmInfoBarDelegate implementation: |
49 virtual int GetIconID() const override { | 49 int GetIconID() const override { |
50 // TODO(davidben): Use a more appropriate icon. | 50 // TODO(davidben): Use a more appropriate icon. |
51 return IDR_INFOBAR_SAVE_PASSWORD; | 51 return IDR_INFOBAR_SAVE_PASSWORD; |
52 } | 52 } |
53 | 53 |
54 virtual Type GetInfoBarType() const override { | 54 Type GetInfoBarType() const override { return PAGE_ACTION_TYPE; } |
55 return PAGE_ACTION_TYPE; | |
56 } | |
57 | 55 |
58 virtual base::string16 GetMessageText() const override { | 56 base::string16 GetMessageText() const override { |
59 // TODO(evanm): GetDisplayName should return UTF-16. | 57 // TODO(evanm): GetDisplayName should return UTF-16. |
60 return l10n_util::GetStringFUTF16(IDS_ADD_CERT_SUCCESS_INFOBAR_LABEL, | 58 return l10n_util::GetStringFUTF16(IDS_ADD_CERT_SUCCESS_INFOBAR_LABEL, |
61 base::UTF8ToUTF16( | 59 base::UTF8ToUTF16( |
62 cert_->issuer().GetDisplayName())); | 60 cert_->issuer().GetDisplayName())); |
63 } | 61 } |
64 | 62 |
65 virtual int GetButtons() const override { | 63 int GetButtons() const override { return BUTTON_OK; } |
66 return BUTTON_OK; | |
67 } | |
68 | 64 |
69 virtual base::string16 GetButtonLabel(InfoBarButton button) const override { | 65 base::string16 GetButtonLabel(InfoBarButton button) const override { |
70 DCHECK_EQ(BUTTON_OK, button); | 66 DCHECK_EQ(BUTTON_OK, button); |
71 return l10n_util::GetStringUTF16(IDS_ADD_CERT_SUCCESS_INFOBAR_BUTTON); | 67 return l10n_util::GetStringUTF16(IDS_ADD_CERT_SUCCESS_INFOBAR_BUTTON); |
72 } | 68 } |
73 | 69 |
74 virtual bool Accept() override { | 70 bool Accept() override { |
75 WebContents* web_contents = | 71 WebContents* web_contents = |
76 InfoBarService::WebContentsFromInfoBar(infobar()); | 72 InfoBarService::WebContentsFromInfoBar(infobar()); |
77 ShowCertificateViewer(web_contents, | 73 ShowCertificateViewer(web_contents, |
78 web_contents->GetTopLevelNativeWindow(), | 74 web_contents->GetTopLevelNativeWindow(), |
79 cert_.get()); | 75 cert_.get()); |
80 // It looks weird to hide the infobar just as the dialog opens. | 76 // It looks weird to hide the infobar just as the dialog opens. |
81 return false; | 77 return false; |
82 } | 78 } |
83 | 79 |
84 // The certificate that was added. | 80 // The certificate that was added. |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 render_process_id, render_frame_id, cert_error)); | 163 render_process_id, render_frame_id, cert_error)); |
168 } else { | 164 } else { |
169 BrowserThread::PostTask( | 165 BrowserThread::PostTask( |
170 BrowserThread::UI, FROM_HERE, | 166 BrowserThread::UI, FROM_HERE, |
171 base::Bind(&ShowSuccessInfoBar, | 167 base::Bind(&ShowSuccessInfoBar, |
172 render_process_id, render_frame_id, cert)); | 168 render_process_id, render_frame_id, cert)); |
173 } | 169 } |
174 } | 170 } |
175 | 171 |
176 } // namespace chrome | 172 } // namespace chrome |
OLD | NEW |