OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/app/chrome_command_ids.h" | 9 #include "chrome/app/chrome_command_ids.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
(...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
569 // ConstrainedWindowViews, public: | 569 // ConstrainedWindowViews, public: |
570 | 570 |
571 ConstrainedWindowViews::ConstrainedWindowViews( | 571 ConstrainedWindowViews::ConstrainedWindowViews( |
572 TabContents* owner, | 572 TabContents* owner, |
573 views::WindowDelegate* window_delegate) | 573 views::WindowDelegate* window_delegate) |
574 : owner_(owner), | 574 : owner_(owner), |
575 ALLOW_THIS_IN_INITIALIZER_LIST(native_constrained_window_( | 575 ALLOW_THIS_IN_INITIALIZER_LIST(native_constrained_window_( |
576 NativeConstrainedWindow::CreateNativeConstrainedWindow(this))) { | 576 NativeConstrainedWindow::CreateNativeConstrainedWindow(this))) { |
577 GetWindow()->non_client_view()->SetFrameView(CreateFrameViewForWindow()); | 577 GetWindow()->non_client_view()->SetFrameView(CreateFrameViewForWindow()); |
578 views::Window::InitParams params(window_delegate); | 578 views::Window::InitParams params(window_delegate); |
| 579 params.native_window = native_constrained_window_->AsNativeWindow(); |
579 params.widget_init_params.child = true; | 580 params.widget_init_params.child = true; |
580 params.widget_init_params.parent = owner->GetNativeView(); | 581 params.widget_init_params.parent = owner->GetNativeView(); |
| 582 params.widget_init_params.native_widget = |
| 583 native_constrained_window_->AsNativeWindow()->AsNativeWidget(); |
581 GetWindow()->InitWindow(params); | 584 GetWindow()->InitWindow(params); |
582 } | 585 } |
583 | 586 |
584 ConstrainedWindowViews::~ConstrainedWindowViews() { | 587 ConstrainedWindowViews::~ConstrainedWindowViews() { |
585 } | 588 } |
586 | 589 |
587 views::Window* ConstrainedWindowViews::GetWindow() { | 590 views::Window* ConstrainedWindowViews::GetWindow() { |
588 return native_constrained_window_->AsNativeWindow()->GetWindow(); | 591 return native_constrained_window_->AsNativeWindow()->GetWindow(); |
589 } | 592 } |
590 | 593 |
(...skipping 10 matching lines...) Expand all Loading... |
601 FocusConstrainedWindow(); | 604 FocusConstrainedWindow(); |
602 } | 605 } |
603 | 606 |
604 void ConstrainedWindowViews::CloseConstrainedWindow() { | 607 void ConstrainedWindowViews::CloseConstrainedWindow() { |
605 // Broadcast to all observers of NOTIFY_CWINDOW_CLOSED. | 608 // Broadcast to all observers of NOTIFY_CWINDOW_CLOSED. |
606 // One example of such an observer is AutomationCWindowTracker in the | 609 // One example of such an observer is AutomationCWindowTracker in the |
607 // automation component. | 610 // automation component. |
608 NotificationService::current()->Notify(NotificationType::CWINDOW_CLOSED, | 611 NotificationService::current()->Notify(NotificationType::CWINDOW_CLOSED, |
609 Source<ConstrainedWindow>(this), | 612 Source<ConstrainedWindow>(this), |
610 NotificationService::NoDetails()); | 613 NotificationService::NoDetails()); |
611 GetWindow()->CloseWindow(); | 614 GetWindow()->Close(); |
612 } | 615 } |
613 | 616 |
614 void ConstrainedWindowViews::FocusConstrainedWindow() { | 617 void ConstrainedWindowViews::FocusConstrainedWindow() { |
615 if ((!owner_->delegate() || | 618 if ((!owner_->delegate() || |
616 owner_->delegate()->ShouldFocusConstrainedWindow()) && | 619 owner_->delegate()->ShouldFocusConstrainedWindow()) && |
617 GetWindow()->window_delegate() && | 620 GetWindow()->window_delegate() && |
618 GetWindow()->window_delegate()->GetInitiallyFocusedView()) { | 621 GetWindow()->window_delegate()->GetInitiallyFocusedView()) { |
619 GetWindow()->window_delegate()->GetInitiallyFocusedView()->RequestFocus(); | 622 GetWindow()->window_delegate()->GetInitiallyFocusedView()->RequestFocus(); |
620 } | 623 } |
621 } | 624 } |
622 | 625 |
623 //////////////////////////////////////////////////////////////////////////////// | 626 //////////////////////////////////////////////////////////////////////////////// |
| 627 // ConstrainedWindowViews, views::Window overrides: |
| 628 |
| 629 views::NonClientFrameView* ConstrainedWindowViews::CreateFrameViewForWindow() { |
| 630 return new ConstrainedWindowFrameView(this); |
| 631 } |
| 632 |
| 633 //////////////////////////////////////////////////////////////////////////////// |
624 // ConstrainedWindowViews, NativeConstrainedWindowDelegate implementation: | 634 // ConstrainedWindowViews, NativeConstrainedWindowDelegate implementation: |
625 | 635 |
626 void ConstrainedWindowViews::OnNativeConstrainedWindowDestroyed() { | 636 void ConstrainedWindowViews::OnNativeConstrainedWindowDestroyed() { |
627 // Tell our constraining TabContents that we've gone so it can update its | 637 // Tell our constraining TabContents that we've gone so it can update its |
628 // list. | 638 // list. |
629 owner_->WillClose(this); | 639 owner_->WillClose(this); |
630 } | 640 } |
631 | 641 |
632 void ConstrainedWindowViews::OnNativeConstrainedWindowMouseActivate() { | 642 void ConstrainedWindowViews::OnNativeConstrainedWindowMouseActivate() { |
633 GetWindow()->Activate(); | 643 GetWindow()->Activate(); |
634 } | 644 } |
635 | 645 |
636 views::NonClientFrameView* ConstrainedWindowViews::CreateFrameViewForWindow() { | 646 views::internal::NativeWindowDelegate* |
637 return new ConstrainedWindowFrameView(this); | 647 ConstrainedWindowViews::AsNativeWindowDelegate() { |
| 648 return this; |
638 } | 649 } |
639 | 650 |
| 651 |
640 //////////////////////////////////////////////////////////////////////////////// | 652 //////////////////////////////////////////////////////////////////////////////// |
641 // ConstrainedWindow, public: | 653 // ConstrainedWindow, public: |
642 | 654 |
643 // static | 655 // static |
644 ConstrainedWindow* ConstrainedWindow::CreateConstrainedDialog( | 656 ConstrainedWindow* ConstrainedWindow::CreateConstrainedDialog( |
645 TabContents* parent, | 657 TabContents* parent, |
646 views::WindowDelegate* window_delegate) { | 658 views::WindowDelegate* window_delegate) { |
647 return new ConstrainedWindowViews(parent, window_delegate); | 659 return new ConstrainedWindowViews(parent, window_delegate); |
648 } | 660 } |
OLD | NEW |