Roll src/third_party/WebKit eac3800:0237a66 (svn 202606:202607)
[chromium-blink-merge.git] / chrome / browser / ui / content_settings / content_setting_bubble_model_unittest.cc
blob3f0b76b23108d819ca81e51d1685445f04ab2be6
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
3 // found in the LICENSE file.
5 #include "base/auto_reset.h"
6 #include "base/command_line.h"
7 #include "base/prefs/pref_service.h"
8 #include "base/strings/utf_string_conversions.h"
9 #include "chrome/browser/content_settings/host_content_settings_map_factory.h"
10 #include "chrome/browser/content_settings/tab_specific_content_settings.h"
11 #include "chrome/browser/custom_handlers/protocol_handler_registry.h"
12 #include "chrome/browser/infobars/infobar_service.h"
13 #include "chrome/browser/media/media_capture_devices_dispatcher.h"
14 #include "chrome/browser/media/media_stream_capture_indicator.h"
15 #include "chrome/browser/profiles/profile.h"
16 #include "chrome/browser/ui/content_settings/content_setting_bubble_model.h"
17 #include "chrome/common/chrome_switches.h"
18 #include "chrome/common/pref_names.h"
19 #include "chrome/grit/generated_resources.h"
20 #include "chrome/test/base/chrome_render_view_host_test_harness.h"
21 #include "chrome/test/base/testing_profile.h"
22 #include "components/content_settings/core/browser/host_content_settings_map.h"
23 #include "components/content_settings/core/common/content_settings.h"
24 #include "components/infobars/core/infobar_delegate.h"
25 #include "components/url_formatter/elide_url.h"
26 #include "content/public/browser/web_contents.h"
27 #include "content/public/test/web_contents_tester.h"
28 #include "testing/gtest/include/gtest/gtest.h"
29 #include "ui/base/l10n/l10n_util.h"
31 using content::WebContentsTester;
33 class ContentSettingBubbleModelTest : public ChromeRenderViewHostTestHarness {
34 protected:
35 void SetUp() override {
36 ChromeRenderViewHostTestHarness::SetUp();
37 TabSpecificContentSettings::CreateForWebContents(web_contents());
38 InfoBarService::CreateForWebContents(web_contents());
41 void CheckGeolocationBubble(size_t expected_domains,
42 bool expect_clear_link,
43 bool expect_reload_hint) {
44 scoped_ptr<ContentSettingBubbleModel> content_setting_bubble_model(
45 ContentSettingBubbleModel::CreateContentSettingBubbleModel(
46 NULL, web_contents(), profile(),
47 CONTENT_SETTINGS_TYPE_GEOLOCATION));
48 const ContentSettingBubbleModel::BubbleContent& bubble_content =
49 content_setting_bubble_model->bubble_content();
50 EXPECT_TRUE(bubble_content.title.empty());
51 EXPECT_TRUE(bubble_content.radio_group.radio_items.empty());
52 EXPECT_TRUE(bubble_content.list_items.empty());
53 EXPECT_EQ(expected_domains, bubble_content.domain_lists.size());
54 EXPECT_NE(expect_clear_link || expect_reload_hint,
55 bubble_content.custom_link.empty());
56 EXPECT_EQ(expect_clear_link, bubble_content.custom_link_enabled);
57 EXPECT_FALSE(bubble_content.manage_link.empty());
60 std::string GetDefaultAudioDevice() {
61 PrefService* prefs = profile()->GetPrefs();
62 return prefs->GetString(prefs::kDefaultAudioCaptureDevice);
65 std::string GetDefaultVideoDevice() {
66 PrefService* prefs = profile()->GetPrefs();
67 return prefs->GetString(prefs::kDefaultVideoCaptureDevice);
71 TEST_F(ContentSettingBubbleModelTest, ImageRadios) {
72 TabSpecificContentSettings* content_settings =
73 TabSpecificContentSettings::FromWebContents(web_contents());
74 content_settings->OnContentBlocked(CONTENT_SETTINGS_TYPE_IMAGES);
76 scoped_ptr<ContentSettingBubbleModel> content_setting_bubble_model(
77 ContentSettingBubbleModel::CreateContentSettingBubbleModel(
78 NULL, web_contents(), profile(),
79 CONTENT_SETTINGS_TYPE_IMAGES));
80 const ContentSettingBubbleModel::BubbleContent& bubble_content =
81 content_setting_bubble_model->bubble_content();
82 EXPECT_FALSE(bubble_content.title.empty());
83 EXPECT_EQ(2U, bubble_content.radio_group.radio_items.size());
84 EXPECT_EQ(0, bubble_content.radio_group.default_item);
85 EXPECT_TRUE(bubble_content.custom_link.empty());
86 EXPECT_FALSE(bubble_content.manage_link.empty());
89 TEST_F(ContentSettingBubbleModelTest, Cookies) {
90 TabSpecificContentSettings* content_settings =
91 TabSpecificContentSettings::FromWebContents(web_contents());
92 content_settings->OnContentBlocked(CONTENT_SETTINGS_TYPE_COOKIES);
94 scoped_ptr<ContentSettingBubbleModel> content_setting_bubble_model(
95 ContentSettingBubbleModel::CreateContentSettingBubbleModel(
96 NULL, web_contents(), profile(), CONTENT_SETTINGS_TYPE_COOKIES));
97 const ContentSettingBubbleModel::BubbleContent& bubble_content =
98 content_setting_bubble_model->bubble_content();
99 std::string title = bubble_content.title;
100 EXPECT_FALSE(title.empty());
101 ASSERT_EQ(2U, bubble_content.radio_group.radio_items.size());
102 EXPECT_FALSE(bubble_content.custom_link.empty());
103 EXPECT_TRUE(bubble_content.custom_link_enabled);
104 EXPECT_FALSE(bubble_content.manage_link.empty());
106 content_settings->ClearCookieSpecificContentSettings();
107 content_settings->OnContentAllowed(CONTENT_SETTINGS_TYPE_COOKIES);
108 content_setting_bubble_model.reset(
109 ContentSettingBubbleModel::CreateContentSettingBubbleModel(
110 NULL, web_contents(), profile(), CONTENT_SETTINGS_TYPE_COOKIES));
111 const ContentSettingBubbleModel::BubbleContent& bubble_content_2 =
112 content_setting_bubble_model->bubble_content();
114 EXPECT_FALSE(bubble_content_2.title.empty());
115 EXPECT_NE(title, bubble_content_2.title);
116 ASSERT_EQ(2U, bubble_content_2.radio_group.radio_items.size());
117 EXPECT_EQ(bubble_content_2.radio_group.radio_items[0],
118 l10n_util::GetStringUTF8(IDS_ALLOWED_COOKIES_NO_ACTION));
119 EXPECT_EQ(bubble_content_2.radio_group.radio_items[1],
120 l10n_util::GetStringFUTF8(
121 IDS_ALLOWED_COOKIES_BLOCK,
122 url_formatter::FormatUrlForSecurityDisplay(
123 web_contents()->GetURL(), profile()->GetPrefs()->GetString(
124 prefs::kAcceptLanguages))));
125 EXPECT_FALSE(bubble_content_2.custom_link.empty());
126 EXPECT_TRUE(bubble_content_2.custom_link_enabled);
127 EXPECT_FALSE(bubble_content_2.manage_link.empty());
130 TEST_F(ContentSettingBubbleModelTest, MediastreamMicAndCamera) {
131 // Required to break dependency on BrowserMainLoop.
132 MediaCaptureDevicesDispatcher::GetInstance()->
133 DisableDeviceEnumerationForTesting();
135 TabSpecificContentSettings* content_settings =
136 TabSpecificContentSettings::FromWebContents(web_contents());
137 std::string request_host = "google.com";
138 GURL security_origin("http://" + request_host);
139 TabSpecificContentSettings::MicrophoneCameraState microphone_camera_state =
140 TabSpecificContentSettings::MICROPHONE_ACCESSED |
141 TabSpecificContentSettings::CAMERA_ACCESSED;
142 content_settings->OnMediaStreamPermissionSet(security_origin,
143 microphone_camera_state,
144 GetDefaultAudioDevice(),
145 GetDefaultVideoDevice(),
146 std::string(),
147 std::string());
149 scoped_ptr<ContentSettingBubbleModel> content_setting_bubble_model(
150 ContentSettingBubbleModel::CreateContentSettingBubbleModel(
151 NULL, web_contents(), profile(),
152 CONTENT_SETTINGS_TYPE_MEDIASTREAM));
153 const ContentSettingBubbleModel::BubbleContent& bubble_content =
154 content_setting_bubble_model->bubble_content();
155 EXPECT_EQ(bubble_content.title,
156 l10n_util::GetStringUTF8(IDS_MICROPHONE_CAMERA_ALLOWED));
157 EXPECT_EQ(2U, bubble_content.radio_group.radio_items.size());
158 EXPECT_EQ(bubble_content.radio_group.radio_items[0],
159 l10n_util::GetStringFUTF8(
160 IDS_ALLOWED_MEDIASTREAM_MIC_AND_CAMERA_NO_ACTION,
161 url_formatter::FormatUrlForSecurityDisplay(
162 security_origin, profile()->GetPrefs()->GetString(
163 prefs::kAcceptLanguages))));
164 EXPECT_EQ(bubble_content.radio_group.radio_items[1],
165 l10n_util::GetStringUTF8(
166 IDS_ALLOWED_MEDIASTREAM_MIC_AND_CAMERA_BLOCK));
167 EXPECT_EQ(0, bubble_content.radio_group.default_item);
168 EXPECT_TRUE(bubble_content.custom_link.empty());
169 EXPECT_FALSE(bubble_content.custom_link_enabled);
170 EXPECT_FALSE(bubble_content.manage_link.empty());
171 EXPECT_EQ(2U, bubble_content.media_menus.size());
174 TEST_F(ContentSettingBubbleModelTest, BlockedMediastreamMicAndCamera) {
175 // Required to break dependency on BrowserMainLoop.
176 MediaCaptureDevicesDispatcher::GetInstance()->
177 DisableDeviceEnumerationForTesting();
179 WebContentsTester::For(web_contents())->
180 NavigateAndCommit(GURL("https://www.example.com"));
181 GURL url = web_contents()->GetURL();
183 HostContentSettingsMap* host_content_settings_map =
184 HostContentSettingsMapFactory::GetForProfile(profile());
185 ContentSettingsPattern primary_pattern =
186 ContentSettingsPattern::FromURL(url);
187 ContentSetting setting = CONTENT_SETTING_BLOCK;
188 host_content_settings_map->SetContentSetting(
189 primary_pattern,
190 ContentSettingsPattern::Wildcard(),
191 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC,
192 std::string(),
193 setting);
194 host_content_settings_map->SetContentSetting(
195 primary_pattern,
196 ContentSettingsPattern::Wildcard(),
197 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA,
198 std::string(),
199 setting);
201 TabSpecificContentSettings* content_settings =
202 TabSpecificContentSettings::FromWebContents(web_contents());
203 TabSpecificContentSettings::MicrophoneCameraState microphone_camera_state =
204 TabSpecificContentSettings::MICROPHONE_ACCESSED |
205 TabSpecificContentSettings::MICROPHONE_BLOCKED |
206 TabSpecificContentSettings::CAMERA_ACCESSED |
207 TabSpecificContentSettings::CAMERA_BLOCKED;
208 content_settings->OnMediaStreamPermissionSet(url,
209 microphone_camera_state,
210 GetDefaultAudioDevice(),
211 GetDefaultVideoDevice(),
212 std::string(),
213 std::string());
215 scoped_ptr<ContentSettingBubbleModel> content_setting_bubble_model(
216 ContentSettingBubbleModel::CreateContentSettingBubbleModel(
217 NULL, web_contents(), profile(),
218 CONTENT_SETTINGS_TYPE_MEDIASTREAM));
219 const ContentSettingBubbleModel::BubbleContent& bubble_content =
220 content_setting_bubble_model->bubble_content();
221 // Test if the correct radio item is selected for the blocked mediastream
222 // setting.
223 EXPECT_EQ(1, bubble_content.radio_group.default_item);
226 // Test that the media settings where not changed.
227 EXPECT_EQ(CONTENT_SETTING_BLOCK,
228 host_content_settings_map->GetContentSetting(
229 url,
230 url,
231 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC,
232 std::string()));
233 EXPECT_EQ(CONTENT_SETTING_BLOCK,
234 host_content_settings_map->GetContentSetting(
235 url,
236 url,
237 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA,
238 std::string()));
241 scoped_ptr<ContentSettingBubbleModel> content_setting_bubble_model(
242 ContentSettingBubbleModel::CreateContentSettingBubbleModel(
243 NULL, web_contents(), profile(),
244 CONTENT_SETTINGS_TYPE_MEDIASTREAM));
245 // Change the radio setting.
246 content_setting_bubble_model->OnRadioClicked(0);
248 // Test that the media setting were change correctly.
249 EXPECT_EQ(CONTENT_SETTING_ALLOW,
250 host_content_settings_map->GetContentSetting(
251 url,
252 url,
253 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC,
254 std::string()));
255 EXPECT_EQ(CONTENT_SETTING_ALLOW,
256 host_content_settings_map->GetContentSetting(
257 url,
258 url,
259 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA,
260 std::string()));
263 // Tests whether a changed setting in the setting bubble is displayed again when
264 // the bubble is re-opened.
265 TEST_F(ContentSettingBubbleModelTest, MediastreamContentBubble) {
266 // Required to break dependency on BrowserMainLoop.
267 MediaCaptureDevicesDispatcher::GetInstance()->
268 DisableDeviceEnumerationForTesting();
270 WebContentsTester::For(web_contents())->
271 NavigateAndCommit(GURL("https://www.example.com"));
272 GURL url = web_contents()->GetURL();
274 HostContentSettingsMap* host_content_settings_map =
275 HostContentSettingsMapFactory::GetForProfile(profile());
276 ContentSettingsPattern primary_pattern =
277 ContentSettingsPattern::FromURL(url);
278 ContentSetting setting = CONTENT_SETTING_BLOCK;
279 host_content_settings_map->SetContentSetting(
280 primary_pattern,
281 ContentSettingsPattern::Wildcard(),
282 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC,
283 std::string(),
284 setting);
286 TabSpecificContentSettings* content_settings =
287 TabSpecificContentSettings::FromWebContents(web_contents());
288 TabSpecificContentSettings::MicrophoneCameraState microphone_camera_state =
289 TabSpecificContentSettings::MICROPHONE_ACCESSED |
290 TabSpecificContentSettings::MICROPHONE_BLOCKED;
291 content_settings->OnMediaStreamPermissionSet(url,
292 microphone_camera_state,
293 GetDefaultAudioDevice(),
294 std::string(),
295 std::string(),
296 std::string());
298 scoped_ptr<ContentSettingBubbleModel> content_setting_bubble_model(
299 ContentSettingBubbleModel::CreateContentSettingBubbleModel(
300 NULL, web_contents(), profile(),
301 CONTENT_SETTINGS_TYPE_MEDIASTREAM));
302 const ContentSettingBubbleModel::BubbleContent& bubble_content =
303 content_setting_bubble_model->bubble_content();
304 // Test if the correct radio item is selected for the blocked mediastream
305 // setting.
306 EXPECT_EQ(1, bubble_content.radio_group.default_item);
307 // Change the radio setting.
308 content_setting_bubble_model->OnRadioClicked(0);
310 // Test that the setting was changed.
311 EXPECT_EQ(CONTENT_SETTING_ALLOW,
312 host_content_settings_map->GetContentSetting(
313 url,
314 url,
315 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC,
316 std::string()));
319 scoped_ptr<ContentSettingBubbleModel> content_setting_bubble_model(
320 ContentSettingBubbleModel::CreateContentSettingBubbleModel(
321 NULL, web_contents(), profile(),
322 CONTENT_SETTINGS_TYPE_MEDIASTREAM));
323 const ContentSettingBubbleModel::BubbleContent& bubble_content =
324 content_setting_bubble_model->bubble_content();
325 // Test that the reload hint is displayed.
326 EXPECT_FALSE(bubble_content.custom_link_enabled);
327 EXPECT_EQ(bubble_content.custom_link, l10n_util::GetStringUTF8(
328 IDS_MEDIASTREAM_SETTING_CHANGED_MESSAGE));
330 EXPECT_EQ(0, bubble_content.radio_group.default_item);
331 // Restore the radio setting (to block).
332 content_setting_bubble_model->OnRadioClicked(1);
334 // Test that the media settings were changed again.
335 EXPECT_EQ(CONTENT_SETTING_BLOCK,
336 host_content_settings_map->GetContentSetting(
337 url,
338 url,
339 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC,
340 std::string()));
343 scoped_ptr<ContentSettingBubbleModel> content_setting_bubble_model(
344 ContentSettingBubbleModel::CreateContentSettingBubbleModel(
345 NULL, web_contents(), profile(),
346 CONTENT_SETTINGS_TYPE_MEDIASTREAM));
347 const ContentSettingBubbleModel::BubbleContent& bubble_content =
348 content_setting_bubble_model->bubble_content();
349 // Test that the reload hint is not displayed any more.
350 EXPECT_FALSE(bubble_content.custom_link_enabled);
351 EXPECT_TRUE(bubble_content.custom_link.empty());
353 EXPECT_EQ(1, bubble_content.radio_group.default_item);
357 // Tests whether the media menu settings are correctly persisted in the bubble.
358 TEST_F(ContentSettingBubbleModelTest, MediastreamContentBubbleMediaMenus) {
359 // Required to break dependency on BrowserMainLoop.
360 MediaCaptureDevicesDispatcher::GetInstance()->
361 DisableDeviceEnumerationForTesting();
363 WebContentsTester::For(web_contents())->
364 NavigateAndCommit(GURL("https://www.example.com"));
365 GURL url = web_contents()->GetURL();
367 content::MediaStreamDevices audio_devices;
368 content::MediaStreamDevice fake_audio_device1(
369 content::MEDIA_DEVICE_AUDIO_CAPTURE, "fake_dev1", "Fake Audio Device 1");
370 content::MediaStreamDevice fake_audio_device2(
371 content::MEDIA_DEVICE_AUDIO_CAPTURE, "fake_dev2", "Fake Audio Device 2");
372 content::MediaStreamDevice fake_audio_device3(
373 content::MEDIA_DEVICE_AUDIO_CAPTURE, "fake_dev3", "Fake Audio Device 3");
374 audio_devices.push_back(fake_audio_device1);
375 audio_devices.push_back(fake_audio_device2);
376 audio_devices.push_back(fake_audio_device3);
377 MediaCaptureDevicesDispatcher::GetInstance()->SetTestAudioCaptureDevices(
378 audio_devices);
380 TabSpecificContentSettings* content_settings =
381 TabSpecificContentSettings::FromWebContents(web_contents());
382 TabSpecificContentSettings::MicrophoneCameraState microphone_camera_state =
383 TabSpecificContentSettings::MICROPHONE_ACCESSED |
384 TabSpecificContentSettings::MICROPHONE_BLOCKED;
385 content_settings->OnMediaStreamPermissionSet(url,
386 microphone_camera_state,
387 GetDefaultAudioDevice(),
388 std::string(),
389 std::string(),
390 std::string());
392 scoped_ptr<ContentSettingBubbleModel> content_setting_bubble_model(
393 ContentSettingBubbleModel::CreateContentSettingBubbleModel(
394 NULL, web_contents(), profile(),
395 CONTENT_SETTINGS_TYPE_MEDIASTREAM));
396 const ContentSettingBubbleModel::BubbleContent& bubble_content =
397 content_setting_bubble_model->bubble_content();
398 EXPECT_TRUE(bubble_content.custom_link.empty());
400 EXPECT_EQ(1U, bubble_content.media_menus.size());
401 EXPECT_EQ(content::MEDIA_DEVICE_AUDIO_CAPTURE,
402 bubble_content.media_menus.begin()->first);
403 EXPECT_FALSE(bubble_content.media_menus.begin()->second.disabled);
404 // The first audio device should be selected by default.
405 EXPECT_TRUE(fake_audio_device1.IsEqual(
406 bubble_content.media_menus.begin()->second.selected_device));
408 // Select a different (the second) device.
409 content_setting_bubble_model->OnMediaMenuClicked(
410 content::MEDIA_DEVICE_AUDIO_CAPTURE,
411 fake_audio_device2.id);
414 scoped_ptr<ContentSettingBubbleModel> content_setting_bubble_model(
415 ContentSettingBubbleModel::CreateContentSettingBubbleModel(
416 NULL, web_contents(), profile(),
417 CONTENT_SETTINGS_TYPE_MEDIASTREAM));
418 const ContentSettingBubbleModel::BubbleContent& bubble_content =
419 content_setting_bubble_model->bubble_content();
420 EXPECT_EQ(1U, bubble_content.media_menus.size());
421 EXPECT_EQ(content::MEDIA_DEVICE_AUDIO_CAPTURE,
422 bubble_content.media_menus.begin()->first);
423 EXPECT_FALSE(bubble_content.media_menus.begin()->second.disabled);
424 // The second audio device should be selected.
425 EXPECT_TRUE(fake_audio_device2.IsEqual(
426 bubble_content.media_menus.begin()->second.selected_device));
427 // The "settings changed" message should not be displayed when there is no
428 // active capture.
429 EXPECT_FALSE(bubble_content.custom_link_enabled);
430 EXPECT_TRUE(bubble_content.custom_link.empty());
433 // Simulate that an audio stream is being captured.
434 scoped_refptr<MediaStreamCaptureIndicator> indicator =
435 MediaCaptureDevicesDispatcher::GetInstance()->
436 GetMediaStreamCaptureIndicator();
437 scoped_ptr<content::MediaStreamUI> media_stream_ui =
438 indicator->RegisterMediaStream(web_contents(), audio_devices);
439 media_stream_ui->OnStarted(base::Closure());
440 microphone_camera_state &= ~TabSpecificContentSettings::MICROPHONE_BLOCKED;
441 content_settings->OnMediaStreamPermissionSet(url,
442 microphone_camera_state,
443 GetDefaultAudioDevice(),
444 std::string(),
445 std::string(),
446 std::string());
449 scoped_ptr<ContentSettingBubbleModel> content_setting_bubble_model(
450 ContentSettingBubbleModel::CreateContentSettingBubbleModel(
451 NULL, web_contents(), profile(),
452 CONTENT_SETTINGS_TYPE_MEDIASTREAM));
453 const ContentSettingBubbleModel::BubbleContent& bubble_content =
454 content_setting_bubble_model->bubble_content();
455 // Settings not changed yet, so the "settings changed" message should not be
456 // shown.
457 EXPECT_TRUE(bubble_content.custom_link.empty());
459 EXPECT_EQ(1U, bubble_content.media_menus.size());
460 EXPECT_EQ(content::MEDIA_DEVICE_AUDIO_CAPTURE,
461 bubble_content.media_menus.begin()->first);
462 EXPECT_FALSE(bubble_content.media_menus.begin()->second.disabled);
463 EXPECT_TRUE(fake_audio_device2.IsEqual(
464 bubble_content.media_menus.begin()->second.selected_device));
466 // Select a different different device.
467 content_setting_bubble_model->OnMediaMenuClicked(
468 content::MEDIA_DEVICE_AUDIO_CAPTURE,
469 fake_audio_device3.id);
473 scoped_ptr<ContentSettingBubbleModel> content_setting_bubble_model(
474 ContentSettingBubbleModel::CreateContentSettingBubbleModel(
475 NULL, web_contents(), profile(),
476 CONTENT_SETTINGS_TYPE_MEDIASTREAM));
477 const ContentSettingBubbleModel::BubbleContent& bubble_content =
478 content_setting_bubble_model->bubble_content();
479 // Test that the reload hint is displayed.
480 EXPECT_FALSE(bubble_content.custom_link_enabled);
481 EXPECT_EQ(bubble_content.custom_link, l10n_util::GetStringUTF8(
482 IDS_MEDIASTREAM_SETTING_CHANGED_MESSAGE));
485 // Simulate that yet another audio stream capture request was initiated.
486 microphone_camera_state |= TabSpecificContentSettings::MICROPHONE_BLOCKED;
487 content_settings->OnMediaStreamPermissionSet(url,
488 microphone_camera_state,
489 GetDefaultAudioDevice(),
490 std::string(),
491 std::string(),
492 std::string());
495 scoped_ptr<ContentSettingBubbleModel> content_setting_bubble_model(
496 ContentSettingBubbleModel::CreateContentSettingBubbleModel(
497 NULL, web_contents(), profile(),
498 CONTENT_SETTINGS_TYPE_MEDIASTREAM));
499 const ContentSettingBubbleModel::BubbleContent& bubble_content =
500 content_setting_bubble_model->bubble_content();
501 // Test that the reload hint is not displayed any more, because this is a
502 // new permission request.
503 EXPECT_FALSE(bubble_content.custom_link_enabled);
504 EXPECT_TRUE(bubble_content.custom_link.empty());
506 // Though the audio menu setting should have persisted.
507 EXPECT_EQ(1U, bubble_content.media_menus.size());
508 EXPECT_EQ(content::MEDIA_DEVICE_AUDIO_CAPTURE,
509 bubble_content.media_menus.begin()->first);
510 EXPECT_FALSE(bubble_content.media_menus.begin()->second.disabled);
511 EXPECT_TRUE(fake_audio_device3.IsEqual(
512 bubble_content.media_menus.begin()->second.selected_device));
516 TEST_F(ContentSettingBubbleModelTest, MediastreamMic) {
517 // Required to break dependency on BrowserMainLoop.
518 MediaCaptureDevicesDispatcher::GetInstance()->
519 DisableDeviceEnumerationForTesting();
521 TabSpecificContentSettings* content_settings =
522 TabSpecificContentSettings::FromWebContents(web_contents());
523 std::string request_host = "google.com";
524 GURL security_origin("http://" + request_host);
525 TabSpecificContentSettings::MicrophoneCameraState microphone_camera_state =
526 TabSpecificContentSettings::MICROPHONE_ACCESSED;
527 content_settings->OnMediaStreamPermissionSet(security_origin,
528 microphone_camera_state,
529 GetDefaultAudioDevice(),
530 std::string(),
531 std::string(),
532 std::string());
534 scoped_ptr<ContentSettingBubbleModel> content_setting_bubble_model(
535 ContentSettingBubbleModel::CreateContentSettingBubbleModel(
536 NULL, web_contents(), profile(),
537 CONTENT_SETTINGS_TYPE_MEDIASTREAM));
538 const ContentSettingBubbleModel::BubbleContent& bubble_content =
539 content_setting_bubble_model->bubble_content();
540 EXPECT_EQ(bubble_content.title,
541 l10n_util::GetStringUTF8(IDS_MICROPHONE_ACCESSED));
542 EXPECT_EQ(2U, bubble_content.radio_group.radio_items.size());
543 EXPECT_EQ(bubble_content.radio_group.radio_items[0],
544 l10n_util::GetStringFUTF8(
545 IDS_ALLOWED_MEDIASTREAM_MIC_NO_ACTION,
546 url_formatter::FormatUrlForSecurityDisplay(
547 security_origin, profile()->GetPrefs()->GetString(
548 prefs::kAcceptLanguages))));
549 EXPECT_EQ(bubble_content.radio_group.radio_items[1],
550 l10n_util::GetStringUTF8(
551 IDS_ALLOWED_MEDIASTREAM_MIC_BLOCK));
552 EXPECT_EQ(0, bubble_content.radio_group.default_item);
553 EXPECT_TRUE(bubble_content.custom_link.empty());
554 EXPECT_FALSE(bubble_content.custom_link_enabled);
555 EXPECT_FALSE(bubble_content.manage_link.empty());
556 EXPECT_EQ(1U, bubble_content.media_menus.size());
557 EXPECT_EQ(content::MEDIA_DEVICE_AUDIO_CAPTURE,
558 bubble_content.media_menus.begin()->first);
560 // Change the microphone access.
561 microphone_camera_state |= TabSpecificContentSettings::MICROPHONE_BLOCKED;
562 content_settings->OnMediaStreamPermissionSet(security_origin,
563 microphone_camera_state,
564 GetDefaultAudioDevice(),
565 std::string(),
566 std::string(),
567 std::string());
568 content_setting_bubble_model.reset(
569 ContentSettingBubbleModel::CreateContentSettingBubbleModel(
570 NULL, web_contents(), profile(),
571 CONTENT_SETTINGS_TYPE_MEDIASTREAM));
572 const ContentSettingBubbleModel::BubbleContent& new_bubble_content =
573 content_setting_bubble_model->bubble_content();
574 EXPECT_EQ(new_bubble_content.title,
575 l10n_util::GetStringUTF8(IDS_MICROPHONE_BLOCKED));
576 EXPECT_EQ(2U, new_bubble_content.radio_group.radio_items.size());
577 EXPECT_EQ(new_bubble_content.radio_group.radio_items[0],
578 l10n_util::GetStringFUTF8(
579 IDS_BLOCKED_MEDIASTREAM_MIC_ASK,
580 url_formatter::FormatUrlForSecurityDisplay(
581 security_origin, profile()->GetPrefs()->GetString(
582 prefs::kAcceptLanguages))));
583 EXPECT_EQ(new_bubble_content.radio_group.radio_items[1],
584 l10n_util::GetStringUTF8(
585 IDS_BLOCKED_MEDIASTREAM_MIC_NO_ACTION));
586 EXPECT_EQ(1, new_bubble_content.radio_group.default_item);
587 EXPECT_TRUE(new_bubble_content.custom_link.empty());
588 EXPECT_FALSE(new_bubble_content.custom_link_enabled);
589 EXPECT_FALSE(new_bubble_content.manage_link.empty());
590 EXPECT_EQ(1U, new_bubble_content.media_menus.size());
591 EXPECT_EQ(content::MEDIA_DEVICE_AUDIO_CAPTURE,
592 new_bubble_content.media_menus.begin()->first);
595 TEST_F(ContentSettingBubbleModelTest, MediastreamCamera) {
596 // Required to break dependency on BrowserMainLoop.
597 MediaCaptureDevicesDispatcher::GetInstance()->
598 DisableDeviceEnumerationForTesting();
600 TabSpecificContentSettings* content_settings =
601 TabSpecificContentSettings::FromWebContents(web_contents());
602 std::string request_host = "google.com";
603 GURL security_origin("http://" + request_host);
604 TabSpecificContentSettings::MicrophoneCameraState microphone_camera_state =
605 TabSpecificContentSettings::CAMERA_ACCESSED;
606 content_settings->OnMediaStreamPermissionSet(security_origin,
607 microphone_camera_state,
608 std::string(),
609 GetDefaultVideoDevice(),
610 std::string(),
611 std::string());
613 scoped_ptr<ContentSettingBubbleModel> content_setting_bubble_model(
614 ContentSettingBubbleModel::CreateContentSettingBubbleModel(
615 NULL, web_contents(), profile(),
616 CONTENT_SETTINGS_TYPE_MEDIASTREAM));
617 const ContentSettingBubbleModel::BubbleContent& bubble_content =
618 content_setting_bubble_model->bubble_content();
619 EXPECT_EQ(bubble_content.title,
620 l10n_util::GetStringUTF8(IDS_CAMERA_ACCESSED));
621 EXPECT_EQ(2U, bubble_content.radio_group.radio_items.size());
622 EXPECT_EQ(bubble_content.radio_group.radio_items[0],
623 l10n_util::GetStringFUTF8(
624 IDS_ALLOWED_MEDIASTREAM_CAMERA_NO_ACTION,
625 url_formatter::FormatUrlForSecurityDisplay(
626 security_origin, profile()->GetPrefs()->GetString(
627 prefs::kAcceptLanguages))));
628 EXPECT_EQ(bubble_content.radio_group.radio_items[1],
629 l10n_util::GetStringUTF8(
630 IDS_ALLOWED_MEDIASTREAM_CAMERA_BLOCK));
631 EXPECT_EQ(0, bubble_content.radio_group.default_item);
632 EXPECT_TRUE(bubble_content.custom_link.empty());
633 EXPECT_FALSE(bubble_content.custom_link_enabled);
634 EXPECT_FALSE(bubble_content.manage_link.empty());
635 EXPECT_EQ(1U, bubble_content.media_menus.size());
636 EXPECT_EQ(content::MEDIA_DEVICE_VIDEO_CAPTURE,
637 bubble_content.media_menus.begin()->first);
639 // Change the camera access.
640 microphone_camera_state |= TabSpecificContentSettings::CAMERA_BLOCKED;
641 content_settings->OnMediaStreamPermissionSet(security_origin,
642 microphone_camera_state,
643 std::string(),
644 GetDefaultVideoDevice(),
645 std::string(),
646 std::string());
647 content_setting_bubble_model.reset(
648 ContentSettingBubbleModel::CreateContentSettingBubbleModel(
649 NULL, web_contents(), profile(),
650 CONTENT_SETTINGS_TYPE_MEDIASTREAM));
651 const ContentSettingBubbleModel::BubbleContent& new_bubble_content =
652 content_setting_bubble_model->bubble_content();
653 EXPECT_EQ(new_bubble_content.title,
654 l10n_util::GetStringUTF8(IDS_CAMERA_BLOCKED));
655 EXPECT_EQ(2U, new_bubble_content.radio_group.radio_items.size());
656 EXPECT_EQ(new_bubble_content.radio_group.radio_items[0],
657 l10n_util::GetStringFUTF8(
658 IDS_BLOCKED_MEDIASTREAM_CAMERA_ASK,
659 url_formatter::FormatUrlForSecurityDisplay(
660 security_origin, profile()->GetPrefs()->GetString(
661 prefs::kAcceptLanguages))));
662 EXPECT_EQ(new_bubble_content.radio_group.radio_items[1],
663 l10n_util::GetStringUTF8(
664 IDS_BLOCKED_MEDIASTREAM_CAMERA_NO_ACTION));
665 EXPECT_EQ(1, new_bubble_content.radio_group.default_item);
666 EXPECT_TRUE(new_bubble_content.custom_link.empty());
667 EXPECT_FALSE(new_bubble_content.custom_link_enabled);
668 EXPECT_FALSE(new_bubble_content.manage_link.empty());
669 EXPECT_EQ(1U, new_bubble_content.media_menus.size());
670 EXPECT_EQ(content::MEDIA_DEVICE_VIDEO_CAPTURE,
671 new_bubble_content.media_menus.begin()->first);
674 TEST_F(ContentSettingBubbleModelTest, AccumulateMediastreamMicAndCamera) {
675 // Required to break dependency on BrowserMainLoop.
676 MediaCaptureDevicesDispatcher::GetInstance()->
677 DisableDeviceEnumerationForTesting();
679 TabSpecificContentSettings* content_settings =
680 TabSpecificContentSettings::FromWebContents(web_contents());
681 std::string request_host = "google.com";
682 GURL security_origin("http://" + request_host);
684 // Firstly, add microphone access.
685 TabSpecificContentSettings::MicrophoneCameraState microphone_camera_state =
686 TabSpecificContentSettings::MICROPHONE_ACCESSED;
687 content_settings->OnMediaStreamPermissionSet(security_origin,
688 microphone_camera_state,
689 GetDefaultAudioDevice(),
690 std::string(),
691 std::string(),
692 std::string());
694 scoped_ptr<ContentSettingBubbleModel> content_setting_bubble_model(
695 ContentSettingBubbleModel::CreateContentSettingBubbleModel(
696 NULL, web_contents(), profile(),
697 CONTENT_SETTINGS_TYPE_MEDIASTREAM));
698 const ContentSettingBubbleModel::BubbleContent& bubble_content =
699 content_setting_bubble_model->bubble_content();
700 EXPECT_EQ(bubble_content.title,
701 l10n_util::GetStringUTF8(IDS_MICROPHONE_ACCESSED));
702 EXPECT_EQ(2U, bubble_content.radio_group.radio_items.size());
703 EXPECT_EQ(bubble_content.radio_group.radio_items[0],
704 l10n_util::GetStringFUTF8(
705 IDS_ALLOWED_MEDIASTREAM_MIC_NO_ACTION,
706 url_formatter::FormatUrlForSecurityDisplay(
707 security_origin, profile()->GetPrefs()->GetString(
708 prefs::kAcceptLanguages))));
709 EXPECT_EQ(bubble_content.radio_group.radio_items[1],
710 l10n_util::GetStringUTF8(
711 IDS_ALLOWED_MEDIASTREAM_MIC_BLOCK));
712 EXPECT_EQ(0, bubble_content.radio_group.default_item);
713 EXPECT_EQ(1U, bubble_content.media_menus.size());
714 EXPECT_EQ(content::MEDIA_DEVICE_AUDIO_CAPTURE,
715 bubble_content.media_menus.begin()->first);
717 // Then add camera access.
718 microphone_camera_state |= TabSpecificContentSettings::CAMERA_ACCESSED;
719 content_settings->OnMediaStreamPermissionSet(security_origin,
720 microphone_camera_state,
721 GetDefaultAudioDevice(),
722 GetDefaultVideoDevice(),
723 std::string(),
724 std::string());
726 content_setting_bubble_model.reset(
727 ContentSettingBubbleModel::CreateContentSettingBubbleModel(
728 NULL, web_contents(), profile(),
729 CONTENT_SETTINGS_TYPE_MEDIASTREAM));
730 const ContentSettingBubbleModel::BubbleContent& new_bubble_content =
731 content_setting_bubble_model->bubble_content();
732 EXPECT_EQ(new_bubble_content.title,
733 l10n_util::GetStringUTF8(IDS_MICROPHONE_CAMERA_ALLOWED));
734 EXPECT_EQ(2U, new_bubble_content.radio_group.radio_items.size());
735 EXPECT_EQ(new_bubble_content.radio_group.radio_items[0],
736 l10n_util::GetStringFUTF8(
737 IDS_ALLOWED_MEDIASTREAM_MIC_AND_CAMERA_NO_ACTION,
738 url_formatter::FormatUrlForSecurityDisplay(
739 security_origin, profile()->GetPrefs()->GetString(
740 prefs::kAcceptLanguages))));
741 EXPECT_EQ(new_bubble_content.radio_group.radio_items[1],
742 l10n_util::GetStringUTF8(
743 IDS_ALLOWED_MEDIASTREAM_MIC_AND_CAMERA_BLOCK));
744 EXPECT_EQ(0, new_bubble_content.radio_group.default_item);
745 EXPECT_EQ(2U, new_bubble_content.media_menus.size());
748 TEST_F(ContentSettingBubbleModelTest, Plugins) {
749 TabSpecificContentSettings* content_settings =
750 TabSpecificContentSettings::FromWebContents(web_contents());
751 const base::string16 plugin_name = base::ASCIIToUTF16("plugin_name");
753 content_settings->OnContentBlockedWithDetail(CONTENT_SETTINGS_TYPE_PLUGINS,
754 plugin_name);
756 scoped_ptr<ContentSettingBubbleModel> content_setting_bubble_model(
757 ContentSettingBubbleModel::CreateContentSettingBubbleModel(
758 NULL, web_contents(), profile(),
759 CONTENT_SETTINGS_TYPE_PLUGINS));
760 const ContentSettingBubbleModel::BubbleContent& bubble_content =
761 content_setting_bubble_model->bubble_content();
762 EXPECT_FALSE(bubble_content.title.empty());
763 ASSERT_EQ(1U, bubble_content.list_items.size());
764 EXPECT_EQ(plugin_name,
765 base::ASCIIToUTF16(bubble_content.list_items[0].title));
766 EXPECT_EQ(2U, bubble_content.radio_group.radio_items.size());
767 EXPECT_FALSE(bubble_content.custom_link.empty());
768 EXPECT_TRUE(bubble_content.custom_link_enabled);
769 EXPECT_FALSE(bubble_content.manage_link.empty());
770 EXPECT_FALSE(bubble_content.learn_more_link.empty());
773 TEST_F(ContentSettingBubbleModelTest, PepperBroker) {
774 TabSpecificContentSettings* content_settings =
775 TabSpecificContentSettings::FromWebContents(web_contents());
776 content_settings->OnContentBlocked(CONTENT_SETTINGS_TYPE_PPAPI_BROKER);
778 scoped_ptr<ContentSettingBubbleModel> content_setting_bubble_model(
779 ContentSettingBubbleModel::CreateContentSettingBubbleModel(
780 NULL, web_contents(), profile(),
781 CONTENT_SETTINGS_TYPE_PPAPI_BROKER));
782 const ContentSettingBubbleModel::BubbleContent& bubble_content =
783 content_setting_bubble_model->bubble_content();
785 std::string title = bubble_content.title;
786 EXPECT_FALSE(title.empty());
787 ASSERT_EQ(2U, bubble_content.radio_group.radio_items.size());
788 std::string radio1 = bubble_content.radio_group.radio_items[0];
789 std::string radio2 = bubble_content.radio_group.radio_items[1];
790 EXPECT_FALSE(bubble_content.custom_link_enabled);
791 EXPECT_FALSE(bubble_content.manage_link.empty());
793 content_settings->ClearBlockedContentSettingsExceptForCookies();
794 content_settings->OnContentAllowed(CONTENT_SETTINGS_TYPE_PPAPI_BROKER);
795 content_setting_bubble_model.reset(
796 ContentSettingBubbleModel::CreateContentSettingBubbleModel(
797 NULL, web_contents(), profile(),
798 CONTENT_SETTINGS_TYPE_PPAPI_BROKER));
799 const ContentSettingBubbleModel::BubbleContent& bubble_content_2 =
800 content_setting_bubble_model->bubble_content();
802 EXPECT_FALSE(bubble_content_2.title.empty());
803 EXPECT_NE(title, bubble_content_2.title);
804 ASSERT_EQ(2U, bubble_content_2.radio_group.radio_items.size());
805 EXPECT_NE(radio1, bubble_content_2.radio_group.radio_items[0]);
806 EXPECT_NE(radio2, bubble_content_2.radio_group.radio_items[1]);
807 EXPECT_FALSE(bubble_content_2.custom_link_enabled);
808 EXPECT_FALSE(bubble_content_2.manage_link.empty());
811 TEST_F(ContentSettingBubbleModelTest, Geolocation) {
812 const GURL page_url("http://toplevel.example/");
813 const GURL frame1_url("http://host1.example/");
814 const GURL frame2_url("http://host2.example:999/");
816 NavigateAndCommit(page_url);
817 TabSpecificContentSettings* content_settings =
818 TabSpecificContentSettings::FromWebContents(web_contents());
820 // One permitted frame, but not in the content map: requires reload.
821 content_settings->OnGeolocationPermissionSet(frame1_url, true);
822 CheckGeolocationBubble(1, false, true);
824 // Add it to the content map, should now have a clear link.
825 HostContentSettingsMap* setting_map =
826 HostContentSettingsMapFactory::GetForProfile(profile());
827 setting_map->SetContentSetting(
828 ContentSettingsPattern::FromURLNoWildcard(frame1_url),
829 ContentSettingsPattern::FromURLNoWildcard(page_url),
830 CONTENT_SETTINGS_TYPE_GEOLOCATION,
831 std::string(),
832 CONTENT_SETTING_ALLOW);
833 CheckGeolocationBubble(1, true, false);
835 // Change the default to allow: no message needed.
836 setting_map->SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_GEOLOCATION,
837 CONTENT_SETTING_ALLOW);
838 CheckGeolocationBubble(1, false, false);
840 // Second frame denied, but not stored in the content map: requires reload.
841 content_settings->OnGeolocationPermissionSet(frame2_url, false);
842 CheckGeolocationBubble(2, false, true);
844 // Change the default to block: offer a clear link for the persisted frame 1.
845 setting_map->SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_GEOLOCATION,
846 CONTENT_SETTING_BLOCK);
847 CheckGeolocationBubble(2, true, false);
850 TEST_F(ContentSettingBubbleModelTest, FileURL) {
851 std::string file_url("file:///tmp/test.html");
852 NavigateAndCommit(GURL(file_url));
853 TabSpecificContentSettings::FromWebContents(web_contents())->OnContentBlocked(
854 CONTENT_SETTINGS_TYPE_IMAGES);
855 scoped_ptr<ContentSettingBubbleModel> content_setting_bubble_model(
856 ContentSettingBubbleModel::CreateContentSettingBubbleModel(
857 NULL, web_contents(), profile(),
858 CONTENT_SETTINGS_TYPE_IMAGES));
859 std::string title =
860 content_setting_bubble_model->bubble_content().radio_group.radio_items[0];
861 ASSERT_NE(std::string::npos, title.find(file_url));
864 TEST_F(ContentSettingBubbleModelTest, RegisterProtocolHandler) {
865 const GURL page_url("http://toplevel.example/");
866 NavigateAndCommit(page_url);
867 TabSpecificContentSettings* content_settings =
868 TabSpecificContentSettings::FromWebContents(web_contents());
869 content_settings->set_pending_protocol_handler(
870 ProtocolHandler::CreateProtocolHandler(
871 "mailto", GURL("http://www.toplevel.example/")));
873 ContentSettingRPHBubbleModel content_setting_bubble_model(
874 NULL, web_contents(), profile(), NULL);
876 const ContentSettingBubbleModel::BubbleContent& bubble_content =
877 content_setting_bubble_model.bubble_content();
878 EXPECT_FALSE(bubble_content.title.empty());
879 EXPECT_FALSE(bubble_content.radio_group.radio_items.empty());
880 EXPECT_TRUE(bubble_content.list_items.empty());
881 EXPECT_TRUE(bubble_content.domain_lists.empty());
882 EXPECT_TRUE(bubble_content.custom_link.empty());
883 EXPECT_FALSE(bubble_content.custom_link_enabled);
884 EXPECT_FALSE(bubble_content.manage_link.empty());
887 class FakeDelegate : public ProtocolHandlerRegistry::Delegate {
888 public:
889 void RegisterExternalHandler(const std::string& protocol) override {
890 // Overrides in order to not register the handler with the
891 // ChildProcessSecurityPolicy. That has persistent and unalterable
892 // side effects on other tests.
895 ShellIntegration::DefaultProtocolClientWorker* CreateShellWorker(
896 ShellIntegration::DefaultWebClientObserver* observer,
897 const std::string& protocol) override {
898 VLOG(1) << "CreateShellWorker";
899 return NULL;
902 ProtocolHandlerRegistry::DefaultClientObserver* CreateShellObserver(
903 ProtocolHandlerRegistry* registry) override {
904 return NULL;
907 void RegisterWithOSAsDefaultClient(
908 const std::string& protocol,
909 ProtocolHandlerRegistry* registry) override {
910 VLOG(1) << "Register With OS";
914 TEST_F(ContentSettingBubbleModelTest, RPHAllow) {
915 ProtocolHandlerRegistry registry(profile(), new FakeDelegate());
916 registry.InitProtocolSettings();
918 const GURL page_url("http://toplevel.example/");
919 NavigateAndCommit(page_url);
920 TabSpecificContentSettings* content_settings =
921 TabSpecificContentSettings::FromWebContents(web_contents());
922 ProtocolHandler test_handler = ProtocolHandler::CreateProtocolHandler(
923 "mailto", GURL("http://www.toplevel.example/"));
924 content_settings->set_pending_protocol_handler(test_handler);
926 ContentSettingRPHBubbleModel content_setting_bubble_model(
927 NULL, web_contents(), profile(), &registry);
930 ProtocolHandler handler = registry.GetHandlerFor("mailto");
931 EXPECT_TRUE(handler.IsEmpty());
932 EXPECT_EQ(CONTENT_SETTING_DEFAULT,
933 content_settings->pending_protocol_handler_setting());
936 // "0" is the "Allow" radio button.
937 content_setting_bubble_model.OnRadioClicked(0);
939 ProtocolHandler handler = registry.GetHandlerFor("mailto");
940 ASSERT_FALSE(handler.IsEmpty());
941 EXPECT_EQ(CONTENT_SETTING_ALLOW,
942 content_settings->pending_protocol_handler_setting());
945 // "1" is the "Deny" radio button.
946 content_setting_bubble_model.OnRadioClicked(1);
948 ProtocolHandler handler = registry.GetHandlerFor("mailto");
949 EXPECT_TRUE(handler.IsEmpty());
950 EXPECT_EQ(CONTENT_SETTING_BLOCK,
951 content_settings->pending_protocol_handler_setting());
954 // "2" is the "Ignore button.
955 content_setting_bubble_model.OnRadioClicked(2);
957 ProtocolHandler handler = registry.GetHandlerFor("mailto");
958 EXPECT_TRUE(handler.IsEmpty());
959 EXPECT_EQ(CONTENT_SETTING_DEFAULT,
960 content_settings->pending_protocol_handler_setting());
961 EXPECT_TRUE(registry.IsIgnored(test_handler));
964 // "0" is the "Allow" radio button.
965 content_setting_bubble_model.OnRadioClicked(0);
967 ProtocolHandler handler = registry.GetHandlerFor("mailto");
968 ASSERT_FALSE(handler.IsEmpty());
969 EXPECT_EQ(CONTENT_SETTING_ALLOW,
970 content_settings->pending_protocol_handler_setting());
971 EXPECT_FALSE(registry.IsIgnored(test_handler));
974 registry.Shutdown();