OLD | NEW |
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/utf_string_conversions.h" | 7 #include "base/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 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 url, | 282 url, |
283 CONTENT_SETTINGS_TYPE_PLUGINS, | 283 CONTENT_SETTINGS_TYPE_PLUGINS, |
284 fooPlugin)); | 284 fooPlugin)); |
285 EXPECT_EQ(CONTENT_SETTING_ALLOW, | 285 EXPECT_EQ(CONTENT_SETTING_ALLOW, |
286 map->GetContentSetting(url, | 286 map->GetContentSetting(url, |
287 url, | 287 url, |
288 CONTENT_SETTINGS_TYPE_PLUGINS, | 288 CONTENT_SETTINGS_TYPE_PLUGINS, |
289 barPlugin)); | 289 barPlugin)); |
290 } | 290 } |
291 | 291 |
| 292 TEST_F(ContentSettingBubbleModelTest, PepperBroker) { |
| 293 TabSpecificContentSettings* content_settings = |
| 294 TabSpecificContentSettings::FromWebContents(web_contents()); |
| 295 content_settings->OnContentBlocked(CONTENT_SETTINGS_TYPE_PPAPI_BROKER, |
| 296 std::string()); |
| 297 |
| 298 scoped_ptr<ContentSettingBubbleModel> content_setting_bubble_model( |
| 299 ContentSettingBubbleModel::CreateContentSettingBubbleModel( |
| 300 NULL, web_contents(), profile(), |
| 301 CONTENT_SETTINGS_TYPE_PPAPI_BROKER)); |
| 302 const ContentSettingBubbleModel::BubbleContent& bubble_content = |
| 303 content_setting_bubble_model->bubble_content(); |
| 304 |
| 305 std::string title = bubble_content.title; |
| 306 EXPECT_FALSE(title.empty()); |
| 307 ASSERT_EQ(2U, bubble_content.radio_group.radio_items.size()); |
| 308 std::string radio1 = bubble_content.radio_group.radio_items[0]; |
| 309 std::string radio2 = bubble_content.radio_group.radio_items[1]; |
| 310 EXPECT_FALSE(bubble_content.custom_link_enabled); |
| 311 EXPECT_FALSE(bubble_content.manage_link.empty()); |
| 312 |
| 313 content_settings->ClearBlockedContentSettingsExceptForCookies(); |
| 314 content_settings->OnContentAccessed(CONTENT_SETTINGS_TYPE_PPAPI_BROKER); |
| 315 content_setting_bubble_model.reset( |
| 316 ContentSettingBubbleModel::CreateContentSettingBubbleModel( |
| 317 NULL, web_contents(), profile(), |
| 318 CONTENT_SETTINGS_TYPE_PPAPI_BROKER)); |
| 319 const ContentSettingBubbleModel::BubbleContent& bubble_content_2 = |
| 320 content_setting_bubble_model->bubble_content(); |
| 321 |
| 322 EXPECT_FALSE(bubble_content_2.title.empty()); |
| 323 EXPECT_NE(title, bubble_content_2.title); |
| 324 ASSERT_EQ(2U, bubble_content_2.radio_group.radio_items.size()); |
| 325 EXPECT_NE(radio1, bubble_content_2.radio_group.radio_items[0]); |
| 326 EXPECT_NE(radio2, bubble_content_2.radio_group.radio_items[1]); |
| 327 EXPECT_FALSE(bubble_content_2.custom_link_enabled); |
| 328 EXPECT_FALSE(bubble_content_2.manage_link.empty()); |
| 329 } |
| 330 |
292 TEST_F(ContentSettingBubbleModelTest, Geolocation) { | 331 TEST_F(ContentSettingBubbleModelTest, Geolocation) { |
293 const GURL page_url("http://toplevel.example/"); | 332 const GURL page_url("http://toplevel.example/"); |
294 const GURL frame1_url("http://host1.example/"); | 333 const GURL frame1_url("http://host1.example/"); |
295 const GURL frame2_url("http://host2.example:999/"); | 334 const GURL frame2_url("http://host2.example:999/"); |
296 | 335 |
297 NavigateAndCommit(page_url); | 336 NavigateAndCommit(page_url); |
298 TabSpecificContentSettings* content_settings = | 337 TabSpecificContentSettings* content_settings = |
299 TabSpecificContentSettings::FromWebContents(web_contents()); | 338 TabSpecificContentSettings::FromWebContents(web_contents()); |
300 | 339 |
301 // One permitted frame, but not in the content map: requires reload. | 340 // One permitted frame, but not in the content map: requires reload. |
(...skipping 22 matching lines...) Expand all Loading... |
324 | 363 |
325 // Change the default to block: offer a clear link for the persisted frame 1. | 364 // Change the default to block: offer a clear link for the persisted frame 1. |
326 profile()->GetHostContentSettingsMap()->SetDefaultContentSetting( | 365 profile()->GetHostContentSettingsMap()->SetDefaultContentSetting( |
327 CONTENT_SETTINGS_TYPE_GEOLOCATION, CONTENT_SETTING_BLOCK); | 366 CONTENT_SETTINGS_TYPE_GEOLOCATION, CONTENT_SETTING_BLOCK); |
328 CheckGeolocationBubble(2, true, false); | 367 CheckGeolocationBubble(2, true, false); |
329 } | 368 } |
330 | 369 |
331 TEST_F(ContentSettingBubbleModelTest, FileURL) { | 370 TEST_F(ContentSettingBubbleModelTest, FileURL) { |
332 std::string file_url("file:///tmp/test.html"); | 371 std::string file_url("file:///tmp/test.html"); |
333 NavigateAndCommit(GURL(file_url)); | 372 NavigateAndCommit(GURL(file_url)); |
| 373 TabSpecificContentSettings::FromWebContents(web_contents())->OnContentBlocked( |
| 374 CONTENT_SETTINGS_TYPE_IMAGES, std::string()); |
334 scoped_ptr<ContentSettingBubbleModel> content_setting_bubble_model( | 375 scoped_ptr<ContentSettingBubbleModel> content_setting_bubble_model( |
335 ContentSettingBubbleModel::CreateContentSettingBubbleModel( | 376 ContentSettingBubbleModel::CreateContentSettingBubbleModel( |
336 NULL, web_contents(), profile(), | 377 NULL, web_contents(), profile(), |
337 CONTENT_SETTINGS_TYPE_IMAGES)); | 378 CONTENT_SETTINGS_TYPE_IMAGES)); |
338 std::string title = | 379 std::string title = |
339 content_setting_bubble_model->bubble_content().radio_group.radio_items[0]; | 380 content_setting_bubble_model->bubble_content().radio_group.radio_items[0]; |
340 ASSERT_NE(std::string::npos, title.find(file_url)); | 381 ASSERT_NE(std::string::npos, title.find(file_url)); |
341 } | 382 } |
342 | 383 |
343 TEST_F(ContentSettingBubbleModelTest, RegisterProtocolHandler) { | 384 TEST_F(ContentSettingBubbleModelTest, RegisterProtocolHandler) { |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
452 ProtocolHandler handler = registry.GetHandlerFor("mailto"); | 493 ProtocolHandler handler = registry.GetHandlerFor("mailto"); |
453 ASSERT_FALSE(handler.IsEmpty()); | 494 ASSERT_FALSE(handler.IsEmpty()); |
454 EXPECT_EQ(ASCIIToUTF16("Handler"), handler.title()); | 495 EXPECT_EQ(ASCIIToUTF16("Handler"), handler.title()); |
455 EXPECT_EQ(CONTENT_SETTING_ALLOW, | 496 EXPECT_EQ(CONTENT_SETTING_ALLOW, |
456 content_settings->pending_protocol_handler_setting()); | 497 content_settings->pending_protocol_handler_setting()); |
457 EXPECT_FALSE(registry.IsIgnored(test_handler)); | 498 EXPECT_FALSE(registry.IsIgnored(test_handler)); |
458 } | 499 } |
459 | 500 |
460 registry.Shutdown(); | 501 registry.Shutdown(); |
461 } | 502 } |
OLD | NEW |