| 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/web_modal/web_contents_modal_dialog_manager.h" | 5 #include "components/web_modal/web_contents_modal_dialog_manager.h" |
| 6 | 6 |
| 7 #include <utility> |
| 8 |
| 7 #include "components/web_modal/web_contents_modal_dialog_manager_delegate.h" | 9 #include "components/web_modal/web_contents_modal_dialog_manager_delegate.h" |
| 8 #include "content/public/browser/navigation_details.h" | 10 #include "content/public/browser/navigation_details.h" |
| 9 #include "content/public/browser/navigation_entry.h" | 11 #include "content/public/browser/navigation_entry.h" |
| 10 #include "content/public/browser/render_view_host.h" | 12 #include "content/public/browser/render_view_host.h" |
| 11 #include "content/public/browser/render_widget_host.h" | 13 #include "content/public/browser/render_widget_host.h" |
| 12 #include "content/public/browser/web_contents.h" | 14 #include "content/public/browser/web_contents.h" |
| 13 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" | 15 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
| 14 | 16 |
| 15 using content::WebContents; | 17 using content::WebContents; |
| 16 | 18 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 29 for (WebContentsModalDialogList::iterator it = child_dialogs_.begin(); | 31 for (WebContentsModalDialogList::iterator it = child_dialogs_.begin(); |
| 30 it != child_dialogs_.end(); it++) { | 32 it != child_dialogs_.end(); it++) { |
| 31 // Delegate can be NULL on Views/Win32 during tab drag. | 33 // Delegate can be NULL on Views/Win32 during tab drag. |
| 32 (*it)->manager->HostChanged(d ? d->GetWebContentsModalDialogHost() : NULL); | 34 (*it)->manager->HostChanged(d ? d->GetWebContentsModalDialogHost() : NULL); |
| 33 } | 35 } |
| 34 } | 36 } |
| 35 | 37 |
| 36 void WebContentsModalDialogManager::ShowModalDialog(gfx::NativeWindow dialog) { | 38 void WebContentsModalDialogManager::ShowModalDialog(gfx::NativeWindow dialog) { |
| 37 scoped_ptr<SingleWebContentsDialogManager> mgr( | 39 scoped_ptr<SingleWebContentsDialogManager> mgr( |
| 38 CreateNativeWebModalManager(dialog, this)); | 40 CreateNativeWebModalManager(dialog, this)); |
| 39 ShowDialogWithManager(dialog, mgr.Pass()); | 41 ShowDialogWithManager(dialog, std::move(mgr)); |
| 40 } | 42 } |
| 41 | 43 |
| 42 // TODO(gbillock): Maybe "ShowBubbleWithManager"? | 44 // TODO(gbillock): Maybe "ShowBubbleWithManager"? |
| 43 void WebContentsModalDialogManager::ShowDialogWithManager( | 45 void WebContentsModalDialogManager::ShowDialogWithManager( |
| 44 gfx::NativeWindow dialog, | 46 gfx::NativeWindow dialog, |
| 45 scoped_ptr<SingleWebContentsDialogManager> manager) { | 47 scoped_ptr<SingleWebContentsDialogManager> manager) { |
| 46 if (delegate_) | 48 if (delegate_) |
| 47 manager->HostChanged(delegate_->GetWebContentsModalDialogHost()); | 49 manager->HostChanged(delegate_->GetWebContentsModalDialogHost()); |
| 48 child_dialogs_.push_back(new DialogState(dialog, manager.Pass())); | 50 child_dialogs_.push_back(new DialogState(dialog, std::move(manager))); |
| 49 | 51 |
| 50 if (child_dialogs_.size() == 1) { | 52 if (child_dialogs_.size() == 1) { |
| 51 BlockWebContentsInteraction(true); | 53 BlockWebContentsInteraction(true); |
| 52 if (delegate_ && delegate_->IsWebContentsVisible(web_contents())) | 54 if (delegate_ && delegate_->IsWebContentsVisible(web_contents())) |
| 53 child_dialogs_.back()->manager->Show(); | 55 child_dialogs_.back()->manager->Show(); |
| 54 } | 56 } |
| 55 } | 57 } |
| 56 | 58 |
| 57 bool WebContentsModalDialogManager::IsDialogActive() const { | 59 bool WebContentsModalDialogManager::IsDialogActive() const { |
| 58 return !child_dialogs_.empty(); | 60 return !child_dialogs_.empty(); |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 // some of these to close. CloseAllDialogs is async, so it might get called | 177 // some of these to close. CloseAllDialogs is async, so it might get called |
| 176 // twice before it runs. | 178 // twice before it runs. |
| 177 CloseAllDialogs(); | 179 CloseAllDialogs(); |
| 178 } | 180 } |
| 179 | 181 |
| 180 void WebContentsModalDialogManager::DidAttachInterstitialPage() { | 182 void WebContentsModalDialogManager::DidAttachInterstitialPage() { |
| 181 CloseAllDialogs(); | 183 CloseAllDialogs(); |
| 182 } | 184 } |
| 183 | 185 |
| 184 } // namespace web_modal | 186 } // namespace web_modal |
| OLD | NEW |