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

Side by Side Diff: trunk/src/chrome/browser/ssl/ssl_tab_helper.cc

Issue 102163002: Revert 238283 "Infobar system refactor." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 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 | Annotate | Revision Log
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_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 24 matching lines...) Expand all
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 37
38 38
39 // SSLCertResultInfoBarDelegate ----------------------------------------------- 39 // SSLCertResultInfoBarDelegate -----------------------------------------------
40 40
41 namespace { 41 namespace {
42 42
43 class SSLCertResultInfoBarDelegate : public ConfirmInfoBarDelegate { 43 class SSLCertResultInfoBarDelegate : public ConfirmInfoBarDelegate {
44 public: 44 public:
45 // Creates an SSL cert result infobar and delegate. If |previous_infobar| is 45 // Creates an SSL cert result infobar delegate. If |previous_infobar| is
46 // NULL, adds the infobar to |infobar_service|; otherwise, replaces 46 // NULL, adds the infobar to |infobar_service|; otherwise, replaces
47 // |previous_infobar|. Returns the new infobar if it was successfully added. 47 // |previous_infobar|. Returns the new infobar if it was successfully added.
48 // |cert| is valid iff cert addition was successful. 48 // |cert| is valid iff cert addition was successful.
49 static InfoBar* Create(InfoBarService* infobar_service, 49 static InfoBarDelegate* Create(InfoBarService* infobar_service,
50 InfoBar* previous_infobar, 50 InfoBarDelegate* previous_infobar,
51 const string16& message, 51 const string16& message,
52 net::X509Certificate* cert); 52 net::X509Certificate* cert);
53 53
54 private: 54 private:
55 SSLCertResultInfoBarDelegate(const string16& message, 55 SSLCertResultInfoBarDelegate(InfoBarService* infobar_service,
56 const string16& message,
56 net::X509Certificate* cert); 57 net::X509Certificate* cert);
57 virtual ~SSLCertResultInfoBarDelegate(); 58 virtual ~SSLCertResultInfoBarDelegate();
58 59
59 // ConfirmInfoBarDelegate: 60 // ConfirmInfoBarDelegate:
60 virtual int GetIconID() const OVERRIDE; 61 virtual int GetIconID() const OVERRIDE;
61 virtual Type GetInfoBarType() const OVERRIDE; 62 virtual Type GetInfoBarType() const OVERRIDE;
62 virtual string16 GetMessageText() const OVERRIDE; 63 virtual string16 GetMessageText() const OVERRIDE;
63 virtual int GetButtons() const OVERRIDE; 64 virtual int GetButtons() const OVERRIDE;
64 virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE; 65 virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE;
65 virtual bool Accept() OVERRIDE; 66 virtual bool Accept() OVERRIDE;
66 67
67 string16 message_; 68 string16 message_;
68 scoped_refptr<net::X509Certificate> cert_; // The cert we added, if any. 69 scoped_refptr<net::X509Certificate> cert_; // The cert we added, if any.
69 70
70 DISALLOW_COPY_AND_ASSIGN(SSLCertResultInfoBarDelegate); 71 DISALLOW_COPY_AND_ASSIGN(SSLCertResultInfoBarDelegate);
71 }; 72 };
72 73
73 // static 74 // static
74 InfoBar* SSLCertResultInfoBarDelegate::Create(InfoBarService* infobar_service, 75 InfoBarDelegate* SSLCertResultInfoBarDelegate::Create(
75 InfoBar* previous_infobar, 76 InfoBarService* infobar_service,
76 const string16& message, 77 InfoBarDelegate* previous_infobar,
77 net::X509Certificate* cert) { 78 const string16& message,
78 scoped_ptr<InfoBar> infobar(ConfirmInfoBarDelegate::CreateInfoBar( 79 net::X509Certificate* cert) {
79 scoped_ptr<ConfirmInfoBarDelegate>( 80 scoped_ptr<InfoBarDelegate> infobar(
80 new SSLCertResultInfoBarDelegate(message, cert)))); 81 new SSLCertResultInfoBarDelegate(infobar_service, message, cert));
81 return previous_infobar ? 82 return previous_infobar ?
82 infobar_service->ReplaceInfoBar(previous_infobar, infobar.Pass()) : 83 infobar_service->ReplaceInfoBar(previous_infobar, infobar.Pass()) :
83 infobar_service->AddInfoBar(infobar.Pass()); 84 infobar_service->AddInfoBar(infobar.Pass());
84 } 85 }
85 86
86 SSLCertResultInfoBarDelegate::SSLCertResultInfoBarDelegate( 87 SSLCertResultInfoBarDelegate::SSLCertResultInfoBarDelegate(
88 InfoBarService* infobar_service,
87 const string16& message, 89 const string16& message,
88 net::X509Certificate* cert) 90 net::X509Certificate* cert)
89 : ConfirmInfoBarDelegate(), 91 : ConfirmInfoBarDelegate(infobar_service),
90 message_(message), 92 message_(message),
91 cert_(cert) { 93 cert_(cert) {
92 } 94 }
93 95
94 SSLCertResultInfoBarDelegate::~SSLCertResultInfoBarDelegate() { 96 SSLCertResultInfoBarDelegate::~SSLCertResultInfoBarDelegate() {
95 } 97 }
96 98
97 int SSLCertResultInfoBarDelegate::GetIconID() const { 99 int SSLCertResultInfoBarDelegate::GetIconID() const {
98 // TODO(davidben): use a more appropriate icon. 100 // TODO(davidben): use a more appropriate icon.
99 return IDR_INFOBAR_SAVE_PASSWORD; 101 return IDR_INFOBAR_SAVE_PASSWORD;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 // Displays an infobar, replacing |infobar_| if it exists. 140 // Displays an infobar, replacing |infobar_| if it exists.
139 void ShowInfoBar(const string16& message, net::X509Certificate* cert); 141 void ShowInfoBar(const string16& message, net::X509Certificate* cert);
140 142
141 private: 143 private:
142 // content::NotificationObserver: 144 // content::NotificationObserver:
143 virtual void Observe(int type, 145 virtual void Observe(int type,
144 const content::NotificationSource& source, 146 const content::NotificationSource& source,
145 const content::NotificationDetails& details) OVERRIDE; 147 const content::NotificationDetails& details) OVERRIDE;
146 148
147 InfoBarService* infobar_service_; 149 InfoBarService* infobar_service_;
148 InfoBar* infobar_; 150 InfoBarDelegate* infobar_;
149 content::NotificationRegistrar registrar_; 151 content::NotificationRegistrar registrar_;
150 152
151 DISALLOW_COPY_AND_ASSIGN(SSLAddCertData); 153 DISALLOW_COPY_AND_ASSIGN(SSLAddCertData);
152 }; 154 };
153 155
154 SSLTabHelper::SSLAddCertData::SSLAddCertData(InfoBarService* infobar_service) 156 SSLTabHelper::SSLAddCertData::SSLAddCertData(InfoBarService* infobar_service)
155 : infobar_service_(infobar_service), 157 : infobar_service_(infobar_service),
156 infobar_(NULL) { 158 infobar_(NULL) {
157 content::Source<InfoBarService> source(infobar_service_); 159 content::Source<InfoBarService> source(infobar_service_);
158 registrar_.Add(this, chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED, 160 registrar_.Add(this, chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED,
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 // Find/create the slot. 262 // Find/create the slot.
261 linked_ptr<SSLAddCertData>& ptr_ref = 263 linked_ptr<SSLAddCertData>& ptr_ref =
262 request_id_to_add_cert_data_[handler->network_request_id()]; 264 request_id_to_add_cert_data_[handler->network_request_id()];
263 // Fill it if necessary. 265 // Fill it if necessary.
264 if (!ptr_ref.get()) { 266 if (!ptr_ref.get()) {
265 ptr_ref.reset( 267 ptr_ref.reset(
266 new SSLAddCertData(InfoBarService::FromWebContents(web_contents_))); 268 new SSLAddCertData(InfoBarService::FromWebContents(web_contents_)));
267 } 269 }
268 return ptr_ref.get(); 270 return ptr_ref.get();
269 } 271 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698