| OLD | NEW |
| 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" |
| (...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 557 private: | 557 private: |
| 558 ConstrainedWindowViews* container_; // not owned | 558 ConstrainedWindowViews* container_; // not owned |
| 559 DISALLOW_COPY_AND_ASSIGN(ConstrainedWindowFrameViewAsh); | 559 DISALLOW_COPY_AND_ASSIGN(ConstrainedWindowFrameViewAsh); |
| 560 }; | 560 }; |
| 561 #endif // defined(USE_ASH) | 561 #endif // defined(USE_ASH) |
| 562 | 562 |
| 563 ConstrainedWindowViews::ConstrainedWindowViews( | 563 ConstrainedWindowViews::ConstrainedWindowViews( |
| 564 content::WebContents* web_contents, | 564 content::WebContents* web_contents, |
| 565 views::WidgetDelegate* widget_delegate, | 565 views::WidgetDelegate* widget_delegate, |
| 566 bool enable_chrome_style, | 566 bool enable_chrome_style, |
| 567 ChromeStyleClientInsets chrome_style_client_insets) | 567 ChromeStyleFrameLayout chrome_style_frame_layout) |
| 568 : WebContentsObserver(web_contents), | 568 : WebContentsObserver(web_contents), |
| 569 web_contents_(web_contents), | 569 web_contents_(web_contents), |
| 570 enable_chrome_style_(enable_chrome_style), | 570 enable_chrome_style_(enable_chrome_style), |
| 571 chrome_style_client_insets_(chrome_style_client_insets), | 571 chrome_style_frame_layout_(chrome_style_frame_layout), |
| 572 ALLOW_THIS_IN_INITIALIZER_LIST(native_constrained_window_( | 572 ALLOW_THIS_IN_INITIALIZER_LIST(native_constrained_window_( |
| 573 NativeConstrainedWindow::CreateNativeConstrainedWindow(this))) { | 573 NativeConstrainedWindow::CreateNativeConstrainedWindow(this))) { |
| 574 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); | 574 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); |
| 575 params.delegate = widget_delegate; | 575 params.delegate = widget_delegate; |
| 576 params.native_widget = native_constrained_window_->AsNativeWidget(); | 576 params.native_widget = native_constrained_window_->AsNativeWidget(); |
| 577 params.child = true; | 577 params.child = true; |
| 578 | 578 |
| 579 if (enable_chrome_style_) { | 579 if (enable_chrome_style_) { |
| 580 params.parent_widget = Widget::GetTopLevelWidgetForNativeView( | 580 params.parent_widget = Widget::GetTopLevelWidgetForNativeView( |
| 581 web_contents_->GetView()->GetNativeView()); | 581 web_contents_->GetView()->GetNativeView()); |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 684 | 684 |
| 685 void ConstrainedWindowViews::CenterWindow(const gfx::Size& size) { | 685 void ConstrainedWindowViews::CenterWindow(const gfx::Size& size) { |
| 686 if (enable_chrome_style_) | 686 if (enable_chrome_style_) |
| 687 PositionChromeStyleWindow(size); | 687 PositionChromeStyleWindow(size); |
| 688 else | 688 else |
| 689 Widget::CenterWindow(size); | 689 Widget::CenterWindow(size); |
| 690 } | 690 } |
| 691 | 691 |
| 692 views::NonClientFrameView* ConstrainedWindowViews::CreateNonClientFrameView() { | 692 views::NonClientFrameView* ConstrainedWindowViews::CreateNonClientFrameView() { |
| 693 if (enable_chrome_style_) | 693 if (enable_chrome_style_) |
| 694 return new ConstrainedWindowFrameSimple(this, chrome_style_client_insets_); | 694 return new ConstrainedWindowFrameSimple(this, chrome_style_frame_layout_); |
| 695 #if defined(USE_ASH) | 695 #if defined(USE_ASH) |
| 696 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 696 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 697 if (command_line->HasSwitch(ash::switches::kAuraGoogleDialogFrames)) | 697 if (command_line->HasSwitch(ash::switches::kAuraGoogleDialogFrames)) |
| 698 return ash::Shell::GetInstance()->CreateDefaultNonClientFrameView(this); | 698 return ash::Shell::GetInstance()->CreateDefaultNonClientFrameView(this); |
| 699 ConstrainedWindowFrameViewAsh* frame = new ConstrainedWindowFrameViewAsh; | 699 ConstrainedWindowFrameViewAsh* frame = new ConstrainedWindowFrameViewAsh; |
| 700 frame->Init(this); | 700 frame->Init(this); |
| 701 return frame; | 701 return frame; |
| 702 #endif | 702 #endif |
| 703 return new ConstrainedWindowFrameView(this); | 703 return new ConstrainedWindowFrameView(this); |
| 704 } | 704 } |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 753 ConstrainedWindowTabHelper::FromWebContents(web_contents_)->delegate(); | 753 ConstrainedWindowTabHelper::FromWebContents(web_contents_)->delegate(); |
| 754 gfx::Point point; | 754 gfx::Point point; |
| 755 if (!tab_helper_delegate || | 755 if (!tab_helper_delegate || |
| 756 !tab_helper_delegate->GetConstrainedWindowTopCenter(&point)) { | 756 !tab_helper_delegate->GetConstrainedWindowTopCenter(&point)) { |
| 757 Widget::CenterWindow(size); | 757 Widget::CenterWindow(size); |
| 758 return; | 758 return; |
| 759 } | 759 } |
| 760 | 760 |
| 761 SetBounds(gfx::Rect(point - gfx::Vector2d(size.width() / 2, 0), size)); | 761 SetBounds(gfx::Rect(point - gfx::Vector2d(size.width() / 2, 0), size)); |
| 762 } | 762 } |
| OLD | NEW |