| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/constrained_window_views.h" | 5 #include "chrome/browser/ui/views/constrained_window_views.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| (...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 376 client_view_bounds_ = CalculateClientAreaBounds(width(), height()); | 376 client_view_bounds_ = CalculateClientAreaBounds(width(), height()); |
| 377 } | 377 } |
| 378 | 378 |
| 379 void ConstrainedWindowFrameView::OnThemeChanged() { | 379 void ConstrainedWindowFrameView::OnThemeChanged() { |
| 380 InitWindowResources(); | 380 InitWindowResources(); |
| 381 } | 381 } |
| 382 | 382 |
| 383 void ConstrainedWindowFrameView::ButtonPressed( | 383 void ConstrainedWindowFrameView::ButtonPressed( |
| 384 views::Button* sender, const ui::Event& event) { | 384 views::Button* sender, const ui::Event& event) { |
| 385 if (sender == close_button_) | 385 if (sender == close_button_) |
| 386 container_->CloseConstrainedWindow(); | 386 container_->CloseWebContentsModalDialog(); |
| 387 } | 387 } |
| 388 | 388 |
| 389 int ConstrainedWindowFrameView::NonClientBorderThickness() const { | 389 int ConstrainedWindowFrameView::NonClientBorderThickness() const { |
| 390 return kFrameBorderThickness + kClientEdgeThickness; | 390 return kFrameBorderThickness + kClientEdgeThickness; |
| 391 } | 391 } |
| 392 | 392 |
| 393 int ConstrainedWindowFrameView::NonClientTopBorderHeight() const { | 393 int ConstrainedWindowFrameView::NonClientTopBorderHeight() const { |
| 394 return std::max(kFrameBorderThickness + IconSize(), | 394 return std::max(kFrameBorderThickness + IconSize(), |
| 395 kFrameShadowThickness + kCaptionButtonHeightWithPadding) + | 395 kFrameShadowThickness + kCaptionButtonHeightWithPadding) + |
| 396 TitlebarBottomThickness(); | 396 TitlebarBottomThickness(); |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 542 container_ = container; | 542 container_ = container; |
| 543 ash::CustomFrameViewAsh::Init(container); | 543 ash::CustomFrameViewAsh::Init(container); |
| 544 // Always use "active" look. | 544 // Always use "active" look. |
| 545 SetInactiveRenderingDisabled(true); | 545 SetInactiveRenderingDisabled(true); |
| 546 } | 546 } |
| 547 | 547 |
| 548 // views::ButtonListener overrides: | 548 // views::ButtonListener overrides: |
| 549 virtual void ButtonPressed(views::Button* sender, | 549 virtual void ButtonPressed(views::Button* sender, |
| 550 const ui::Event& event) OVERRIDE { | 550 const ui::Event& event) OVERRIDE { |
| 551 if (sender == close_button()) | 551 if (sender == close_button()) |
| 552 container_->CloseConstrainedWindow(); | 552 container_->CloseWebContentsModalDialog(); |
| 553 } | 553 } |
| 554 | 554 |
| 555 private: | 555 private: |
| 556 ConstrainedWindowViews* container_; // not owned | 556 ConstrainedWindowViews* container_; // not owned |
| 557 DISALLOW_COPY_AND_ASSIGN(ConstrainedWindowFrameViewAsh); | 557 DISALLOW_COPY_AND_ASSIGN(ConstrainedWindowFrameViewAsh); |
| 558 }; | 558 }; |
| 559 #endif // defined(USE_ASH) | 559 #endif // defined(USE_ASH) |
| 560 | 560 |
| 561 ConstrainedWindowViews::ConstrainedWindowViews( | 561 ConstrainedWindowViews::ConstrainedWindowViews( |
| 562 content::WebContents* web_contents, | 562 content::WebContents* web_contents, |
| (...skipping 16 matching lines...) Expand all Loading... |
| 579 // the window stack which will then cause many problems. | 579 // the window stack which will then cause many problems. |
| 580 if (params.parent && params.parent->parent()) { | 580 if (params.parent && params.parent->parent()) { |
| 581 params.parent->parent()->SetProperty(aura::client::kAnimationsDisabledKey, | 581 params.parent->parent()->SetProperty(aura::client::kAnimationsDisabledKey, |
| 582 true); | 582 true); |
| 583 } | 583 } |
| 584 #endif | 584 #endif |
| 585 Init(params); | 585 Init(params); |
| 586 | 586 |
| 587 ConstrainedWindowTabHelper* constrained_window_tab_helper = | 587 ConstrainedWindowTabHelper* constrained_window_tab_helper = |
| 588 ConstrainedWindowTabHelper::FromWebContents(web_contents_); | 588 ConstrainedWindowTabHelper::FromWebContents(web_contents_); |
| 589 constrained_window_tab_helper->AddConstrainedDialog(this); | 589 constrained_window_tab_helper->AddDialog(this); |
| 590 #if defined(USE_ASH) | 590 #if defined(USE_ASH) |
| 591 GetNativeWindow()->SetProperty(ash::kConstrainedWindowKey, true); | 591 GetNativeWindow()->SetProperty(ash::kConstrainedWindowKey, true); |
| 592 views::corewm::SetModalParent(GetNativeWindow(), | 592 views::corewm::SetModalParent(GetNativeWindow(), |
| 593 web_contents_->GetView()->GetNativeView()); | 593 web_contents_->GetView()->GetNativeView()); |
| 594 #endif | 594 #endif |
| 595 } | 595 } |
| 596 | 596 |
| 597 ConstrainedWindowViews::~ConstrainedWindowViews() { | 597 ConstrainedWindowViews::~ConstrainedWindowViews() { |
| 598 } | 598 } |
| 599 | 599 |
| 600 void ConstrainedWindowViews::ShowConstrainedWindow() { | 600 void ConstrainedWindowViews::ShowWebContentsModalDialog() { |
| 601 Show(); | 601 Show(); |
| 602 FocusConstrainedWindow(); | 602 FocusWebContentsModalDialog(); |
| 603 } | 603 } |
| 604 | 604 |
| 605 void ConstrainedWindowViews::CloseConstrainedWindow() { | 605 void ConstrainedWindowViews::CloseWebContentsModalDialog() { |
| 606 #if defined(USE_ASH) | 606 #if defined(USE_ASH) |
| 607 gfx::NativeView view = web_contents_->GetNativeView(); | 607 gfx::NativeView view = web_contents_->GetNativeView(); |
| 608 // Allow the parent to animate again. | 608 // Allow the parent to animate again. |
| 609 if (view && view->parent()) | 609 if (view && view->parent()) |
| 610 view->parent()->ClearProperty(aura::client::kAnimationsDisabledKey); | 610 view->parent()->ClearProperty(aura::client::kAnimationsDisabledKey); |
| 611 #endif | 611 #endif |
| 612 NotifyTabHelperWillClose(); | 612 NotifyTabHelperWillClose(); |
| 613 Close(); | 613 Close(); |
| 614 } | 614 } |
| 615 | 615 |
| 616 void ConstrainedWindowViews::FocusConstrainedWindow() { | 616 void ConstrainedWindowViews::FocusWebContentsModalDialog() { |
| 617 ConstrainedWindowTabHelper* helper = | 617 ConstrainedWindowTabHelper* helper = |
| 618 ConstrainedWindowTabHelper::FromWebContents(web_contents_); | 618 ConstrainedWindowTabHelper::FromWebContents(web_contents_); |
| 619 if ((!helper->delegate() || | 619 if ((!helper->delegate() || |
| 620 helper->delegate()->ShouldFocusConstrainedWindow()) && | 620 helper->delegate()->ShouldFocusConstrainedWindow()) && |
| 621 widget_delegate() && | 621 widget_delegate() && |
| 622 widget_delegate()->GetInitiallyFocusedView()) { | 622 widget_delegate()->GetInitiallyFocusedView()) { |
| 623 widget_delegate()->GetInitiallyFocusedView()->RequestFocus(); | 623 widget_delegate()->GetInitiallyFocusedView()->RequestFocus(); |
| 624 } | 624 } |
| 625 #if defined(USE_ASH) | 625 #if defined(USE_ASH) |
| 626 // We don't necessarily have a RootWindow yet. | 626 // We don't necessarily have a RootWindow yet. |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 664 | 664 |
| 665 views::internal::NativeWidgetDelegate* | 665 views::internal::NativeWidgetDelegate* |
| 666 ConstrainedWindowViews::AsNativeWidgetDelegate() { | 666 ConstrainedWindowViews::AsNativeWidgetDelegate() { |
| 667 return this; | 667 return this; |
| 668 } | 668 } |
| 669 | 669 |
| 670 int ConstrainedWindowViews::GetNonClientComponent(const gfx::Point& point) { | 670 int ConstrainedWindowViews::GetNonClientComponent(const gfx::Point& point) { |
| 671 // Prevent a constrained window to be moved by the user. | 671 // Prevent a constrained window to be moved by the user. |
| 672 return HTNOWHERE; | 672 return HTNOWHERE; |
| 673 } | 673 } |
| OLD | NEW |