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

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

Issue 10826085: Fixing problems with constrained windows (i.e. print preview) (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 4 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
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/profiles/profile.h" 12 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/browser/themes/theme_service.h" 13 #include "chrome/browser/themes/theme_service.h"
14 #include "chrome/browser/ui/constrained_window_tab_helper.h" 14 #include "chrome/browser/ui/constrained_window_tab_helper.h"
15 #include "chrome/browser/ui/tab_contents/tab_contents.h" 15 #include "chrome/browser/ui/tab_contents/tab_contents.h"
16 #include "chrome/browser/ui/toolbar/toolbar_model.h" 16 #include "chrome/browser/ui/toolbar/toolbar_model.h"
17 #include "chrome/browser/ui/views/constrained_window_frame_simple.h" 17 #include "chrome/browser/ui/views/constrained_window_frame_simple.h"
18 #include "chrome/browser/ui/views/frame/browser_view.h" 18 #include "chrome/browser/ui/views/frame/browser_view.h"
19 #include "chrome/common/chrome_constants.h" 19 #include "chrome/common/chrome_constants.h"
20 #include "chrome/common/chrome_switches.h" 20 #include "chrome/common/chrome_switches.h"
21 #include "chrome/common/chrome_notification_types.h" 21 #include "chrome/common/chrome_notification_types.h"
22 #include "content/public/browser/web_contents.h" 22 #include "content/public/browser/web_contents.h"
23 #include "content/public/browser/web_contents_view.h" 23 #include "content/public/browser/web_contents_view.h"
24 #include "grit/chromium_strings.h" 24 #include "grit/chromium_strings.h"
25 #include "grit/generated_resources.h" 25 #include "grit/generated_resources.h"
26 #include "grit/theme_resources.h" 26 #include "grit/theme_resources.h"
27 #include "grit/ui_resources.h" 27 #include "grit/ui_resources.h"
28 #include "net/base/net_util.h" 28 #include "net/base/net_util.h"
29 #include "ui/aura/client/aura_constants.h"
29 #include "ui/base/hit_test.h" 30 #include "ui/base/hit_test.h"
30 #include "ui/base/resource/resource_bundle.h" 31 #include "ui/base/resource/resource_bundle.h"
31 #include "ui/gfx/canvas.h" 32 #include "ui/gfx/canvas.h"
32 #include "ui/gfx/font.h" 33 #include "ui/gfx/font.h"
33 #include "ui/gfx/path.h" 34 #include "ui/gfx/path.h"
34 #include "ui/gfx/rect.h" 35 #include "ui/gfx/rect.h"
35 #include "ui/gfx/screen.h" 36 #include "ui/gfx/screen.h"
36 #include "ui/views/color_constants.h" 37 #include "ui/views/color_constants.h"
37 #include "ui/views/controls/button/image_button.h" 38 #include "ui/views/controls/button/image_button.h"
38 #include "ui/views/focus/focus_manager.h" 39 #include "ui/views/focus/focus_manager.h"
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after
579 NativeConstrainedWindow::CreateNativeConstrainedWindow(this))) { 580 NativeConstrainedWindow::CreateNativeConstrainedWindow(this))) {
580 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); 581 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW);
581 params.delegate = widget_delegate; 582 params.delegate = widget_delegate;
582 params.native_widget = native_constrained_window_->AsNativeWidget(); 583 params.native_widget = native_constrained_window_->AsNativeWidget();
583 params.child = true; 584 params.child = true;
584 params.parent = tab_contents->web_contents()->GetNativeView(); 585 params.parent = tab_contents->web_contents()->GetNativeView();
585 #if defined(USE_ASH) 586 #if defined(USE_ASH)
586 // Ash window headers can be transparent. 587 // Ash window headers can be transparent.
587 params.transparent = true; 588 params.transparent = true;
588 ash::SetChildWindowVisibilityChangesAnimated(params.parent); 589 ash::SetChildWindowVisibilityChangesAnimated(params.parent);
590 // No animations should get performed on the window since that will re-order
591 // the window stack which will then cause many problems.
592 if (params.parent && params.parent->parent()) {
593 params.parent->parent()->SetProperty(aura::client::kAnimationsDisabledKey,
594 true);
595 }
589 #endif 596 #endif
590 Init(params); 597 Init(params);
591 598
592 tab_contents_->constrained_window_tab_helper()->AddConstrainedDialog(this); 599 tab_contents_->constrained_window_tab_helper()->AddConstrainedDialog(this);
593 } 600 }
594 601
595 ConstrainedWindowViews::~ConstrainedWindowViews() { 602 ConstrainedWindowViews::~ConstrainedWindowViews() {
596 } 603 }
597 604
598 //////////////////////////////////////////////////////////////////////////////// 605 ////////////////////////////////////////////////////////////////////////////////
599 // ConstrainedWindowViews, ConstrainedWindow implementation: 606 // ConstrainedWindowViews, ConstrainedWindow implementation:
600 607
601 void ConstrainedWindowViews::ShowConstrainedWindow() { 608 void ConstrainedWindowViews::ShowConstrainedWindow() {
602 ConstrainedWindowTabHelper* helper = 609 ConstrainedWindowTabHelper* helper =
603 tab_contents_->constrained_window_tab_helper(); 610 tab_contents_->constrained_window_tab_helper();
604 if (helper && helper->delegate()) 611 if (helper && helper->delegate())
605 helper->delegate()->WillShowConstrainedWindow(tab_contents_); 612 helper->delegate()->WillShowConstrainedWindow(tab_contents_);
606 Show(); 613 Show();
607 FocusConstrainedWindow(); 614 FocusConstrainedWindow();
608 } 615 }
609 616
610 void ConstrainedWindowViews::CloseConstrainedWindow() { 617 void ConstrainedWindowViews::CloseConstrainedWindow() {
618 #if defined(USE_ASH)
619 gfx::NativeView view = tab_contents_->web_contents()->GetNativeView();
620 // Allow the parent to animate again.
621 if (view && view->parent())
622 view->parent()->ClearProperty(aura::client::kAnimationsDisabledKey);
623 #endif
611 tab_contents_->constrained_window_tab_helper()->WillClose(this); 624 tab_contents_->constrained_window_tab_helper()->WillClose(this);
612 Close(); 625 Close();
613 } 626 }
614 627
615 void ConstrainedWindowViews::FocusConstrainedWindow() { 628 void ConstrainedWindowViews::FocusConstrainedWindow() {
616 ConstrainedWindowTabHelper* helper = 629 ConstrainedWindowTabHelper* helper =
617 tab_contents_->constrained_window_tab_helper(); 630 tab_contents_->constrained_window_tab_helper();
618 if ((!helper->delegate() || 631 if ((!helper->delegate() ||
619 helper->delegate()->ShouldFocusConstrainedWindow()) && 632 helper->delegate()->ShouldFocusConstrainedWindow()) &&
620 widget_delegate() && 633 widget_delegate() &&
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
657 } 670 }
658 671
659 void ConstrainedWindowViews::OnNativeConstrainedWindowMouseActivate() { 672 void ConstrainedWindowViews::OnNativeConstrainedWindowMouseActivate() {
660 Activate(); 673 Activate();
661 } 674 }
662 675
663 views::internal::NativeWidgetDelegate* 676 views::internal::NativeWidgetDelegate*
664 ConstrainedWindowViews::AsNativeWidgetDelegate() { 677 ConstrainedWindowViews::AsNativeWidgetDelegate() {
665 return this; 678 return this;
666 } 679 }
680
681 int ConstrainedWindowViews::GetNonClientComponent(const gfx::Point& point) {
682 // Prevent a constrained window to be moved by the user.
683 return HTNOWHERE;
684 }
OLDNEW
« ash/wm/frame_painter.cc ('K') | « chrome/browser/ui/views/constrained_window_views.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698