| Index: chrome/browser/ui/views/constrained_window_views.cc
|
| diff --git a/chrome/browser/ui/views/constrained_window_views.cc b/chrome/browser/ui/views/constrained_window_views.cc
|
| index 6e0058acad6851e52c1f63fd37ca6ce70d40c58e..63d265648ed8326a2950c88438da9b0b9b75955b 100644
|
| --- a/chrome/browser/ui/views/constrained_window_views.cc
|
| +++ b/chrome/browser/ui/views/constrained_window_views.cc
|
| @@ -20,6 +20,10 @@
|
| #include "chrome/common/chrome_constants.h"
|
| #include "chrome/common/chrome_notification_types.h"
|
| #include "chrome/common/chrome_switches.h"
|
| +#include "content/public/browser/navigation_controller.h"
|
| +#include "content/public/browser/notification_service.h"
|
| +#include "content/public/browser/notification_source.h"
|
| +#include "content/public/browser/notification_types.h"
|
| #include "content/public/browser/web_contents.h"
|
| #include "content/public/browser/web_contents_view.h"
|
| #include "grit/chromium_strings.h"
|
| @@ -163,9 +167,6 @@ class VistaWindowResources : public views::WindowResources {
|
| gfx::ImageSkia* XPWindowResources::images_[];
|
| gfx::ImageSkia* VistaWindowResources::images_[];
|
|
|
| -////////////////////////////////////////////////////////////////////////////////
|
| -// ConstrainedWindowFrameView
|
| -
|
| class ConstrainedWindowFrameView : public views::NonClientFrameView,
|
| public views::ButtonListener {
|
| public:
|
| @@ -285,9 +286,6 @@ const SkColor kContentsBorderShadow = SkColorSetARGB(51, 0, 0, 0);
|
|
|
| } // namespace
|
|
|
| -////////////////////////////////////////////////////////////////////////////////
|
| -// ConstrainedWindowFrameView, public:
|
| -
|
| ConstrainedWindowFrameView::ConstrainedWindowFrameView(
|
| ConstrainedWindowViews* container)
|
| : NonClientFrameView(),
|
| @@ -320,9 +318,6 @@ void ConstrainedWindowFrameView::UpdateWindowTitle() {
|
| SchedulePaintInRect(title_bounds_);
|
| }
|
|
|
| -////////////////////////////////////////////////////////////////////////////////
|
| -// ConstrainedWindowFrameView, views::NonClientFrameView implementation:
|
| -
|
| gfx::Rect ConstrainedWindowFrameView::GetBoundsForClientView() const {
|
| return client_view_bounds_;
|
| }
|
| @@ -371,9 +366,6 @@ void ConstrainedWindowFrameView::GetWindowMask(const gfx::Size& size,
|
| views::GetDefaultWindowMask(size, window_mask);
|
| }
|
|
|
| -////////////////////////////////////////////////////////////////////////////////
|
| -// ConstrainedWindowFrameView, views::View implementation:
|
| -
|
| void ConstrainedWindowFrameView::OnPaint(gfx::Canvas* canvas) {
|
| PaintFrameBorder(canvas);
|
| PaintTitleBar(canvas);
|
| @@ -390,18 +382,12 @@ void ConstrainedWindowFrameView::OnThemeChanged() {
|
| InitWindowResources();
|
| }
|
|
|
| -////////////////////////////////////////////////////////////////////////////////
|
| -// ConstrainedWindowFrameView, views::ButtonListener implementation:
|
| -
|
| void ConstrainedWindowFrameView::ButtonPressed(
|
| views::Button* sender, const ui::Event& event) {
|
| if (sender == close_button_)
|
| container_->CloseConstrainedWindow();
|
| }
|
|
|
| -////////////////////////////////////////////////////////////////////////////////
|
| -// ConstrainedWindowFrameView, private:
|
| -
|
| int ConstrainedWindowFrameView::NonClientBorderThickness() const {
|
| return kFrameBorderThickness + kClientEdgeThickness;
|
| }
|
| @@ -574,18 +560,17 @@ class ConstrainedWindowFrameViewAsh : public ash::CustomFrameViewAsh {
|
| };
|
| #endif // defined(USE_ASH)
|
|
|
| -////////////////////////////////////////////////////////////////////////////////
|
| -// ConstrainedWindowViews, public:
|
| -
|
| ConstrainedWindowViews::ConstrainedWindowViews(
|
| content::WebContents* web_contents,
|
| views::WidgetDelegate* widget_delegate,
|
| - bool enable_chrome_style)
|
| + bool enable_chrome_style,
|
| + ChromeStyleClientInsets chrome_style_client_insets)
|
| : WebContentsObserver(web_contents),
|
| web_contents_(web_contents),
|
| + enable_chrome_style_(enable_chrome_style),
|
| + chrome_style_client_insets_(chrome_style_client_insets),
|
| ALLOW_THIS_IN_INITIALIZER_LIST(native_constrained_window_(
|
| - NativeConstrainedWindow::CreateNativeConstrainedWindow(this))),
|
| - enable_chrome_style_(enable_chrome_style) {
|
| + NativeConstrainedWindow::CreateNativeConstrainedWindow(this))) {
|
| views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW);
|
| params.delegate = widget_delegate;
|
| params.native_widget = native_constrained_window_->AsNativeWidget();
|
| @@ -594,9 +579,9 @@ ConstrainedWindowViews::ConstrainedWindowViews(
|
|
|
| if (enable_chrome_style_) {
|
| params.parent_widget = Widget::GetTopLevelWidgetForNativeView(
|
| - web_contents->GetView()->GetNativeView());
|
| + web_contents_->GetView()->GetNativeView());
|
| } else {
|
| - params.parent = web_contents->GetNativeView();
|
| + params.parent = web_contents_->GetNativeView();
|
| }
|
|
|
| #if defined(USE_ASH)
|
| @@ -622,7 +607,10 @@ ConstrainedWindowViews::ConstrainedWindowViews(
|
| if (dialog_client_view)
|
| dialog_client_view->set_background(background);
|
| }
|
| - PositionChromeStyleWindow();
|
| + PositionChromeStyleWindow(GetRootView()->bounds().size());
|
| + registrar_.Add(this,
|
| + content::NOTIFICATION_WEB_CONTENTS_VISIBILITY_CHANGED,
|
| + content::Source<content::WebContents>(web_contents));
|
| }
|
|
|
| ConstrainedWindowTabHelper* constrained_window_tab_helper =
|
| @@ -636,9 +624,6 @@ ConstrainedWindowViews::ConstrainedWindowViews(
|
| ConstrainedWindowViews::~ConstrainedWindowViews() {
|
| }
|
|
|
| -////////////////////////////////////////////////////////////////////////////////
|
| -// ConstrainedWindowViews, ConstrainedWindow implementation:
|
| -
|
| void ConstrainedWindowViews::ShowConstrainedWindow() {
|
| Show();
|
| FocusConstrainedWindow();
|
| @@ -684,34 +669,27 @@ void ConstrainedWindowViews::NotifyTabHelperWillClose() {
|
| constrained_window_tab_helper->WillClose(this);
|
| }
|
|
|
| -////////////////////////////////////////////////////////////////////////////////
|
| -// ConstrainedWindowViews, views::Widget overrides:
|
| -
|
| void ConstrainedWindowViews::CenterWindow(const gfx::Size& size) {
|
| - Widget::CenterWindow(size);
|
| if (enable_chrome_style_)
|
| - PositionChromeStyleWindow();
|
| + PositionChromeStyleWindow(size);
|
| + else
|
| + Widget::CenterWindow(size);
|
| }
|
|
|
| views::NonClientFrameView* ConstrainedWindowViews::CreateNonClientFrameView() {
|
| - if (enable_chrome_style_) {
|
| - return new ConstrainedWindowFrameSimple(this);
|
| - } else {
|
| + if (enable_chrome_style_)
|
| + return new ConstrainedWindowFrameSimple(this, chrome_style_client_insets_);
|
| #if defined(USE_ASH)
|
| - CommandLine* command_line = CommandLine::ForCurrentProcess();
|
| - if (command_line->HasSwitch(ash::switches::kAuraGoogleDialogFrames))
|
| - return ash::Shell::GetInstance()->CreateDefaultNonClientFrameView(this);
|
| - ConstrainedWindowFrameViewAsh* frame = new ConstrainedWindowFrameViewAsh;
|
| - frame->Init(this);
|
| - return frame;
|
| + CommandLine* command_line = CommandLine::ForCurrentProcess();
|
| + if (command_line->HasSwitch(ash::switches::kAuraGoogleDialogFrames))
|
| + return ash::Shell::GetInstance()->CreateDefaultNonClientFrameView(this);
|
| + ConstrainedWindowFrameViewAsh* frame = new ConstrainedWindowFrameViewAsh;
|
| + frame->Init(this);
|
| + return frame;
|
| #endif
|
| - return new ConstrainedWindowFrameView(this);
|
| - }
|
| + return new ConstrainedWindowFrameView(this);
|
| }
|
|
|
| -////////////////////////////////////////////////////////////////////////////////
|
| -// ConstrainedWindowViews, NativeConstrainedWindowDelegate implementation:
|
| -
|
| void ConstrainedWindowViews::OnNativeConstrainedWindowDestroyed() {
|
| NotifyTabHelperWillClose();
|
| }
|
| @@ -730,27 +708,35 @@ int ConstrainedWindowViews::GetNonClientComponent(const gfx::Point& point) {
|
| return HTNOWHERE;
|
| }
|
|
|
| -void ConstrainedWindowViews::PositionChromeStyleWindow() {
|
| +void ConstrainedWindowViews::WebContentsDestroyed(
|
| + content::WebContents* web_contents) {
|
| + web_contents_ = NULL;
|
| +}
|
| +
|
| +void ConstrainedWindowViews::Observe(
|
| + int type,
|
| + const content::NotificationSource& source,
|
| + const content::NotificationDetails& details) {
|
| + DCHECK(enable_chrome_style_);
|
| + DCHECK_EQ(type, content::NOTIFICATION_WEB_CONTENTS_VISIBILITY_CHANGED);
|
| + if (*content::Details<bool>(details).ptr())
|
| + Show();
|
| + else
|
| + Hide();
|
| +}
|
| +
|
| +void ConstrainedWindowViews::PositionChromeStyleWindow(const gfx::Size& size) {
|
| DCHECK(enable_chrome_style_);
|
| - gfx::Rect bounds = GetRootView()->bounds();
|
| + gfx::Rect bounds(GetRootView()->bounds().origin(), size);
|
| ConstrainedWindowTabHelperDelegate* tab_helper_delegate =
|
| ConstrainedWindowTabHelper::FromWebContents(web_contents_)->delegate();
|
| -
|
| BrowserWindow* browser_window =
|
| tab_helper_delegate ? tab_helper_delegate->GetBrowserWindow() : NULL;
|
| - int top_y;
|
| - if (browser_window && browser_window->GetConstrainedWindowTopY(&top_y)) {
|
| - bounds.set_y(top_y);
|
| - bounds.set_x(
|
| - browser_window->GetBounds().width() / 2 - bounds.width() / 2);
|
| - SetBounds(bounds);
|
| + if (browser_window) {
|
| + bounds.set_x(browser_window->GetBounds().width() / 2 - bounds.width() / 2);
|
| + int top_y;
|
| + if (browser_window->GetConstrainedWindowTopY(&top_y))
|
| + bounds.set_y(top_y);
|
| }
|
| -}
|
| -
|
| -////////////////////////////////////////////////////////////////////////////////
|
| -// ConstrainedWindowViews, content::WebContentsObserver implementation:
|
| -
|
| -void ConstrainedWindowViews::WebContentsDestroyed(
|
| - content::WebContents* web_contents) {
|
| - web_contents_ = NULL;
|
| + SetBounds(bounds);
|
| }
|
|
|