OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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_request_manager_test_api.h" | 5 #include "chrome/browser/permissions/permission_request_manager_test_api.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "chrome/browser/permissions/permission_request_impl.h" | 9 #include "chrome/browser/permissions/permission_request_impl.h" |
10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
11 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 11 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
12 | 12 |
13 namespace test { | 13 namespace test { |
14 namespace { | 14 namespace { |
15 | 15 |
16 // Wraps a PermissionRequestImpl so that it can pass a closure to itself to the | 16 // Wraps a PermissionRequestImpl so that it can pass a closure to itself to the |
17 // PermissionRequestImpl constructor. Without this wrapper, there's no way to | 17 // PermissionRequestImpl constructor. Without this wrapper, there's no way to |
18 // handle all destruction paths. | 18 // handle all destruction paths. |
19 class TestPermisisonRequestOwner { | 19 class TestPermisisonRequestOwner { |
20 public: | 20 public: |
21 TestPermisisonRequestOwner(Profile* profile, content::PermissionType type) { | 21 TestPermisisonRequestOwner(Profile* profile, ContentSettingsType type) { |
22 bool user_gesture = true; | 22 bool user_gesture = true; |
23 auto decided = [](bool, ContentSetting) {}; | 23 auto decided = [](bool, ContentSetting) {}; |
24 request_ = base::MakeUnique<PermissionRequestImpl>( | 24 request_ = base::MakeUnique<PermissionRequestImpl>( |
25 GURL("https://example.com"), type, profile, user_gesture, | 25 GURL("https://example.com"), type, profile, user_gesture, |
26 base::Bind(decided), base::Bind(&TestPermisisonRequestOwner::DeleteThis, | 26 base::Bind(decided), base::Bind(&TestPermisisonRequestOwner::DeleteThis, |
27 base::Unretained(this))); | 27 base::Unretained(this))); |
28 } | 28 } |
29 | 29 |
30 PermissionRequestImpl* request() { return request_.get(); } | 30 PermissionRequestImpl* request() { return request_.get(); } |
31 | 31 |
(...skipping 11 matching lines...) Expand all Loading... |
43 PermissionRequestManager* manager) | 43 PermissionRequestManager* manager) |
44 : manager_(manager) {} | 44 : manager_(manager) {} |
45 | 45 |
46 PermissionRequestManagerTestApi::PermissionRequestManagerTestApi( | 46 PermissionRequestManagerTestApi::PermissionRequestManagerTestApi( |
47 Browser* browser) | 47 Browser* browser) |
48 : PermissionRequestManagerTestApi(PermissionRequestManager::FromWebContents( | 48 : PermissionRequestManagerTestApi(PermissionRequestManager::FromWebContents( |
49 browser->tab_strip_model()->GetActiveWebContents())) {} | 49 browser->tab_strip_model()->GetActiveWebContents())) {} |
50 | 50 |
51 void PermissionRequestManagerTestApi::AddSimpleRequest( | 51 void PermissionRequestManagerTestApi::AddSimpleRequest( |
52 Profile* profile, | 52 Profile* profile, |
53 content::PermissionType type) { | 53 ContentSettingsType type) { |
54 TestPermisisonRequestOwner* request_owner = | 54 TestPermisisonRequestOwner* request_owner = |
55 new TestPermisisonRequestOwner(profile, type); | 55 new TestPermisisonRequestOwner(profile, type); |
56 manager_->AddRequest(request_owner->request()); | 56 manager_->AddRequest(request_owner->request()); |
57 } | 57 } |
58 | 58 |
59 gfx::NativeWindow PermissionRequestManagerTestApi::GetPromptWindow() { | 59 gfx::NativeWindow PermissionRequestManagerTestApi::GetPromptWindow() { |
60 return manager_->view_ ? manager_->view_->GetNativeWindow() : nullptr; | 60 return manager_->view_ ? manager_->view_->GetNativeWindow() : nullptr; |
61 } | 61 } |
62 | 62 |
63 } // namespace test | 63 } // namespace test |
OLD | NEW |