OLD | NEW |
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/views/collected_cookies_win.h" | 5 #include "chrome/browser/views/collected_cookies_win.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 "chrome/browser/cookies_tree_model.h" | 9 #include "chrome/browser/cookies_tree_model.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 ContentSetting setting, | 73 ContentSetting setting, |
74 const std::wstring& domain_name) { | 74 const std::wstring& domain_name) { |
75 if (!is_visible) { | 75 if (!is_visible) { |
76 SetVisible(false); | 76 SetVisible(false); |
77 return; | 77 return; |
78 } | 78 } |
79 | 79 |
80 std::wstring label; | 80 std::wstring label; |
81 switch (setting) { | 81 switch (setting) { |
82 case CONTENT_SETTING_BLOCK: | 82 case CONTENT_SETTING_BLOCK: |
83 label = l10n_util::GetStringF( | 83 label = UTF16ToWide(l10n_util::GetStringFUTF16( |
84 IDS_COLLECTED_COOKIES_BLOCK_RULE_CREATED, domain_name); | 84 IDS_COLLECTED_COOKIES_BLOCK_RULE_CREATED, |
| 85 WideToUTF16(domain_name))); |
85 break; | 86 break; |
86 | 87 |
87 case CONTENT_SETTING_ALLOW: | 88 case CONTENT_SETTING_ALLOW: |
88 label = l10n_util::GetStringF( | 89 label = UTF16ToWide(l10n_util::GetStringFUTF16( |
89 IDS_COLLECTED_COOKIES_ALLOW_RULE_CREATED, domain_name); | 90 IDS_COLLECTED_COOKIES_ALLOW_RULE_CREATED, |
| 91 WideToUTF16(domain_name))); |
90 break; | 92 break; |
91 | 93 |
92 case CONTENT_SETTING_SESSION_ONLY: | 94 case CONTENT_SETTING_SESSION_ONLY: |
93 label = l10n_util::GetStringF( | 95 label = UTF16ToWide(l10n_util::GetStringFUTF16( |
94 IDS_COLLECTED_COOKIES_SESSION_RULE_CREATED, domain_name); | 96 IDS_COLLECTED_COOKIES_SESSION_RULE_CREATED, |
| 97 WideToUTF16(domain_name))); |
95 break; | 98 break; |
96 | 99 |
97 default: | 100 default: |
98 NOTREACHED(); | 101 NOTREACHED(); |
99 } | 102 } |
100 label_->SetText(label); | 103 label_->SetText(label); |
101 content_->Layout(); | 104 content_->Layout(); |
102 SetVisible(true); | 105 SetVisible(true); |
103 } | 106 } |
104 | 107 |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 blocked_cookies_tree_->SetModel(NULL); | 182 blocked_cookies_tree_->SetModel(NULL); |
180 } | 183 } |
181 | 184 |
182 void CollectedCookiesWin::Init() { | 185 void CollectedCookiesWin::Init() { |
183 TabSpecificContentSettings* content_settings = | 186 TabSpecificContentSettings* content_settings = |
184 tab_contents_->GetTabSpecificContentSettings(); | 187 tab_contents_->GetTabSpecificContentSettings(); |
185 HostContentSettingsMap* host_content_settings_map = | 188 HostContentSettingsMap* host_content_settings_map = |
186 tab_contents_->profile()->GetHostContentSettingsMap(); | 189 tab_contents_->profile()->GetHostContentSettingsMap(); |
187 | 190 |
188 // Allowed Cookie list. | 191 // Allowed Cookie list. |
189 allowed_label_ = new views::Label( | 192 allowed_label_ = new views::Label(UTF16ToWide(l10n_util::GetStringUTF16( |
190 l10n_util::GetString(IDS_COLLECTED_COOKIES_ALLOWED_COOKIES_LABEL)); | 193 IDS_COLLECTED_COOKIES_ALLOWED_COOKIES_LABEL))); |
191 allowed_cookies_tree_model_.reset( | 194 allowed_cookies_tree_model_.reset( |
192 content_settings->GetAllowedCookiesTreeModel()); | 195 content_settings->GetAllowedCookiesTreeModel()); |
193 allowed_cookies_tree_ = new views::TreeView(); | 196 allowed_cookies_tree_ = new views::TreeView(); |
194 allowed_cookies_tree_->SetModel(allowed_cookies_tree_model_.get()); | 197 allowed_cookies_tree_->SetModel(allowed_cookies_tree_model_.get()); |
195 allowed_cookies_tree_->SetController(this); | 198 allowed_cookies_tree_->SetController(this); |
196 allowed_cookies_tree_->SetRootShown(false); | 199 allowed_cookies_tree_->SetRootShown(false); |
197 allowed_cookies_tree_->SetEditable(false); | 200 allowed_cookies_tree_->SetEditable(false); |
198 allowed_cookies_tree_->set_lines_at_root(true); | 201 allowed_cookies_tree_->set_lines_at_root(true); |
199 allowed_cookies_tree_->set_auto_expand_children(true); | 202 allowed_cookies_tree_->set_auto_expand_children(true); |
200 | 203 |
201 // Blocked Cookie list. | 204 // Blocked Cookie list. |
202 blocked_label_ = new views::Label( | 205 blocked_label_ = new views::Label( |
203 l10n_util::GetString( | 206 UTF16ToWide(l10n_util::GetStringUTF16( |
204 host_content_settings_map->BlockThirdPartyCookies() ? | 207 host_content_settings_map->BlockThirdPartyCookies() ? |
205 IDS_COLLECTED_COOKIES_BLOCKED_THIRD_PARTY_BLOCKING_ENABLED : | 208 IDS_COLLECTED_COOKIES_BLOCKED_THIRD_PARTY_BLOCKING_ENABLED : |
206 IDS_COLLECTED_COOKIES_BLOCKED_COOKIES_LABEL)); | 209 IDS_COLLECTED_COOKIES_BLOCKED_COOKIES_LABEL))); |
207 blocked_label_->SetMultiLine(true); | 210 blocked_label_->SetMultiLine(true); |
208 blocked_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); | 211 blocked_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); |
209 blocked_cookies_tree_model_.reset( | 212 blocked_cookies_tree_model_.reset( |
210 content_settings->GetBlockedCookiesTreeModel()); | 213 content_settings->GetBlockedCookiesTreeModel()); |
211 blocked_cookies_tree_ = new views::TreeView(); | 214 blocked_cookies_tree_ = new views::TreeView(); |
212 blocked_cookies_tree_->SetModel(blocked_cookies_tree_model_.get()); | 215 blocked_cookies_tree_->SetModel(blocked_cookies_tree_model_.get()); |
213 blocked_cookies_tree_->SetController(this); | 216 blocked_cookies_tree_->SetController(this); |
214 blocked_cookies_tree_->SetRootShown(false); | 217 blocked_cookies_tree_->SetRootShown(false); |
215 blocked_cookies_tree_->SetEditable(false); | 218 blocked_cookies_tree_->SetEditable(false); |
216 blocked_cookies_tree_->set_lines_at_root(true); | 219 blocked_cookies_tree_->set_lines_at_root(true); |
(...skipping 21 matching lines...) Expand all Loading... |
238 layout->AddView(allowed_label_); | 241 layout->AddView(allowed_label_); |
239 | 242 |
240 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); | 243 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); |
241 layout->StartRow(1, single_column_layout_id); | 244 layout->StartRow(1, single_column_layout_id); |
242 layout->AddView( | 245 layout->AddView( |
243 allowed_cookies_tree_, 1, 1, GridLayout::FILL, GridLayout::FILL, | 246 allowed_cookies_tree_, 1, 1, GridLayout::FILL, GridLayout::FILL, |
244 kTreeViewWidth, kTreeViewHeight); | 247 kTreeViewWidth, kTreeViewHeight); |
245 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); | 248 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); |
246 | 249 |
247 layout->StartRow(0, single_column_layout_id); | 250 layout->StartRow(0, single_column_layout_id); |
248 block_allowed_button_ = new views::NativeButton( | 251 block_allowed_button_ = new views::NativeButton(this, UTF16ToWide( |
249 this, l10n_util::GetString(IDS_COLLECTED_COOKIES_BLOCK_BUTTON)); | 252 l10n_util::GetStringUTF16(IDS_COLLECTED_COOKIES_BLOCK_BUTTON))); |
250 layout->AddView( | 253 layout->AddView( |
251 block_allowed_button_, 1, 1, GridLayout::LEADING, GridLayout::CENTER); | 254 block_allowed_button_, 1, 1, GridLayout::LEADING, GridLayout::CENTER); |
252 layout->AddPaddingRow(0, kUnrelatedControlVerticalSpacing); | 255 layout->AddPaddingRow(0, kUnrelatedControlVerticalSpacing); |
253 | 256 |
254 layout->StartRow(0, single_column_layout_id); | 257 layout->StartRow(0, single_column_layout_id); |
255 layout->AddView( | 258 layout->AddView( |
256 new views::Separator(), 1, 1, GridLayout::FILL, GridLayout::FILL); | 259 new views::Separator(), 1, 1, GridLayout::FILL, GridLayout::FILL); |
257 layout->AddPaddingRow(0, kUnrelatedControlVerticalSpacing); | 260 layout->AddPaddingRow(0, kUnrelatedControlVerticalSpacing); |
258 | 261 |
259 layout->StartRow(0, single_column_layout_id); | 262 layout->StartRow(0, single_column_layout_id); |
260 layout->AddView(blocked_label_, 1, 1, GridLayout::FILL, GridLayout::FILL); | 263 layout->AddView(blocked_label_, 1, 1, GridLayout::FILL, GridLayout::FILL); |
261 | 264 |
262 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); | 265 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); |
263 layout->StartRow(1, single_column_layout_id); | 266 layout->StartRow(1, single_column_layout_id); |
264 layout->AddView( | 267 layout->AddView( |
265 blocked_cookies_tree_, 1, 1, GridLayout::FILL, GridLayout::FILL, | 268 blocked_cookies_tree_, 1, 1, GridLayout::FILL, GridLayout::FILL, |
266 kTreeViewWidth, kTreeViewHeight); | 269 kTreeViewWidth, kTreeViewHeight); |
267 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); | 270 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); |
268 | 271 |
269 layout->StartRow(0, three_columns_layout_id); | 272 layout->StartRow(0, three_columns_layout_id); |
270 allow_blocked_button_ = new views::NativeButton( | 273 allow_blocked_button_ = new views::NativeButton(this, UTF16ToWide( |
271 this, l10n_util::GetString(IDS_COLLECTED_COOKIES_ALLOW_BUTTON)); | 274 l10n_util::GetStringUTF16(IDS_COLLECTED_COOKIES_ALLOW_BUTTON))); |
272 layout->AddView(allow_blocked_button_); | 275 layout->AddView(allow_blocked_button_); |
273 for_session_blocked_button_ = new views::NativeButton( | 276 for_session_blocked_button_ = new views::NativeButton(this, UTF16ToWide( |
274 this, l10n_util::GetString(IDS_COLLECTED_COOKIES_SESSION_ONLY_BUTTON)); | 277 l10n_util::GetStringUTF16(IDS_COLLECTED_COOKIES_SESSION_ONLY_BUTTON))); |
275 layout->AddView(for_session_blocked_button_); | 278 layout->AddView(for_session_blocked_button_); |
276 | 279 |
277 layout->StartRow(0, single_column_layout_id); | 280 layout->StartRow(0, single_column_layout_id); |
278 infobar_ = new InfobarView(); | 281 infobar_ = new InfobarView(); |
279 layout->AddView(infobar_, 1, 1, GridLayout::FILL, GridLayout::FILL); | 282 layout->AddView(infobar_, 1, 1, GridLayout::FILL, GridLayout::FILL); |
280 | 283 |
281 EnableControls(); | 284 EnableControls(); |
282 } | 285 } |
283 | 286 |
284 /////////////////////////////////////////////////////////////////////////////// | 287 /////////////////////////////////////////////////////////////////////////////// |
285 // ConstrainedDialogDelegate implementation. | 288 // ConstrainedDialogDelegate implementation. |
286 | 289 |
287 std::wstring CollectedCookiesWin::GetWindowTitle() const { | 290 std::wstring CollectedCookiesWin::GetWindowTitle() const { |
288 return l10n_util::GetString(IDS_COLLECTED_COOKIES_DIALOG_TITLE); | 291 return UTF16ToWide( |
| 292 l10n_util::GetStringUTF16(IDS_COLLECTED_COOKIES_DIALOG_TITLE)); |
289 } | 293 } |
290 | 294 |
291 int CollectedCookiesWin::GetDialogButtons() const { | 295 int CollectedCookiesWin::GetDialogButtons() const { |
292 return MessageBoxFlags::DIALOGBUTTON_CANCEL; | 296 return MessageBoxFlags::DIALOGBUTTON_CANCEL; |
293 } | 297 } |
294 | 298 |
295 std::wstring CollectedCookiesWin::GetDialogButtonLabel( | 299 std::wstring CollectedCookiesWin::GetDialogButtonLabel( |
296 MessageBoxFlags::DialogButton button) const { | 300 MessageBoxFlags::DialogButton button) const { |
297 return l10n_util::GetString(IDS_CLOSE); | 301 return UTF16ToWide(l10n_util::GetStringUTF16(IDS_CLOSE)); |
298 } | 302 } |
299 | 303 |
300 void CollectedCookiesWin::DeleteDelegate() { | 304 void CollectedCookiesWin::DeleteDelegate() { |
301 delete this; | 305 delete this; |
302 } | 306 } |
303 | 307 |
304 bool CollectedCookiesWin::Cancel() { | 308 bool CollectedCookiesWin::Cancel() { |
305 return true; | 309 return true; |
306 } | 310 } |
307 | 311 |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 // NotificationObserver implementation. | 387 // NotificationObserver implementation. |
384 | 388 |
385 void CollectedCookiesWin::Observe(NotificationType type, | 389 void CollectedCookiesWin::Observe(NotificationType type, |
386 const NotificationSource& source, | 390 const NotificationSource& source, |
387 const NotificationDetails& details) { | 391 const NotificationDetails& details) { |
388 DCHECK(type == NotificationType::COLLECTED_COOKIES_SHOWN); | 392 DCHECK(type == NotificationType::COLLECTED_COOKIES_SHOWN); |
389 DCHECK_EQ(Source<TabSpecificContentSettings>(source).ptr(), | 393 DCHECK_EQ(Source<TabSpecificContentSettings>(source).ptr(), |
390 tab_contents_->GetTabSpecificContentSettings()); | 394 tab_contents_->GetTabSpecificContentSettings()); |
391 window_->CloseConstrainedWindow(); | 395 window_->CloseConstrainedWindow(); |
392 } | 396 } |
OLD | NEW |