Chromium Code Reviews| Index: chrome/browser/ui/website_settings/permission_bubble_manager.h |
| diff --git a/chrome/browser/ui/website_settings/permission_bubble_manager.h b/chrome/browser/ui/website_settings/permission_bubble_manager.h |
| index b6f1606b59f2368e33ed1612287204d69527628e..b8180b2e4db8dbea1097fdfb3310dd4f781ac14f 100644 |
| --- a/chrome/browser/ui/website_settings/permission_bubble_manager.h |
| +++ b/chrome/browser/ui/website_settings/permission_bubble_manager.h |
| @@ -10,12 +10,15 @@ |
| #include "base/gtest_prod_util.h" |
| #include "base/memory/weak_ptr.h" |
| #include "base/observer_list.h" |
| -#include "chrome/browser/ui/website_settings/permission_bubble_view.h" |
| +#include "components/bubble/bubble_manager.h" |
| #include "content/public/browser/web_contents_observer.h" |
| #include "content/public/browser/web_contents_user_data.h" |
| +class BubbleManager; |
| class PermissionBubbleRequest; |
| +// TODO(hcarmona): Rename to PermissionRequestQueue or PermissionRequestManager. |
| + |
| // Provides access to permissions bubbles. Allows clients to add a request |
| // callback interface to the existing permission bubble configuration. |
| // Depending on the situation and policy, that may add new UI to an existing |
| @@ -29,8 +32,7 @@ class PermissionBubbleRequest; |
| // The PermissionBubbleManager should be addressed on the UI thread. |
| class PermissionBubbleManager |
| : public content::WebContentsObserver, |
| - public content::WebContentsUserData<PermissionBubbleManager>, |
| - public PermissionBubbleView::Delegate { |
| + public content::WebContentsUserData<PermissionBubbleManager> { |
| public: |
| class Observer { |
| public: |
| @@ -68,24 +70,6 @@ class PermissionBubbleManager |
| // at which time the caller is free to delete the request. |
| virtual void CancelRequest(PermissionBubbleRequest* request); |
| - // Hides the bubble. |
| - void HideBubble(); |
| - |
| - // Will show a permission bubble if there is a pending permission request on |
| - // the web contents that the PermissionBubbleManager belongs to. |
| - void DisplayPendingRequests(Browser* browser); |
| - |
| - // Will reposition the bubble (may change parent if necessary). |
| - void UpdateAnchorPosition(); |
| - |
| - // True if a permission bubble is currently visible. |
| - // TODO(hcarmona): Remove this as part of the bubble API work. |
| - bool IsBubbleVisible(); |
| - |
| - // Get the native window of the bubble. |
| - // TODO(hcarmona): Remove this as part of the bubble API work. |
| - gfx::NativeWindow GetBubbleWindow(); |
| - |
| // Controls whether incoming permission requests require user gestures. |
| // If |required| is false, requests will be displayed as soon as they come in. |
| // If |required| is true, requests will be silently queued until a request |
| @@ -104,6 +88,20 @@ class PermissionBubbleManager |
| auto_response_for_test_ = response; |
| } |
| + const std::vector<PermissionBubbleRequest*>& requests() const { |
| + return requests_; |
| + } |
| + |
| + const std::vector<bool>& accept_states() const { return accept_states_; } |
| + |
| + void ToggleAccept(int request_index, bool new_value); |
| + void Accept(); |
| + void Deny(); |
| + void Closing(); |
| + |
| + // Finalize the pending permissions. Called after the bubble is closed. |
| + void DidClose(); |
| + |
| private: |
| // TODO(felt): Update testing so that it doesn't involve a lot of friends. |
| friend class DownloadRequestLimiterTest; |
| @@ -127,25 +125,16 @@ class PermissionBubbleManager |
| // If a page on which permissions requests are pending is navigated, |
| // they will be finalized as if canceled by the user. |
|
msw
2015/08/13 03:37:21
Is simulating cancellation by the user really nece
|
| - void NavigationEntryCommitted( |
| - const content::LoadCommittedDetails& details) override; |
| void WebContentsDestroyed() override; |
| - // PermissionBubbleView::Delegate: |
| - void ToggleAccept(int request_index, bool new_value) override; |
| - void Accept() override; |
| - void Deny() override; |
| - void Closing() override; |
| - |
| - // Posts a task which will allow the bubble to become visible if it is needed. |
| void ScheduleShowBubble(); |
| // Shows the bubble if it is not already visible and there are pending |
| // requests. |
| void TriggerShowBubble(); |
| - // Finalize the pending permissions request. |
| - void FinalizeBubble(); |
| + // Closes the bubble. |
|
msw
2015/08/13 03:37:21
comment not necessary.
|
| + void CloseBubble(); |
| // Cancel any pending requests. This is called if the WebContents |
| // on which permissions calls are pending is destroyed or navigated away |
| @@ -164,19 +153,23 @@ class PermissionBubbleManager |
| bool HasUserGestureRequest( |
| const std::vector<PermissionBubbleRequest*>& queue); |
| + BubbleManager* GetBubbleManager(); |
| + |
| void NotifyBubbleAdded(); |
| void DoAutoResponseForTesting(); |
| + // True if a permission bubble is currently visible. |
| + bool IsBubbleVisible(); |
| + |
| // Whether to delay displaying the bubble until a request with a user gesture. |
| // False by default, unless RequireUserGesture(bool) changes the value. |
| bool require_user_gesture_; |
| // Factory to be used to create views when needed. |
| - PermissionBubbleView::Factory view_factory_; |
| - |
| - // The UI surface to be used to display the permissions requests. |
| - scoped_ptr<PermissionBubbleView> view_; |
| + // TODO(hcarmona): Investigate not using a factory, currently used for tests. |
| + base::Callback<scoped_ptr<BubbleUI>(PermissionBubbleManager*)> ui_factory_; |
| + BubbleReference active_bubble_; |
| std::vector<PermissionBubbleRequest*> requests_; |
| std::vector<PermissionBubbleRequest*> queued_requests_; |
| @@ -193,6 +186,8 @@ class PermissionBubbleManager |
| AutoResponseType auto_response_for_test_; |
| base::WeakPtrFactory<PermissionBubbleManager> weak_factory_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(PermissionBubbleManager); |
| }; |
| #endif // CHROME_BROWSER_UI_WEBSITE_SETTINGS_PERMISSION_BUBBLE_MANAGER_H_ |