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

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

Issue 7880003: content: Move constrained window code from TabContents to TabContentsWrapper (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix mac regression now that shutdown timing was changed for views. Created 9 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "chrome/app/chrome_command_ids.h" 9 #include "chrome/app/chrome_command_ids.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
11 #include "chrome/browser/ui/constrained_window_tab_helper.h"
12 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
11 #include "chrome/browser/ui/toolbar/toolbar_model.h" 13 #include "chrome/browser/ui/toolbar/toolbar_model.h"
12 #include "chrome/browser/ui/views/frame/browser_view.h" 14 #include "chrome/browser/ui/views/frame/browser_view.h"
13 #include "chrome/browser/ui/window_sizer.h" 15 #include "chrome/browser/ui/window_sizer.h"
14 #include "chrome/common/chrome_constants.h" 16 #include "chrome/common/chrome_constants.h"
15 #include "chrome/common/chrome_notification_types.h" 17 #include "chrome/common/chrome_notification_types.h"
16 #include "content/browser/tab_contents/tab_contents.h" 18 #include "content/browser/tab_contents/tab_contents.h"
17 #include "content/browser/tab_contents/tab_contents_view.h" 19 #include "content/browser/tab_contents/tab_contents_view.h"
18 #include "content/common/notification_service.h" 20 #include "content/common/notification_service.h"
19 #include "grit/chromium_strings.h" 21 #include "grit/chromium_strings.h"
20 #include "grit/generated_resources.h" 22 #include "grit/generated_resources.h"
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 void PaintClientEdge(gfx::Canvas* canvas); 199 void PaintClientEdge(gfx::Canvas* canvas);
198 200
199 // Layout various sub-components of this view. 201 // Layout various sub-components of this view.
200 void LayoutWindowControls(); 202 void LayoutWindowControls();
201 void LayoutTitleBar(); 203 void LayoutTitleBar();
202 204
203 // Returns the bounds of the client area for the specified view size. 205 // Returns the bounds of the client area for the specified view size.
204 gfx::Rect CalculateClientAreaBounds(int width, int height) const; 206 gfx::Rect CalculateClientAreaBounds(int width, int height) const;
205 207
206 SkColor GetTitleColor() const { 208 SkColor GetTitleColor() const {
207 return container_->owner()->browser_context()->IsOffTheRecord() 209 return container_->owner()->profile()->IsOffTheRecord()
208 #if defined(OS_WIN) && !defined(USE_AURA) 210 #if defined(OS_WIN) && !defined(USE_AURA)
209 || !views::NativeWidgetWin::IsAeroGlassEnabled() 211 || !views::NativeWidgetWin::IsAeroGlassEnabled()
210 #endif 212 #endif
211 ? SK_ColorWHITE : SK_ColorBLACK; 213 ? SK_ColorWHITE : SK_ColorBLACK;
212 } 214 }
213 215
214 // Loads the appropriate set of WindowResources for the frame view. 216 // Loads the appropriate set of WindowResources for the frame view.
215 void InitWindowResources(); 217 void InitWindowResources();
216 218
217 ConstrainedWindowViews* container_; 219 ConstrainedWindowViews* container_;
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
564 title_font_ = NULL; 566 title_font_ = NULL;
565 #endif 567 #endif
566 initialized = true; 568 initialized = true;
567 } 569 }
568 } 570 }
569 571
570 //////////////////////////////////////////////////////////////////////////////// 572 ////////////////////////////////////////////////////////////////////////////////
571 // ConstrainedWindowViews, public: 573 // ConstrainedWindowViews, public:
572 574
573 ConstrainedWindowViews::ConstrainedWindowViews( 575 ConstrainedWindowViews::ConstrainedWindowViews(
574 TabContents* owner, 576 TabContentsWrapper* wrapper,
575 views::WidgetDelegate* widget_delegate) 577 views::WidgetDelegate* widget_delegate)
576 : owner_(owner), 578 : wrapper_(wrapper),
577 ALLOW_THIS_IN_INITIALIZER_LIST(native_constrained_window_( 579 ALLOW_THIS_IN_INITIALIZER_LIST(native_constrained_window_(
578 NativeConstrainedWindow::CreateNativeConstrainedWindow(this))) { 580 NativeConstrainedWindow::CreateNativeConstrainedWindow(this))) {
579 views::Widget::InitParams params; 581 views::Widget::InitParams params;
580 params.delegate = widget_delegate; 582 params.delegate = widget_delegate;
581 params.child = true; 583 params.child = true;
582 params.parent = owner->GetNativeView(); 584 params.parent = wrapper->tab_contents()->GetNativeView();
583 params.native_widget = native_constrained_window_->AsNativeWidget(); 585 params.native_widget = native_constrained_window_->AsNativeWidget();
584 Init(params); 586 Init(params);
585 owner->AddConstrainedDialog(this); 587
588 wrapper_->constrained_window_tab_helper()->AddConstrainedDialog(this);
586 } 589 }
587 590
588 ConstrainedWindowViews::~ConstrainedWindowViews() { 591 ConstrainedWindowViews::~ConstrainedWindowViews() {
589 } 592 }
590 593
591 //////////////////////////////////////////////////////////////////////////////// 594 ////////////////////////////////////////////////////////////////////////////////
592 // ConstrainedWindowViews, ConstrainedWindow implementation: 595 // ConstrainedWindowViews, ConstrainedWindow implementation:
593 596
594 void ConstrainedWindowViews::ShowConstrainedWindow() { 597 void ConstrainedWindowViews::ShowConstrainedWindow() {
595 // We marked the view as hidden during construction. Mark it as 598 // We marked the view as hidden during construction. Mark it as
596 // visible now so FocusManager will let us receive focus. 599 // visible now so FocusManager will let us receive focus.
597 non_client_view()->SetVisible(true); 600 non_client_view()->SetVisible(true);
598 if (owner_->delegate()) 601 if (wrapper_->delegate())
599 owner_->delegate()->WillShowConstrainedWindow(owner_); 602 wrapper_->delegate()->WillShowConstrainedWindow(wrapper_);
600 Activate(); 603 Activate();
601 FocusConstrainedWindow(); 604 FocusConstrainedWindow();
602 } 605 }
603 606
604 void ConstrainedWindowViews::CloseConstrainedWindow() { 607 void ConstrainedWindowViews::CloseConstrainedWindow() {
605 Close(); 608 Close();
606 } 609 }
607 610
608 void ConstrainedWindowViews::FocusConstrainedWindow() { 611 void ConstrainedWindowViews::FocusConstrainedWindow() {
609 if ((!owner_->delegate() || 612 if ((!wrapper_->delegate() ||
610 owner_->delegate()->ShouldFocusConstrainedWindow()) && 613 wrapper_->delegate()->ShouldFocusConstrainedWindow()) &&
611 widget_delegate() && 614 widget_delegate() &&
612 widget_delegate()->GetInitiallyFocusedView()) { 615 widget_delegate()->GetInitiallyFocusedView()) {
613 widget_delegate()->GetInitiallyFocusedView()->RequestFocus(); 616 widget_delegate()->GetInitiallyFocusedView()->RequestFocus();
614 } 617 }
615 } 618 }
616 619
617 //////////////////////////////////////////////////////////////////////////////// 620 ////////////////////////////////////////////////////////////////////////////////
618 // ConstrainedWindowViews, views::Window overrides: 621 // ConstrainedWindowViews, views::Window overrides:
619 622
620 views::NonClientFrameView* ConstrainedWindowViews::CreateNonClientFrameView() { 623 views::NonClientFrameView* ConstrainedWindowViews::CreateNonClientFrameView() {
621 return new ConstrainedWindowFrameView(this); 624 return new ConstrainedWindowFrameView(this);
622 } 625 }
623 626
624 //////////////////////////////////////////////////////////////////////////////// 627 ////////////////////////////////////////////////////////////////////////////////
625 // ConstrainedWindowViews, NativeConstrainedWindowDelegate implementation: 628 // ConstrainedWindowViews, NativeConstrainedWindowDelegate implementation:
626 629
627 void ConstrainedWindowViews::OnNativeConstrainedWindowDestroyed() { 630 void ConstrainedWindowViews::OnNativeConstrainedWindowDestroyed() {
628 // Tell our constraining TabContents that we've gone so it can update its 631 wrapper_->constrained_window_tab_helper()->WillClose(this);
629 // list.
630 owner_->WillClose(this);
631 } 632 }
632 633
633 void ConstrainedWindowViews::OnNativeConstrainedWindowMouseActivate() { 634 void ConstrainedWindowViews::OnNativeConstrainedWindowMouseActivate() {
634 Activate(); 635 Activate();
635 } 636 }
636 637
637 views::internal::NativeWidgetDelegate* 638 views::internal::NativeWidgetDelegate*
638 ConstrainedWindowViews::AsNativeWidgetDelegate() { 639 ConstrainedWindowViews::AsNativeWidgetDelegate() {
639 return this; 640 return this;
640 } 641 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698