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

Side by Side Diff: chrome/browser/ui/views/constrained_window_views.cc

Issue 11633052: Rename platform-independent ConstrainedWindow types to WebContentsModalDialog types (part 2) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: use gtk_widget_get_toplevel for GetNativeWindow Created 7 years, 11 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 | Annotate | Revision Log
OLDNEW
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"
11 #include "chrome/app/chrome_command_ids.h" 11 #include "chrome/app/chrome_command_ids.h"
12 #include "chrome/browser/platform_util.h" 12 #include "chrome/browser/platform_util.h"
13 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
14 #include "chrome/browser/themes/theme_service.h" 14 #include "chrome/browser/themes/theme_service.h"
15 #include "chrome/browser/ui/constrained_window_tab_helper.h"
16 #include "chrome/browser/ui/toolbar/toolbar_model.h" 15 #include "chrome/browser/ui/toolbar/toolbar_model.h"
17 #include "chrome/browser/ui/views/frame/browser_view.h" 16 #include "chrome/browser/ui/views/frame/browser_view.h"
17 #include "chrome/browser/ui/web_contents_modal_dialog_manager.h"
18 #include "chrome/common/chrome_constants.h" 18 #include "chrome/common/chrome_constants.h"
19 #include "content/public/browser/navigation_controller.h" 19 #include "content/public/browser/navigation_controller.h"
20 #include "content/public/browser/web_contents.h" 20 #include "content/public/browser/web_contents.h"
21 #include "content/public/browser/web_contents_view.h" 21 #include "content/public/browser/web_contents_view.h"
22 #include "grit/chromium_strings.h" 22 #include "grit/chromium_strings.h"
23 #include "grit/generated_resources.h" 23 #include "grit/generated_resources.h"
24 #include "grit/theme_resources.h" 24 #include "grit/theme_resources.h"
25 #include "grit/ui_resources.h" 25 #include "grit/ui_resources.h"
26 #include "net/base/net_util.h" 26 #include "net/base/net_util.h"
27 #include "ui/aura/client/aura_constants.h" 27 #include "ui/aura/client/aura_constants.h"
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 views::corewm::SetChildWindowVisibilityChangesAnimated(params.parent); 577 views::corewm::SetChildWindowVisibilityChangesAnimated(params.parent);
578 // No animations should get performed on the window since that will re-order 578 // No animations should get performed on the window since that will re-order
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 WebContentsModalDialogManager* web_contents_modal_dialog_manager =
588 ConstrainedWindowTabHelper::FromWebContents(web_contents_); 588 WebContentsModalDialogManager::FromWebContents(web_contents_);
589 constrained_window_tab_helper->AddDialog(this); 589 web_contents_modal_dialog_manager->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::ShowWebContentsModalDialog() { 600 void ConstrainedWindowViews::ShowWebContentsModalDialog() {
601 Show(); 601 Show();
602 FocusWebContentsModalDialog(); 602 FocusWebContentsModalDialog();
603 } 603 }
604 604
605 void ConstrainedWindowViews::CloseWebContentsModalDialog() { 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::FocusWebContentsModalDialog() { 616 void ConstrainedWindowViews::FocusWebContentsModalDialog() {
617 ConstrainedWindowTabHelper* helper = 617 WebContentsModalDialogManager* manager =
618 ConstrainedWindowTabHelper::FromWebContents(web_contents_); 618 WebContentsModalDialogManager::FromWebContents(web_contents_);
619 if ((!helper->delegate() || 619 if ((!manager->delegate() ||
620 helper->delegate()->ShouldFocusConstrainedWindow()) && 620 manager->delegate()->ShouldFocusWebContentsModalDialog()) &&
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.
627 if (GetNativeView()->GetRootWindow()) 627 if (GetNativeView()->GetRootWindow())
628 GetNativeView()->Focus(); 628 GetNativeView()->Focus();
629 #endif 629 #endif
630 } 630 }
631 631
632 void ConstrainedWindowViews::PulseWebContentsModalDialog() {
633 }
634
635 bool ConstrainedWindowViews::CanShowWebContentsModalDialog() {
636 return true;
637 }
638
632 gfx::NativeWindow ConstrainedWindowViews::GetNativeWindow() { 639 gfx::NativeWindow ConstrainedWindowViews::GetNativeWindow() {
633 return Widget::GetNativeWindow(); 640 return Widget::GetNativeWindow();
634 } 641 }
635 642
636 void ConstrainedWindowViews::NotifyTabHelperWillClose() { 643 void ConstrainedWindowViews::NotifyTabHelperWillClose() {
637 if (!web_contents_) 644 if (!web_contents_)
638 return; 645 return;
639 646
640 ConstrainedWindowTabHelper* constrained_window_tab_helper = 647 WebContentsModalDialogManager* web_contents_modal_dialog_manager =
641 ConstrainedWindowTabHelper::FromWebContents(web_contents_); 648 WebContentsModalDialogManager::FromWebContents(web_contents_);
642 constrained_window_tab_helper->WillClose(this); 649 web_contents_modal_dialog_manager->WillClose(this);
643 } 650 }
644 651
645 views::NonClientFrameView* ConstrainedWindowViews::CreateNonClientFrameView() { 652 views::NonClientFrameView* ConstrainedWindowViews::CreateNonClientFrameView() {
646 #if defined(USE_ASH) 653 #if defined(USE_ASH)
647 CommandLine* command_line = CommandLine::ForCurrentProcess(); 654 CommandLine* command_line = CommandLine::ForCurrentProcess();
648 if (command_line->HasSwitch(switches::kEnableNewDialogStyle)) 655 if (command_line->HasSwitch(switches::kEnableNewDialogStyle))
649 return ash::Shell::GetInstance()->CreateDefaultNonClientFrameView(this); 656 return ash::Shell::GetInstance()->CreateDefaultNonClientFrameView(this);
650 ConstrainedWindowFrameViewAsh* frame = new ConstrainedWindowFrameViewAsh; 657 ConstrainedWindowFrameViewAsh* frame = new ConstrainedWindowFrameViewAsh;
651 frame->Init(this); 658 frame->Init(this);
652 return frame; 659 return frame;
(...skipping 11 matching lines...) Expand all
664 671
665 views::internal::NativeWidgetDelegate* 672 views::internal::NativeWidgetDelegate*
666 ConstrainedWindowViews::AsNativeWidgetDelegate() { 673 ConstrainedWindowViews::AsNativeWidgetDelegate() {
667 return this; 674 return this;
668 } 675 }
669 676
670 int ConstrainedWindowViews::GetNonClientComponent(const gfx::Point& point) { 677 int ConstrainedWindowViews::GetNonClientComponent(const gfx::Point& point) {
671 // Prevent a constrained window to be moved by the user. 678 // Prevent a constrained window to be moved by the user.
672 return HTNOWHERE; 679 return HTNOWHERE;
673 } 680 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/constrained_window_views.h ('k') | chrome/browser/ui/views/constrained_window_views_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698