Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
|
please use gerrit instead
2015/07/22 23:56:09
Should be a BubbleDelegate. When a new permission
| |
| 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_UI_WEBSITE_SETTINGS_PERMISSION_BUBBLE_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBSITE_SETTINGS_PERMISSION_BUBBLE_MANAGER_H_ |
| 6 #define CHROME_BROWSER_UI_WEBSITE_SETTINGS_PERMISSION_BUBBLE_MANAGER_H_ | 6 #define CHROME_BROWSER_UI_WEBSITE_SETTINGS_PERMISSION_BUBBLE_MANAGER_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/gtest_prod_util.h" | 10 #include "base/gtest_prod_util.h" |
| 11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
| 12 #include "base/observer_list.h" | 12 #include "base/observer_list.h" |
| 13 #include "chrome/browser/ui/website_settings/permission_bubble_view.h" | 13 #include "chrome/browser/ui/website_settings/permission_bubble_view.h" |
| 14 #include "content/public/browser/web_contents_observer.h" | 14 #include "content/public/browser/web_contents_observer.h" |
| 15 #include "content/public/browser/web_contents_user_data.h" | 15 #include "content/public/browser/web_contents_user_data.h" |
| 16 | 16 |
| 17 class PermissionBubbleDelegate; | |
| 17 class PermissionBubbleRequest; | 18 class PermissionBubbleRequest; |
| 19 class BubbleDelegate; | |
| 20 class BubbleManager; | |
| 18 | 21 |
| 19 // Provides access to permissions bubbles. Allows clients to add a request | 22 // Provides access to permissions bubbles. Allows clients to add a request |
| 20 // callback interface to the existing permission bubble configuration. | 23 // callback interface to the existing permission bubble configuration. |
| 21 // Depending on the situation and policy, that may add new UI to an existing | 24 // Depending on the situation and policy, that may add new UI to an existing |
| 22 // permission bubble, create and show a new permission bubble, or provide no | 25 // permission bubble, create and show a new permission bubble, or provide no |
| 23 // visible UI action at all. (In that case, the request will be immediately | 26 // visible UI action at all. (In that case, the request will be immediately |
| 24 // informed that the permission request failed.) | 27 // informed that the permission request failed.) |
| 25 // | 28 // |
| 26 // A PermissionBubbleManager is associated with a particular WebContents. | 29 // A PermissionBubbleManager is associated with a particular WebContents. |
| 27 // Requests attached to a particular WebContents' PBM must outlive it. | 30 // Requests attached to a particular WebContents' PBM must outlive it. |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 105 } | 108 } |
| 106 | 109 |
| 107 private: | 110 private: |
| 108 // TODO(felt): Update testing so that it doesn't involve a lot of friends. | 111 // TODO(felt): Update testing so that it doesn't involve a lot of friends. |
| 109 friend class DownloadRequestLimiterTest; | 112 friend class DownloadRequestLimiterTest; |
| 110 friend class GeolocationBrowserTest; | 113 friend class GeolocationBrowserTest; |
| 111 friend class GeolocationPermissionContextTests; | 114 friend class GeolocationPermissionContextTests; |
| 112 friend class GeolocationPermissionContextParamTests; | 115 friend class GeolocationPermissionContextParamTests; |
| 113 friend class MockPermissionBubbleView; | 116 friend class MockPermissionBubbleView; |
| 114 friend class PermissionBubbleManagerTest; | 117 friend class PermissionBubbleManagerTest; |
| 118 friend class PermissionBubbleDelegate; | |
| 115 friend class PermissionContextBaseTests; | 119 friend class PermissionContextBaseTests; |
| 116 friend class content::WebContentsUserData<PermissionBubbleManager>; | 120 friend class content::WebContentsUserData<PermissionBubbleManager>; |
| 117 FRIEND_TEST_ALL_PREFIXES(DownloadTest, TestMultipleDownloadsBubble); | 121 FRIEND_TEST_ALL_PREFIXES(DownloadTest, TestMultipleDownloadsBubble); |
| 118 | 122 |
| 119 explicit PermissionBubbleManager(content::WebContents* web_contents); | 123 explicit PermissionBubbleManager(content::WebContents* web_contents); |
| 120 | 124 |
| 121 // WebContentsObserver: | 125 // WebContentsObserver: |
| 122 void DidNavigateMainFrame( | 126 void DidNavigateMainFrame( |
| 123 const content::LoadCommittedDetails& details, | 127 const content::LoadCommittedDetails& details, |
| 124 const content::FrameNavigateParams& params) override; | 128 const content::FrameNavigateParams& params) override; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 166 const std::vector<PermissionBubbleRequest*>& queue); | 170 const std::vector<PermissionBubbleRequest*>& queue); |
| 167 | 171 |
| 168 void NotifyBubbleAdded(); | 172 void NotifyBubbleAdded(); |
| 169 | 173 |
| 170 void DoAutoResponseForTesting(); | 174 void DoAutoResponseForTesting(); |
| 171 | 175 |
| 172 // Whether to delay displaying the bubble until a request with a user gesture. | 176 // Whether to delay displaying the bubble until a request with a user gesture. |
| 173 // False by default, unless RequireUserGesture(bool) changes the value. | 177 // False by default, unless RequireUserGesture(bool) changes the value. |
| 174 bool require_user_gesture_; | 178 bool require_user_gesture_; |
| 175 | 179 |
| 176 // Factory to be used to create views when needed. | 180 // Delegate for permission bubbles. |
| 177 PermissionBubbleView::Factory view_factory_; | 181 scoped_ptr<BubbleDelegate> bubble_delegate_; |
| 178 | 182 |
| 179 // The UI surface to be used to display the permissions requests. | 183 // The bubble_manager_ that the bubble_delegate_ is shown in. Weak. |
| 180 scoped_ptr<PermissionBubbleView> view_; | 184 BubbleManager* bubble_manager_; |
| 181 | 185 |
| 182 std::vector<PermissionBubbleRequest*> requests_; | 186 std::vector<PermissionBubbleRequest*> requests_; |
| 183 std::vector<PermissionBubbleRequest*> queued_requests_; | 187 std::vector<PermissionBubbleRequest*> queued_requests_; |
| 184 std::vector<PermissionBubbleRequest*> queued_frame_requests_; | 188 std::vector<PermissionBubbleRequest*> queued_frame_requests_; |
| 185 | 189 |
| 186 // URL of the main frame in the WebContents to which this manager is attached. | 190 // URL of the main frame in the WebContents to which this manager is attached. |
| 187 // TODO(gbillock): if there are iframes in the page, we need to deal with it. | 191 // TODO(gbillock): if there are iframes in the page, we need to deal with it. |
| 188 GURL request_url_; | 192 GURL request_url_; |
| 189 bool main_frame_has_fully_loaded_; | 193 bool main_frame_has_fully_loaded_; |
| 190 | 194 |
| 191 std::vector<bool> accept_states_; | 195 std::vector<bool> accept_states_; |
| 192 | 196 |
| 193 base::ObserverList<Observer> observer_list_; | 197 base::ObserverList<Observer> observer_list_; |
| 194 AutoResponseType auto_response_for_test_; | 198 AutoResponseType auto_response_for_test_; |
| 195 | 199 |
| 196 base::WeakPtrFactory<PermissionBubbleManager> weak_factory_; | 200 base::WeakPtrFactory<PermissionBubbleManager> weak_factory_; |
| 197 }; | 201 }; |
| 198 | 202 |
| 199 #endif // CHROME_BROWSER_UI_WEBSITE_SETTINGS_PERMISSION_BUBBLE_MANAGER_H_ | 203 #endif // CHROME_BROWSER_UI_WEBSITE_SETTINGS_PERMISSION_BUBBLE_MANAGER_H_ |
| OLD | NEW |