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

Side by Side Diff: chrome/browser/ui/content_settings/content_setting_bubble_model_unittest.cc

Issue 112913004: Update some uses of UTF conversions in chrome/browser to use the base:: namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 12 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 | 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 "base/auto_reset.h" 5 #include "base/auto_reset.h"
6 #include "base/command_line.h" 6 #include "base/command_line.h"
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "chrome/browser/content_settings/host_content_settings_map.h" 8 #include "chrome/browser/content_settings/host_content_settings_map.h"
9 #include "chrome/browser/content_settings/tab_specific_content_settings.h" 9 #include "chrome/browser/content_settings/tab_specific_content_settings.h"
10 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" 10 #include "chrome/browser/custom_handlers/protocol_handler_registry.h"
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 NULL, web_contents(), profile(), 132 NULL, web_contents(), profile(),
133 CONTENT_SETTINGS_TYPE_MEDIASTREAM)); 133 CONTENT_SETTINGS_TYPE_MEDIASTREAM));
134 const ContentSettingBubbleModel::BubbleContent& bubble_content = 134 const ContentSettingBubbleModel::BubbleContent& bubble_content =
135 content_setting_bubble_model->bubble_content(); 135 content_setting_bubble_model->bubble_content();
136 EXPECT_EQ(bubble_content.title, 136 EXPECT_EQ(bubble_content.title,
137 l10n_util::GetStringUTF8(IDS_MICROPHONE_CAMERA_ALLOWED)); 137 l10n_util::GetStringUTF8(IDS_MICROPHONE_CAMERA_ALLOWED));
138 EXPECT_EQ(2U, bubble_content.radio_group.radio_items.size()); 138 EXPECT_EQ(2U, bubble_content.radio_group.radio_items.size());
139 EXPECT_EQ(bubble_content.radio_group.radio_items[0], 139 EXPECT_EQ(bubble_content.radio_group.radio_items[0],
140 l10n_util::GetStringFUTF8( 140 l10n_util::GetStringFUTF8(
141 IDS_ALLOWED_MEDIASTREAM_MIC_AND_CAMERA_NO_ACTION, 141 IDS_ALLOWED_MEDIASTREAM_MIC_AND_CAMERA_NO_ACTION,
142 UTF8ToUTF16(request_host))); 142 base::UTF8ToUTF16(request_host)));
143 EXPECT_EQ(bubble_content.radio_group.radio_items[1], 143 EXPECT_EQ(bubble_content.radio_group.radio_items[1],
144 l10n_util::GetStringUTF8( 144 l10n_util::GetStringUTF8(
145 IDS_ALLOWED_MEDIASTREAM_MIC_AND_CAMERA_BLOCK)); 145 IDS_ALLOWED_MEDIASTREAM_MIC_AND_CAMERA_BLOCK));
146 EXPECT_EQ(0, bubble_content.radio_group.default_item); 146 EXPECT_EQ(0, bubble_content.radio_group.default_item);
147 EXPECT_TRUE(bubble_content.custom_link.empty()); 147 EXPECT_TRUE(bubble_content.custom_link.empty());
148 EXPECT_FALSE(bubble_content.custom_link_enabled); 148 EXPECT_FALSE(bubble_content.custom_link_enabled);
149 EXPECT_FALSE(bubble_content.manage_link.empty()); 149 EXPECT_FALSE(bubble_content.manage_link.empty());
150 EXPECT_EQ(2U, bubble_content.media_menus.size()); 150 EXPECT_EQ(2U, bubble_content.media_menus.size());
151 } 151 }
152 152
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 NULL, web_contents(), profile(), 260 NULL, web_contents(), profile(),
261 CONTENT_SETTINGS_TYPE_MEDIASTREAM)); 261 CONTENT_SETTINGS_TYPE_MEDIASTREAM));
262 const ContentSettingBubbleModel::BubbleContent& bubble_content = 262 const ContentSettingBubbleModel::BubbleContent& bubble_content =
263 content_setting_bubble_model->bubble_content(); 263 content_setting_bubble_model->bubble_content();
264 EXPECT_EQ(bubble_content.title, 264 EXPECT_EQ(bubble_content.title,
265 l10n_util::GetStringUTF8(IDS_MICROPHONE_ACCESSED)); 265 l10n_util::GetStringUTF8(IDS_MICROPHONE_ACCESSED));
266 EXPECT_EQ(2U, bubble_content.radio_group.radio_items.size()); 266 EXPECT_EQ(2U, bubble_content.radio_group.radio_items.size());
267 EXPECT_EQ(bubble_content.radio_group.radio_items[0], 267 EXPECT_EQ(bubble_content.radio_group.radio_items[0],
268 l10n_util::GetStringFUTF8( 268 l10n_util::GetStringFUTF8(
269 IDS_ALLOWED_MEDIASTREAM_MIC_NO_ACTION, 269 IDS_ALLOWED_MEDIASTREAM_MIC_NO_ACTION,
270 UTF8ToUTF16(request_host))); 270 base::UTF8ToUTF16(request_host)));
271 EXPECT_EQ(bubble_content.radio_group.radio_items[1], 271 EXPECT_EQ(bubble_content.radio_group.radio_items[1],
272 l10n_util::GetStringUTF8( 272 l10n_util::GetStringUTF8(
273 IDS_ALLOWED_MEDIASTREAM_MIC_BLOCK)); 273 IDS_ALLOWED_MEDIASTREAM_MIC_BLOCK));
274 EXPECT_EQ(0, bubble_content.radio_group.default_item); 274 EXPECT_EQ(0, bubble_content.radio_group.default_item);
275 EXPECT_TRUE(bubble_content.custom_link.empty()); 275 EXPECT_TRUE(bubble_content.custom_link.empty());
276 EXPECT_FALSE(bubble_content.custom_link_enabled); 276 EXPECT_FALSE(bubble_content.custom_link_enabled);
277 EXPECT_FALSE(bubble_content.manage_link.empty()); 277 EXPECT_FALSE(bubble_content.manage_link.empty());
278 EXPECT_EQ(1U, bubble_content.media_menus.size()); 278 EXPECT_EQ(1U, bubble_content.media_menus.size());
279 EXPECT_EQ(content::MEDIA_DEVICE_AUDIO_CAPTURE, 279 EXPECT_EQ(content::MEDIA_DEVICE_AUDIO_CAPTURE,
280 bubble_content.media_menus.begin()->first); 280 bubble_content.media_menus.begin()->first);
281 281
282 // Change the microphone access. 282 // Change the microphone access.
283 request_permissions[content::MEDIA_DEVICE_AUDIO_CAPTURE].permission = 283 request_permissions[content::MEDIA_DEVICE_AUDIO_CAPTURE].permission =
284 MediaStreamDevicesController::MEDIA_BLOCKED_BY_USER; 284 MediaStreamDevicesController::MEDIA_BLOCKED_BY_USER;
285 content_settings->OnMediaStreamPermissionSet(security_origin, 285 content_settings->OnMediaStreamPermissionSet(security_origin,
286 request_permissions); 286 request_permissions);
287 content_setting_bubble_model.reset( 287 content_setting_bubble_model.reset(
288 ContentSettingBubbleModel::CreateContentSettingBubbleModel( 288 ContentSettingBubbleModel::CreateContentSettingBubbleModel(
289 NULL, web_contents(), profile(), 289 NULL, web_contents(), profile(),
290 CONTENT_SETTINGS_TYPE_MEDIASTREAM)); 290 CONTENT_SETTINGS_TYPE_MEDIASTREAM));
291 const ContentSettingBubbleModel::BubbleContent& new_bubble_content = 291 const ContentSettingBubbleModel::BubbleContent& new_bubble_content =
292 content_setting_bubble_model->bubble_content(); 292 content_setting_bubble_model->bubble_content();
293 EXPECT_EQ(new_bubble_content.title, 293 EXPECT_EQ(new_bubble_content.title,
294 l10n_util::GetStringUTF8(IDS_MICROPHONE_BLOCKED)); 294 l10n_util::GetStringUTF8(IDS_MICROPHONE_BLOCKED));
295 EXPECT_EQ(2U, new_bubble_content.radio_group.radio_items.size()); 295 EXPECT_EQ(2U, new_bubble_content.radio_group.radio_items.size());
296 EXPECT_EQ(new_bubble_content.radio_group.radio_items[0], 296 EXPECT_EQ(new_bubble_content.radio_group.radio_items[0],
297 l10n_util::GetStringFUTF8( 297 l10n_util::GetStringFUTF8(
298 IDS_BLOCKED_MEDIASTREAM_MIC_ASK, 298 IDS_BLOCKED_MEDIASTREAM_MIC_ASK,
299 UTF8ToUTF16(request_host))); 299 base::UTF8ToUTF16(request_host)));
300 EXPECT_EQ(new_bubble_content.radio_group.radio_items[1], 300 EXPECT_EQ(new_bubble_content.radio_group.radio_items[1],
301 l10n_util::GetStringUTF8( 301 l10n_util::GetStringUTF8(
302 IDS_BLOCKED_MEDIASTREAM_MIC_NO_ACTION)); 302 IDS_BLOCKED_MEDIASTREAM_MIC_NO_ACTION));
303 EXPECT_EQ(1, new_bubble_content.radio_group.default_item); 303 EXPECT_EQ(1, new_bubble_content.radio_group.default_item);
304 EXPECT_TRUE(new_bubble_content.custom_link.empty()); 304 EXPECT_TRUE(new_bubble_content.custom_link.empty());
305 EXPECT_FALSE(new_bubble_content.custom_link_enabled); 305 EXPECT_FALSE(new_bubble_content.custom_link_enabled);
306 EXPECT_FALSE(new_bubble_content.manage_link.empty()); 306 EXPECT_FALSE(new_bubble_content.manage_link.empty());
307 EXPECT_EQ(1U, new_bubble_content.media_menus.size()); 307 EXPECT_EQ(1U, new_bubble_content.media_menus.size());
308 EXPECT_EQ(content::MEDIA_DEVICE_AUDIO_CAPTURE, 308 EXPECT_EQ(content::MEDIA_DEVICE_AUDIO_CAPTURE,
309 new_bubble_content.media_menus.begin()->first); 309 new_bubble_content.media_menus.begin()->first);
(...skipping 20 matching lines...) Expand all
330 NULL, web_contents(), profile(), 330 NULL, web_contents(), profile(),
331 CONTENT_SETTINGS_TYPE_MEDIASTREAM)); 331 CONTENT_SETTINGS_TYPE_MEDIASTREAM));
332 const ContentSettingBubbleModel::BubbleContent& bubble_content = 332 const ContentSettingBubbleModel::BubbleContent& bubble_content =
333 content_setting_bubble_model->bubble_content(); 333 content_setting_bubble_model->bubble_content();
334 EXPECT_EQ(bubble_content.title, 334 EXPECT_EQ(bubble_content.title,
335 l10n_util::GetStringUTF8(IDS_CAMERA_ACCESSED)); 335 l10n_util::GetStringUTF8(IDS_CAMERA_ACCESSED));
336 EXPECT_EQ(2U, bubble_content.radio_group.radio_items.size()); 336 EXPECT_EQ(2U, bubble_content.radio_group.radio_items.size());
337 EXPECT_EQ(bubble_content.radio_group.radio_items[0], 337 EXPECT_EQ(bubble_content.radio_group.radio_items[0],
338 l10n_util::GetStringFUTF8( 338 l10n_util::GetStringFUTF8(
339 IDS_ALLOWED_MEDIASTREAM_CAMERA_NO_ACTION, 339 IDS_ALLOWED_MEDIASTREAM_CAMERA_NO_ACTION,
340 UTF8ToUTF16(request_host))); 340 base::UTF8ToUTF16(request_host)));
341 EXPECT_EQ(bubble_content.radio_group.radio_items[1], 341 EXPECT_EQ(bubble_content.radio_group.radio_items[1],
342 l10n_util::GetStringUTF8( 342 l10n_util::GetStringUTF8(
343 IDS_ALLOWED_MEDIASTREAM_CAMERA_BLOCK)); 343 IDS_ALLOWED_MEDIASTREAM_CAMERA_BLOCK));
344 EXPECT_EQ(0, bubble_content.radio_group.default_item); 344 EXPECT_EQ(0, bubble_content.radio_group.default_item);
345 EXPECT_TRUE(bubble_content.custom_link.empty()); 345 EXPECT_TRUE(bubble_content.custom_link.empty());
346 EXPECT_FALSE(bubble_content.custom_link_enabled); 346 EXPECT_FALSE(bubble_content.custom_link_enabled);
347 EXPECT_FALSE(bubble_content.manage_link.empty()); 347 EXPECT_FALSE(bubble_content.manage_link.empty());
348 EXPECT_EQ(1U, bubble_content.media_menus.size()); 348 EXPECT_EQ(1U, bubble_content.media_menus.size());
349 EXPECT_EQ(content::MEDIA_DEVICE_VIDEO_CAPTURE, 349 EXPECT_EQ(content::MEDIA_DEVICE_VIDEO_CAPTURE,
350 bubble_content.media_menus.begin()->first); 350 bubble_content.media_menus.begin()->first);
351 351
352 // Change the camera access. 352 // Change the camera access.
353 request_permissions[content::MEDIA_DEVICE_VIDEO_CAPTURE].permission = 353 request_permissions[content::MEDIA_DEVICE_VIDEO_CAPTURE].permission =
354 MediaStreamDevicesController::MEDIA_BLOCKED_BY_USER; 354 MediaStreamDevicesController::MEDIA_BLOCKED_BY_USER;
355 content_settings->OnMediaStreamPermissionSet(security_origin, 355 content_settings->OnMediaStreamPermissionSet(security_origin,
356 request_permissions); 356 request_permissions);
357 content_setting_bubble_model.reset( 357 content_setting_bubble_model.reset(
358 ContentSettingBubbleModel::CreateContentSettingBubbleModel( 358 ContentSettingBubbleModel::CreateContentSettingBubbleModel(
359 NULL, web_contents(), profile(), 359 NULL, web_contents(), profile(),
360 CONTENT_SETTINGS_TYPE_MEDIASTREAM)); 360 CONTENT_SETTINGS_TYPE_MEDIASTREAM));
361 const ContentSettingBubbleModel::BubbleContent& new_bubble_content = 361 const ContentSettingBubbleModel::BubbleContent& new_bubble_content =
362 content_setting_bubble_model->bubble_content(); 362 content_setting_bubble_model->bubble_content();
363 EXPECT_EQ(new_bubble_content.title, 363 EXPECT_EQ(new_bubble_content.title,
364 l10n_util::GetStringUTF8(IDS_CAMERA_BLOCKED)); 364 l10n_util::GetStringUTF8(IDS_CAMERA_BLOCKED));
365 EXPECT_EQ(2U, new_bubble_content.radio_group.radio_items.size()); 365 EXPECT_EQ(2U, new_bubble_content.radio_group.radio_items.size());
366 EXPECT_EQ(new_bubble_content.radio_group.radio_items[0], 366 EXPECT_EQ(new_bubble_content.radio_group.radio_items[0],
367 l10n_util::GetStringFUTF8( 367 l10n_util::GetStringFUTF8(
368 IDS_BLOCKED_MEDIASTREAM_CAMERA_ASK, 368 IDS_BLOCKED_MEDIASTREAM_CAMERA_ASK,
369 UTF8ToUTF16(request_host))); 369 base::UTF8ToUTF16(request_host)));
370 EXPECT_EQ(new_bubble_content.radio_group.radio_items[1], 370 EXPECT_EQ(new_bubble_content.radio_group.radio_items[1],
371 l10n_util::GetStringUTF8( 371 l10n_util::GetStringUTF8(
372 IDS_BLOCKED_MEDIASTREAM_CAMERA_NO_ACTION)); 372 IDS_BLOCKED_MEDIASTREAM_CAMERA_NO_ACTION));
373 EXPECT_EQ(1, new_bubble_content.radio_group.default_item); 373 EXPECT_EQ(1, new_bubble_content.radio_group.default_item);
374 EXPECT_TRUE(new_bubble_content.custom_link.empty()); 374 EXPECT_TRUE(new_bubble_content.custom_link.empty());
375 EXPECT_FALSE(new_bubble_content.custom_link_enabled); 375 EXPECT_FALSE(new_bubble_content.custom_link_enabled);
376 EXPECT_FALSE(new_bubble_content.manage_link.empty()); 376 EXPECT_FALSE(new_bubble_content.manage_link.empty());
377 EXPECT_EQ(1U, new_bubble_content.media_menus.size()); 377 EXPECT_EQ(1U, new_bubble_content.media_menus.size());
378 EXPECT_EQ(content::MEDIA_DEVICE_VIDEO_CAPTURE, 378 EXPECT_EQ(content::MEDIA_DEVICE_VIDEO_CAPTURE,
379 new_bubble_content.media_menus.begin()->first); 379 new_bubble_content.media_menus.begin()->first);
(...skipping 22 matching lines...) Expand all
402 NULL, web_contents(), profile(), 402 NULL, web_contents(), profile(),
403 CONTENT_SETTINGS_TYPE_MEDIASTREAM)); 403 CONTENT_SETTINGS_TYPE_MEDIASTREAM));
404 const ContentSettingBubbleModel::BubbleContent& bubble_content = 404 const ContentSettingBubbleModel::BubbleContent& bubble_content =
405 content_setting_bubble_model->bubble_content(); 405 content_setting_bubble_model->bubble_content();
406 EXPECT_EQ(bubble_content.title, 406 EXPECT_EQ(bubble_content.title,
407 l10n_util::GetStringUTF8(IDS_MICROPHONE_ACCESSED)); 407 l10n_util::GetStringUTF8(IDS_MICROPHONE_ACCESSED));
408 EXPECT_EQ(2U, bubble_content.radio_group.radio_items.size()); 408 EXPECT_EQ(2U, bubble_content.radio_group.radio_items.size());
409 EXPECT_EQ(bubble_content.radio_group.radio_items[0], 409 EXPECT_EQ(bubble_content.radio_group.radio_items[0],
410 l10n_util::GetStringFUTF8( 410 l10n_util::GetStringFUTF8(
411 IDS_ALLOWED_MEDIASTREAM_MIC_NO_ACTION, 411 IDS_ALLOWED_MEDIASTREAM_MIC_NO_ACTION,
412 UTF8ToUTF16(request_host))); 412 base::UTF8ToUTF16(request_host)));
413 EXPECT_EQ(bubble_content.radio_group.radio_items[1], 413 EXPECT_EQ(bubble_content.radio_group.radio_items[1],
414 l10n_util::GetStringUTF8( 414 l10n_util::GetStringUTF8(
415 IDS_ALLOWED_MEDIASTREAM_MIC_BLOCK)); 415 IDS_ALLOWED_MEDIASTREAM_MIC_BLOCK));
416 EXPECT_EQ(0, bubble_content.radio_group.default_item); 416 EXPECT_EQ(0, bubble_content.radio_group.default_item);
417 EXPECT_EQ(1U, bubble_content.media_menus.size()); 417 EXPECT_EQ(1U, bubble_content.media_menus.size());
418 EXPECT_EQ(content::MEDIA_DEVICE_AUDIO_CAPTURE, 418 EXPECT_EQ(content::MEDIA_DEVICE_AUDIO_CAPTURE,
419 bubble_content.media_menus.begin()->first); 419 bubble_content.media_menus.begin()->first);
420 420
421 // Then add camera access. 421 // Then add camera access.
422 request_permissions[content::MEDIA_DEVICE_VIDEO_CAPTURE].permission = 422 request_permissions[content::MEDIA_DEVICE_VIDEO_CAPTURE].permission =
423 MediaStreamDevicesController::MEDIA_ALLOWED; 423 MediaStreamDevicesController::MEDIA_ALLOWED;
424 content_settings->OnMediaStreamPermissionSet(security_origin, 424 content_settings->OnMediaStreamPermissionSet(security_origin,
425 request_permissions); 425 request_permissions);
426 426
427 content_setting_bubble_model.reset( 427 content_setting_bubble_model.reset(
428 ContentSettingBubbleModel::CreateContentSettingBubbleModel( 428 ContentSettingBubbleModel::CreateContentSettingBubbleModel(
429 NULL, web_contents(), profile(), 429 NULL, web_contents(), profile(),
430 CONTENT_SETTINGS_TYPE_MEDIASTREAM)); 430 CONTENT_SETTINGS_TYPE_MEDIASTREAM));
431 const ContentSettingBubbleModel::BubbleContent& new_bubble_content = 431 const ContentSettingBubbleModel::BubbleContent& new_bubble_content =
432 content_setting_bubble_model->bubble_content(); 432 content_setting_bubble_model->bubble_content();
433 EXPECT_EQ(new_bubble_content.title, 433 EXPECT_EQ(new_bubble_content.title,
434 l10n_util::GetStringUTF8(IDS_MICROPHONE_CAMERA_ALLOWED)); 434 l10n_util::GetStringUTF8(IDS_MICROPHONE_CAMERA_ALLOWED));
435 EXPECT_EQ(2U, new_bubble_content.radio_group.radio_items.size()); 435 EXPECT_EQ(2U, new_bubble_content.radio_group.radio_items.size());
436 EXPECT_EQ(new_bubble_content.radio_group.radio_items[0], 436 EXPECT_EQ(new_bubble_content.radio_group.radio_items[0],
437 l10n_util::GetStringFUTF8( 437 l10n_util::GetStringFUTF8(
438 IDS_ALLOWED_MEDIASTREAM_MIC_AND_CAMERA_NO_ACTION, 438 IDS_ALLOWED_MEDIASTREAM_MIC_AND_CAMERA_NO_ACTION,
439 UTF8ToUTF16(request_host))); 439 base::UTF8ToUTF16(request_host)));
440 EXPECT_EQ(new_bubble_content.radio_group.radio_items[1], 440 EXPECT_EQ(new_bubble_content.radio_group.radio_items[1],
441 l10n_util::GetStringUTF8( 441 l10n_util::GetStringUTF8(
442 IDS_ALLOWED_MEDIASTREAM_MIC_AND_CAMERA_BLOCK)); 442 IDS_ALLOWED_MEDIASTREAM_MIC_AND_CAMERA_BLOCK));
443 EXPECT_EQ(0, new_bubble_content.radio_group.default_item); 443 EXPECT_EQ(0, new_bubble_content.radio_group.default_item);
444 EXPECT_EQ(2U, new_bubble_content.media_menus.size()); 444 EXPECT_EQ(2U, new_bubble_content.media_menus.size());
445 } 445 }
446 446
447 TEST_F(ContentSettingBubbleModelTest, Plugins) { 447 TEST_F(ContentSettingBubbleModelTest, Plugins) {
448 TabSpecificContentSettings* content_settings = 448 TabSpecificContentSettings* content_settings =
449 TabSpecificContentSettings::FromWebContents(web_contents()); 449 TabSpecificContentSettings::FromWebContents(web_contents());
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 ASSERT_NE(std::string::npos, title.find(file_url)); 553 ASSERT_NE(std::string::npos, title.find(file_url));
554 } 554 }
555 555
556 TEST_F(ContentSettingBubbleModelTest, RegisterProtocolHandler) { 556 TEST_F(ContentSettingBubbleModelTest, RegisterProtocolHandler) {
557 const GURL page_url("http://toplevel.example/"); 557 const GURL page_url("http://toplevel.example/");
558 NavigateAndCommit(page_url); 558 NavigateAndCommit(page_url);
559 TabSpecificContentSettings* content_settings = 559 TabSpecificContentSettings* content_settings =
560 TabSpecificContentSettings::FromWebContents(web_contents()); 560 TabSpecificContentSettings::FromWebContents(web_contents());
561 content_settings->set_pending_protocol_handler( 561 content_settings->set_pending_protocol_handler(
562 ProtocolHandler::CreateProtocolHandler("mailto", 562 ProtocolHandler::CreateProtocolHandler("mailto",
563 GURL("http://www.toplevel.example/"), ASCIIToUTF16("Handler"))); 563 GURL("http://www.toplevel.example/"), base::ASCIIToUTF16("Handler")));
564 564
565 ContentSettingRPHBubbleModel content_setting_bubble_model( 565 ContentSettingRPHBubbleModel content_setting_bubble_model(
566 NULL, web_contents(), profile(), NULL, 566 NULL, web_contents(), profile(), NULL,
567 CONTENT_SETTINGS_TYPE_PROTOCOL_HANDLERS); 567 CONTENT_SETTINGS_TYPE_PROTOCOL_HANDLERS);
568 568
569 const ContentSettingBubbleModel::BubbleContent& bubble_content = 569 const ContentSettingBubbleModel::BubbleContent& bubble_content =
570 content_setting_bubble_model.bubble_content(); 570 content_setting_bubble_model.bubble_content();
571 EXPECT_FALSE(bubble_content.title.empty()); 571 EXPECT_FALSE(bubble_content.title.empty());
572 EXPECT_FALSE(bubble_content.radio_group.radio_items.empty()); 572 EXPECT_FALSE(bubble_content.radio_group.radio_items.empty());
573 EXPECT_TRUE(bubble_content.popup_items.empty()); 573 EXPECT_TRUE(bubble_content.popup_items.empty());
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
607 TEST_F(ContentSettingBubbleModelTest, RPHAllow) { 607 TEST_F(ContentSettingBubbleModelTest, RPHAllow) {
608 ProtocolHandlerRegistry registry(profile(), new FakeDelegate()); 608 ProtocolHandlerRegistry registry(profile(), new FakeDelegate());
609 registry.InitProtocolSettings(); 609 registry.InitProtocolSettings();
610 610
611 const GURL page_url("http://toplevel.example/"); 611 const GURL page_url("http://toplevel.example/");
612 NavigateAndCommit(page_url); 612 NavigateAndCommit(page_url);
613 TabSpecificContentSettings* content_settings = 613 TabSpecificContentSettings* content_settings =
614 TabSpecificContentSettings::FromWebContents(web_contents()); 614 TabSpecificContentSettings::FromWebContents(web_contents());
615 ProtocolHandler test_handler = ProtocolHandler::CreateProtocolHandler( 615 ProtocolHandler test_handler = ProtocolHandler::CreateProtocolHandler(
616 "mailto", GURL("http://www.toplevel.example/"), 616 "mailto", GURL("http://www.toplevel.example/"),
617 ASCIIToUTF16("Handler")); 617 base::ASCIIToUTF16("Handler"));
618 content_settings->set_pending_protocol_handler(test_handler); 618 content_settings->set_pending_protocol_handler(test_handler);
619 619
620 ContentSettingRPHBubbleModel content_setting_bubble_model( 620 ContentSettingRPHBubbleModel content_setting_bubble_model(
621 NULL, web_contents(), profile(), &registry, 621 NULL, web_contents(), profile(), &registry,
622 CONTENT_SETTINGS_TYPE_PROTOCOL_HANDLERS); 622 CONTENT_SETTINGS_TYPE_PROTOCOL_HANDLERS);
623 623
624 { 624 {
625 ProtocolHandler handler = registry.GetHandlerFor("mailto"); 625 ProtocolHandler handler = registry.GetHandlerFor("mailto");
626 EXPECT_TRUE(handler.IsEmpty()); 626 EXPECT_TRUE(handler.IsEmpty());
627 EXPECT_EQ(CONTENT_SETTING_DEFAULT, 627 EXPECT_EQ(CONTENT_SETTING_DEFAULT,
628 content_settings->pending_protocol_handler_setting()); 628 content_settings->pending_protocol_handler_setting());
629 } 629 }
630 630
631 // "0" is the "Allow" radio button. 631 // "0" is the "Allow" radio button.
632 content_setting_bubble_model.OnRadioClicked(0); 632 content_setting_bubble_model.OnRadioClicked(0);
633 { 633 {
634 ProtocolHandler handler = registry.GetHandlerFor("mailto"); 634 ProtocolHandler handler = registry.GetHandlerFor("mailto");
635 ASSERT_FALSE(handler.IsEmpty()); 635 ASSERT_FALSE(handler.IsEmpty());
636 EXPECT_EQ(ASCIIToUTF16("Handler"), handler.title()); 636 EXPECT_EQ(base::ASCIIToUTF16("Handler"), handler.title());
637 EXPECT_EQ(CONTENT_SETTING_ALLOW, 637 EXPECT_EQ(CONTENT_SETTING_ALLOW,
638 content_settings->pending_protocol_handler_setting()); 638 content_settings->pending_protocol_handler_setting());
639 } 639 }
640 640
641 // "1" is the "Deny" radio button. 641 // "1" is the "Deny" radio button.
642 content_setting_bubble_model.OnRadioClicked(1); 642 content_setting_bubble_model.OnRadioClicked(1);
643 { 643 {
644 ProtocolHandler handler = registry.GetHandlerFor("mailto"); 644 ProtocolHandler handler = registry.GetHandlerFor("mailto");
645 EXPECT_TRUE(handler.IsEmpty()); 645 EXPECT_TRUE(handler.IsEmpty());
646 EXPECT_EQ(CONTENT_SETTING_BLOCK, 646 EXPECT_EQ(CONTENT_SETTING_BLOCK,
647 content_settings->pending_protocol_handler_setting()); 647 content_settings->pending_protocol_handler_setting());
648 } 648 }
649 649
650 // "2" is the "Ignore button. 650 // "2" is the "Ignore button.
651 content_setting_bubble_model.OnRadioClicked(2); 651 content_setting_bubble_model.OnRadioClicked(2);
652 { 652 {
653 ProtocolHandler handler = registry.GetHandlerFor("mailto"); 653 ProtocolHandler handler = registry.GetHandlerFor("mailto");
654 EXPECT_TRUE(handler.IsEmpty()); 654 EXPECT_TRUE(handler.IsEmpty());
655 EXPECT_EQ(CONTENT_SETTING_DEFAULT, 655 EXPECT_EQ(CONTENT_SETTING_DEFAULT,
656 content_settings->pending_protocol_handler_setting()); 656 content_settings->pending_protocol_handler_setting());
657 EXPECT_TRUE(registry.IsIgnored(test_handler)); 657 EXPECT_TRUE(registry.IsIgnored(test_handler));
658 } 658 }
659 659
660 // "0" is the "Allow" radio button. 660 // "0" is the "Allow" radio button.
661 content_setting_bubble_model.OnRadioClicked(0); 661 content_setting_bubble_model.OnRadioClicked(0);
662 { 662 {
663 ProtocolHandler handler = registry.GetHandlerFor("mailto"); 663 ProtocolHandler handler = registry.GetHandlerFor("mailto");
664 ASSERT_FALSE(handler.IsEmpty()); 664 ASSERT_FALSE(handler.IsEmpty());
665 EXPECT_EQ(ASCIIToUTF16("Handler"), handler.title()); 665 EXPECT_EQ(base::ASCIIToUTF16("Handler"), handler.title());
666 EXPECT_EQ(CONTENT_SETTING_ALLOW, 666 EXPECT_EQ(CONTENT_SETTING_ALLOW,
667 content_settings->pending_protocol_handler_setting()); 667 content_settings->pending_protocol_handler_setting());
668 EXPECT_FALSE(registry.IsIgnored(test_handler)); 668 EXPECT_FALSE(registry.IsIgnored(test_handler));
669 } 669 }
670 670
671 registry.Shutdown(); 671 registry.Shutdown();
672 } 672 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698