Chromium Code Reviews| 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 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 387 // The anchor rect is ignored unless |anchor_view| is nullptr. | 387 // The anchor rect is ignored unless |anchor_view| is nullptr. |
| 388 SetAnchorRect(gfx::Rect(anchor_point, gfx::Size())); | 388 SetAnchorRect(gfx::Rect(anchor_point, gfx::Size())); |
| 389 } | 389 } |
| 390 | 390 |
| 391 ////////////////////////////////////////////////////////////////////////////// | 391 ////////////////////////////////////////////////////////////////////////////// |
| 392 // PermissionPromptImpl | 392 // PermissionPromptImpl |
| 393 | 393 |
| 394 PermissionPromptImpl::PermissionPromptImpl(Browser* browser) | 394 PermissionPromptImpl::PermissionPromptImpl(Browser* browser) |
| 395 : browser_(browser), | 395 : browser_(browser), |
| 396 delegate_(nullptr), | 396 delegate_(nullptr), |
| 397 bubble_delegate_(nullptr) { | 397 bubble_delegate_(nullptr) {} |
|
hcarmona
2016/10/10 18:08:19
Same here.
dominickn
2016/10/10 22:55:48
See other comment
| |
| 398 DCHECK(browser); | |
| 399 DCHECK(browser->window()); | |
| 400 } | |
| 401 | 398 |
| 402 PermissionPromptImpl::~PermissionPromptImpl() { | 399 PermissionPromptImpl::~PermissionPromptImpl() { |
| 403 } | 400 } |
| 404 | 401 |
| 405 void PermissionPromptImpl::SetDelegate(Delegate* delegate) { | 402 void PermissionPromptImpl::SetDelegate(Delegate* delegate) { |
| 406 delegate_ = delegate; | 403 delegate_ = delegate; |
| 407 } | 404 } |
| 408 | 405 |
| 409 void PermissionPromptImpl::Show(const std::vector<PermissionRequest*>& requests, | 406 void PermissionPromptImpl::Show(const std::vector<PermissionRequest*>& requests, |
| 410 const std::vector<bool>& values) { | 407 const std::vector<bool>& values) { |
| 408 DCHECK(browser_); | |
| 409 DCHECK(browser_->window()); | |
| 410 | |
| 411 if (bubble_delegate_) | 411 if (bubble_delegate_) |
| 412 bubble_delegate_->CloseBubble(); | 412 bubble_delegate_->CloseBubble(); |
| 413 | 413 |
| 414 bubble_delegate_ = | 414 bubble_delegate_ = |
| 415 new PermissionsBubbleDialogDelegateView(this, requests, values); | 415 new PermissionsBubbleDialogDelegateView(this, requests, values); |
| 416 | 416 |
| 417 // Set |parent_window| because some valid anchors can become hidden. | 417 // Set |parent_window| because some valid anchors can become hidden. |
| 418 bubble_delegate_->set_parent_window( | 418 bubble_delegate_->set_parent_window( |
| 419 platform_util::GetViewForWindow(browser_->window()->GetNativeWindow())); | 419 platform_util::GetViewForWindow(browser_->window()->GetNativeWindow())); |
| 420 | 420 |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 435 bubble_delegate_->CloseBubble(); | 435 bubble_delegate_->CloseBubble(); |
| 436 bubble_delegate_ = nullptr; | 436 bubble_delegate_ = nullptr; |
| 437 } | 437 } |
| 438 } | 438 } |
| 439 | 439 |
| 440 bool PermissionPromptImpl::IsVisible() { | 440 bool PermissionPromptImpl::IsVisible() { |
| 441 return bubble_delegate_ != nullptr; | 441 return bubble_delegate_ != nullptr; |
| 442 } | 442 } |
| 443 | 443 |
| 444 void PermissionPromptImpl::UpdateAnchorPosition() { | 444 void PermissionPromptImpl::UpdateAnchorPosition() { |
| 445 DCHECK(browser_); | |
| 446 DCHECK(browser_->window()); | |
| 447 | |
| 445 if (IsVisible()) { | 448 if (IsVisible()) { |
| 446 bubble_delegate_->set_parent_window( | 449 bubble_delegate_->set_parent_window( |
| 447 platform_util::GetViewForWindow(browser_->window()->GetNativeWindow())); | 450 platform_util::GetViewForWindow(browser_->window()->GetNativeWindow())); |
| 448 bubble_delegate_->UpdateAnchor(GetAnchorView(), | 451 bubble_delegate_->UpdateAnchor(GetAnchorView(), |
| 449 GetAnchorPoint(), | 452 GetAnchorPoint(), |
| 450 GetAnchorArrow()); | 453 GetAnchorArrow()); |
| 451 } | 454 } |
| 452 } | 455 } |
| 453 | 456 |
| 454 gfx::NativeWindow PermissionPromptImpl::GetNativeWindow() { | 457 gfx::NativeWindow PermissionPromptImpl::GetNativeWindow() { |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 476 | 479 |
| 477 void PermissionPromptImpl::Accept() { | 480 void PermissionPromptImpl::Accept() { |
| 478 if (delegate_) | 481 if (delegate_) |
| 479 delegate_->Accept(); | 482 delegate_->Accept(); |
| 480 } | 483 } |
| 481 | 484 |
| 482 void PermissionPromptImpl::Deny() { | 485 void PermissionPromptImpl::Deny() { |
| 483 if (delegate_) | 486 if (delegate_) |
| 484 delegate_->Deny(); | 487 delegate_->Deny(); |
| 485 } | 488 } |
| OLD | NEW |