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

Unified Diff: chrome/browser/ui/cocoa/web_contents_modal_dialog_manager_views_mac_views.mm

Issue 1779383002: MacViews: Remove constrained window dependencies for certificate viewer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix positioning after resize from top, don't allow interaction with tab WebContents while certifica… Created 4 years, 8 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/cocoa/web_contents_modal_dialog_manager_views_mac_views.mm
diff --git a/chrome/browser/ui/cocoa/web_contents_modal_dialog_manager_views_mac_views.mm b/chrome/browser/ui/cocoa/web_contents_modal_dialog_manager_views_mac_views.mm
new file mode 100644
index 0000000000000000000000000000000000000000..0e7d3093c7be5702c7da601f2a8efb2e2fa1da27
--- /dev/null
+++ b/chrome/browser/ui/cocoa/web_contents_modal_dialog_manager_views_mac_views.mm
@@ -0,0 +1,83 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
tapted 2016/05/04 03:29:25 call this file native_web_contents_modal_dialog_ma
Patti Lor 2016/05/11 01:35:18 Done.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/views/web_contents_modal_dialog_manager_views.h"
+
+#include <Cocoa/Cocoa.h>
tapted 2016/05/04 03:29:25 nit: import
Patti Lor 2016/05/11 01:35:18 Done.
+
+#include "components/constrained_window/constrained_window_views.h"
+
+class NativeWebContentsModalDialogManagerViewsMac
tapted 2016/05/04 03:29:25 nit: needs a comment
Patti Lor 2016/05/11 01:35:19 Done.
+ : public NativeWebContentsModalDialogManagerViews {
+ public:
+ NativeWebContentsModalDialogManagerViewsMac(
+ gfx::NativeWindow dialog,
+ web_modal::SingleWebContentsDialogManagerDelegate* native_delegate)
+ : NativeWebContentsModalDialogManagerViews(dialog, native_delegate) {}
+
+ // NativeWebContentsModalDialogManagerViews:
+ void OnPositionRequiresUpdate() override {
+ views::Widget* widget = GetWidget(dialog());
+ gfx::Rect originalBounds = widget->GetWindowBoundsInScreen();
tapted 2016/05/04 03:29:25 perhaps just `bounds` since we change it later
Patti Lor 2016/05/11 01:35:18 Removed it entirely.
+ NativeWebContentsModalDialogManagerViews::OnPositionRequiresUpdate();
tapted 2016/05/04 03:29:25 does this need to be called at all?
Patti Lor 2016/05/11 01:35:19 Yup, the views version of ConstrainedWindow sets t
+
+ // Reset the dialog size to the area under the browser UI to avoid Cocoa
tapted 2016/05/04 03:29:25 I don't think this is working right -- I can inter
Patti Lor 2016/05/11 01:35:19 Was this after resizing the browser? I realised th
+ // using the incorrect animation when dismissing the Cocoa sheet (changes
+ // depending on whether the parent window is larger than the sheet).
+ originalBounds.set_x(widget->GetWindowBoundsInScreen().x() -
+ originalBounds.width() / 2);
+ originalBounds.set_y(widget->GetWindowBoundsInScreen().y());
+ widget->SetBounds(originalBounds);
+ }
+
+ void ShowWidget(views::Widget* widget) override {
+ NSWindow* dialogWindow = widget->GetNativeWindow();
tapted 2016/05/04 03:29:25 dialogWindow -> dialog_window (camelCase only betw
Patti Lor 2016/05/11 01:35:18 Done. Oops, sorry - thanks!
+ if (![dialogWindow attachedSheet]) {
tapted 2016/05/04 03:29:25 comment about this? (when does it come up?)
Patti Lor 2016/05/11 01:35:19 Done.
+ NativeWebContentsModalDialogManagerViews::ShowWidget(widget);
+ return;
+ }
+
+ ChangeVisibilityAndMouseEvents(dialogWindow, true);
+ }
+
+ void HideWidget(views::Widget* widget) override {
+ NSWindow* dialogWindow = widget->GetNativeWindow();
+ if (![dialogWindow attachedSheet]) {
+ NativeWebContentsModalDialogManagerViews::HideWidget(widget);
+ return;
+ }
+
+ // Avoid views::Widget::Show() as a call to orderOut: on a NSWindow with an
+ // attached sheet will close the sheet. Instead, just set the sheet to 0
+ // opacity and don't accept click events.
+ ChangeVisibilityAndMouseEvents(dialogWindow, false);
+ }
+
+ private:
+ /** Makes the given window invisible and ignore mouse events.
+ */
+ void ChangeVisibilityAndMouseEvents(gfx::NativeWindow window, bool show) {
tapted 2016/05/04 03:29:25 perhaps call this void SetOverlayVisible(gfx::Na
Patti Lor 2016/05/11 01:35:18 The overlay should be invisible the whole time, so
+ CGFloat alpha = show ? 1.0 : 0.0;
+ BOOL mouseEvents = show ? NO : YES;
tapted 2016/05/04 03:29:25 mouseEvents -> ignore_events
Patti Lor 2016/05/11 01:35:19 Done.
+
+ // Don't allow interaction with the tab underneath the certificate viewer.
tapted 2016/05/04 03:29:25 tab -> overlayWindow?
Patti Lor 2016/05/11 01:35:19 Maybe WebContents? The line below is setting the o
+ [window setIgnoresMouseEvents:mouseEvents];
+
+ [[window attachedSheet] setAlphaValue:alpha];
tapted 2016/05/04 03:29:25 does this always hide the sheet? I thought we'd ne
Patti Lor 2016/05/11 01:35:18 What do you mean by 'always'? Are there cases othe
+ [[window attachedSheet] setIgnoresMouseEvents:mouseEvents];
+ }
+
+};
tapted 2016/05/04 03:29:25 DISALLOW_COPY_AND_ASSIGN(..)
Patti Lor 2016/05/11 01:35:19 Done.
+
+namespace web_modal {
+
+SingleWebContentsDialogManager*
+WebContentsModalDialogManager::CreateNativeWebModalManager(
+ gfx::NativeWindow dialog,
+ SingleWebContentsDialogManagerDelegate* native_delegate) {
+ return new NativeWebContentsModalDialogManagerViewsMac(dialog,
+ native_delegate);
+}
+
+} // namespace web_modal

Powered by Google App Engine
This is Rietveld 408576698