OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <vector> | 6 #include <vector> |
7 | 7 |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "base/path_service.h" | 11 #include "base/path_service.h" |
12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
13 #include "base/time/time.h" | 13 #include "base/time/time.h" |
14 #include "chrome/browser/notifications/desktop_notification_profile_util.h" | 14 #include "chrome/browser/notifications/desktop_notification_profile_util.h" |
15 #include "chrome/browser/notifications/notification.h" | 15 #include "chrome/browser/notifications/notification.h" |
16 #include "chrome/browser/notifications/notification_permission_context.h" | |
17 #include "chrome/browser/notifications/notification_permission_context_factory.h
" | |
18 #include "chrome/browser/notifications/notification_test_util.h" | 16 #include "chrome/browser/notifications/notification_test_util.h" |
19 #include "chrome/browser/notifications/platform_notification_service_impl.h" | 17 #include "chrome/browser/notifications/platform_notification_service_impl.h" |
| 18 #include "chrome/browser/permissions/permission_context_base.h" |
| 19 #include "chrome/browser/permissions/permission_manager.h" |
| 20 #include "chrome/browser/permissions/permission_manager_factory.h" |
20 #include "chrome/browser/ui/browser.h" | 21 #include "chrome/browser/ui/browser.h" |
21 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 22 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
22 #include "chrome/browser/ui/website_settings/permission_bubble_manager.h" | 23 #include "chrome/browser/ui/website_settings/permission_bubble_manager.h" |
23 #include "chrome/grit/generated_resources.h" | 24 #include "chrome/grit/generated_resources.h" |
24 #include "chrome/test/base/in_process_browser_test.h" | 25 #include "chrome/test/base/in_process_browser_test.h" |
25 #include "chrome/test/base/ui_test_utils.h" | 26 #include "chrome/test/base/ui_test_utils.h" |
26 #include "content/public/common/content_switches.h" | 27 #include "content/public/common/content_switches.h" |
27 #include "content/public/test/browser_test_utils.h" | 28 #include "content/public/test/browser_test_utils.h" |
28 #include "net/base/filename_util.h" | 29 #include "net/base/filename_util.h" |
29 #include "net/test/embedded_test_server/embedded_test_server.h" | 30 #include "net/test/embedded_test_server/embedded_test_server.h" |
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
393 notification.origin_url().spec()); | 394 notification.origin_url().spec()); |
394 } | 395 } |
395 | 396 |
396 // TODO(felt): This DCHECKs when bubbles are enabled, when the file_url is | 397 // TODO(felt): This DCHECKs when bubbles are enabled, when the file_url is |
397 // persisted. crbug.com/502057 | 398 // persisted. crbug.com/502057 |
398 IN_PROC_BROWSER_TEST_F(PlatformNotificationServiceBrowserTest, | 399 IN_PROC_BROWSER_TEST_F(PlatformNotificationServiceBrowserTest, |
399 DISABLED_CheckFilePermissionNotGranted) { | 400 DISABLED_CheckFilePermissionNotGranted) { |
400 // This case should succeed because a normal page URL is used. | 401 // This case should succeed because a normal page URL is used. |
401 std::string script_result; | 402 std::string script_result; |
402 | 403 |
403 NotificationPermissionContext* permission_context = | 404 PermissionContextBase* permission_context = |
404 NotificationPermissionContextFactory::GetForProfile(browser()->profile()); | 405 PermissionManagerFactory::GetForProfile(browser()->profile()) |
405 ASSERT_TRUE(permission_context); | 406 ->GetPermissionContext(content::PermissionType::NOTIFICATIONS); |
406 | 407 |
407 EXPECT_EQ(CONTENT_SETTING_ASK, | 408 EXPECT_EQ(CONTENT_SETTING_ASK, permission_context->GetPermissionStatus( |
408 permission_context->GetPermissionStatus(TestPageUrl(), | 409 TestPageUrl(), TestPageUrl())); |
409 TestPageUrl())); | |
410 | 410 |
411 RequestAndAcceptPermission(); | 411 RequestAndAcceptPermission(); |
412 EXPECT_EQ(CONTENT_SETTING_ALLOW, | 412 EXPECT_EQ(CONTENT_SETTING_ALLOW, permission_context->GetPermissionStatus( |
413 permission_context->GetPermissionStatus(TestPageUrl(), | 413 TestPageUrl(), TestPageUrl())); |
414 TestPageUrl())); | |
415 | 414 |
416 // This case should fail because a file URL is used. | 415 // This case should fail because a file URL is used. |
417 base::FilePath dir_source_root; | 416 base::FilePath dir_source_root; |
418 EXPECT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &dir_source_root)); | 417 EXPECT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &dir_source_root)); |
419 base::FilePath full_file_path = | 418 base::FilePath full_file_path = |
420 dir_source_root.Append(server_root()).AppendASCII(kTestFileName); | 419 dir_source_root.Append(server_root()).AppendASCII(kTestFileName); |
421 GURL file_url(net::FilePathToFileURL(full_file_path)); | 420 GURL file_url(net::FilePathToFileURL(full_file_path)); |
422 | 421 |
423 ui_test_utils::NavigateToURL(browser(), file_url); | 422 ui_test_utils::NavigateToURL(browser(), file_url); |
424 | 423 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
487 EXPECT_EQ("actionTitle2", base::UTF16ToUTF8(notification.buttons()[1].title)); | 486 EXPECT_EQ("actionTitle2", base::UTF16ToUTF8(notification.buttons()[1].title)); |
488 | 487 |
489 notification.delegate()->ButtonClick(0); | 488 notification.delegate()->ButtonClick(0); |
490 ASSERT_TRUE(RunScript("GetMessageFromWorker()", &script_result)); | 489 ASSERT_TRUE(RunScript("GetMessageFromWorker()", &script_result)); |
491 EXPECT_EQ("action_button_click actionId1", script_result); | 490 EXPECT_EQ("action_button_click actionId1", script_result); |
492 | 491 |
493 notification.delegate()->ButtonClick(1); | 492 notification.delegate()->ButtonClick(1); |
494 ASSERT_TRUE(RunScript("GetMessageFromWorker()", &script_result)); | 493 ASSERT_TRUE(RunScript("GetMessageFromWorker()", &script_result)); |
495 EXPECT_EQ("action_button_click actionId2", script_result); | 494 EXPECT_EQ("action_button_click actionId2", script_result); |
496 } | 495 } |
OLD | NEW |