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

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

Issue 11044020: Make Web Intents picker in Views conform to latest mocks (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Add a .cc file for constants to be able to compile in debug mode 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
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/browser_window.h" 15 #include "chrome/browser/ui/browser_window.h"
16 #include "chrome/browser/ui/constrained_window_tab_helper.h" 16 #include "chrome/browser/ui/constrained_window_tab_helper.h"
17 #include "chrome/browser/ui/toolbar/toolbar_model.h" 17 #include "chrome/browser/ui/toolbar/toolbar_model.h"
18 #include "chrome/browser/ui/views/constrained_window_frame_simple.h" 18 #include "chrome/browser/ui/views/constrained_window_frame_simple.h"
19 #include "chrome/browser/ui/views/frame/browser_view.h" 19 #include "chrome/browser/ui/views/frame/browser_view.h"
20 #include "chrome/common/chrome_constants.h" 20 #include "chrome/common/chrome_constants.h"
21 #include "chrome/common/chrome_notification_types.h" 21 #include "chrome/common/chrome_notification_types.h"
22 #include "chrome/common/chrome_switches.h" 22 #include "chrome/common/chrome_switches.h"
23 #include "content/public/browser/navigation_controller.h"
24 #include "content/public/browser/notification_service.h"
25 #include "content/public/browser/notification_source.h"
26 #include "content/public/browser/notification_types.h"
23 #include "content/public/browser/web_contents.h" 27 #include "content/public/browser/web_contents.h"
24 #include "content/public/browser/web_contents_view.h" 28 #include "content/public/browser/web_contents_view.h"
25 #include "grit/chromium_strings.h" 29 #include "grit/chromium_strings.h"
26 #include "grit/generated_resources.h" 30 #include "grit/generated_resources.h"
27 #include "grit/theme_resources.h" 31 #include "grit/theme_resources.h"
28 #include "grit/ui_resources.h" 32 #include "grit/ui_resources.h"
29 #include "net/base/net_util.h" 33 #include "net/base/net_util.h"
30 #include "ui/aura/client/aura_constants.h" 34 #include "ui/aura/client/aura_constants.h"
31 #include "ui/base/hit_test.h" 35 #include "ui/base/hit_test.h"
32 #include "ui/base/resource/resource_bundle.h" 36 #include "ui/base/resource/resource_bundle.h"
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 } 160 }
157 161
158 static gfx::ImageSkia* images_[FRAME_PART_IMAGE_COUNT]; 162 static gfx::ImageSkia* images_[FRAME_PART_IMAGE_COUNT];
159 163
160 DISALLOW_COPY_AND_ASSIGN(VistaWindowResources); 164 DISALLOW_COPY_AND_ASSIGN(VistaWindowResources);
161 }; 165 };
162 166
163 gfx::ImageSkia* XPWindowResources::images_[]; 167 gfx::ImageSkia* XPWindowResources::images_[];
164 gfx::ImageSkia* VistaWindowResources::images_[]; 168 gfx::ImageSkia* VistaWindowResources::images_[];
165 169
166 ////////////////////////////////////////////////////////////////////////////////
167 // ConstrainedWindowFrameView
168
169 class ConstrainedWindowFrameView : public views::NonClientFrameView, 170 class ConstrainedWindowFrameView : public views::NonClientFrameView,
170 public views::ButtonListener { 171 public views::ButtonListener {
171 public: 172 public:
172 explicit ConstrainedWindowFrameView(ConstrainedWindowViews* container); 173 explicit ConstrainedWindowFrameView(ConstrainedWindowViews* container);
173 virtual ~ConstrainedWindowFrameView(); 174 virtual ~ConstrainedWindowFrameView();
174 175
175 void UpdateWindowTitle(); 176 void UpdateWindowTitle();
176 177
177 // Overridden from views::NonClientFrameView: 178 // Overridden from views::NonClientFrameView:
178 virtual gfx::Rect GetBoundsForClientView() const OVERRIDE; 179 virtual gfx::Rect GetBoundsForClientView() const OVERRIDE;
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 const int kIconMinimumSize = 16; 279 const int kIconMinimumSize = 16;
279 // The title text starts 2 px from the right edge of the left frame border. 280 // The title text starts 2 px from the right edge of the left frame border.
280 const int kTitleLeftSpacing = 2; 281 const int kTitleLeftSpacing = 2;
281 // There is a 5 px gap between the title text and the caption buttons. 282 // There is a 5 px gap between the title text and the caption buttons.
282 const int kTitleCaptionSpacing = 5; 283 const int kTitleCaptionSpacing = 5;
283 284
284 const SkColor kContentsBorderShadow = SkColorSetARGB(51, 0, 0, 0); 285 const SkColor kContentsBorderShadow = SkColorSetARGB(51, 0, 0, 0);
285 286
286 } // namespace 287 } // namespace
287 288
288 ////////////////////////////////////////////////////////////////////////////////
289 // ConstrainedWindowFrameView, public:
290
291 ConstrainedWindowFrameView::ConstrainedWindowFrameView( 289 ConstrainedWindowFrameView::ConstrainedWindowFrameView(
292 ConstrainedWindowViews* container) 290 ConstrainedWindowViews* container)
293 : NonClientFrameView(), 291 : NonClientFrameView(),
294 container_(container), 292 container_(container),
295 close_button_(new views::ImageButton(this)), 293 close_button_(new views::ImageButton(this)),
296 frame_background_(new views::FrameBackground()) { 294 frame_background_(new views::FrameBackground()) {
297 InitClass(); 295 InitClass();
298 InitWindowResources(); 296 InitWindowResources();
299 297
300 // Constrained windows always use the custom frame - they just have a 298 // Constrained windows always use the custom frame - they just have a
(...skipping 12 matching lines...) Expand all
313 AddChildView(close_button_); 311 AddChildView(close_button_);
314 } 312 }
315 313
316 ConstrainedWindowFrameView::~ConstrainedWindowFrameView() { 314 ConstrainedWindowFrameView::~ConstrainedWindowFrameView() {
317 } 315 }
318 316
319 void ConstrainedWindowFrameView::UpdateWindowTitle() { 317 void ConstrainedWindowFrameView::UpdateWindowTitle() {
320 SchedulePaintInRect(title_bounds_); 318 SchedulePaintInRect(title_bounds_);
321 } 319 }
322 320
323 ////////////////////////////////////////////////////////////////////////////////
324 // ConstrainedWindowFrameView, views::NonClientFrameView implementation:
325
326 gfx::Rect ConstrainedWindowFrameView::GetBoundsForClientView() const { 321 gfx::Rect ConstrainedWindowFrameView::GetBoundsForClientView() const {
327 return client_view_bounds_; 322 return client_view_bounds_;
328 } 323 }
329 324
330 gfx::Rect ConstrainedWindowFrameView::GetWindowBoundsForClientBounds( 325 gfx::Rect ConstrainedWindowFrameView::GetWindowBoundsForClientBounds(
331 const gfx::Rect& client_bounds) const { 326 const gfx::Rect& client_bounds) const {
332 int top_height = NonClientTopBorderHeight(); 327 int top_height = NonClientTopBorderHeight();
333 int border_thickness = NonClientBorderThickness(); 328 int border_thickness = NonClientBorderThickness();
334 return gfx::Rect(std::max(0, client_bounds.x() - border_thickness), 329 return gfx::Rect(std::max(0, client_bounds.x() - border_thickness),
335 std::max(0, client_bounds.y() - top_height), 330 std::max(0, client_bounds.y() - top_height),
(...skipping 28 matching lines...) Expand all
364 // Fall back to the caption if no other component matches. 359 // Fall back to the caption if no other component matches.
365 return (window_component == HTNOWHERE) ? HTCAPTION : window_component; 360 return (window_component == HTNOWHERE) ? HTCAPTION : window_component;
366 } 361 }
367 362
368 void ConstrainedWindowFrameView::GetWindowMask(const gfx::Size& size, 363 void ConstrainedWindowFrameView::GetWindowMask(const gfx::Size& size,
369 gfx::Path* window_mask) { 364 gfx::Path* window_mask) {
370 DCHECK(window_mask); 365 DCHECK(window_mask);
371 views::GetDefaultWindowMask(size, window_mask); 366 views::GetDefaultWindowMask(size, window_mask);
372 } 367 }
373 368
374 ////////////////////////////////////////////////////////////////////////////////
375 // ConstrainedWindowFrameView, views::View implementation:
376
377 void ConstrainedWindowFrameView::OnPaint(gfx::Canvas* canvas) { 369 void ConstrainedWindowFrameView::OnPaint(gfx::Canvas* canvas) {
378 PaintFrameBorder(canvas); 370 PaintFrameBorder(canvas);
379 PaintTitleBar(canvas); 371 PaintTitleBar(canvas);
380 PaintClientEdge(canvas); 372 PaintClientEdge(canvas);
381 } 373 }
382 374
383 void ConstrainedWindowFrameView::Layout() { 375 void ConstrainedWindowFrameView::Layout() {
384 LayoutWindowControls(); 376 LayoutWindowControls();
385 LayoutTitleBar(); 377 LayoutTitleBar();
386 client_view_bounds_ = CalculateClientAreaBounds(width(), height()); 378 client_view_bounds_ = CalculateClientAreaBounds(width(), height());
387 } 379 }
388 380
389 void ConstrainedWindowFrameView::OnThemeChanged() { 381 void ConstrainedWindowFrameView::OnThemeChanged() {
390 InitWindowResources(); 382 InitWindowResources();
391 } 383 }
392 384
393 ////////////////////////////////////////////////////////////////////////////////
394 // ConstrainedWindowFrameView, views::ButtonListener implementation:
395
396 void ConstrainedWindowFrameView::ButtonPressed( 385 void ConstrainedWindowFrameView::ButtonPressed(
397 views::Button* sender, const ui::Event& event) { 386 views::Button* sender, const ui::Event& event) {
398 if (sender == close_button_) 387 if (sender == close_button_)
399 container_->CloseConstrainedWindow(); 388 container_->CloseConstrainedWindow();
400 } 389 }
401 390
402 ////////////////////////////////////////////////////////////////////////////////
403 // ConstrainedWindowFrameView, private:
404
405 int ConstrainedWindowFrameView::NonClientBorderThickness() const { 391 int ConstrainedWindowFrameView::NonClientBorderThickness() const {
406 return kFrameBorderThickness + kClientEdgeThickness; 392 return kFrameBorderThickness + kClientEdgeThickness;
407 } 393 }
408 394
409 int ConstrainedWindowFrameView::NonClientTopBorderHeight() const { 395 int ConstrainedWindowFrameView::NonClientTopBorderHeight() const {
410 return std::max(kFrameBorderThickness + IconSize(), 396 return std::max(kFrameBorderThickness + IconSize(),
411 kFrameShadowThickness + kCaptionButtonHeightWithPadding) + 397 kFrameShadowThickness + kCaptionButtonHeightWithPadding) +
412 TitlebarBottomThickness(); 398 TitlebarBottomThickness();
413 } 399 }
414 400
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
567 if (sender == close_button()) 553 if (sender == close_button())
568 container_->CloseConstrainedWindow(); 554 container_->CloseConstrainedWindow();
569 } 555 }
570 556
571 private: 557 private:
572 ConstrainedWindowViews* container_; // not owned 558 ConstrainedWindowViews* container_; // not owned
573 DISALLOW_COPY_AND_ASSIGN(ConstrainedWindowFrameViewAsh); 559 DISALLOW_COPY_AND_ASSIGN(ConstrainedWindowFrameViewAsh);
574 }; 560 };
575 #endif // defined(USE_ASH) 561 #endif // defined(USE_ASH)
576 562
577 ////////////////////////////////////////////////////////////////////////////////
578 // ConstrainedWindowViews, public:
579
580 ConstrainedWindowViews::ConstrainedWindowViews( 563 ConstrainedWindowViews::ConstrainedWindowViews(
581 content::WebContents* web_contents, 564 content::WebContents* web_contents,
582 views::WidgetDelegate* widget_delegate, 565 views::WidgetDelegate* widget_delegate,
583 bool enable_chrome_style) 566 bool enable_chrome_style,
567 ChromeStyleClientInsets chrome_style_client_insets)
584 : WebContentsObserver(web_contents), 568 : WebContentsObserver(web_contents),
585 web_contents_(web_contents), 569 web_contents_(web_contents),
570 enable_chrome_style_(enable_chrome_style),
571 chrome_style_client_insets_(chrome_style_client_insets),
586 ALLOW_THIS_IN_INITIALIZER_LIST(native_constrained_window_( 572 ALLOW_THIS_IN_INITIALIZER_LIST(native_constrained_window_(
587 NativeConstrainedWindow::CreateNativeConstrainedWindow(this))), 573 NativeConstrainedWindow::CreateNativeConstrainedWindow(this))) {
588 enable_chrome_style_(enable_chrome_style) {
589 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); 574 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW);
590 params.delegate = widget_delegate; 575 params.delegate = widget_delegate;
591 params.native_widget = native_constrained_window_->AsNativeWidget(); 576 params.native_widget = native_constrained_window_->AsNativeWidget();
592 params.child = true; 577 params.child = true;
593 ConstrainedWindowTabHelper::CreateForWebContents(web_contents); 578 ConstrainedWindowTabHelper::CreateForWebContents(web_contents);
594 579
595 if (enable_chrome_style_) { 580 if (enable_chrome_style_) {
596 params.parent_widget = Widget::GetTopLevelWidgetForNativeView( 581 params.parent_widget = Widget::GetTopLevelWidgetForNativeView(
597 web_contents->GetView()->GetNativeView()); 582 web_contents_->GetView()->GetNativeView());
598 } else { 583 } else {
599 params.parent = web_contents->GetNativeView(); 584 params.parent = web_contents_->GetNativeView();
600 } 585 }
601 586
602 #if defined(USE_ASH) 587 #if defined(USE_ASH)
603 // Ash window headers can be transparent. 588 // Ash window headers can be transparent.
604 params.transparent = true; 589 params.transparent = true;
605 ash::SetChildWindowVisibilityChangesAnimated(params.GetParent()); 590 ash::SetChildWindowVisibilityChangesAnimated(params.GetParent());
606 // No animations should get performed on the window since that will re-order 591 // No animations should get performed on the window since that will re-order
607 // the window stack which will then cause many problems. 592 // the window stack which will then cause many problems.
608 if (params.parent && params.parent->parent()) { 593 if (params.parent && params.parent->parent()) {
609 params.parent->parent()->SetProperty(aura::client::kAnimationsDisabledKey, 594 params.parent->parent()->SetProperty(aura::client::kAnimationsDisabledKey,
610 true); 595 true);
611 } 596 }
612 #endif 597 #endif
613 Init(params); 598 Init(params);
614 599
615 if (enable_chrome_style_) { 600 if (enable_chrome_style_) {
616 // Set the dialog background color. 601 // Set the dialog background color.
617 if (widget_delegate && widget_delegate->AsDialogDelegate()) { 602 if (widget_delegate && widget_delegate->AsDialogDelegate()) {
618 views::Background* background = views::Background::CreateSolidBackground( 603 views::Background* background = views::Background::CreateSolidBackground(
619 ConstrainedWindow::GetBackgroundColor()); 604 ConstrainedWindow::GetBackgroundColor());
620 views::DialogClientView* dialog_client_view = 605 views::DialogClientView* dialog_client_view =
621 widget_delegate->AsDialogDelegate()->GetDialogClientView(); 606 widget_delegate->AsDialogDelegate()->GetDialogClientView();
622 if (dialog_client_view) 607 if (dialog_client_view)
623 dialog_client_view->set_background(background); 608 dialog_client_view->set_background(background);
624 } 609 }
625 PositionChromeStyleWindow(); 610 PositionChromeStyleWindow(GetRootView()->bounds().size());
611 registrar_.Add(this,
612 content::NOTIFICATION_WEB_CONTENTS_VISIBILITY_CHANGED,
613 content::Source<content::WebContents>(web_contents));
626 } 614 }
627 615
628 ConstrainedWindowTabHelper* constrained_window_tab_helper = 616 ConstrainedWindowTabHelper* constrained_window_tab_helper =
629 ConstrainedWindowTabHelper::FromWebContents(web_contents_); 617 ConstrainedWindowTabHelper::FromWebContents(web_contents_);
630 constrained_window_tab_helper->AddConstrainedDialog(this); 618 constrained_window_tab_helper->AddConstrainedDialog(this);
631 #if defined(USE_ASH) 619 #if defined(USE_ASH)
632 GetNativeWindow()->SetProperty(ash::kConstrainedWindowKey, true); 620 GetNativeWindow()->SetProperty(ash::kConstrainedWindowKey, true);
633 #endif 621 #endif
634 } 622 }
635 623
636 ConstrainedWindowViews::~ConstrainedWindowViews() { 624 ConstrainedWindowViews::~ConstrainedWindowViews() {
637 } 625 }
638 626
639 ////////////////////////////////////////////////////////////////////////////////
640 // ConstrainedWindowViews, ConstrainedWindow implementation:
641
642 void ConstrainedWindowViews::ShowConstrainedWindow() { 627 void ConstrainedWindowViews::ShowConstrainedWindow() {
643 Show(); 628 Show();
644 FocusConstrainedWindow(); 629 FocusConstrainedWindow();
645 } 630 }
646 631
647 void ConstrainedWindowViews::CloseConstrainedWindow() { 632 void ConstrainedWindowViews::CloseConstrainedWindow() {
648 #if defined(USE_ASH) 633 #if defined(USE_ASH)
649 gfx::NativeView view = web_contents_->GetNativeView(); 634 gfx::NativeView view = web_contents_->GetNativeView();
650 // Allow the parent to animate again. 635 // Allow the parent to animate again.
651 if (view && view->parent()) 636 if (view && view->parent())
(...skipping 25 matching lines...) Expand all
677 662
678 void ConstrainedWindowViews::NotifyTabHelperWillClose() { 663 void ConstrainedWindowViews::NotifyTabHelperWillClose() {
679 if (!web_contents_) 664 if (!web_contents_)
680 return; 665 return;
681 666
682 ConstrainedWindowTabHelper* constrained_window_tab_helper = 667 ConstrainedWindowTabHelper* constrained_window_tab_helper =
683 ConstrainedWindowTabHelper::FromWebContents(web_contents_); 668 ConstrainedWindowTabHelper::FromWebContents(web_contents_);
684 constrained_window_tab_helper->WillClose(this); 669 constrained_window_tab_helper->WillClose(this);
685 } 670 }
686 671
687 ////////////////////////////////////////////////////////////////////////////////
688 // ConstrainedWindowViews, views::Widget overrides:
689
690 void ConstrainedWindowViews::CenterWindow(const gfx::Size& size) { 672 void ConstrainedWindowViews::CenterWindow(const gfx::Size& size) {
691 Widget::CenterWindow(size);
692 if (enable_chrome_style_) 673 if (enable_chrome_style_)
693 PositionChromeStyleWindow(); 674 PositionChromeStyleWindow(size);
675 else
676 Widget::CenterWindow(size);
694 } 677 }
695 678
696 views::NonClientFrameView* ConstrainedWindowViews::CreateNonClientFrameView() { 679 views::NonClientFrameView* ConstrainedWindowViews::CreateNonClientFrameView() {
697 if (enable_chrome_style_) { 680 if (enable_chrome_style_)
698 return new ConstrainedWindowFrameSimple(this); 681 return new ConstrainedWindowFrameSimple(this, chrome_style_client_insets_);
699 } else {
700 #if defined(USE_ASH) 682 #if defined(USE_ASH)
701 CommandLine* command_line = CommandLine::ForCurrentProcess(); 683 CommandLine* command_line = CommandLine::ForCurrentProcess();
702 if (command_line->HasSwitch(ash::switches::kAuraGoogleDialogFrames)) 684 if (command_line->HasSwitch(ash::switches::kAuraGoogleDialogFrames))
703 return ash::Shell::GetInstance()->CreateDefaultNonClientFrameView(this); 685 return ash::Shell::GetInstance()->CreateDefaultNonClientFrameView(this);
704 ConstrainedWindowFrameViewAsh* frame = new ConstrainedWindowFrameViewAsh; 686 ConstrainedWindowFrameViewAsh* frame = new ConstrainedWindowFrameViewAsh;
705 frame->Init(this); 687 frame->Init(this);
706 return frame; 688 return frame;
707 #endif 689 #endif
708 return new ConstrainedWindowFrameView(this); 690 return new ConstrainedWindowFrameView(this);
709 }
710 } 691 }
711 692
712 ////////////////////////////////////////////////////////////////////////////////
713 // ConstrainedWindowViews, NativeConstrainedWindowDelegate implementation:
714
715 void ConstrainedWindowViews::OnNativeConstrainedWindowDestroyed() { 693 void ConstrainedWindowViews::OnNativeConstrainedWindowDestroyed() {
716 NotifyTabHelperWillClose(); 694 NotifyTabHelperWillClose();
717 } 695 }
718 696
719 void ConstrainedWindowViews::OnNativeConstrainedWindowMouseActivate() { 697 void ConstrainedWindowViews::OnNativeConstrainedWindowMouseActivate() {
720 Activate(); 698 Activate();
721 } 699 }
722 700
723 views::internal::NativeWidgetDelegate* 701 views::internal::NativeWidgetDelegate*
724 ConstrainedWindowViews::AsNativeWidgetDelegate() { 702 ConstrainedWindowViews::AsNativeWidgetDelegate() {
725 return this; 703 return this;
726 } 704 }
727 705
728 int ConstrainedWindowViews::GetNonClientComponent(const gfx::Point& point) { 706 int ConstrainedWindowViews::GetNonClientComponent(const gfx::Point& point) {
729 // Prevent a constrained window to be moved by the user. 707 // Prevent a constrained window to be moved by the user.
730 return HTNOWHERE; 708 return HTNOWHERE;
731 } 709 }
732 710
733 void ConstrainedWindowViews::PositionChromeStyleWindow() {
734 DCHECK(enable_chrome_style_);
735 gfx::Rect bounds = GetRootView()->bounds();
736 ConstrainedWindowTabHelperDelegate* tab_helper_delegate =
737 ConstrainedWindowTabHelper::FromWebContents(web_contents_)->delegate();
738
739 BrowserWindow* browser_window =
740 tab_helper_delegate ? tab_helper_delegate->GetBrowserWindow() : NULL;
741 int top_y;
742 if (browser_window && browser_window->GetConstrainedWindowTopY(&top_y)) {
743 bounds.set_y(top_y);
744 bounds.set_x(
745 browser_window->GetBounds().width() / 2 - bounds.width() / 2);
746 SetBounds(bounds);
747 }
748 }
749
750 ////////////////////////////////////////////////////////////////////////////////
751 // ConstrainedWindowViews, content::WebContentsObserver implementation:
752
753 void ConstrainedWindowViews::WebContentsDestroyed( 711 void ConstrainedWindowViews::WebContentsDestroyed(
754 content::WebContents* web_contents) { 712 content::WebContents* web_contents) {
755 web_contents_ = NULL; 713 web_contents_ = NULL;
756 } 714 }
715
716 void ConstrainedWindowViews::Observe(
717 int type,
718 const content::NotificationSource& source,
719 const content::NotificationDetails& details) {
720 DCHECK(enable_chrome_style_);
721 DCHECK_EQ(type, content::NOTIFICATION_WEB_CONTENTS_VISIBILITY_CHANGED);
722 if (*content::Details<bool>(details).ptr())
723 Show();
724 else
725 Hide();
726 }
727
728 void ConstrainedWindowViews::PositionChromeStyleWindow(const gfx::Size& size) {
729 DCHECK(enable_chrome_style_);
730 gfx::Rect bounds(GetRootView()->bounds().origin(), size);
731 ConstrainedWindowTabHelperDelegate* tab_helper_delegate =
732 ConstrainedWindowTabHelper::FromWebContents(web_contents_)->delegate();
733 BrowserWindow* browser_window =
734 tab_helper_delegate ? tab_helper_delegate->GetBrowserWindow() : NULL;
735 if (browser_window) {
736 bounds.set_x(browser_window->GetBounds().width() / 2 - bounds.width() / 2);
737 int top_y;
738 if (browser_window->GetConstrainedWindowTopY(&top_y))
739 bounds.set_y(top_y);
740 }
741 SetBounds(bounds);
742 }
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