OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/apps/native_app_window_views.h" | 5 #include "chrome/browser/ui/views/apps/native_app_window_views.h" |
6 | 6 |
7 #include "apps/ui/views/shell_window_frame_view.h" | 7 #include "apps/ui/views/shell_window_frame_view.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
448 return ash::wm::GetWindowState(window_->GetNativeWindow())-> | 448 return ash::wm::GetWindowState(window_->GetNativeWindow())-> |
449 panel_attached(); | 449 panel_attached(); |
450 #else | 450 #else |
451 return true; | 451 return true; |
452 #endif | 452 #endif |
453 } else { | 453 } else { |
454 return window_->IsAlwaysOnTop(); | 454 return window_->IsAlwaysOnTop(); |
455 } | 455 } |
456 } | 456 } |
457 | 457 |
458 bool NativeAppWindowViews::IsFrameless() const { | |
459 return frameless_; | |
460 } | |
461 | |
462 gfx::Insets NativeAppWindowViews::GetFrameInsets() const { | |
463 if (frameless_) | |
464 return gfx::Insets(); | |
465 | |
466 // The pretend client_bounds passed in need to be large enough to ensure that | |
467 // GetWindowBoundsForClientBounds() doesn't decide that it needs more than | |
468 // the specified amount of space to fit the window controls in, and return a | |
469 // number larger than the real frame insets. Most window controls are smaller | |
470 // than 1000x1000px, so this should be big enough. | |
471 gfx::Rect client_bounds = gfx::Rect(1000, 1000); | |
472 gfx::Rect window_bounds = | |
473 window_->non_client_view()->GetWindowBoundsForClientBounds( | |
474 client_bounds); | |
475 return window_bounds.InsetsFrom(client_bounds); | |
476 } | |
477 | |
478 bool NativeAppWindowViews::IsVisible() const { | |
479 return window_->IsVisible(); | |
480 } | |
481 | |
482 void NativeAppWindowViews::HideWithApp() {} | |
483 void NativeAppWindowViews::ShowWithApp() {} | |
484 | |
485 void NativeAppWindowViews::SetAlwaysOnTop(bool always_on_top) { | 458 void NativeAppWindowViews::SetAlwaysOnTop(bool always_on_top) { |
486 window_->SetAlwaysOnTop(always_on_top); | 459 window_->SetAlwaysOnTop(always_on_top); |
487 shell_window_->OnNativeWindowChanged(); | 460 shell_window_->OnNativeWindowChanged(); |
488 } | 461 } |
489 | 462 |
490 gfx::NativeView NativeAppWindowViews::GetHostView() const { | 463 gfx::NativeView NativeAppWindowViews::GetHostView() const { |
491 return window_->GetNativeView(); | 464 return window_->GetNativeView(); |
492 } | 465 } |
493 | 466 |
494 gfx::Point NativeAppWindowViews::GetDialogPosition(const gfx::Size& size) { | 467 gfx::Point NativeAppWindowViews::GetDialogPosition(const gfx::Size& size) { |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
635 } | 608 } |
636 | 609 |
637 views::Widget* NativeAppWindowViews::GetWidget() { | 610 views::Widget* NativeAppWindowViews::GetWidget() { |
638 return window_; | 611 return window_; |
639 } | 612 } |
640 | 613 |
641 const views::Widget* NativeAppWindowViews::GetWidget() const { | 614 const views::Widget* NativeAppWindowViews::GetWidget() const { |
642 return window_; | 615 return window_; |
643 } | 616 } |
644 | 617 |
| 618 views::View* NativeAppWindowViews::GetContentsView() { |
| 619 return this; |
| 620 } |
| 621 |
645 views::NonClientFrameView* NativeAppWindowViews::CreateNonClientFrameView( | 622 views::NonClientFrameView* NativeAppWindowViews::CreateNonClientFrameView( |
646 views::Widget* widget) { | 623 views::Widget* widget) { |
647 #if defined(USE_ASH) | 624 #if defined(USE_ASH) |
648 if (chrome::IsNativeViewInAsh(widget->GetNativeView())) { | 625 if (chrome::IsNativeViewInAsh(widget->GetNativeView())) { |
649 if (shell_window_->window_type_is_panel()) { | 626 if (shell_window_->window_type_is_panel()) { |
650 ash::PanelFrameView::FrameType frame_type = frameless_ ? | 627 ash::PanelFrameView::FrameType frame_type = frameless_ ? |
651 ash::PanelFrameView::FRAME_NONE : ash::PanelFrameView::FRAME_ASH; | 628 ash::PanelFrameView::FRAME_NONE : ash::PanelFrameView::FRAME_ASH; |
652 return new ash::PanelFrameView(widget, frame_type); | 629 return new ash::PanelFrameView(widget, frame_type); |
653 } | 630 } |
654 if (!frameless_) { | 631 if (!frameless_) { |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
710 background.setConfig(SkBitmap::kARGB_8888_Config, 1, 1); | 687 background.setConfig(SkBitmap::kARGB_8888_Config, 1, 1); |
711 background.allocPixels(); | 688 background.allocPixels(); |
712 background.eraseARGB(0x00, 0x00, 0x00, 0x00); | 689 background.eraseARGB(0x00, 0x00, 0x00, 0x00); |
713 | 690 |
714 content::RenderWidgetHostView* view = render_view_host->GetView(); | 691 content::RenderWidgetHostView* view = render_view_host->GetView(); |
715 DCHECK(view); | 692 DCHECK(view); |
716 view->SetBackground(background); | 693 view->SetBackground(background); |
717 } | 694 } |
718 } | 695 } |
719 | 696 |
| 697 void NativeAppWindowViews::RenderViewHostChanged( |
| 698 content::RenderViewHost* old_host, |
| 699 content::RenderViewHost* new_host) { |
| 700 OnViewWasResized(); |
| 701 } |
| 702 |
720 // views::View implementation. | 703 // views::View implementation. |
721 | 704 |
722 void NativeAppWindowViews::Layout() { | 705 void NativeAppWindowViews::Layout() { |
723 DCHECK(web_view_); | 706 DCHECK(web_view_); |
724 web_view_->SetBounds(0, 0, width(), height()); | 707 web_view_->SetBounds(0, 0, width(), height()); |
725 OnViewWasResized(); | 708 OnViewWasResized(); |
726 } | 709 } |
727 | 710 |
728 void NativeAppWindowViews::ViewHierarchyChanged( | 711 void NativeAppWindowViews::ViewHierarchyChanged( |
729 const ViewHierarchyChangedDetails& details) { | 712 const ViewHierarchyChangedDetails& details) { |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
790 bool NativeAppWindowViews::IsDetached() const { | 773 bool NativeAppWindowViews::IsDetached() const { |
791 if (!shell_window_->window_type_is_panel()) | 774 if (!shell_window_->window_type_is_panel()) |
792 return false; | 775 return false; |
793 #if defined(USE_ASH) | 776 #if defined(USE_ASH) |
794 return !ash::wm::GetWindowState(window_->GetNativeWindow())->panel_attached(); | 777 return !ash::wm::GetWindowState(window_->GetNativeWindow())->panel_attached(); |
795 #else | 778 #else |
796 return false; | 779 return false; |
797 #endif | 780 #endif |
798 } | 781 } |
799 | 782 |
800 views::View* NativeAppWindowViews::GetContentsView() { | |
801 return this; | |
802 } | |
803 | |
804 void NativeAppWindowViews::UpdateWindowIcon() { | 783 void NativeAppWindowViews::UpdateWindowIcon() { |
805 window_->UpdateWindowIcon(); | 784 window_->UpdateWindowIcon(); |
806 } | 785 } |
807 | 786 |
808 void NativeAppWindowViews::UpdateWindowTitle() { | 787 void NativeAppWindowViews::UpdateWindowTitle() { |
809 window_->UpdateWindowTitle(); | 788 window_->UpdateWindowTitle(); |
810 } | 789 } |
811 | 790 |
812 void NativeAppWindowViews::UpdateInputRegion(scoped_ptr<SkRegion> region) { | |
813 input_region_ = region.Pass(); | |
814 } | |
815 | |
816 void NativeAppWindowViews::UpdateDraggableRegions( | 791 void NativeAppWindowViews::UpdateDraggableRegions( |
817 const std::vector<extensions::DraggableRegion>& regions) { | 792 const std::vector<extensions::DraggableRegion>& regions) { |
818 // Draggable region is not supported for non-frameless window. | 793 // Draggable region is not supported for non-frameless window. |
819 if (!frameless_) | 794 if (!frameless_) |
820 return; | 795 return; |
821 | 796 |
822 draggable_region_.reset(ShellWindow::RawDraggableRegionsToSkRegion(regions)); | 797 draggable_region_.reset(ShellWindow::RawDraggableRegionsToSkRegion(regions)); |
823 OnViewWasResized(); | 798 OnViewWasResized(); |
824 } | 799 } |
825 | 800 |
826 SkRegion* NativeAppWindowViews::GetDraggableRegion() { | 801 SkRegion* NativeAppWindowViews::GetDraggableRegion() { |
827 return draggable_region_.get(); | 802 return draggable_region_.get(); |
828 } | 803 } |
829 | 804 |
| 805 void NativeAppWindowViews::UpdateInputRegion(scoped_ptr<SkRegion> region) { |
| 806 input_region_ = region.Pass(); |
| 807 } |
| 808 |
830 void NativeAppWindowViews::HandleKeyboardEvent( | 809 void NativeAppWindowViews::HandleKeyboardEvent( |
831 const content::NativeWebKeyboardEvent& event) { | 810 const content::NativeWebKeyboardEvent& event) { |
832 unhandled_keyboard_event_handler_.HandleKeyboardEvent(event, | 811 unhandled_keyboard_event_handler_.HandleKeyboardEvent(event, |
833 GetFocusManager()); | 812 GetFocusManager()); |
834 } | 813 } |
835 | 814 |
836 void NativeAppWindowViews::RenderViewHostChanged( | 815 bool NativeAppWindowViews::IsFrameless() const { |
837 content::RenderViewHost* old_host, | 816 return frameless_; |
838 content::RenderViewHost* new_host) { | |
839 OnViewWasResized(); | |
840 } | 817 } |
| 818 |
| 819 gfx::Insets NativeAppWindowViews::GetFrameInsets() const { |
| 820 if (frameless_) |
| 821 return gfx::Insets(); |
| 822 |
| 823 // The pretend client_bounds passed in need to be large enough to ensure that |
| 824 // GetWindowBoundsForClientBounds() doesn't decide that it needs more than |
| 825 // the specified amount of space to fit the window controls in, and return a |
| 826 // number larger than the real frame insets. Most window controls are smaller |
| 827 // than 1000x1000px, so this should be big enough. |
| 828 gfx::Rect client_bounds = gfx::Rect(1000, 1000); |
| 829 gfx::Rect window_bounds = |
| 830 window_->non_client_view()->GetWindowBoundsForClientBounds( |
| 831 client_bounds); |
| 832 return window_bounds.InsetsFrom(client_bounds); |
| 833 } |
| 834 |
| 835 bool NativeAppWindowViews::IsVisible() const { |
| 836 return window_->IsVisible(); |
| 837 } |
| 838 |
| 839 void NativeAppWindowViews::HideWithApp() {} |
| 840 void NativeAppWindowViews::ShowWithApp() {} |
OLD | NEW |