| 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_tab_helper.h" | 5 #include "chrome/browser/ssl/ssl_tab_helper.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 #include "content/public/browser/notification_observer.h" | 27 #include "content/public/browser/notification_observer.h" |
| 28 #include "content/public/browser/notification_registrar.h" | 28 #include "content/public/browser/notification_registrar.h" |
| 29 #include "content/public/browser/notification_source.h" | 29 #include "content/public/browser/notification_source.h" |
| 30 #include "content/public/browser/web_contents.h" | 30 #include "content/public/browser/web_contents.h" |
| 31 #include "content/public/browser/web_contents_view.h" | 31 #include "content/public/browser/web_contents_view.h" |
| 32 #include "grit/generated_resources.h" | 32 #include "grit/generated_resources.h" |
| 33 #include "grit/theme_resources.h" | 33 #include "grit/theme_resources.h" |
| 34 #include "net/base/net_errors.h" | 34 #include "net/base/net_errors.h" |
| 35 #include "net/cert/x509_certificate.h" | 35 #include "net/cert/x509_certificate.h" |
| 36 #include "ui/base/l10n/l10n_util.h" | 36 #include "ui/base/l10n/l10n_util.h" |
| 37 #include "ui/base/resource/resource_bundle.h" | |
| 38 | 37 |
| 39 | 38 |
| 40 // SSLCertResultInfoBarDelegate ----------------------------------------------- | 39 // SSLCertResultInfoBarDelegate ----------------------------------------------- |
| 41 | 40 |
| 42 namespace { | 41 namespace { |
| 43 | 42 |
| 44 class SSLCertResultInfoBarDelegate : public ConfirmInfoBarDelegate { | 43 class SSLCertResultInfoBarDelegate : public ConfirmInfoBarDelegate { |
| 45 public: | 44 public: |
| 46 // Creates an SSL cert result delegate. If |previous_infobar| is | 45 // Creates an SSL cert result delegate. If |previous_infobar| is |
| 47 // NULL, adds the infobar to |infobar_service|; otherwise, replaces | 46 // NULL, adds the infobar to |infobar_service|; otherwise, replaces |
| 48 // |previous_infobar|. Returns the new delegate if it was successfully added. | 47 // |previous_infobar|. Returns the new delegate if it was successfully added. |
| 49 // |cert| is valid iff cert addition was successful. | 48 // |cert| is valid iff cert addition was successful. |
| 50 static InfoBarDelegate* Create(InfoBarService* infobar_service, | 49 static InfoBarDelegate* Create(InfoBarService* infobar_service, |
| 51 InfoBarDelegate* previous_infobar, | 50 InfoBarDelegate* previous_infobar, |
| 52 const string16& message, | 51 const string16& message, |
| 53 net::X509Certificate* cert); | 52 net::X509Certificate* cert); |
| 54 | 53 |
| 55 private: | 54 private: |
| 56 SSLCertResultInfoBarDelegate(InfoBarService* infobar_service, | 55 SSLCertResultInfoBarDelegate(InfoBarService* infobar_service, |
| 57 const string16& message, | 56 const string16& message, |
| 58 net::X509Certificate* cert); | 57 net::X509Certificate* cert); |
| 59 virtual ~SSLCertResultInfoBarDelegate(); | 58 virtual ~SSLCertResultInfoBarDelegate(); |
| 60 | 59 |
| 61 // ConfirmInfoBarDelegate: | 60 // ConfirmInfoBarDelegate: |
| 62 virtual gfx::Image* GetIcon() const OVERRIDE; | 61 virtual int GetIconID() const OVERRIDE; |
| 63 virtual Type GetInfoBarType() const OVERRIDE; | 62 virtual Type GetInfoBarType() const OVERRIDE; |
| 64 virtual string16 GetMessageText() const OVERRIDE; | 63 virtual string16 GetMessageText() const OVERRIDE; |
| 65 virtual int GetButtons() const OVERRIDE; | 64 virtual int GetButtons() const OVERRIDE; |
| 66 virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE; | 65 virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE; |
| 67 virtual bool Accept() OVERRIDE; | 66 virtual bool Accept() OVERRIDE; |
| 68 | 67 |
| 69 string16 message_; | 68 string16 message_; |
| 70 scoped_refptr<net::X509Certificate> cert_; // The cert we added, if any. | 69 scoped_refptr<net::X509Certificate> cert_; // The cert we added, if any. |
| 71 | 70 |
| 72 DISALLOW_COPY_AND_ASSIGN(SSLCertResultInfoBarDelegate); | 71 DISALLOW_COPY_AND_ASSIGN(SSLCertResultInfoBarDelegate); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 90 const string16& message, | 89 const string16& message, |
| 91 net::X509Certificate* cert) | 90 net::X509Certificate* cert) |
| 92 : ConfirmInfoBarDelegate(infobar_service), | 91 : ConfirmInfoBarDelegate(infobar_service), |
| 93 message_(message), | 92 message_(message), |
| 94 cert_(cert) { | 93 cert_(cert) { |
| 95 } | 94 } |
| 96 | 95 |
| 97 SSLCertResultInfoBarDelegate::~SSLCertResultInfoBarDelegate() { | 96 SSLCertResultInfoBarDelegate::~SSLCertResultInfoBarDelegate() { |
| 98 } | 97 } |
| 99 | 98 |
| 100 gfx::Image* SSLCertResultInfoBarDelegate::GetIcon() const { | 99 int SSLCertResultInfoBarDelegate::GetIconID() const { |
| 101 // TODO(davidben): use a more appropriate icon. | 100 // TODO(davidben): use a more appropriate icon. |
| 102 return &ResourceBundle::GetSharedInstance().GetNativeImageNamed( | 101 return IDR_INFOBAR_SAVE_PASSWORD; |
| 103 IDR_INFOBAR_SAVE_PASSWORD); | |
| 104 } | 102 } |
| 105 | 103 |
| 106 InfoBarDelegate::Type SSLCertResultInfoBarDelegate::GetInfoBarType() const { | 104 InfoBarDelegate::Type SSLCertResultInfoBarDelegate::GetInfoBarType() const { |
| 107 return cert_.get() ? PAGE_ACTION_TYPE : WARNING_TYPE; | 105 return cert_.get() ? PAGE_ACTION_TYPE : WARNING_TYPE; |
| 108 } | 106 } |
| 109 | 107 |
| 110 string16 SSLCertResultInfoBarDelegate::GetMessageText() const { | 108 string16 SSLCertResultInfoBarDelegate::GetMessageText() const { |
| 111 return message_; | 109 return message_; |
| 112 } | 110 } |
| 113 | 111 |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 SSLTabHelper::SSLAddCertData* | 265 SSLTabHelper::SSLAddCertData* |
| 268 SSLTabHelper::GetAddCertData(SSLAddCertHandler* handler) { | 266 SSLTabHelper::GetAddCertData(SSLAddCertHandler* handler) { |
| 269 // Find/create the slot. | 267 // Find/create the slot. |
| 270 linked_ptr<SSLAddCertData>& ptr_ref = | 268 linked_ptr<SSLAddCertData>& ptr_ref = |
| 271 request_id_to_add_cert_data_[handler->network_request_id()]; | 269 request_id_to_add_cert_data_[handler->network_request_id()]; |
| 272 // Fill it if necessary. | 270 // Fill it if necessary. |
| 273 if (!ptr_ref.get()) | 271 if (!ptr_ref.get()) |
| 274 ptr_ref.reset(new SSLAddCertData(web_contents_)); | 272 ptr_ref.reset(new SSLAddCertData(web_contents_)); |
| 275 return ptr_ref.get(); | 273 return ptr_ref.get(); |
| 276 } | 274 } |
| OLD | NEW |