| 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/content_settings/permission_queue_controller.h" | 5 #include "chrome/browser/content_settings/permission_queue_controller.h" | 
| 6 | 6 | 
| 7 #include "base/synchronization/waitable_event.h" | 7 #include "base/synchronization/waitable_event.h" | 
| 8 #include "chrome/browser/chrome_notification_types.h" | 8 #include "chrome/browser/chrome_notification_types.h" | 
| 9 #include "chrome/browser/infobars/infobar_service.h" | 9 #include "chrome/browser/infobars/infobar_service.h" | 
| 10 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | 10 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | 
| 11 #include "chrome/test/base/testing_profile.h" | 11 #include "chrome/test/base/testing_profile.h" | 
| 12 #include "components/content_settings/core/common/content_settings_types.h" | 12 #include "components/content_settings/core/common/content_settings_types.h" | 
| 13 #include "components/content_settings/core/common/permission_request_id.h" | 13 #include "components/content_settings/core/common/permission_request_id.h" | 
|  | 14 #include "components/infobars/test/test_confirm_infobar_delegate_factory.h" | 
| 14 #include "content/public/browser/web_contents.h" | 15 #include "content/public/browser/web_contents.h" | 
| 15 #include "content/public/test/mock_render_process_host.h" | 16 #include "content/public/test/mock_render_process_host.h" | 
| 16 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" | 
| 17 | 18 | 
| 18 | 19 | 
| 19 // PermissionQueueControllerTests --------------------------------------------- | 20 // PermissionQueueControllerTests --------------------------------------------- | 
| 20 | 21 | 
| 21 class PermissionQueueControllerTests : public ChromeRenderViewHostTestHarness { | 22 class PermissionQueueControllerTests : public ChromeRenderViewHostTestHarness { | 
| 22  protected: | 23  protected: | 
| 23   PermissionQueueControllerTests() {} | 24   PermissionQueueControllerTests() {} | 
| 24   ~PermissionQueueControllerTests() override {} | 25   ~PermissionQueueControllerTests() override {} | 
| 25 | 26 | 
| 26   PermissionRequestID RequestID(int bridge_id) { | 27   PermissionRequestID RequestID(int bridge_id) { | 
| 27     return PermissionRequestID( | 28     return PermissionRequestID( | 
| 28         web_contents()->GetRenderProcessHost()->GetID(), | 29         web_contents()->GetRenderProcessHost()->GetID(), | 
| 29         web_contents()->GetRenderViewHost()->GetRoutingID(), | 30         web_contents()->GetRenderViewHost()->GetRoutingID(), | 
| 30         bridge_id, | 31         bridge_id, | 
| 31         GURL()); | 32         GURL()); | 
| 32   } | 33   } | 
| 33 | 34 | 
| 34  private: | 35  private: | 
| 35   // ChromeRenderViewHostTestHarness: | 36   // ChromeRenderViewHostTestHarness: | 
| 36   void SetUp() override { | 37   void SetUp() override { | 
| 37     ChromeRenderViewHostTestHarness::SetUp(); | 38     ChromeRenderViewHostTestHarness::SetUp(); | 
| 38     InfoBarService::CreateForWebContents(web_contents()); | 39     InfoBarService::CreateForWebContents(web_contents()); | 
| 39   } | 40   } | 
| 40 | 41 | 
|  | 42   TestConfirmInfoBarDelegateFactory confirm_info_bar_delegate_factory_; | 
|  | 43 | 
| 41   DISALLOW_COPY_AND_ASSIGN(PermissionQueueControllerTests); | 44   DISALLOW_COPY_AND_ASSIGN(PermissionQueueControllerTests); | 
| 42 }; | 45 }; | 
| 43 | 46 | 
| 44 | 47 | 
| 45 // ObservationCountingQueueController ----------------------------------------- | 48 // ObservationCountingQueueController ----------------------------------------- | 
| 46 | 49 | 
| 47 class ObservationCountingQueueController : public PermissionQueueController { | 50 class ObservationCountingQueueController : public PermissionQueueController { | 
| 48  public: | 51  public: | 
| 49   explicit ObservationCountingQueueController(Profile* profile); | 52   explicit ObservationCountingQueueController(Profile* profile); | 
| 50   ~ObservationCountingQueueController() override; | 53   ~ObservationCountingQueueController() override; | 
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 106 | 109 | 
| 107 TEST_F(PermissionQueueControllerTests, FailOnBadPattern) { | 110 TEST_F(PermissionQueueControllerTests, FailOnBadPattern) { | 
| 108   ObservationCountingQueueController queue_controller(profile()); | 111   ObservationCountingQueueController queue_controller(profile()); | 
| 109   GURL url("chrome://settings"); | 112   GURL url("chrome://settings"); | 
| 110   base::Callback<void(bool)> callback; | 113   base::Callback<void(bool)> callback; | 
| 111   queue_controller.CreateInfoBarRequest( | 114   queue_controller.CreateInfoBarRequest( | 
| 112       RequestID(0), url, url, callback); | 115       RequestID(0), url, url, callback); | 
| 113   queue_controller.CancelInfoBarRequest(RequestID(0)); | 116   queue_controller.CancelInfoBarRequest(RequestID(0)); | 
| 114   EXPECT_EQ(0, queue_controller.call_count()); | 117   EXPECT_EQ(0, queue_controller.call_count()); | 
| 115 }; | 118 }; | 
| OLD | NEW | 
|---|