| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/website_settings/permission_bubble_manager.h" | 5 #include "chrome/browser/ui/website_settings/permission_bubble_manager.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "chrome/browser/ui/website_settings/permission_bubble_request.h" | 8 #include "chrome/browser/ui/website_settings/permission_bubble_request.h" |
| 9 #include "chrome/common/chrome_switches.h" | 9 #include "chrome/common/chrome_switches.h" |
| 10 | 10 |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 for (requests_iter = requests_.begin(); | 161 for (requests_iter = requests_.begin(); |
| 162 requests_iter != requests_.end(); | 162 requests_iter != requests_.end(); |
| 163 requests_iter++) { | 163 requests_iter++) { |
| 164 (*requests_iter)->Cancelled(); | 164 (*requests_iter)->Cancelled(); |
| 165 } | 165 } |
| 166 FinalizeBubble(); | 166 FinalizeBubble(); |
| 167 } | 167 } |
| 168 | 168 |
| 169 void PermissionBubbleManager::ShowBubble() { | 169 void PermissionBubbleManager::ShowBubble() { |
| 170 if (view_ && !bubble_showing_ && requests_.size()) { | 170 if (view_ && !bubble_showing_ && requests_.size()) { |
| 171 view_->SetDelegate(this); | |
| 172 view_->Show(requests_, accept_states_, customization_mode_); | 171 view_->Show(requests_, accept_states_, customization_mode_); |
| 173 bubble_showing_ = true; | 172 bubble_showing_ = true; |
| 174 } | 173 } |
| 175 } | 174 } |
| 176 | 175 |
| 177 void PermissionBubbleManager::FinalizeBubble() { | 176 void PermissionBubbleManager::FinalizeBubble() { |
| 178 if (view_) { | 177 if (view_) |
| 179 view_->SetDelegate(NULL); | |
| 180 view_->Hide(); | 178 view_->Hide(); |
| 181 } | 179 bubble_showing_ = false; |
| 182 | 180 |
| 183 std::vector<PermissionBubbleRequest*>::iterator requests_iter; | 181 std::vector<PermissionBubbleRequest*>::iterator requests_iter; |
| 184 for (requests_iter = requests_.begin(); | 182 for (requests_iter = requests_.begin(); |
| 185 requests_iter != requests_.end(); | 183 requests_iter != requests_.end(); |
| 186 requests_iter++) { | 184 requests_iter++) { |
| 187 (*requests_iter)->RequestFinished(); | 185 (*requests_iter)->RequestFinished(); |
| 188 } | 186 } |
| 189 requests_.clear(); | 187 requests_.clear(); |
| 190 accept_states_.clear(); | 188 accept_states_.clear(); |
| 191 bubble_showing_ = false; | |
| 192 if (queued_requests_.size()) { | 189 if (queued_requests_.size()) { |
| 193 requests_ = queued_requests_; | 190 requests_ = queued_requests_; |
| 194 accept_states_.resize(requests_.size(), true); | 191 accept_states_.resize(requests_.size(), true); |
| 195 queued_requests_.clear(); | 192 queued_requests_.clear(); |
| 196 // TODO(leng): Explore other options of showing the next bubble. The | 193 // TODO(leng): Explore other options of showing the next bubble. The |
| 197 // advantage of this is that it uses the same code path as the first bubble. | 194 // advantage of this is that it uses the same code path as the first bubble. |
| 198 timer_->Reset(); | 195 timer_->Reset(); |
| 199 } | 196 } |
| 200 } | 197 } |
| 201 | 198 |
| 202 void PermissionBubbleManager::SetCoalesceIntervalForTesting(int interval_ms) { | 199 void PermissionBubbleManager::SetCoalesceIntervalForTesting(int interval_ms) { |
| 203 timer_.reset(new base::Timer(FROM_HERE, | 200 timer_.reset(new base::Timer(FROM_HERE, |
| 204 base::TimeDelta::FromMilliseconds(interval_ms), | 201 base::TimeDelta::FromMilliseconds(interval_ms), |
| 205 base::Bind(&PermissionBubbleManager::ShowBubble, base::Unretained(this)), | 202 base::Bind(&PermissionBubbleManager::ShowBubble, base::Unretained(this)), |
| 206 false)); | 203 false)); |
| 207 } | 204 } |
| OLD | NEW |