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

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: Partial Feedback 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..5059becab1bf1741d2e87d1cc0bd1a9393d0fdee 100644
--- a/chrome/browser/ui/website_settings/permission_bubble_manager.h
+++ b/chrome/browser/ui/website_settings/permission_bubble_manager.h
@@ -11,11 +11,15 @@
#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;
+// 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 +33,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 +54,9 @@ class PermissionBubbleManager
~PermissionBubbleManager() override;
+ // Associte this instnce with a browser.
+ void SetBrowser(Browser* browser) { browser_ = browser; }
hcarmona 2015/08/07 23:02:38 Remove this and use FindBrowserWithWebContents in
hcarmona 2015/08/11 02:35:46 Done.
+
// 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,24 +74,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 +92,20 @@ class PermissionBubbleManager
auto_response_for_test_ = response;
}
+ const std::vector<PermissionBubbleRequest*>& requests() { return requests_; }
please use gerrit instead 2015/08/07 23:02:27 const functions.
hcarmona 2015/08/11 02:35:46 Done.
+
+ 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();
+
+ // Finalize the pending permissions. Called after the bubble is closed.
+ void Finalize();
+
private:
// TODO(felt): Update testing so that it doesn't involve a lot of friends.
friend class DownloadRequestLimiterTest;
@@ -131,21 +133,12 @@ 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();
-
// 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.
+ void CloseBubble();
// Cancel any pending requests. This is called if the WebContents
// on which permissions calls are pending is destroyed or navigated away
@@ -168,15 +161,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_;
please use gerrit instead 2015/08/07 23:02:27 TODO: examine factory usage. It's for testing only
hcarmona 2015/08/11 02:35:46 Acknowledged.
-
- // 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,7 +186,11 @@ class PermissionBubbleManager
base::ObserverList<Observer> observer_list_;
AutoResponseType auto_response_for_test_;
+ Browser* browser_;
+
base::WeakPtrFactory<PermissionBubbleManager> weak_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(PermissionBubbleManager);
};
#endif // CHROME_BROWSER_UI_WEBSITE_SETTINGS_PERMISSION_BUBBLE_MANAGER_H_

Powered by Google App Engine
This is Rietveld 408576698