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

Side by Side Diff: chrome/browser/cocoa/infobar_test_helper.h

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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/infobar_delegate.h" 5 #include "chrome/browser/tab_contents/infobar_delegate.h"
6 6
7 namespace { 7 namespace {
8 const wchar_t* kMockAlertInfoBarMessage = L"MockAlertInfoBarMessage"; 8 const char kMockAlertInfoBarMessage[] = "MockAlertInfoBarMessage";
9 const wchar_t* kMockLinkInfoBarMessage = L"MockLinkInfoBarMessage"; 9 const char kMockLinkInfoBarMessage[] = "MockLinkInfoBarMessage";
10 const wchar_t* kMockLinkInfoBarLink = L"http://dev.chromium.org"; 10 const char kMockLinkInfoBarLink[] = "http://dev.chromium.org";
11 const wchar_t* kMockConfirmInfoBarMessage = L"MockConfirmInfoBarMessage"; 11 const char kMockConfirmInfoBarMessage[] = "MockConfirmInfoBarMessage";
12 } 12 }
13 13
14 ////////////////////////////////////////////////////////////////////////// 14 //////////////////////////////////////////////////////////////////////////
15 // Mock InfoBarDelgates 15 // Mock InfoBarDelgates
16 16
17 class MockAlertInfoBarDelegate : public AlertInfoBarDelegate { 17 class MockAlertInfoBarDelegate : public AlertInfoBarDelegate {
18 public: 18 public:
19 explicit MockAlertInfoBarDelegate() 19 explicit MockAlertInfoBarDelegate()
20 : AlertInfoBarDelegate(NULL), 20 : AlertInfoBarDelegate(NULL),
21 message_text_accessed(false), 21 message_text_accessed(false),
22 icon_accessed(false), 22 icon_accessed(false),
23 closed(false) { 23 closed(false) {
24 } 24 }
25 25
26 virtual std::wstring GetMessageText() const { 26 virtual string16 GetMessageText() const {
27 message_text_accessed = true; 27 message_text_accessed = true;
28 return kMockAlertInfoBarMessage; 28 return ASCIIToUTF16(kMockAlertInfoBarMessage);
29 } 29 }
30 30
31 virtual SkBitmap* GetIcon() const { 31 virtual SkBitmap* GetIcon() const {
32 icon_accessed = true; 32 icon_accessed = true;
33 return NULL; 33 return NULL;
34 } 34 }
35 35
36 virtual void InfoBarClosed() { 36 virtual void InfoBarClosed() {
37 closed = true; 37 closed = true;
38 } 38 }
39 39
40 // These are declared mutable to get around const-ness issues. 40 // These are declared mutable to get around const-ness issues.
41 mutable bool message_text_accessed; 41 mutable bool message_text_accessed;
42 mutable bool icon_accessed; 42 mutable bool icon_accessed;
43 bool closed; 43 bool closed;
44 }; 44 };
45 45
46 class MockLinkInfoBarDelegate : public LinkInfoBarDelegate { 46 class MockLinkInfoBarDelegate : public LinkInfoBarDelegate {
47 public: 47 public:
48 explicit MockLinkInfoBarDelegate() 48 explicit MockLinkInfoBarDelegate()
49 : LinkInfoBarDelegate(NULL), 49 : LinkInfoBarDelegate(NULL),
50 message_text_accessed(false), 50 message_text_accessed(false),
51 link_text_accessed(false), 51 link_text_accessed(false),
52 icon_accessed(false), 52 icon_accessed(false),
53 link_clicked(false), 53 link_clicked(false),
54 closed(false), 54 closed(false),
55 closes_on_action(true) { 55 closes_on_action(true) {
56 } 56 }
57 57
58 virtual std::wstring GetMessageTextWithOffset(size_t* link_offset) const { 58 virtual string16 GetMessageTextWithOffset(size_t* link_offset) const {
59 message_text_accessed = true; 59 message_text_accessed = true;
60 return kMockLinkInfoBarMessage; 60 return ASCIIToUTF16(kMockLinkInfoBarMessage);
61 } 61 }
62 62
63 virtual std::wstring GetLinkText() const { 63 virtual string16 GetLinkText() const {
64 link_text_accessed = true; 64 link_text_accessed = true;
65 return kMockLinkInfoBarLink; 65 return ASCIIToUTF16(kMockLinkInfoBarLink);
66 } 66 }
67 67
68 virtual SkBitmap* GetIcon() const { 68 virtual SkBitmap* GetIcon() const {
69 icon_accessed = true; 69 icon_accessed = true;
70 return NULL; 70 return NULL;
71 } 71 }
72 72
73 virtual bool LinkClicked(WindowOpenDisposition disposition) { 73 virtual bool LinkClicked(WindowOpenDisposition disposition) {
74 link_clicked = true; 74 link_clicked = true;
75 return closes_on_action; 75 return closes_on_action;
(...skipping 25 matching lines...) Expand all
101 cancel_clicked(false), 101 cancel_clicked(false),
102 link_clicked(false), 102 link_clicked(false),
103 closed(false), 103 closed(false),
104 closes_on_action(true) { 104 closes_on_action(true) {
105 } 105 }
106 106
107 virtual int GetButtons() const { 107 virtual int GetButtons() const {
108 return (BUTTON_OK | BUTTON_CANCEL); 108 return (BUTTON_OK | BUTTON_CANCEL);
109 } 109 }
110 110
111 virtual std::wstring GetButtonLabel(InfoBarButton button) const { 111 virtual string16 GetButtonLabel(InfoBarButton button) const {
112 if (button == BUTTON_OK) 112 if (button == BUTTON_OK)
113 return L"OK"; 113 return ASCIIToUTF16("OK");
114 else 114 else
115 return L"Cancel"; 115 return ASCIIToUTF16("Cancel");
116 } 116 }
117 117
118 virtual bool Accept() { 118 virtual bool Accept() {
119 ok_clicked = true; 119 ok_clicked = true;
120 return closes_on_action; 120 return closes_on_action;
121 } 121 }
122 122
123 virtual bool Cancel() { 123 virtual bool Cancel() {
124 cancel_clicked = true; 124 cancel_clicked = true;
125 return closes_on_action; 125 return closes_on_action;
126 } 126 }
127 127
128 virtual std::wstring GetMessageText() const { 128 virtual string16 GetMessageText() const {
129 message_text_accessed = true; 129 message_text_accessed = true;
130 return kMockConfirmInfoBarMessage; 130 return ASCIIToUTF16(kMockConfirmInfoBarMessage);
131 } 131 }
132 132
133 virtual SkBitmap* GetIcon() const { 133 virtual SkBitmap* GetIcon() const {
134 icon_accessed = true; 134 icon_accessed = true;
135 return NULL; 135 return NULL;
136 } 136 }
137 137
138 virtual void InfoBarClosed() { 138 virtual void InfoBarClosed() {
139 closed = true; 139 closed = true;
140 } 140 }
141 141
142 virtual std::wstring GetLinkText() { 142 virtual string16 GetLinkText() {
143 link_text_accessed = true; 143 link_text_accessed = true;
144 return std::wstring(); 144 return string16();
145 } 145 }
146 146
147 virtual bool LinkClicked(WindowOpenDisposition disposition) { 147 virtual bool LinkClicked(WindowOpenDisposition disposition) {
148 link_clicked = true; 148 link_clicked = true;
149 return closes_on_action; 149 return closes_on_action;
150 } 150 }
151 151
152 // These are declared mutable to get around const-ness issues. 152 // These are declared mutable to get around const-ness issues.
153 mutable bool message_text_accessed; 153 mutable bool message_text_accessed;
154 mutable bool link_text_accessed; 154 mutable bool link_text_accessed;
155 mutable bool icon_accessed; 155 mutable bool icon_accessed;
156 bool ok_clicked; 156 bool ok_clicked;
157 bool cancel_clicked; 157 bool cancel_clicked;
158 bool link_clicked; 158 bool link_clicked;
159 bool closed; 159 bool closed;
160 160
161 // Determines whether the infobar closes when an action is taken or not. 161 // Determines whether the infobar closes when an action is taken or not.
162 bool closes_on_action; 162 bool closes_on_action;
163 }; 163 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698