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

Side by Side Diff: chrome/browser/notifications/message_center_settings_controller_unittest.cc

Issue 2675483002: Replace PermissionType in chrome/ with ContentSettingsType (Closed)
Patch Set: rebase Created 3 years, 10 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
OLDNEW
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"
11 #include "build/build_config.h" 11 #include "build/build_config.h"
12 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" 12 #include "chrome/browser/content_settings/host_content_settings_map_factory.h"
13 #include "chrome/browser/extensions/extension_service.h" 13 #include "chrome/browser/extensions/extension_service.h"
14 #include "chrome/browser/extensions/test_extension_system.h" 14 #include "chrome/browser/extensions/test_extension_system.h"
15 #include "chrome/browser/notifications/message_center_settings_controller.h" 15 #include "chrome/browser/notifications/message_center_settings_controller.h"
16 #include "chrome/browser/permissions/permission_manager.h" 16 #include "chrome/browser/permissions/permission_manager.h"
17 #include "chrome/browser/profiles/profile_manager.h" 17 #include "chrome/browser/profiles/profile_manager.h"
18 #include "chrome/test/base/testing_browser_process.h" 18 #include "chrome/test/base/testing_browser_process.h"
19 #include "chrome/test/base/testing_profile_manager.h" 19 #include "chrome/test/base/testing_profile_manager.h"
20 #include "components/content_settings/core/browser/host_content_settings_map.h" 20 #include "components/content_settings/core/browser/host_content_settings_map.h"
21 #include "content/public/browser/permission_type.h"
22 #include "content/public/test/test_browser_thread_bundle.h" 21 #include "content/public/test/test_browser_thread_bundle.h"
23 #include "extensions/common/extension.h" 22 #include "extensions/common/extension.h"
24 #include "extensions/common/extension_builder.h" 23 #include "extensions/common/extension_builder.h"
25 #include "testing/gtest/include/gtest/gtest.h" 24 #include "testing/gtest/include/gtest/gtest.h"
26 #include "ui/message_center/notifier_settings.h" 25 #include "ui/message_center/notifier_settings.h"
27 26
28 #if defined(OS_CHROMEOS) 27 #if defined(OS_CHROMEOS)
29 #include "ash/common/system/system_notifier.h" 28 #include "ash/common/system/system_notifier.h"
30 #include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h" 29 #include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h"
31 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" 30 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h"
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 HostContentSettingsMapFactory::GetForProfile(profile) 309 HostContentSettingsMapFactory::GetForProfile(profile)
311 ->GetDefaultContentSetting(CONTENT_SETTINGS_TYPE_NOTIFICATIONS, NULL); 310 ->GetDefaultContentSetting(CONTENT_SETTINGS_TYPE_NOTIFICATIONS, NULL);
312 ASSERT_EQ(CONTENT_SETTING_ASK, default_setting); 311 ASSERT_EQ(CONTENT_SETTING_ASK, default_setting);
313 312
314 PermissionManager* permission_manager = PermissionManager::Get(profile); 313 PermissionManager* permission_manager = PermissionManager::Get(profile);
315 314
316 // (1) Enable the permission when the default is to ask (expected to set). 315 // (1) Enable the permission when the default is to ask (expected to set).
317 controller()->SetNotifierEnabled(disabled_notifier, true); 316 controller()->SetNotifierEnabled(disabled_notifier, true);
318 EXPECT_EQ(blink::mojom::PermissionStatus::GRANTED, 317 EXPECT_EQ(blink::mojom::PermissionStatus::GRANTED,
319 permission_manager->GetPermissionStatus( 318 permission_manager->GetPermissionStatus(
320 content::PermissionType::NOTIFICATIONS, origin, origin)); 319 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, origin, origin));
321 320
322 // (2) Disable the permission when the default is to ask (expected to clear). 321 // (2) Disable the permission when the default is to ask (expected to clear).
323 controller()->SetNotifierEnabled(enabled_notifier, false); 322 controller()->SetNotifierEnabled(enabled_notifier, false);
324 EXPECT_EQ(blink::mojom::PermissionStatus::ASK, 323 EXPECT_EQ(blink::mojom::PermissionStatus::ASK,
325 permission_manager->GetPermissionStatus( 324 permission_manager->GetPermissionStatus(
326 content::PermissionType::NOTIFICATIONS, origin, origin)); 325 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, origin, origin));
327 326
328 // Change the default content setting vaule for notifications to ALLOW. 327 // Change the default content setting vaule for notifications to ALLOW.
329 HostContentSettingsMapFactory::GetForProfile(profile) 328 HostContentSettingsMapFactory::GetForProfile(profile)
330 ->SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_NOTIFICATIONS, 329 ->SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_NOTIFICATIONS,
331 CONTENT_SETTING_ALLOW); 330 CONTENT_SETTING_ALLOW);
332 331
333 // (3) Disable the permission when the default is allowed (expected to set). 332 // (3) Disable the permission when the default is allowed (expected to set).
334 controller()->SetNotifierEnabled(enabled_notifier, false); 333 controller()->SetNotifierEnabled(enabled_notifier, false);
335 EXPECT_EQ(blink::mojom::PermissionStatus::DENIED, 334 EXPECT_EQ(blink::mojom::PermissionStatus::DENIED,
336 permission_manager->GetPermissionStatus( 335 permission_manager->GetPermissionStatus(
337 content::PermissionType::NOTIFICATIONS, origin, origin)); 336 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, origin, origin));
338 337
339 // (4) Enable the permission when the default is allowed (expected to clear). 338 // (4) Enable the permission when the default is allowed (expected to clear).
340 controller()->SetNotifierEnabled(disabled_notifier, true); 339 controller()->SetNotifierEnabled(disabled_notifier, true);
341 EXPECT_EQ(blink::mojom::PermissionStatus::GRANTED, 340 EXPECT_EQ(blink::mojom::PermissionStatus::GRANTED,
342 permission_manager->GetPermissionStatus( 341 permission_manager->GetPermissionStatus(
343 content::PermissionType::NOTIFICATIONS, origin, origin)); 342 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, origin, origin));
344 343
345 // Now change the default content setting value to BLOCK. 344 // Now change the default content setting value to BLOCK.
346 HostContentSettingsMapFactory::GetForProfile(profile) 345 HostContentSettingsMapFactory::GetForProfile(profile)
347 ->SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_NOTIFICATIONS, 346 ->SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_NOTIFICATIONS,
348 CONTENT_SETTING_BLOCK); 347 CONTENT_SETTING_BLOCK);
349 348
350 // (5) Enable the permission when the default is blocked (expected to set). 349 // (5) Enable the permission when the default is blocked (expected to set).
351 controller()->SetNotifierEnabled(disabled_notifier, true); 350 controller()->SetNotifierEnabled(disabled_notifier, true);
352 EXPECT_EQ(blink::mojom::PermissionStatus::GRANTED, 351 EXPECT_EQ(blink::mojom::PermissionStatus::GRANTED,
353 permission_manager->GetPermissionStatus( 352 permission_manager->GetPermissionStatus(
354 content::PermissionType::NOTIFICATIONS, origin, origin)); 353 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, origin, origin));
355 354
356 // (6) Disable the permission when the default is blocked (expected to clear). 355 // (6) Disable the permission when the default is blocked (expected to clear).
357 controller()->SetNotifierEnabled(enabled_notifier, false); 356 controller()->SetNotifierEnabled(enabled_notifier, false);
358 EXPECT_EQ(blink::mojom::PermissionStatus::DENIED, 357 EXPECT_EQ(blink::mojom::PermissionStatus::DENIED,
359 permission_manager->GetPermissionStatus( 358 permission_manager->GetPermissionStatus(
360 content::PermissionType::NOTIFICATIONS, origin, origin)); 359 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, origin, origin));
361 } 360 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698