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

Side by Side Diff: chrome/browser/tab_contents/tab_contents_ssl_helper.cc

Issue 3127009: Convert infobar APIs to UTF-16. (Closed)
Patch Set: works Created 10 years, 4 months 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "app/l10n_util.h" 7 #include "app/l10n_util.h"
8 #include "app/resource_bundle.h" 8 #include "app/resource_bundle.h"
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/string_number_conversions.h" 10 #include "base/string_number_conversions.h"
(...skipping 23 matching lines...) Expand all
34 net::X509Certificate* cert) 34 net::X509Certificate* cert)
35 : ConfirmInfoBarDelegate(tab_contents), 35 : ConfirmInfoBarDelegate(tab_contents),
36 tab_contents_(tab_contents), 36 tab_contents_(tab_contents),
37 cert_(cert) { 37 cert_(cert) {
38 } 38 }
39 39
40 virtual ~SSLCertAddedInfoBarDelegate() { 40 virtual ~SSLCertAddedInfoBarDelegate() {
41 } 41 }
42 42
43 // Overridden from ConfirmInfoBarDelegate: 43 // Overridden from ConfirmInfoBarDelegate:
44 virtual std::wstring GetMessageText() const { 44 virtual string16 GetMessageText() const {
45 return l10n_util::GetStringF(IDS_ADD_CERT_SUCCESS_INFOBAR_LABEL, 45 // TODO(evanm): GetDisplayName should return UTF-16.
46 UTF8ToWide(cert_->issuer().GetDisplayName())); 46 return l10n_util::GetStringFUTF16(
47 IDS_ADD_CERT_SUCCESS_INFOBAR_LABEL,
48 UTF8ToUTF16(cert_->issuer().GetDisplayName()));
47 } 49 }
48 50
49 virtual SkBitmap* GetIcon() const { 51 virtual SkBitmap* GetIcon() const {
50 return GetCertIcon(); 52 return GetCertIcon();
51 } 53 }
52 54
53 virtual int GetButtons() const { 55 virtual int GetButtons() const {
54 return BUTTON_OK; 56 return BUTTON_OK;
55 } 57 }
56 58
57 virtual std::wstring GetButtonLabel(InfoBarButton button) const { 59 virtual string16 GetButtonLabel(InfoBarButton button) const {
58 switch (button) { 60 switch (button) {
59 case BUTTON_OK: 61 case BUTTON_OK:
60 return l10n_util::GetString(IDS_ADD_CERT_SUCCESS_INFOBAR_BUTTON); 62 return l10n_util::GetStringUTF16(IDS_ADD_CERT_SUCCESS_INFOBAR_BUTTON);
61 default: 63 default:
62 return std::wstring(); 64 return string16();
63 } 65 }
64 } 66 }
65 67
66 virtual Type GetInfoBarType() { 68 virtual Type GetInfoBarType() {
67 return PAGE_ACTION_TYPE; 69 return PAGE_ACTION_TYPE;
68 } 70 }
69 71
70 virtual bool Accept() { 72 virtual bool Accept() {
71 ShowCertificateViewer(tab_contents_->GetMessageBoxRootWindow(), cert_); 73 ShowCertificateViewer(tab_contents_->GetMessageBoxRootWindow(), cert_);
72 return false; // Hiding the infobar just as the dialog opens looks weird. 74 return false; // Hiding the infobar just as the dialog opens looks weird.
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 // still active. 107 // still active.
106 void ShowInfoBar(InfoBarDelegate* delegate) { 108 void ShowInfoBar(InfoBarDelegate* delegate) {
107 if (infobar_delegate_) { 109 if (infobar_delegate_) {
108 tab_->ReplaceInfoBar(infobar_delegate_, delegate); 110 tab_->ReplaceInfoBar(infobar_delegate_, delegate);
109 } else { 111 } else {
110 tab_->AddInfoBar(delegate); 112 tab_->AddInfoBar(delegate);
111 } 113 }
112 infobar_delegate_ = delegate; 114 infobar_delegate_ = delegate;
113 } 115 }
114 116
115 void ShowErrorInfoBar(const std::wstring& message) { 117 void ShowErrorInfoBar(const std::wstring& message) {
viettrungluu 2010/08/13 19:22:03 We'll leave converting this to another day. ;)
116 ShowInfoBar( 118 ShowInfoBar(
117 new SimpleAlertInfoBarDelegate(tab_, message, GetCertIcon(), true)); 119 new SimpleAlertInfoBarDelegate(tab_, WideToUTF16(message), GetCertIcon() ,
viettrungluu 2010/08/13 19:22:03 80 cols
120 true));
118 } 121 }
119 122
120 // NotificationObserver implementation. 123 // NotificationObserver implementation.
121 virtual void Observe(NotificationType type, 124 virtual void Observe(NotificationType type,
122 const NotificationSource& source, 125 const NotificationSource& source,
123 const NotificationDetails& details) { 126 const NotificationDetails& details) {
124 switch (type.value) { 127 switch (type.value) {
125 case NotificationType::TAB_CONTENTS_INFOBAR_REMOVED: 128 case NotificationType::TAB_CONTENTS_INFOBAR_REMOVED:
126 InfoBarClosed(Details<InfoBarDelegate>(details).ptr()); 129 InfoBarClosed(Details<InfoBarDelegate>(details).ptr());
127 break; 130 break;
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 TabContentsSSLHelper::SSLAddCertData* TabContentsSSLHelper::GetAddCertData( 214 TabContentsSSLHelper::SSLAddCertData* TabContentsSSLHelper::GetAddCertData(
212 SSLAddCertHandler* handler) { 215 SSLAddCertHandler* handler) {
213 // Find/create the slot. 216 // Find/create the slot.
214 linked_ptr<SSLAddCertData>& ptr_ref = 217 linked_ptr<SSLAddCertData>& ptr_ref =
215 request_id_to_add_cert_data_[handler->network_request_id()]; 218 request_id_to_add_cert_data_[handler->network_request_id()];
216 // Fill it if necessary. 219 // Fill it if necessary.
217 if (!ptr_ref.get()) 220 if (!ptr_ref.get())
218 ptr_ref.reset(new SSLAddCertData(tab_contents_, handler)); 221 ptr_ref.reset(new SSLAddCertData(tab_contents_, handler));
219 return ptr_ref.get(); 222 return ptr_ref.get();
220 } 223 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698