| 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/views/website_settings/permission_prompt_impl.h" | 5 #include "chrome/browser/ui/views/website_settings/permission_prompt_impl.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| (...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 386 // The anchor rect is ignored unless |anchor_view| is nullptr. | 386 // The anchor rect is ignored unless |anchor_view| is nullptr. |
| 387 SetAnchorRect(gfx::Rect(anchor_point, gfx::Size())); | 387 SetAnchorRect(gfx::Rect(anchor_point, gfx::Size())); |
| 388 } | 388 } |
| 389 | 389 |
| 390 ////////////////////////////////////////////////////////////////////////////// | 390 ////////////////////////////////////////////////////////////////////////////// |
| 391 // PermissionPromptImpl | 391 // PermissionPromptImpl |
| 392 | 392 |
| 393 PermissionPromptImpl::PermissionPromptImpl(Browser* browser) | 393 PermissionPromptImpl::PermissionPromptImpl(Browser* browser) |
| 394 : browser_(browser), | 394 : browser_(browser), |
| 395 delegate_(nullptr), | 395 delegate_(nullptr), |
| 396 bubble_delegate_(nullptr) { | 396 bubble_delegate_(nullptr) {} |
| 397 DCHECK(browser); | |
| 398 DCHECK(browser->window()); | |
| 399 } | |
| 400 | 397 |
| 401 PermissionPromptImpl::~PermissionPromptImpl() { | 398 PermissionPromptImpl::~PermissionPromptImpl() { |
| 402 } | 399 } |
| 403 | 400 |
| 404 void PermissionPromptImpl::SetDelegate(Delegate* delegate) { | 401 void PermissionPromptImpl::SetDelegate(Delegate* delegate) { |
| 405 delegate_ = delegate; | 402 delegate_ = delegate; |
| 406 } | 403 } |
| 407 | 404 |
| 408 void PermissionPromptImpl::Show(const std::vector<PermissionRequest*>& requests, | 405 void PermissionPromptImpl::Show(const std::vector<PermissionRequest*>& requests, |
| 409 const std::vector<bool>& values) { | 406 const std::vector<bool>& values) { |
| 407 DCHECK(browser_); |
| 408 DCHECK(browser_->window()); |
| 409 |
| 410 if (bubble_delegate_) | 410 if (bubble_delegate_) |
| 411 bubble_delegate_->CloseBubble(); | 411 bubble_delegate_->CloseBubble(); |
| 412 | 412 |
| 413 bubble_delegate_ = | 413 bubble_delegate_ = |
| 414 new PermissionsBubbleDialogDelegateView(this, requests, values); | 414 new PermissionsBubbleDialogDelegateView(this, requests, values); |
| 415 | 415 |
| 416 // Set |parent_window| because some valid anchors can become hidden. | 416 // Set |parent_window| because some valid anchors can become hidden. |
| 417 bubble_delegate_->set_parent_window( | 417 bubble_delegate_->set_parent_window( |
| 418 platform_util::GetViewForWindow(browser_->window()->GetNativeWindow())); | 418 platform_util::GetViewForWindow(browser_->window()->GetNativeWindow())); |
| 419 | 419 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 434 bubble_delegate_->CloseBubble(); | 434 bubble_delegate_->CloseBubble(); |
| 435 bubble_delegate_ = nullptr; | 435 bubble_delegate_ = nullptr; |
| 436 } | 436 } |
| 437 } | 437 } |
| 438 | 438 |
| 439 bool PermissionPromptImpl::IsVisible() { | 439 bool PermissionPromptImpl::IsVisible() { |
| 440 return bubble_delegate_ != nullptr; | 440 return bubble_delegate_ != nullptr; |
| 441 } | 441 } |
| 442 | 442 |
| 443 void PermissionPromptImpl::UpdateAnchorPosition() { | 443 void PermissionPromptImpl::UpdateAnchorPosition() { |
| 444 DCHECK(browser_); |
| 445 DCHECK(browser_->window()); |
| 446 |
| 444 if (IsVisible()) { | 447 if (IsVisible()) { |
| 445 bubble_delegate_->set_parent_window( | 448 bubble_delegate_->set_parent_window( |
| 446 platform_util::GetViewForWindow(browser_->window()->GetNativeWindow())); | 449 platform_util::GetViewForWindow(browser_->window()->GetNativeWindow())); |
| 447 bubble_delegate_->UpdateAnchor(GetAnchorView(), | 450 bubble_delegate_->UpdateAnchor(GetAnchorView(), |
| 448 GetAnchorPoint(), | 451 GetAnchorPoint(), |
| 449 GetAnchorArrow()); | 452 GetAnchorArrow()); |
| 450 } | 453 } |
| 451 } | 454 } |
| 452 | 455 |
| 453 gfx::NativeWindow PermissionPromptImpl::GetNativeWindow() { | 456 gfx::NativeWindow PermissionPromptImpl::GetNativeWindow() { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 479 } | 482 } |
| 480 | 483 |
| 481 void PermissionPromptImpl::Deny() { | 484 void PermissionPromptImpl::Deny() { |
| 482 if (delegate_) | 485 if (delegate_) |
| 483 delegate_->Deny(); | 486 delegate_->Deny(); |
| 484 } | 487 } |
| 485 | 488 |
| 486 Profile* PermissionPromptImpl::GetProfile() { | 489 Profile* PermissionPromptImpl::GetProfile() { |
| 487 return browser_->profile(); | 490 return browser_->profile(); |
| 488 } | 491 } |
| OLD | NEW |