| 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 #ifndef CHROME_BROWSER_PERMISSIONS_PERMISSION_REQUEST_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_PERMISSIONS_PERMISSION_REQUEST_MANAGER_H_ |
| 6 #define CHROME_BROWSER_PERMISSIONS_PERMISSION_REQUEST_MANAGER_H_ | 6 #define CHROME_BROWSER_PERMISSIONS_PERMISSION_REQUEST_MANAGER_H_ |
| 7 | 7 |
| 8 #include <unordered_map> | 8 #include <unordered_map> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/gtest_prod_util.h" | 11 #include "base/gtest_prod_util.h" |
| 12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 13 #include "base/observer_list.h" | 13 #include "base/observer_list.h" |
| 14 #include "chrome/browser/ui/website_settings/permission_prompt.h" | 14 #include "chrome/browser/ui/website_settings/permission_prompt.h" |
| 15 #include "content/public/browser/web_contents_observer.h" | 15 #include "content/public/browser/web_contents_observer.h" |
| 16 #include "content/public/browser/web_contents_user_data.h" | 16 #include "content/public/browser/web_contents_user_data.h" |
| 17 | 17 |
| 18 class PermissionRequest; | 18 class PermissionRequest; |
| 19 | 19 |
| 20 namespace safe_browsing { | 20 namespace safe_browsing { |
| 21 class PermissionReporterBrowserTest; | 21 class PermissionReporterBrowserTest; |
| 22 } | 22 } |
| 23 | 23 |
| 24 namespace test { |
| 25 class PermissionRequestManagerTestApi; |
| 26 } |
| 27 |
| 24 // Provides access to permissions bubbles. Allows clients to add a request | 28 // Provides access to permissions bubbles. Allows clients to add a request |
| 25 // callback interface to the existing permission bubble configuration. | 29 // callback interface to the existing permission bubble configuration. |
| 26 // Depending on the situation and policy, that may add new UI to an existing | 30 // Depending on the situation and policy, that may add new UI to an existing |
| 27 // permission bubble, create and show a new permission bubble, or provide no | 31 // permission bubble, create and show a new permission bubble, or provide no |
| 28 // visible UI action at all. (In that case, the request will be immediately | 32 // visible UI action at all. (In that case, the request will be immediately |
| 29 // informed that the permission request failed.) | 33 // informed that the permission request failed.) |
| 30 // | 34 // |
| 31 // A PermissionRequestManager is associated with a particular WebContents. | 35 // A PermissionRequestManager is associated with a particular WebContents. |
| 32 // Requests attached to a particular WebContents' PBM must outlive it. | 36 // Requests attached to a particular WebContents' PBM must outlive it. |
| 33 // | 37 // |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 | 104 |
| 101 // Do NOT use this methods in production code. Use this methods in browser | 105 // Do NOT use this methods in production code. Use this methods in browser |
| 102 // tests that need to accept or deny permissions when requested in | 106 // tests that need to accept or deny permissions when requested in |
| 103 // JavaScript. Your test needs to set this appropriately, and then the bubble | 107 // JavaScript. Your test needs to set this appropriately, and then the bubble |
| 104 // will proceed as desired as soon as Show() is called. | 108 // will proceed as desired as soon as Show() is called. |
| 105 void set_auto_response_for_test(AutoResponseType response) { | 109 void set_auto_response_for_test(AutoResponseType response) { |
| 106 auto_response_for_test_ = response; | 110 auto_response_for_test_ = response; |
| 107 } | 111 } |
| 108 | 112 |
| 109 private: | 113 private: |
| 110 // TODO(felt): Update testing so that it doesn't involve a lot of friends. | 114 friend class test::PermissionRequestManagerTestApi; |
| 115 |
| 116 // TODO(felt): Update testing to use the TestApi so that it doesn't involve a |
| 117 // lot of friends. |
| 111 friend class GeolocationBrowserTest; | 118 friend class GeolocationBrowserTest; |
| 112 friend class GeolocationPermissionContextTests; | 119 friend class GeolocationPermissionContextTests; |
| 113 friend class MockPermissionPrompt; | 120 friend class MockPermissionPrompt; |
| 114 friend class MockPermissionPromptFactory; | 121 friend class MockPermissionPromptFactory; |
| 115 friend class PermissionContextBaseTests; | 122 friend class PermissionContextBaseTests; |
| 116 friend class PermissionRequestManagerTest; | 123 friend class PermissionRequestManagerTest; |
| 117 friend class safe_browsing::PermissionReporterBrowserTest; | 124 friend class safe_browsing::PermissionReporterBrowserTest; |
| 118 friend class content::WebContentsUserData<PermissionRequestManager>; | 125 friend class content::WebContentsUserData<PermissionRequestManager>; |
| 119 FRIEND_TEST_ALL_PREFIXES(DownloadTest, TestMultipleDownloadsBubble); | 126 FRIEND_TEST_ALL_PREFIXES(DownloadTest, TestMultipleDownloadsBubble); |
| 120 | 127 |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 // Whether each of the requests in |requests_| is accepted by the user. | 206 // Whether each of the requests in |requests_| is accepted by the user. |
| 200 std::vector<bool> accept_states_; | 207 std::vector<bool> accept_states_; |
| 201 | 208 |
| 202 base::ObserverList<Observer> observer_list_; | 209 base::ObserverList<Observer> observer_list_; |
| 203 AutoResponseType auto_response_for_test_; | 210 AutoResponseType auto_response_for_test_; |
| 204 | 211 |
| 205 base::WeakPtrFactory<PermissionRequestManager> weak_factory_; | 212 base::WeakPtrFactory<PermissionRequestManager> weak_factory_; |
| 206 }; | 213 }; |
| 207 | 214 |
| 208 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_REQUEST_MANAGER_H_ | 215 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_REQUEST_MANAGER_H_ |
| OLD | NEW |