| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/tab_contents/tab_contents_ssl_helper.h" | 5 #include "chrome/browser/tab_contents/tab_contents_ssl_helper.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/string_number_conversions.h" | 8 #include "base/string_number_conversions.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "chrome/browser/ssl/ssl_add_cert_handler.h" | 10 #include "chrome/browser/ssl/ssl_add_cert_handler.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 | 35 |
| 36 class SSLCertAddedInfoBarDelegate : public ConfirmInfoBarDelegate { | 36 class SSLCertAddedInfoBarDelegate : public ConfirmInfoBarDelegate { |
| 37 public: | 37 public: |
| 38 SSLCertAddedInfoBarDelegate(TabContents* tab_contents, | 38 SSLCertAddedInfoBarDelegate(TabContents* tab_contents, |
| 39 net::X509Certificate* cert); | 39 net::X509Certificate* cert); |
| 40 | 40 |
| 41 private: | 41 private: |
| 42 virtual ~SSLCertAddedInfoBarDelegate(); | 42 virtual ~SSLCertAddedInfoBarDelegate(); |
| 43 | 43 |
| 44 // ConfirmInfoBarDelegate: | 44 // ConfirmInfoBarDelegate: |
| 45 virtual void InfoBarClosed(); | 45 virtual gfx::Image* GetIcon() const OVERRIDE; |
| 46 virtual gfx::Image* GetIcon() const; | 46 virtual Type GetInfoBarType() const OVERRIDE; |
| 47 virtual Type GetInfoBarType() const; | 47 virtual string16 GetMessageText() const OVERRIDE; |
| 48 virtual string16 GetMessageText() const; | 48 virtual int GetButtons() const OVERRIDE; |
| 49 virtual int GetButtons() const; | 49 virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE; |
| 50 virtual string16 GetButtonLabel(InfoBarButton button) const; | 50 virtual bool Accept() OVERRIDE; |
| 51 virtual bool Accept(); | |
| 52 | 51 |
| 53 TabContents* tab_contents_; // The TabContents we are attached to. | 52 TabContents* tab_contents_; // The TabContents we are attached to. |
| 54 scoped_refptr<net::X509Certificate> cert_; // The cert we added. | 53 scoped_refptr<net::X509Certificate> cert_; // The cert we added. |
| 55 }; | 54 }; |
| 56 | 55 |
| 57 SSLCertAddedInfoBarDelegate::SSLCertAddedInfoBarDelegate( | 56 SSLCertAddedInfoBarDelegate::SSLCertAddedInfoBarDelegate( |
| 58 TabContents* tab_contents, | 57 TabContents* tab_contents, |
| 59 net::X509Certificate* cert) | 58 net::X509Certificate* cert) |
| 60 : ConfirmInfoBarDelegate(tab_contents), | 59 : ConfirmInfoBarDelegate(tab_contents), |
| 61 tab_contents_(tab_contents), | 60 tab_contents_(tab_contents), |
| 62 cert_(cert) { | 61 cert_(cert) { |
| 63 } | 62 } |
| 64 | 63 |
| 65 SSLCertAddedInfoBarDelegate::~SSLCertAddedInfoBarDelegate() { | 64 SSLCertAddedInfoBarDelegate::~SSLCertAddedInfoBarDelegate() { |
| 66 } | 65 } |
| 67 | 66 |
| 68 void SSLCertAddedInfoBarDelegate::InfoBarClosed() { | |
| 69 // ConfirmInfoBarDelegate doesn't delete itself. | |
| 70 delete this; | |
| 71 } | |
| 72 | |
| 73 gfx::Image* SSLCertAddedInfoBarDelegate::GetIcon() const { | 67 gfx::Image* SSLCertAddedInfoBarDelegate::GetIcon() const { |
| 74 return GetCertIcon(); | 68 return GetCertIcon(); |
| 75 } | 69 } |
| 76 | 70 |
| 77 InfoBarDelegate::Type SSLCertAddedInfoBarDelegate::GetInfoBarType() const { | 71 InfoBarDelegate::Type SSLCertAddedInfoBarDelegate::GetInfoBarType() const { |
| 78 return PAGE_ACTION_TYPE; | 72 return PAGE_ACTION_TYPE; |
| 79 } | 73 } |
| 80 | 74 |
| 81 string16 SSLCertAddedInfoBarDelegate::GetMessageText() const { | 75 string16 SSLCertAddedInfoBarDelegate::GetMessageText() const { |
| 82 // TODO(evanm): GetDisplayName should return UTF-16. | 76 // TODO(evanm): GetDisplayName should return UTF-16. |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 TabContentsSSLHelper::SSLAddCertData* TabContentsSSLHelper::GetAddCertData( | 222 TabContentsSSLHelper::SSLAddCertData* TabContentsSSLHelper::GetAddCertData( |
| 229 SSLAddCertHandler* handler) { | 223 SSLAddCertHandler* handler) { |
| 230 // Find/create the slot. | 224 // Find/create the slot. |
| 231 linked_ptr<SSLAddCertData>& ptr_ref = | 225 linked_ptr<SSLAddCertData>& ptr_ref = |
| 232 request_id_to_add_cert_data_[handler->network_request_id()]; | 226 request_id_to_add_cert_data_[handler->network_request_id()]; |
| 233 // Fill it if necessary. | 227 // Fill it if necessary. |
| 234 if (!ptr_ref.get()) | 228 if (!ptr_ref.get()) |
| 235 ptr_ref.reset(new SSLAddCertData(tab_contents_)); | 229 ptr_ref.reset(new SSLAddCertData(tab_contents_)); |
| 236 return ptr_ref.get(); | 230 return ptr_ref.get(); |
| 237 } | 231 } |
| OLD | NEW |