Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8819)

Unified Diff: chrome/browser/ui/website_settings/permission_bubble_manager.h

Issue 1251633002: Add BubbleManager to manage bubbles and ChromeBubbleManager for events. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..2f6e43366e1b33c8641791861c58bb5258fbe825 100644
--- a/chrome/browser/ui/website_settings/permission_bubble_manager.h
+++ b/chrome/browser/ui/website_settings/permission_bubble_manager.h
@@ -11,9 +11,11 @@
#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 Browser;
class PermissionBubbleRequest;
// Provides access to permissions bubbles. Allows clients to add a request
@@ -29,8 +31,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:
@@ -51,6 +52,9 @@ class PermissionBubbleManager
~PermissionBubbleManager() override;
+ // Associte this instnce with a browser.
+ void SetBrowser(Browser* browser) { browser_ = browser; }
+
// Adds a new request to the permission bubble. Ownership of the request
// remains with the caller. The caller must arrange for the request to
// outlive the PermissionBubbleManager. If a bubble is visible when this
@@ -68,23 +72,9 @@ 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();
+ void DisplayPendingRequests();
// Controls whether incoming permission requests require user gestures.
// If |required| is false, requests will be displayed as soon as they come in.
@@ -104,6 +94,17 @@ class PermissionBubbleManager
auto_response_for_test_ = response;
}
+ const std::vector<PermissionBubbleRequest*>& requests() { return requests_; }
+
+ const std::vector<bool>& accept_states() { return accept_states_; }
+
+ Browser* browser() { return browser_; }
+
+ void ToggleAccept(int request_index, bool new_value);
+ void Accept();
+ void Deny();
+ void Closing();
+
private:
// TODO(felt): Update testing so that it doesn't involve a lot of friends.
friend class DownloadRequestLimiterTest;
@@ -131,12 +132,6 @@ class PermissionBubbleManager
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();
@@ -147,6 +142,9 @@ class PermissionBubbleManager
// Finalize the pending permissions request.
void FinalizeBubble();
+ // Hides the bubble.
+ void HideBubble();
+
// Cancel any pending requests. This is called if the WebContents
// on which permissions calls are pending is destroyed or navigated away
// from the requesting page.
@@ -168,15 +166,16 @@ class PermissionBubbleManager
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_;
+ BubbleReference active_bubble_;
std::vector<PermissionBubbleRequest*> requests_;
std::vector<PermissionBubbleRequest*> queued_requests_;
@@ -192,6 +191,8 @@ class PermissionBubbleManager
base::ObserverList<Observer> observer_list_;
AutoResponseType auto_response_for_test_;
+ Browser* browser_;
+
base::WeakPtrFactory<PermissionBubbleManager> weak_factory_;
};

Powered by Google App Engine
This is Rietveld 408576698