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

Unified Diff: chrome/browser/ui/views/constrained_window_views.cc

Issue 12045037: Refactor modality-specific behavior from ConstrainedWindowViews to WebContentsModalDialogManager (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 11 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 side-by-side diff with in-line comments
Download patch
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 fbbe8f16f7a8712458470506914de71f841d8579..9b03f019dcbb4fbbf1b75e45ee236f86809c777d 100644
--- a/chrome/browser/ui/views/constrained_window_views.cc
+++ b/chrome/browser/ui/views/constrained_window_views.cc
@@ -168,7 +168,8 @@ gfx::ImageSkia* VistaWindowResources::images_[];
class ConstrainedWindowFrameView : public views::NonClientFrameView,
public views::ButtonListener {
public:
- explicit ConstrainedWindowFrameView(ConstrainedWindowViews* container);
+ ConstrainedWindowFrameView(ConstrainedWindowViews* container,
+ bool browser_is_off_the_record);
virtual ~ConstrainedWindowFrameView();
void UpdateWindowTitle();
@@ -224,7 +225,7 @@ class ConstrainedWindowFrameView : public views::NonClientFrameView,
gfx::Rect CalculateClientAreaBounds(int width, int height) const;
SkColor GetTitleColor() const {
- return container_->owner()->GetBrowserContext()->IsOffTheRecord()
+ return browser_is_off_the_record_
#if defined(OS_WIN) && !defined(USE_AURA)
|| !ui::win::IsAeroGlassEnabled()
#endif
@@ -236,6 +237,8 @@ class ConstrainedWindowFrameView : public views::NonClientFrameView,
ConstrainedWindowViews* container_;
+ bool browser_is_off_the_record_;
+
scoped_ptr<views::WindowResources> resources_;
gfx::Rect title_bounds_;
@@ -285,9 +288,10 @@ const SkColor kContentsBorderShadow = SkColorSetARGB(51, 0, 0, 0);
} // namespace
ConstrainedWindowFrameView::ConstrainedWindowFrameView(
- ConstrainedWindowViews* container)
+ ConstrainedWindowViews* container, bool browser_is_off_the_record)
: NonClientFrameView(),
container_(container),
+ browser_is_off_the_record_(browser_is_off_the_record),
close_button_(new views::ImageButton(this)),
frame_background_(new views::FrameBackground()) {
InitClass();
@@ -559,39 +563,22 @@ class ConstrainedWindowFrameViewAsh : public ash::CustomFrameViewAsh {
#endif // defined(USE_ASH)
ConstrainedWindowViews::ConstrainedWindowViews(
- content::WebContents* web_contents,
+ gfx::NativeView parent,
+ bool off_the_record,
views::WidgetDelegate* widget_delegate)
- : web_contents_(web_contents),
- ALLOW_THIS_IN_INITIALIZER_LIST(native_constrained_window_(
- NativeConstrainedWindow::CreateNativeConstrainedWindow(this))) {
+ : off_the_record_(off_the_record) {
views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW);
params.delegate = widget_delegate;
- params.native_widget = native_constrained_window_->AsNativeWidget();
params.child = true;
- params.parent = web_contents_->GetNativeView();
+ params.parent = parent;
#if defined(USE_ASH)
// Ash window headers can be transparent.
params.transparent = true;
- views::corewm::SetChildWindowVisibilityChangesAnimated(params.parent);
- // No animations should get performed on the window since that will re-order
- // the window stack which will then cause many problems.
- if (params.parent && params.parent->parent()) {
- params.parent->parent()->SetProperty(aura::client::kAnimationsDisabledKey,
- true);
- }
#endif
- Init(params);
- WebContentsModalDialogManager* web_contents_modal_dialog_manager =
- WebContentsModalDialogManager::FromWebContents(web_contents_);
- web_contents_modal_dialog_manager->AddDialog(this);
-#if defined(USE_ASH)
- GetNativeWindow()->SetProperty(ash::kConstrainedWindowKey, true);
- views::corewm::SetModalParent(GetNativeWindow(),
- web_contents_->GetView()->GetNativeView());
-#endif
+ Init(params);
}
ConstrainedWindowViews::~ConstrainedWindowViews() {
@@ -603,15 +590,6 @@ void ConstrainedWindowViews::ShowWebContentsModalDialog() {
}
void ConstrainedWindowViews::CloseWebContentsModalDialog() {
-#if defined(USE_ASH)
- gfx::NativeView view = web_contents_->GetNativeView();
- // Allow the parent to animate again.
- if (view && view->parent())
- view->parent()->ClearProperty(aura::client::kAnimationsDisabledKey);
-#endif
- WebContentsModalDialogManager* web_contents_modal_dialog_manager =
- WebContentsModalDialogManager::FromWebContents(web_contents_);
- web_contents_modal_dialog_manager->WillClose(this);
Close();
}
@@ -632,6 +610,19 @@ gfx::NativeWindow ConstrainedWindowViews::GetNativeWindow() {
return Widget::GetNativeWindow();
}
+ConstrainedWindowViews* ConstrainedWindowViews::Create(
+ content::WebContents* web_contents,
+ views::WidgetDelegate* widget_delegate) {
+ WebContentsModalDialogManager* manager =
+ WebContentsModalDialogManager::FromWebContents(web_contents);
+ ConstrainedWindowViews* dialog = new ConstrainedWindowViews(
+ web_contents->GetNativeView(),
+ web_contents->GetBrowserContext()->IsOffTheRecord(),
+ widget_delegate);
+ manager->AddDialog(dialog);
+ return dialog;
+}
+
views::NonClientFrameView* ConstrainedWindowViews::CreateNonClientFrameView() {
#if defined(USE_ASH)
CommandLine* command_line = CommandLine::ForCurrentProcess();
@@ -641,25 +632,5 @@ views::NonClientFrameView* ConstrainedWindowViews::CreateNonClientFrameView() {
frame->Init(this);
return frame;
#endif
- return new ConstrainedWindowFrameView(this);
-}
-
-void ConstrainedWindowViews::OnNativeConstrainedWindowDestroyed() {
- WebContentsModalDialogManager* web_contents_modal_dialog_manager =
- WebContentsModalDialogManager::FromWebContents(web_contents_);
- web_contents_modal_dialog_manager->WillClose(this);
-}
-
-void ConstrainedWindowViews::OnNativeConstrainedWindowMouseActivate() {
- Activate();
-}
-
-views::internal::NativeWidgetDelegate*
- ConstrainedWindowViews::AsNativeWidgetDelegate() {
- return this;
-}
-
-int ConstrainedWindowViews::GetNonClientComponent(const gfx::Point& point) {
- // Prevent a constrained window to be moved by the user.
- return HTNOWHERE;
+ return new ConstrainedWindowFrameView(this, off_the_record_);
}

Powered by Google App Engine
This is Rietveld 408576698