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

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

Issue 10933085: Update ConstrainedWindowViews appearance according to mock (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Browser test fixes Created 8 years, 2 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/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/browser/themes/theme_service.h" 14 #include "chrome/browser/themes/theme_service.h"
15 #include "chrome/browser/ui/browser_window.h"
14 #include "chrome/browser/ui/constrained_window_tab_helper.h" 16 #include "chrome/browser/ui/constrained_window_tab_helper.h"
15 #include "chrome/browser/ui/tab_contents/tab_contents.h" 17 #include "chrome/browser/ui/tab_contents/tab_contents.h"
16 #include "chrome/browser/ui/toolbar/toolbar_model.h" 18 #include "chrome/browser/ui/toolbar/toolbar_model.h"
17 #include "chrome/browser/ui/views/constrained_window_frame_simple.h" 19 #include "chrome/browser/ui/views/constrained_window_frame_simple.h"
18 #include "chrome/browser/ui/views/frame/browser_view.h" 20 #include "chrome/browser/ui/views/frame/browser_view.h"
19 #include "chrome/common/chrome_constants.h" 21 #include "chrome/common/chrome_constants.h"
20 #include "chrome/common/chrome_notification_types.h" 22 #include "chrome/common/chrome_notification_types.h"
21 #include "chrome/common/chrome_switches.h" 23 #include "chrome/common/chrome_switches.h"
22 #include "content/public/browser/web_contents.h" 24 #include "content/public/browser/web_contents.h"
23 #include "content/public/browser/web_contents_view.h" 25 #include "content/public/browser/web_contents_view.h"
24 #include "grit/chromium_strings.h" 26 #include "grit/chromium_strings.h"
25 #include "grit/generated_resources.h" 27 #include "grit/generated_resources.h"
26 #include "grit/theme_resources.h" 28 #include "grit/theme_resources.h"
27 #include "grit/ui_resources.h" 29 #include "grit/ui_resources.h"
28 #include "net/base/net_util.h" 30 #include "net/base/net_util.h"
29 #include "ui/aura/client/aura_constants.h" 31 #include "ui/aura/client/aura_constants.h"
30 #include "ui/base/hit_test.h" 32 #include "ui/base/hit_test.h"
31 #include "ui/base/resource/resource_bundle.h" 33 #include "ui/base/resource/resource_bundle.h"
32 #include "ui/gfx/canvas.h" 34 #include "ui/gfx/canvas.h"
33 #include "ui/gfx/font.h" 35 #include "ui/gfx/font.h"
34 #include "ui/gfx/path.h" 36 #include "ui/gfx/path.h"
35 #include "ui/gfx/rect.h" 37 #include "ui/gfx/rect.h"
36 #include "ui/gfx/screen.h" 38 #include "ui/gfx/screen.h"
37 #include "ui/views/color_constants.h" 39 #include "ui/views/color_constants.h"
38 #include "ui/views/controls/button/image_button.h" 40 #include "ui/views/controls/button/image_button.h"
39 #include "ui/views/focus/focus_manager.h" 41 #include "ui/views/focus/focus_manager.h"
40 #include "ui/views/views_delegate.h" 42 #include "ui/views/views_delegate.h"
41 #include "ui/views/widget/widget.h" 43 #include "ui/views/widget/widget.h"
42 #include "ui/views/window/client_view.h" 44 #include "ui/views/window/client_view.h"
45 #include "ui/views/window/dialog_client_view.h"
46 #include "ui/views/window/dialog_delegate.h"
43 #include "ui/views/window/frame_background.h" 47 #include "ui/views/window/frame_background.h"
44 #include "ui/views/window/non_client_view.h" 48 #include "ui/views/window/non_client_view.h"
45 #include "ui/views/window/window_resources.h" 49 #include "ui/views/window/window_resources.h"
46 #include "ui/views/window/window_shape.h" 50 #include "ui/views/window/window_shape.h"
47 51
48 #if defined(OS_WIN) && !defined(USE_AURA) 52 #if defined(OS_WIN) && !defined(USE_AURA)
49 #include "ui/base/win/shell.h" 53 #include "ui/base/win/shell.h"
50 #include "ui/views/widget/native_widget_win.h" 54 #include "ui/views/widget/native_widget_win.h"
51 #endif 55 #endif
52 56
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 ConstrainedWindowViews::ConstrainedWindowViews( 581 ConstrainedWindowViews::ConstrainedWindowViews(
578 content::WebContents* web_contents, 582 content::WebContents* web_contents,
579 views::WidgetDelegate* widget_delegate) 583 views::WidgetDelegate* widget_delegate)
580 : web_contents_(web_contents), 584 : web_contents_(web_contents),
581 ALLOW_THIS_IN_INITIALIZER_LIST(native_constrained_window_( 585 ALLOW_THIS_IN_INITIALIZER_LIST(native_constrained_window_(
582 NativeConstrainedWindow::CreateNativeConstrainedWindow(this))) { 586 NativeConstrainedWindow::CreateNativeConstrainedWindow(this))) {
583 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); 587 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW);
584 params.delegate = widget_delegate; 588 params.delegate = widget_delegate;
585 params.native_widget = native_constrained_window_->AsNativeWidget(); 589 params.native_widget = native_constrained_window_->AsNativeWidget();
586 params.child = true; 590 params.child = true;
587 params.parent = web_contents->GetNativeView(); 591
592 CommandLine* command_line = CommandLine::ForCurrentProcess();
593 if (command_line->HasSwitch(switches::kEnableFramelessConstrainedDialogs)) {
594 Widget* parent_widget = Widget::GetTopLevelWidgetForNativeView(
595 web_contents->GetView()->GetNativeView());
596 params.parent_widget = parent_widget;
597 } else {
598 params.parent = web_contents->GetNativeView();
599 }
600
588 #if defined(USE_ASH) 601 #if defined(USE_ASH)
589 // Ash window headers can be transparent. 602 // Ash window headers can be transparent.
590 params.transparent = true; 603 params.transparent = true;
591 ash::SetChildWindowVisibilityChangesAnimated(params.parent); 604 ash::SetChildWindowVisibilityChangesAnimated(params.parent);
592 // No animations should get performed on the window since that will re-order 605 // No animations should get performed on the window since that will re-order
593 // the window stack which will then cause many problems. 606 // the window stack which will then cause many problems.
594 if (params.parent && params.parent->parent()) { 607 if (params.parent && params.parent->parent()) {
595 params.parent->parent()->SetProperty(aura::client::kAnimationsDisabledKey, 608 params.parent->parent()->SetProperty(aura::client::kAnimationsDisabledKey,
596 true); 609 true);
597 } 610 }
598 #endif 611 #endif
599 Init(params); 612 Init(params);
600 613
614 if (command_line->HasSwitch(switches::kEnableFramelessConstrainedDialogs)) {
615 // Set the dialog background color.
616 if (widget_delegate && widget_delegate->AsDialogDelegate()) {
617 views::Background* background = views::Background::CreateSolidBackground(
618 ConstrainedWindow::GetBackgroundColor());
619 views::DialogClientView* dialog_client_view =
620 widget_delegate->AsDialogDelegate()->GetDialogClientView();
621 if (dialog_client_view)
622 dialog_client_view->set_background(background);
623 }
624
625 // Set the top of the now-centered window to overlap the browser chrome.
626 gfx::Rect bounds = GetRootView()->bounds();
627 Widget::ConvertRect(this, params.parent_widget, &bounds);
628 ConstrainedWindowTabHelperDelegate* tab_helper_delegate =
629 ConstrainedWindowTabHelper::FromWebContents(web_contents_)->delegate();
630
631 BrowserWindow* browser_window =
632 tab_helper_delegate ? tab_helper_delegate->GetBrowserWindow() : NULL;
633 if (browser_window && browser_window->GetConstrainedWindowTopY() >= 0) {
634 bounds.set_y(browser_window->GetConstrainedWindowTopY());
635 SetBounds(bounds);
636 }
637 }
638
601 ConstrainedWindowTabHelper* constrained_window_tab_helper = 639 ConstrainedWindowTabHelper* constrained_window_tab_helper =
602 ConstrainedWindowTabHelper::FromWebContents(web_contents_); 640 ConstrainedWindowTabHelper::FromWebContents(web_contents_);
603 constrained_window_tab_helper->AddConstrainedDialog(this); 641 constrained_window_tab_helper->AddConstrainedDialog(this);
604 #if defined(USE_ASH) 642 #if defined(USE_ASH)
605 GetNativeWindow()->SetProperty(ash::kConstrainedWindowKey, true); 643 GetNativeWindow()->SetProperty(ash::kConstrainedWindowKey, true);
606 #endif 644 #endif
607 } 645 }
608 646
609 ConstrainedWindowViews::~ConstrainedWindowViews() { 647 ConstrainedWindowViews::~ConstrainedWindowViews() {
610 } 648 }
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
684 722
685 views::internal::NativeWidgetDelegate* 723 views::internal::NativeWidgetDelegate*
686 ConstrainedWindowViews::AsNativeWidgetDelegate() { 724 ConstrainedWindowViews::AsNativeWidgetDelegate() {
687 return this; 725 return this;
688 } 726 }
689 727
690 int ConstrainedWindowViews::GetNonClientComponent(const gfx::Point& point) { 728 int ConstrainedWindowViews::GetNonClientComponent(const gfx::Point& point) {
691 // Prevent a constrained window to be moved by the user. 729 // Prevent a constrained window to be moved by the user.
692 return HTNOWHERE; 730 return HTNOWHERE;
693 } 731 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698