| 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 a2ace674da4eeb7e68fd9d0f0648eea5cbe140ae..c2031c22357faea7d1ced7ef68e61be561171853 100644
|
| --- a/chrome/browser/ui/website_settings/permission_bubble_manager.cc
|
| +++ b/chrome/browser/ui/website_settings/permission_bubble_manager.cc
|
| @@ -6,6 +6,8 @@
|
|
|
| #include "base/command_line.h"
|
| #include "base/metrics/user_metrics_action.h"
|
| +#include "chrome/browser/ui/browser.h"
|
| +#include "chrome/browser/ui/website_settings/permission_bubble_delegate.h"
|
| #include "chrome/browser/ui/website_settings/permission_bubble_request.h"
|
| #include "chrome/common/chrome_switches.h"
|
| #include "content/public/browser/browser_thread.h"
|
| @@ -79,15 +81,13 @@ PermissionBubbleManager::PermissionBubbleManager(
|
| #if !defined(OS_ANDROID) // No bubbles in android tests.
|
| view_factory_(base::Bind(&PermissionBubbleView::Create)),
|
| #endif
|
| - view_(nullptr),
|
| main_frame_has_fully_loaded_(false),
|
| auto_response_for_test_(NONE),
|
| weak_factory_(this) {
|
| }
|
|
|
| PermissionBubbleManager::~PermissionBubbleManager() {
|
| - if (view_ != NULL)
|
| - view_->SetDelegate(NULL);
|
| + HideBubble();
|
|
|
| std::vector<PermissionBubbleRequest*>::iterator requests_iter;
|
| for (requests_iter = requests_.begin();
|
| @@ -174,14 +174,18 @@ void PermissionBubbleManager::CancelRequest(PermissionBubbleRequest* request) {
|
|
|
| // We can simply erase the current entry in the request table if we aren't
|
| // showing the dialog, or if we are showing it and it can accept the update.
|
| - bool can_erase = !IsBubbleVisible() || view_->CanAcceptRequestUpdate();
|
| + bool can_erase = !IsBubbleVisible();
|
| +
|
| + // TODO(hcarmona): Don't forget this logic. Maybe improve it? Or remove it?
|
| + // bool can_erase = !IsBubbleVisible() || view_->CanAcceptRequestUpdate();
|
| +
|
| if (can_erase) {
|
| (*requests_iter)->RequestFinished();
|
| requests_.erase(requests_iter);
|
| accept_states_.erase(accepts_iter);
|
|
|
| if (IsBubbleVisible()) {
|
| - view_->Hide();
|
| + HideBubble();
|
| // Will redraw the bubble if it is being shown.
|
| TriggerShowBubble();
|
| }
|
| @@ -200,38 +204,21 @@ void PermissionBubbleManager::CancelRequest(PermissionBubbleRequest* request) {
|
| }
|
|
|
| void PermissionBubbleManager::HideBubble() {
|
| - // Disengage from the existing view if there is one.
|
| - if (!view_)
|
| + if (!active_bubble_)
|
| return;
|
| -
|
| - view_->SetDelegate(nullptr);
|
| - view_->Hide();
|
| - view_.reset();
|
| + browser_->bubble_manager()->HideBubble(active_bubble_);
|
| }
|
|
|
| -void PermissionBubbleManager::DisplayPendingRequests(Browser* browser) {
|
| +void PermissionBubbleManager::DisplayPendingRequests() {
|
| if (IsBubbleVisible())
|
| return;
|
|
|
| - view_ = view_factory_.Run(browser);
|
| - view_->SetDelegate(this);
|
| -
|
| TriggerShowBubble();
|
| }
|
|
|
| -void PermissionBubbleManager::UpdateAnchorPosition() {
|
| - if (view_)
|
| - view_->UpdateAnchorPosition();
|
| -}
|
| -
|
| bool PermissionBubbleManager::IsBubbleVisible() {
|
| - return view_ && view_->IsVisible();
|
| -}
|
| -
|
| -gfx::NativeWindow PermissionBubbleManager::GetBubbleWindow() {
|
| - if (view_)
|
| - return view_->GetNativeWindow();
|
| - return nullptr;
|
| + // TODO(hcarmona): anything else for "visible check"?
|
| + return active_bubble_;
|
| }
|
|
|
| void PermissionBubbleManager::RequireUserGesture(bool required) {
|
| @@ -269,13 +256,10 @@ void PermissionBubbleManager::NavigationEntryCommitted(
|
| return;
|
|
|
| // If we have navigated to a new url or reloaded the page...
|
| - // GetAsReferrer strips fragment and username/password, meaning
|
| - // the navigation is really to the same page.
|
| - if ((request_url_.GetAsReferrer() !=
|
| - web_contents()->GetLastCommittedURL().GetAsReferrer()) ||
|
| - (details.type == content::NAVIGATION_TYPE_EXISTING_PAGE &&
|
| - !details.is_in_page)) {
|
| - // Kill off existing bubble and cancel any pending requests.
|
| + if (!details.is_in_page ||
|
| + details.type == content::NAVIGATION_TYPE_SAME_PAGE ||
|
| + details.type == content::NAVIGATION_TYPE_EXISTING_PAGE) {
|
| + // kill off existing bubble and cancel any pending requests.
|
| CancelPendingQueues();
|
| FinalizeBubble();
|
| }
|
| @@ -347,8 +331,6 @@ void PermissionBubbleManager::ScheduleShowBubble() {
|
| }
|
|
|
| void PermissionBubbleManager::TriggerShowBubble() {
|
| - if (!view_)
|
| - return;
|
| if (IsBubbleVisible())
|
| return;
|
| if (!main_frame_has_fully_loaded_)
|
| @@ -376,7 +358,9 @@ void PermissionBubbleManager::TriggerShowBubble() {
|
| accept_states_.resize(requests_.size(), true);
|
| }
|
|
|
| - view_->Show(requests_, accept_states_);
|
| + active_bubble_ = browser_->bubble_manager()->ShowBubble(
|
| + make_scoped_ptr(new PermissionBubbleDelegate(this, view_factory_)));
|
| +
|
| NotifyBubbleAdded();
|
|
|
| // If in testing mode, automatically respond to the bubble that was shown.
|
| @@ -385,8 +369,7 @@ void PermissionBubbleManager::TriggerShowBubble() {
|
| }
|
|
|
| void PermissionBubbleManager::FinalizeBubble() {
|
| - if (view_)
|
| - view_->Hide();
|
| + HideBubble();
|
|
|
| std::vector<PermissionBubbleRequest*>::iterator requests_iter;
|
| for (requests_iter = requests_.begin();
|
|
|