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" |
(...skipping 15 matching lines...) Expand all Loading... |
26 PermissionRequestID RequestID(int bridge_id) { | 26 PermissionRequestID RequestID(int bridge_id) { |
27 return PermissionRequestID( | 27 return PermissionRequestID( |
28 web_contents()->GetRenderProcessHost()->GetID(), | 28 web_contents()->GetRenderProcessHost()->GetID(), |
29 web_contents()->GetRenderViewHost()->GetRoutingID(), | 29 web_contents()->GetRenderViewHost()->GetRoutingID(), |
30 bridge_id, | 30 bridge_id, |
31 GURL()); | 31 GURL()); |
32 } | 32 } |
33 | 33 |
34 private: | 34 private: |
35 // ChromeRenderViewHostTestHarness: | 35 // ChromeRenderViewHostTestHarness: |
36 virtual void SetUp() OVERRIDE { | 36 virtual void SetUp() override { |
37 ChromeRenderViewHostTestHarness::SetUp(); | 37 ChromeRenderViewHostTestHarness::SetUp(); |
38 InfoBarService::CreateForWebContents(web_contents()); | 38 InfoBarService::CreateForWebContents(web_contents()); |
39 } | 39 } |
40 | 40 |
41 DISALLOW_COPY_AND_ASSIGN(PermissionQueueControllerTests); | 41 DISALLOW_COPY_AND_ASSIGN(PermissionQueueControllerTests); |
42 }; | 42 }; |
43 | 43 |
44 | 44 |
45 // ObservationCountingQueueController ----------------------------------------- | 45 // ObservationCountingQueueController ----------------------------------------- |
46 | 46 |
47 class ObservationCountingQueueController : public PermissionQueueController { | 47 class ObservationCountingQueueController : public PermissionQueueController { |
48 public: | 48 public: |
49 explicit ObservationCountingQueueController(Profile* profile); | 49 explicit ObservationCountingQueueController(Profile* profile); |
50 virtual ~ObservationCountingQueueController(); | 50 virtual ~ObservationCountingQueueController(); |
51 | 51 |
52 int call_count() const { return call_count_; } | 52 int call_count() const { return call_count_; } |
53 | 53 |
54 private: | 54 private: |
55 int call_count_; | 55 int call_count_; |
56 | 56 |
57 // PermissionQueueController: | 57 // PermissionQueueController: |
58 virtual void Observe(int type, | 58 virtual void Observe(int type, |
59 const content::NotificationSource& source, | 59 const content::NotificationSource& source, |
60 const content::NotificationDetails& details) OVERRIDE; | 60 const content::NotificationDetails& details) override; |
61 | 61 |
62 DISALLOW_COPY_AND_ASSIGN(ObservationCountingQueueController); | 62 DISALLOW_COPY_AND_ASSIGN(ObservationCountingQueueController); |
63 }; | 63 }; |
64 | 64 |
65 ObservationCountingQueueController::ObservationCountingQueueController( | 65 ObservationCountingQueueController::ObservationCountingQueueController( |
66 Profile* profile) | 66 Profile* profile) |
67 : PermissionQueueController(profile, CONTENT_SETTINGS_TYPE_GEOLOCATION), | 67 : PermissionQueueController(profile, CONTENT_SETTINGS_TYPE_GEOLOCATION), |
68 call_count_(0) { | 68 call_count_(0) { |
69 } | 69 } |
70 | 70 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 | 106 |
107 TEST_F(PermissionQueueControllerTests, FailOnBadPattern) { | 107 TEST_F(PermissionQueueControllerTests, FailOnBadPattern) { |
108 ObservationCountingQueueController queue_controller(profile()); | 108 ObservationCountingQueueController queue_controller(profile()); |
109 GURL url("chrome://settings"); | 109 GURL url("chrome://settings"); |
110 base::Callback<void(bool)> callback; | 110 base::Callback<void(bool)> callback; |
111 queue_controller.CreateInfoBarRequest( | 111 queue_controller.CreateInfoBarRequest( |
112 RequestID(0), url, url, callback); | 112 RequestID(0), url, url, callback); |
113 queue_controller.CancelInfoBarRequest(RequestID(0)); | 113 queue_controller.CancelInfoBarRequest(RequestID(0)); |
114 EXPECT_EQ(0, queue_controller.call_count()); | 114 EXPECT_EQ(0, queue_controller.call_count()); |
115 }; | 115 }; |
OLD | NEW |