OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <string> | 5 #include <string> |
6 #include <utility> | 6 #include <utility> |
7 | 7 |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 | 308 |
309 ContentSetting default_setting = | 309 ContentSetting default_setting = |
310 HostContentSettingsMapFactory::GetForProfile(profile) | 310 HostContentSettingsMapFactory::GetForProfile(profile) |
311 ->GetDefaultContentSetting(CONTENT_SETTINGS_TYPE_NOTIFICATIONS, NULL); | 311 ->GetDefaultContentSetting(CONTENT_SETTINGS_TYPE_NOTIFICATIONS, NULL); |
312 ASSERT_EQ(CONTENT_SETTING_ASK, default_setting); | 312 ASSERT_EQ(CONTENT_SETTING_ASK, default_setting); |
313 | 313 |
314 PermissionManager* permission_manager = PermissionManager::Get(profile); | 314 PermissionManager* permission_manager = PermissionManager::Get(profile); |
315 | 315 |
316 // (1) Enable the permission when the default is to ask (expected to set). | 316 // (1) Enable the permission when the default is to ask (expected to set). |
317 controller()->SetNotifierEnabled(disabled_notifier, true); | 317 controller()->SetNotifierEnabled(disabled_notifier, true); |
318 EXPECT_EQ(blink::mojom::PermissionStatus::GRANTED, | 318 EXPECT_EQ(CONTENT_SETTING_ALLOW, |
319 permission_manager->GetPermissionStatus( | 319 permission_manager->GetPermissionStatus( |
320 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, origin, origin)); | 320 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, origin, origin)); |
321 | 321 |
322 // (2) Disable the permission when the default is to ask (expected to clear). | 322 // (2) Disable the permission when the default is to ask (expected to clear). |
323 controller()->SetNotifierEnabled(enabled_notifier, false); | 323 controller()->SetNotifierEnabled(enabled_notifier, false); |
324 EXPECT_EQ(blink::mojom::PermissionStatus::ASK, | 324 EXPECT_EQ(CONTENT_SETTING_ASK, |
325 permission_manager->GetPermissionStatus( | 325 permission_manager->GetPermissionStatus( |
326 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, origin, origin)); | 326 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, origin, origin)); |
327 | 327 |
328 // Change the default content setting vaule for notifications to ALLOW. | 328 // Change the default content setting vaule for notifications to ALLOW. |
329 HostContentSettingsMapFactory::GetForProfile(profile) | 329 HostContentSettingsMapFactory::GetForProfile(profile) |
330 ->SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_NOTIFICATIONS, | 330 ->SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_NOTIFICATIONS, |
331 CONTENT_SETTING_ALLOW); | 331 CONTENT_SETTING_ALLOW); |
332 | 332 |
333 // (3) Disable the permission when the default is allowed (expected to set). | 333 // (3) Disable the permission when the default is allowed (expected to set). |
334 controller()->SetNotifierEnabled(enabled_notifier, false); | 334 controller()->SetNotifierEnabled(enabled_notifier, false); |
335 EXPECT_EQ(blink::mojom::PermissionStatus::DENIED, | 335 EXPECT_EQ(CONTENT_SETTING_BLOCK, |
336 permission_manager->GetPermissionStatus( | 336 permission_manager->GetPermissionStatus( |
337 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, origin, origin)); | 337 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, origin, origin)); |
338 | 338 |
339 // (4) Enable the permission when the default is allowed (expected to clear). | 339 // (4) Enable the permission when the default is allowed (expected to clear). |
340 controller()->SetNotifierEnabled(disabled_notifier, true); | 340 controller()->SetNotifierEnabled(disabled_notifier, true); |
341 EXPECT_EQ(blink::mojom::PermissionStatus::GRANTED, | 341 EXPECT_EQ(CONTENT_SETTING_ALLOW, |
342 permission_manager->GetPermissionStatus( | 342 permission_manager->GetPermissionStatus( |
343 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, origin, origin)); | 343 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, origin, origin)); |
344 | 344 |
345 // Now change the default content setting value to BLOCK. | 345 // Now change the default content setting value to BLOCK. |
346 HostContentSettingsMapFactory::GetForProfile(profile) | 346 HostContentSettingsMapFactory::GetForProfile(profile) |
347 ->SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_NOTIFICATIONS, | 347 ->SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_NOTIFICATIONS, |
348 CONTENT_SETTING_BLOCK); | 348 CONTENT_SETTING_BLOCK); |
349 | 349 |
350 // (5) Enable the permission when the default is blocked (expected to set). | 350 // (5) Enable the permission when the default is blocked (expected to set). |
351 controller()->SetNotifierEnabled(disabled_notifier, true); | 351 controller()->SetNotifierEnabled(disabled_notifier, true); |
352 EXPECT_EQ(blink::mojom::PermissionStatus::GRANTED, | 352 EXPECT_EQ(CONTENT_SETTING_ALLOW, |
353 permission_manager->GetPermissionStatus( | 353 permission_manager->GetPermissionStatus( |
354 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, origin, origin)); | 354 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, origin, origin)); |
355 | 355 |
356 // (6) Disable the permission when the default is blocked (expected to clear). | 356 // (6) Disable the permission when the default is blocked (expected to clear). |
357 controller()->SetNotifierEnabled(enabled_notifier, false); | 357 controller()->SetNotifierEnabled(enabled_notifier, false); |
358 EXPECT_EQ(blink::mojom::PermissionStatus::DENIED, | 358 EXPECT_EQ(CONTENT_SETTING_BLOCK, |
359 permission_manager->GetPermissionStatus( | 359 permission_manager->GetPermissionStatus( |
360 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, origin, origin)); | 360 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, origin, origin)); |
361 } | 361 } |
OLD | NEW |