| 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 "chrome/browser/permissions/permission_queue_controller.h" | 5 #include "chrome/browser/permissions/permission_queue_controller.h" |
| 6 | 6 |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "base/synchronization/waitable_event.h" | 8 #include "base/synchronization/waitable_event.h" |
| 9 #include "chrome/browser/chrome_notification_types.h" | 9 #include "chrome/browser/chrome_notification_types.h" |
| 10 #include "chrome/browser/infobars/infobar_service.h" | 10 #include "chrome/browser/infobars/infobar_service.h" |
| 11 #include "chrome/browser/permissions/permission_request_id.h" | 11 #include "chrome/browser/permissions/permission_request_id.h" |
| 12 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | 12 #include "chrome/test/base/chrome_render_view_host_test_harness.h" |
| 13 #include "chrome/test/base/testing_profile.h" | 13 #include "chrome/test/base/testing_profile.h" |
| 14 #include "components/content_settings/core/common/content_settings_types.h" | 14 #include "components/content_settings/core/common/content_settings_types.h" |
| 15 #include "content/public/browser/permission_type.h" | |
| 16 #include "content/public/browser/render_frame_host.h" | 15 #include "content/public/browser/render_frame_host.h" |
| 17 #include "content/public/browser/web_contents.h" | 16 #include "content/public/browser/web_contents.h" |
| 18 #include "content/public/test/mock_render_process_host.h" | 17 #include "content/public/test/mock_render_process_host.h" |
| 19 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
| 20 | 19 |
| 21 | 20 |
| 22 // PermissionQueueControllerTests --------------------------------------------- | 21 // PermissionQueueControllerTests --------------------------------------------- |
| 23 | 22 |
| 24 class PermissionQueueControllerTests : public ChromeRenderViewHostTestHarness { | 23 class PermissionQueueControllerTests : public ChromeRenderViewHostTestHarness { |
| 25 protected: | 24 protected: |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 void Observe(int type, | 59 void Observe(int type, |
| 61 const content::NotificationSource& source, | 60 const content::NotificationSource& source, |
| 62 const content::NotificationDetails& details) override; | 61 const content::NotificationDetails& details) override; |
| 63 | 62 |
| 64 DISALLOW_COPY_AND_ASSIGN(ObservationCountingQueueController); | 63 DISALLOW_COPY_AND_ASSIGN(ObservationCountingQueueController); |
| 65 }; | 64 }; |
| 66 | 65 |
| 67 ObservationCountingQueueController::ObservationCountingQueueController( | 66 ObservationCountingQueueController::ObservationCountingQueueController( |
| 68 Profile* profile) | 67 Profile* profile) |
| 69 : PermissionQueueController(profile, | 68 : PermissionQueueController(profile, |
| 70 content::PermissionType::GEOLOCATION, | |
| 71 CONTENT_SETTINGS_TYPE_GEOLOCATION), | 69 CONTENT_SETTINGS_TYPE_GEOLOCATION), |
| 72 call_count_(0) {} | 70 call_count_(0) {} |
| 73 | 71 |
| 74 ObservationCountingQueueController::~ObservationCountingQueueController() { | 72 ObservationCountingQueueController::~ObservationCountingQueueController() { |
| 75 } | 73 } |
| 76 | 74 |
| 77 void ObservationCountingQueueController::Observe( | 75 void ObservationCountingQueueController::Observe( |
| 78 int type, | 76 int type, |
| 79 const content::NotificationSource& source, | 77 const content::NotificationSource& source, |
| 80 const content::NotificationDetails& details) { | 78 const content::NotificationDetails& details) { |
| (...skipping 28 matching lines...) Expand all Loading... |
| 109 | 107 |
| 110 TEST_F(PermissionQueueControllerTests, FailOnBadPattern) { | 108 TEST_F(PermissionQueueControllerTests, FailOnBadPattern) { |
| 111 ObservationCountingQueueController queue_controller(profile()); | 109 ObservationCountingQueueController queue_controller(profile()); |
| 112 GURL url("chrome://settings"); | 110 GURL url("chrome://settings"); |
| 113 base::Callback<void(ContentSetting)> callback; | 111 base::Callback<void(ContentSetting)> callback; |
| 114 queue_controller.CreateInfoBarRequest(RequestID(0), url, url, | 112 queue_controller.CreateInfoBarRequest(RequestID(0), url, url, |
| 115 false /* user_gesture */, callback); | 113 false /* user_gesture */, callback); |
| 116 queue_controller.CancelInfoBarRequest(RequestID(0)); | 114 queue_controller.CancelInfoBarRequest(RequestID(0)); |
| 117 EXPECT_EQ(0, queue_controller.call_count()); | 115 EXPECT_EQ(0, queue_controller.call_count()); |
| 118 } | 116 } |
| OLD | NEW |