| OLD | NEW |
| 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 "components/constrained_window/constrained_window_views.h" | 5 #include "components/constrained_window/constrained_window_views.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "components/constrained_window/constrained_window_views_client.h" | 9 #include "components/constrained_window/constrained_window_views_client.h" |
| 10 #include "components/web_modal/popup_manager.h" | 10 #include "components/web_modal/popup_manager.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 const char *const native_window_property) | 36 const char *const native_window_property) |
| 37 : host_(host), | 37 : host_(host), |
| 38 target_widget_(target_widget), | 38 target_widget_(target_widget), |
| 39 native_window_property_(native_window_property) { | 39 native_window_property_(native_window_property) { |
| 40 DCHECK(host_); | 40 DCHECK(host_); |
| 41 DCHECK(target_widget_); | 41 DCHECK(target_widget_); |
| 42 host_->AddObserver(this); | 42 host_->AddObserver(this); |
| 43 target_widget_->AddObserver(this); | 43 target_widget_->AddObserver(this); |
| 44 } | 44 } |
| 45 | 45 |
| 46 virtual ~WidgetModalDialogHostObserverViews() { | 46 ~WidgetModalDialogHostObserverViews() override { |
| 47 if (host_) | 47 if (host_) |
| 48 host_->RemoveObserver(this); | 48 host_->RemoveObserver(this); |
| 49 target_widget_->RemoveObserver(this); | 49 target_widget_->RemoveObserver(this); |
| 50 target_widget_->SetNativeWindowProperty(native_window_property_, NULL); | 50 target_widget_->SetNativeWindowProperty(native_window_property_, NULL); |
| 51 } | 51 } |
| 52 | 52 |
| 53 // WidgetObserver overrides | 53 // WidgetObserver overrides |
| 54 virtual void OnWidgetClosing(views::Widget* widget) override { | 54 void OnWidgetClosing(views::Widget* widget) override { delete this; } |
| 55 delete this; | |
| 56 } | |
| 57 | 55 |
| 58 // WebContentsModalDialogHostObserver overrides | 56 // WebContentsModalDialogHostObserver overrides |
| 59 virtual void OnPositionRequiresUpdate() override { | 57 void OnPositionRequiresUpdate() override { |
| 60 UpdateWidgetModalDialogPosition(target_widget_, host_); | 58 UpdateWidgetModalDialogPosition(target_widget_, host_); |
| 61 } | 59 } |
| 62 | 60 |
| 63 virtual void OnHostDestroying() override { | 61 void OnHostDestroying() override { |
| 64 host_->RemoveObserver(this); | 62 host_->RemoveObserver(this); |
| 65 host_ = NULL; | 63 host_ = NULL; |
| 66 } | 64 } |
| 67 | 65 |
| 68 private: | 66 private: |
| 69 ModalDialogHost* host_; | 67 ModalDialogHost* host_; |
| 70 views::Widget* target_widget_; | 68 views::Widget* target_widget_; |
| 71 const char* const native_window_property_; | 69 const char* const native_window_property_; |
| 72 | 70 |
| 73 DISALLOW_COPY_AND_ASSIGN(WidgetModalDialogHostObserverViews); | 71 DISALLOW_COPY_AND_ASSIGN(WidgetModalDialogHostObserverViews); |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 GetModalDialogHost(parent); | 163 GetModalDialogHost(parent); |
| 166 if (host) { | 164 if (host) { |
| 167 DCHECK_EQ(parent, host->GetHostView()); | 165 DCHECK_EQ(parent, host->GetHostView()); |
| 168 ModalDialogHostObserver* dialog_host_observer = | 166 ModalDialogHostObserver* dialog_host_observer = |
| 169 new WidgetModalDialogHostObserverViews( | 167 new WidgetModalDialogHostObserverViews( |
| 170 host, widget, kWidgetModalDialogHostObserverViewsKey); | 168 host, widget, kWidgetModalDialogHostObserverViewsKey); |
| 171 dialog_host_observer->OnPositionRequiresUpdate(); | 169 dialog_host_observer->OnPositionRequiresUpdate(); |
| 172 } | 170 } |
| 173 return widget; | 171 return widget; |
| 174 } | 172 } |
| OLD | NEW |