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

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

Issue 1610753002: Fixes Permission Bubbles never responding to duplicate requests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix tests and RequestFinishedIncludingDuplicates DCHECK Created 4 years, 11 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 fbde1dac3f99513b67e53784c2db6d82c64f562a..f49afaf8d73f88660f0030b0b970bdc32e2331fe 100644
--- a/chrome/browser/ui/website_settings/permission_bubble_manager.h
+++ b/chrome/browser/ui/website_settings/permission_bubble_manager.h
@@ -5,6 +5,7 @@
#ifndef CHROME_BROWSER_UI_WEBSITE_SETTINGS_PERMISSION_BUBBLE_MANAGER_H_
#define CHROME_BROWSER_UI_WEBSITE_SETTINGS_PERMISSION_BUBBLE_MANAGER_H_
+#include <unordered_map>
#include <vector>
#include "base/gtest_prod_util.h"
@@ -52,8 +53,9 @@ class PermissionBubbleManager
// outlive the PermissionBubbleManager. If a bubble is visible when this
// call is made, the request will be queued up and shown after the current
// bubble closes. A request with message text identical to an outstanding
- // request will receive a RequestFinished call immediately and not be added.
- virtual void AddRequest(PermissionBubbleRequest* request);
+ // request will be merged with the outstanding request, and will have the same
+ // callbacks called as the outstanding request.
+ void AddRequest(PermissionBubbleRequest* request);
// Cancels an outstanding request. This may have different effects depending
// on what is going on with the bubble. If the request is pending, it will be
@@ -62,7 +64,7 @@ class PermissionBubbleManager
// In some circumstances, we can remove the request from the bubble, and may
// do so. The request will have RequestFinished executed on it if it is found,
// at which time the caller is free to delete the request.
- virtual void CancelRequest(PermissionBubbleRequest* request);
+ void CancelRequest(PermissionBubbleRequest* request);
// Hides the bubble.
void HideBubble();
@@ -137,18 +139,26 @@ class PermissionBubbleManager
// from the requesting page.
void CancelPendingQueues();
- // Returns whether or not |request| has already been added to |queue|.
- // |same_object| must be non-null. It will be set to true if |request|
- // is the same object as an existing request in |queue|, false otherwise.
- bool ExistingRequest(PermissionBubbleRequest* request,
- const std::vector<PermissionBubbleRequest*>& queue,
- bool* same_object);
+ // Searches |requests_|, |queued_requests_| and |queued_frame_requests_| - but
+ // *not* |duplicate_requests_| - for a request matching |request|, and returns
+ // the matching request, or |nullptr| if no match. Note that the matching
+ // request may or may not be the same object as |request|.
+ PermissionBubbleRequest* GetExistingRequest(PermissionBubbleRequest* request);
// Returns true if |queue| contains a request which was generated by a user
// gesture. Returns false otherwise.
bool HasUserGestureRequest(
const std::vector<PermissionBubbleRequest*>& queue);
+ // Calls PermissionGranted on a request and all its duplicates.
+ void PermissionGrantedIncludingDuplicates(PermissionBubbleRequest* request);
+ // Calls PermissionDenied on a request and all its duplicates.
+ void PermissionDeniedIncludingDuplicates(PermissionBubbleRequest* request);
+ // Calls Cancelled on a request and all its duplicates.
+ void CancelledIncludingDuplicates(PermissionBubbleRequest* request);
+ // Calls RequestFinished on a request and all its duplicates.
+ void RequestFinishedIncludingDuplicates(PermissionBubbleRequest* request);
+
void NotifyBubbleAdded();
void DoAutoResponseForTesting();
@@ -162,12 +172,17 @@ class PermissionBubbleManager
std::vector<PermissionBubbleRequest*> requests_;
std::vector<PermissionBubbleRequest*> queued_requests_;
std::vector<PermissionBubbleRequest*> queued_frame_requests_;
+ // Maps from the first request of a kind to subsequent requests that were
+ // duped against it.
+ std::unordered_multimap<PermissionBubbleRequest*, PermissionBubbleRequest*>
+ duplicate_requests_;
// URL of the main frame in the WebContents to which this manager is attached.
// TODO(gbillock): if there are iframes in the page, we need to deal with it.
GURL request_url_;
bool main_frame_has_fully_loaded_;
+ // Whether each of the requests in |requests_| is accepted by the user.
std::vector<bool> accept_states_;
base::ObserverList<Observer> observer_list_;

Powered by Google App Engine
This is Rietveld 408576698