Chromium Code Reviews| Index: chrome/browser/ui/website_settings/permission_bubble_manager.cc |
| diff --git a/chrome/browser/ui/website_settings/permission_bubble_manager.cc b/chrome/browser/ui/website_settings/permission_bubble_manager.cc |
| index 97864ddde84228af4c4ae0f1570ddf1eac7e6979..2ef02f86f8b291454ca53313de3e3cfda3b547cb 100644 |
| --- a/chrome/browser/ui/website_settings/permission_bubble_manager.cc |
| +++ b/chrome/browser/ui/website_settings/permission_bubble_manager.cc |
| @@ -24,23 +24,67 @@ bool PermissionBubbleManager::Enabled() { |
| switches::kEnablePermissionsBubbles); |
| } |
| + |
| + |
| +PermissionBubbleManager::PermissionBubbleManager( |
| + content::WebContents* web_contents) |
| + : content::WebContentsObserver(web_contents), |
| + bubble_showing_(false), |
| + view_(NULL), |
| + customization_mode_(false) { |
| + timer_.reset(new base::Timer(FROM_HERE, |
| + base::TimeDelta::FromMilliseconds(kPermissionsCoalesceIntervalMs), |
| + base::Bind(&PermissionBubbleManager::ShowBubble, base::Unretained(this)), |
| + false)); |
| +} |
| + |
| +PermissionBubbleManager::~PermissionBubbleManager() { |
| + if (view_ != NULL) |
| + view_->SetDelegate(NULL); |
| + |
| + std::vector<PermissionBubbleRequest*>::iterator requests_iter; |
| + for (requests_iter = requests_.begin(); |
| + requests_iter != requests_.end(); |
| + requests_iter++) { |
| + (*requests_iter)->RequestFinished(); |
| + } |
| + requests_.clear(); |
|
groby-ooo-7-16
2014/02/25 22:27:36
Why clear? The dtor does that already?
Greg Billock
2014/02/26 00:28:44
Just gives me a warm fuzzy. :-) I'll take it out.
|
| + accept_states_.clear(); |
| + for (requests_iter = queued_requests_.begin(); |
| + requests_iter != queued_requests_.end(); |
| + requests_iter++) { |
| + (*requests_iter)->RequestFinished(); |
| + } |
| + queued_requests_.clear(); |
| +} |
| + |
| void PermissionBubbleManager::AddRequest(PermissionBubbleRequest* request) { |
| - // Don't re-add an existing request. |
| + // Don't re-add an existing request or one with a duplicate text request. |
| std::vector<PermissionBubbleRequest*>::iterator requests_iter; |
| for (requests_iter = requests_.begin(); |
| requests_iter != requests_.end(); |
| requests_iter++) { |
| if (*requests_iter == request) |
| return; |
| + if ((*requests_iter)->GetMessageTextFragment() == |
| + request->GetMessageTextFragment()) { |
| + request->RequestFinished(); |
|
groby-ooo-7-16
2014/02/25 22:27:36
Is that really "RequestFinished"? Shouldn't that b
Greg Billock
2014/02/26 00:28:44
This is basically rejecting requests that the user
|
| + return; |
| + } |
| + } |
| + for (requests_iter = queued_requests_.begin(); |
|
groby-ooo-7-16
2014/02/25 22:27:36
This is a lot of duplicated code - worth factoring
|
| + requests_iter != queued_requests_.end(); |
| + requests_iter++) { |
| + if (*requests_iter == request) |
| + return; |
| + if ((*requests_iter)->GetMessageTextFragment() == |
| + request->GetMessageTextFragment()) { |
| + request->RequestFinished(); |
| + return; |
| + } |
| } |
| if (bubble_showing_) { |
|
groby-ooo-7-16
2014/02/25 22:27:36
It's technically outside of this CL's scope, but:
Greg Billock
2014/02/26 00:28:44
The way I have the handshake working right now, th
|
| - for (requests_iter = queued_requests_.begin(); |
| - requests_iter != queued_requests_.end(); |
| - requests_iter++) { |
| - if (*requests_iter == request) |
| - return; |
| - } |
| queued_requests_.push_back(request); |
| return; |
| } |
| @@ -54,6 +98,11 @@ void PermissionBubbleManager::AddRequest(PermissionBubbleRequest* request) { |
| timer_->Reset(); |
| } |
| +void PermissionBubbleManager::CancelRequest(PermissionBubbleRequest* request) { |
| + // TODO(gbillock): implement |
| + NOTREACHED(); |
| +} |
|
groby-ooo-7-16
2014/02/25 22:27:36
Why add this if it doesn't do anything yet?
Greg Billock
2014/02/26 00:28:44
I was attempting to keep the scope of the CL down.
|
| + |
| void PermissionBubbleManager::SetView(PermissionBubbleView* view) { |
| if (view == view_) |
| return; |
| @@ -78,26 +127,6 @@ void PermissionBubbleManager::SetView(PermissionBubbleView* view) { |
| view_->Hide(); |
| } |
| -PermissionBubbleManager::PermissionBubbleManager( |
| - content::WebContents* web_contents) |
| - : content::WebContentsObserver(web_contents), |
| - bubble_showing_(false), |
| - view_(NULL), |
| - customization_mode_(false) { |
| - timer_.reset(new base::Timer(FROM_HERE, |
| - base::TimeDelta::FromMilliseconds(kPermissionsCoalesceIntervalMs), |
| - base::Bind(&PermissionBubbleManager::ShowBubble, base::Unretained(this)), |
| - false)); |
| -} |
| - |
| -PermissionBubbleManager::~PermissionBubbleManager() { |
| - if (view_ != NULL) { |
| - view_->SetDelegate(NULL); |
| - view_->Hide(); |
| - bubble_showing_ = false; |
| - } |
| -} |
| - |
| void PermissionBubbleManager::DidFinishLoad( |
| int64 frame_id, |
| const GURL& validated_url, |