| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/web_modal/popup_manager.h" | 5 #include "components/web_modal/popup_manager.h" |
| 6 | 6 |
| 7 #include "components/web_modal/web_contents_modal_dialog_host.h" | 7 #include "components/web_modal/web_contents_modal_dialog_host.h" |
| 8 #include "components/web_modal/web_contents_modal_dialog_manager.h" | 8 #include "components/web_modal/web_contents_modal_dialog_manager.h" |
| 9 #include "content/public/browser/web_contents.h" | 9 #include "content/public/browser/web_contents.h" |
| 10 #include "content/public/browser/web_contents_user_data.h" | 10 #include "content/public/browser/web_contents_user_data.h" |
| 11 #include "ui/gfx/geometry/size.h" | 11 #include "ui/gfx/geometry/size.h" |
| 12 | 12 |
| 13 using content::WebContents; | 13 using content::WebContents; |
| 14 | 14 |
| 15 namespace web_modal { | 15 namespace web_modal { |
| 16 | 16 |
| 17 namespace { | 17 namespace { |
| 18 | 18 |
| 19 const char kPopupManagerUserDataKey[] = "PopupManager"; | 19 const char kPopupManagerUserDataKey[] = "PopupManager"; |
| 20 | 20 |
| 21 // This class provides a hook to get a PopupManager from a WebContents. | 21 // This class provides a hook to get a PopupManager from a WebContents. |
| 22 // The PopupManager is browser-scoped, but will use a FromWebContents API | 22 // The PopupManager is browser-scoped, but will use a FromWebContents API |
| 23 // to attach to each WebContents in that browser. | 23 // to attach to each WebContents in that browser. |
| 24 class PopupManagerRelay : public content::WebContentsUserData<PopupManager> { | 24 class PopupManagerRelay : public content::WebContentsUserData<PopupManager> { |
| 25 public: | 25 public: |
| 26 explicit PopupManagerRelay(base::WeakPtr<PopupManager> manager) | 26 explicit PopupManagerRelay(base::WeakPtr<PopupManager> manager) |
| 27 : manager_(manager) {} | 27 : manager_(manager) {} |
| 28 | 28 |
| 29 virtual ~PopupManagerRelay() {} | 29 ~PopupManagerRelay() override {} |
| 30 | 30 |
| 31 base::WeakPtr<PopupManager> manager_; | 31 base::WeakPtr<PopupManager> manager_; |
| 32 }; | 32 }; |
| 33 | 33 |
| 34 } // namespace | 34 } // namespace |
| 35 | 35 |
| 36 PopupManager::PopupManager(WebContentsModalDialogHost* host) | 36 PopupManager::PopupManager(WebContentsModalDialogHost* host) |
| 37 : host_(host), | 37 : host_(host), |
| 38 weak_factory_(this) {} | 38 weak_factory_(this) {} |
| 39 | 39 |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 void PopupManager::CloseAllDialogsForTesting( | 120 void PopupManager::CloseAllDialogsForTesting( |
| 121 content::WebContents* web_contents) { | 121 content::WebContents* web_contents) { |
| 122 // TODO: re-implement, probably in terms of something in the host_, | 122 // TODO: re-implement, probably in terms of something in the host_, |
| 123 // or of owned WCMDMs. | 123 // or of owned WCMDMs. |
| 124 WebContentsModalDialogManager* manager = | 124 WebContentsModalDialogManager* manager = |
| 125 WebContentsModalDialogManager::FromWebContents(web_contents); | 125 WebContentsModalDialogManager::FromWebContents(web_contents); |
| 126 manager->CloseAllDialogs(); | 126 manager->CloseAllDialogs(); |
| 127 } | 127 } |
| 128 | 128 |
| 129 } // namespace web_modal | 129 } // namespace web_modal |
| OLD | NEW |