Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(243)

Side by Side Diff: chrome/browser/ui/views/website_settings/permissions_bubble_view.cc

Issue 1970113002: [diff] avoiding regressions for views permissions prompts in fullscreen (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@20161112-MacViews-PermisisonBubble
Patch Set: Keep hasVisibleLocationBar for browser_tests Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/ui/views/website_settings/permissions_bubble_view.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/permissions_bubble_view.h" 5 #include "chrome/browser/ui/views/website_settings/permissions_bubble_view.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 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 delegate_(nullptr), 375 delegate_(nullptr),
376 bubble_delegate_(nullptr), 376 bubble_delegate_(nullptr),
377 anchor_delegate_(CreateAnchorDelegate(browser)) { 377 anchor_delegate_(CreateAnchorDelegate(browser)) {
378 DCHECK(browser); 378 DCHECK(browser);
379 DCHECK(browser->window()); 379 DCHECK(browser->window());
380 } 380 }
381 381
382 PermissionBubbleViewViews::~PermissionBubbleViewViews() { 382 PermissionBubbleViewViews::~PermissionBubbleViewViews() {
383 } 383 }
384 384
385 views::BubbleBorder::Arrow PermissionBubbleViewViews::GetAnchorArrow() {
386 if (browser_->SupportsWindowFeature(Browser::FEATURE_LOCATIONBAR))
387 return views::BubbleBorder::TOP_LEFT;
388 return views::BubbleBorder::NONE;
389 }
390
391 void PermissionBubbleViewViews::SetDelegate(Delegate* delegate) { 385 void PermissionBubbleViewViews::SetDelegate(Delegate* delegate) {
392 delegate_ = delegate; 386 delegate_ = delegate;
393 } 387 }
394 388
395 void PermissionBubbleViewViews::Show( 389 void PermissionBubbleViewViews::Show(
396 const std::vector<PermissionBubbleRequest*>& requests, 390 const std::vector<PermissionBubbleRequest*>& requests,
397 const std::vector<bool>& values) { 391 const std::vector<bool>& values) {
398 if (bubble_delegate_) 392 if (bubble_delegate_)
399 bubble_delegate_->CloseBubble(); 393 bubble_delegate_->CloseBubble();
400 394
401 bubble_delegate_ = new PermissionsBubbleDialogDelegateView( 395 bubble_delegate_ = new PermissionsBubbleDialogDelegateView(
402 this, requests, values); 396 this, requests, values);
403 397
404 // Set |parent_window| because some valid anchors can become hidden. 398 // Set |parent_window| because some valid anchors can become hidden.
405 bubble_delegate_->set_parent_window( 399 bubble_delegate_->set_parent_window(
406 platform_util::GetViewForWindow(browser_->window()->GetNativeWindow())); 400 platform_util::GetViewForWindow(browser_->window()->GetNativeWindow()));
407 401
408 views::BubbleDialogDelegateView::CreateBubble(bubble_delegate_)->Show(); 402 views::BubbleDialogDelegateView::CreateBubble(bubble_delegate_)->Show();
409 bubble_delegate_->SizeToContents(); 403 bubble_delegate_->SizeToContents();
410 404
411 bubble_delegate_->UpdateAnchor( 405 bubble_delegate_->UpdateAnchor(anchor_delegate_->GetAnchorView(),
412 anchor_delegate_->GetAnchorView(), 406 anchor_delegate_->GetAnchorPoint(),
413 anchor_delegate_->GetAnchorPoint(), 407 anchor_delegate_->GetAnchorArrow());
414 GetAnchorArrow());
415 } 408 }
416 409
417 bool PermissionBubbleViewViews::CanAcceptRequestUpdate() { 410 bool PermissionBubbleViewViews::CanAcceptRequestUpdate() {
418 return !(bubble_delegate_ && bubble_delegate_->IsMouseHovered()); 411 return !(bubble_delegate_ && bubble_delegate_->IsMouseHovered());
419 } 412 }
420 413
421 void PermissionBubbleViewViews::Hide() { 414 void PermissionBubbleViewViews::Hide() {
422 if (bubble_delegate_) { 415 if (bubble_delegate_) {
423 bubble_delegate_->CloseBubble(); 416 bubble_delegate_->CloseBubble();
424 bubble_delegate_ = nullptr; 417 bubble_delegate_ = nullptr;
425 } 418 }
426 } 419 }
427 420
428 bool PermissionBubbleViewViews::IsVisible() { 421 bool PermissionBubbleViewViews::IsVisible() {
429 return bubble_delegate_ != nullptr; 422 return bubble_delegate_ != nullptr;
430 } 423 }
431 424
432 void PermissionBubbleViewViews::UpdateAnchorPosition() { 425 void PermissionBubbleViewViews::UpdateAnchorPosition() {
433 if (IsVisible()) { 426 if (IsVisible()) {
434 bubble_delegate_->set_parent_window( 427 bubble_delegate_->set_parent_window(
435 platform_util::GetViewForWindow(browser_->window()->GetNativeWindow())); 428 platform_util::GetViewForWindow(browser_->window()->GetNativeWindow()));
436 bubble_delegate_->UpdateAnchor(anchor_delegate_->GetAnchorView(), 429 bubble_delegate_->UpdateAnchor(anchor_delegate_->GetAnchorView(),
437 anchor_delegate_->GetAnchorPoint(), 430 anchor_delegate_->GetAnchorPoint(),
438 GetAnchorArrow()); 431 anchor_delegate_->GetAnchorArrow());
439 } 432 }
440 } 433 }
441 434
442 gfx::NativeWindow PermissionBubbleViewViews::GetNativeWindow() { 435 gfx::NativeWindow PermissionBubbleViewViews::GetNativeWindow() {
443 if (bubble_delegate_ && bubble_delegate_->GetWidget()) 436 if (bubble_delegate_ && bubble_delegate_->GetWidget())
444 return bubble_delegate_->GetWidget()->GetNativeWindow(); 437 return bubble_delegate_->GetWidget()->GetNativeWindow();
445 return nullptr; 438 return nullptr;
446 } 439 }
447 440
448 void PermissionBubbleViewViews::Closing() { 441 void PermissionBubbleViewViews::Closing() {
(...skipping 10 matching lines...) Expand all
459 452
460 void PermissionBubbleViewViews::Accept() { 453 void PermissionBubbleViewViews::Accept() {
461 if (delegate_) 454 if (delegate_)
462 delegate_->Accept(); 455 delegate_->Accept();
463 } 456 }
464 457
465 void PermissionBubbleViewViews::Deny() { 458 void PermissionBubbleViewViews::Deny() {
466 if (delegate_) 459 if (delegate_)
467 delegate_->Deny(); 460 delegate_->Deny();
468 } 461 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/website_settings/permissions_bubble_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698