Index: chrome/browser/ui/views/web_contents_modal_dialog_manager_views.h |
diff --git a/chrome/browser/ui/views/web_contents_modal_dialog_manager_views.h b/chrome/browser/ui/views/web_contents_modal_dialog_manager_views.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..fb31f7a77c99a83d1a571355b12b026528026065 |
--- /dev/null |
+++ b/chrome/browser/ui/views/web_contents_modal_dialog_manager_views.h |
@@ -0,0 +1,73 @@ |
+// Copyright 2016 The Chromium Authors. All rights reserved. |
tapted
2016/05/04 03:29:25
since this CL is large, it's probably worth splitt
Patti Lor
2016/05/11 01:35:19
Done.
|
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef CHROME_BROWSER_UI_VIEWS_WEB_CONTENTS_MODAL_DIALOG_MANAGER_VIEWS_H_ |
tapted
2016/05/04 03:29:25
Hum - this file should get called native_web_conte
Patti Lor
2016/05/11 01:35:19
Done, updated the ifdefs as well.
|
+#define CHROME_BROWSER_UI_VIEWS_WEB_CONTENTS_MODAL_DIALOG_MANAGER_VIEWS_H_ |
+ |
+#include "components/web_modal/web_contents_modal_dialog_host.h" |
+#include "components/web_modal/web_contents_modal_dialog_manager.h" |
+#include "ui/views/widget/widget.h" |
tapted
2016/05/04 03:29:26
this can probably be forward-declared
Patti Lor
2016/05/11 01:35:19
Done.
|
+#include "ui/views/widget/widget_observer.h" |
+ |
+class NativeWebContentsModalDialogManagerViews |
tapted
2016/05/04 03:29:25
nit: needs a comment
Patti Lor
2016/05/11 01:35:19
Done.
|
+ : public web_modal::SingleWebContentsDialogManager, |
+ public web_modal::ModalDialogHostObserver, |
+ public views::WidgetObserver { |
+ public: |
+ NativeWebContentsModalDialogManagerViews( |
+ gfx::NativeWindow dialog, |
+ web_modal::SingleWebContentsDialogManagerDelegate* native_delegate); |
+ |
+ ~NativeWebContentsModalDialogManagerViews() override; |
+ |
+ // Sets up this object to manage the dialog_. Registers for closing events |
tapted
2016/05/04 03:29:25
nit: dialog_ -> |dialog_|
Patti Lor
2016/05/11 01:35:19
Done.
|
+ // in order to notify the delegate. |
+ virtual void ManageDialog(); |
+ |
+ // web_modal::SingleWebContentsDialogManager: |
+ void Show() override; |
+ void Hide() override; |
+ void Close() override; |
+ void Focus() override; |
+ void Pulse() override {} |
+ |
+ // web_modal::WebContentsModalDialogHostObserver: |
+ void OnPositionRequiresUpdate() override; |
+ void OnHostDestroying() override; |
+ |
+ // views::WidgetObserver: |
+ |
+ // NOTE(wittman): OnWidgetClosing is overriden to ensure that, when the widget |
+ // is explicitly closed, the destruction occurs within the same call |
+ // stack. This avoids event races that lead to non-deterministic destruction |
+ // ordering in e.g. the print preview dialog. OnWidgetDestroying is overridden |
+ // because OnWidgetClosing is *only* invoked on explicit close, not when the |
+ // widget is implicitly destroyed due to its parent being closed. This |
+ // situation occurs with app windows. WidgetClosing removes the observer, so |
+ // only one of these two functions is ever invoked for a given widget. |
+ void OnWidgetClosing(views::Widget* widget) override; |
+ void OnWidgetDestroying(views::Widget* widget) override; |
+ void HostChanged(web_modal::WebContentsModalDialogHost* new_host) override; |
+ gfx::NativeWindow dialog() override; |
+ |
+ protected: |
+ virtual void ShowWidget(views::Widget* widget); |
+ virtual void HideWidget(views::Widget* widget); |
+ |
+ static views::Widget* GetWidget(gfx::NativeWindow dialog); |
+ |
+ private: |
+ void WidgetClosing(views::Widget* widget); |
+ |
+ web_modal::SingleWebContentsDialogManagerDelegate* native_delegate_; |
+ gfx::NativeWindow dialog_; |
+ web_modal::WebContentsModalDialogHost* host_; |
+ bool host_destroying_; |
+ std::set<views::Widget*> observed_widgets_; |
+ std::set<views::Widget*> shown_widgets_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(NativeWebContentsModalDialogManagerViews); |
+}; |
+ |
+#endif // CHROME_BROWSER_UI_VIEWS_WEB_CONTENTS_MODAL_DIALOG_MANAGER_VIEWS_H_ |