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

Side by Side Diff: components/web_modal/web_contents_modal_dialog_manager.cc

Issue 985133002: Remove NativeWebContentsModalDialog and NativePopup typedefs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@extension-popup
Patch Set: Created 5 years, 9 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 unified diff | Download patch
OLDNEW
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 "components/web_modal/web_contents_modal_dialog_manager_delegate.h" 7 #include "components/web_modal/web_contents_modal_dialog_manager_delegate.h"
8 #include "content/public/browser/navigation_details.h" 8 #include "content/public/browser/navigation_details.h"
9 #include "content/public/browser/navigation_entry.h" 9 #include "content/public/browser/navigation_entry.h"
10 #include "content/public/browser/render_view_host.h" 10 #include "content/public/browser/render_view_host.h"
(...skipping 14 matching lines...) Expand all
25 WebContentsModalDialogManagerDelegate* d) { 25 WebContentsModalDialogManagerDelegate* d) {
26 delegate_ = d; 26 delegate_ = d;
27 27
28 for (WebContentsModalDialogList::iterator it = child_dialogs_.begin(); 28 for (WebContentsModalDialogList::iterator it = child_dialogs_.begin();
29 it != child_dialogs_.end(); it++) { 29 it != child_dialogs_.end(); it++) {
30 // Delegate can be NULL on Views/Win32 during tab drag. 30 // Delegate can be NULL on Views/Win32 during tab drag.
31 (*it)->manager->HostChanged(d ? d->GetWebContentsModalDialogHost() : NULL); 31 (*it)->manager->HostChanged(d ? d->GetWebContentsModalDialogHost() : NULL);
32 } 32 }
33 } 33 }
34 34
35 void WebContentsModalDialogManager::ShowModalDialog( 35 void WebContentsModalDialogManager::ShowModalDialog(gfx::NativeWindow dialog) {
36 NativeWebContentsModalDialog dialog) {
37 scoped_ptr<SingleWebContentsDialogManager> mgr( 36 scoped_ptr<SingleWebContentsDialogManager> mgr(
38 CreateNativeWebModalManager(dialog, this)); 37 CreateNativeWebModalManager(dialog, this));
39 ShowDialogWithManager(dialog, mgr.Pass()); 38 ShowDialogWithManager(dialog, mgr.Pass());
40 } 39 }
41 40
42 // TODO(gbillock): Maybe "ShowBubbleWithManager"? 41 // TODO(gbillock): Maybe "ShowBubbleWithManager"?
43 void WebContentsModalDialogManager::ShowDialogWithManager( 42 void WebContentsModalDialogManager::ShowDialogWithManager(
44 NativeWebContentsModalDialog dialog, 43 gfx::NativeWindow dialog,
45 scoped_ptr<SingleWebContentsDialogManager> manager) { 44 scoped_ptr<SingleWebContentsDialogManager> manager) {
46 if (delegate_) 45 if (delegate_)
47 manager->HostChanged(delegate_->GetWebContentsModalDialogHost()); 46 manager->HostChanged(delegate_->GetWebContentsModalDialogHost());
48 child_dialogs_.push_back(new DialogState(dialog, manager.Pass())); 47 child_dialogs_.push_back(new DialogState(dialog, manager.Pass()));
49 48
50 if (child_dialogs_.size() == 1) { 49 if (child_dialogs_.size() == 1) {
51 BlockWebContentsInteraction(true); 50 BlockWebContentsInteraction(true);
52 if (delegate_ && delegate_->IsWebContentsVisible(web_contents())) 51 if (delegate_ && delegate_->IsWebContentsVisible(web_contents()))
53 child_dialogs_.back()->manager->Show(); 52 child_dialogs_.back()->manager->Show();
54 } 53 }
55 } 54 }
56 55
57 bool WebContentsModalDialogManager::IsDialogActive() const { 56 bool WebContentsModalDialogManager::IsDialogActive() const {
58 return !child_dialogs_.empty(); 57 return !child_dialogs_.empty();
59 } 58 }
60 59
61 void WebContentsModalDialogManager::FocusTopmostDialog() const { 60 void WebContentsModalDialogManager::FocusTopmostDialog() const {
62 DCHECK(!child_dialogs_.empty()); 61 DCHECK(!child_dialogs_.empty());
63 child_dialogs_.front()->manager->Focus(); 62 child_dialogs_.front()->manager->Focus();
64 } 63 }
65 64
66 content::WebContents* WebContentsModalDialogManager::GetWebContents() const { 65 content::WebContents* WebContentsModalDialogManager::GetWebContents() const {
67 return web_contents(); 66 return web_contents();
68 } 67 }
69 68
70 void WebContentsModalDialogManager::WillClose( 69 void WebContentsModalDialogManager::WillClose(gfx::NativeWindow dialog) {
71 NativeWebContentsModalDialog dialog) {
72 WebContentsModalDialogList::iterator dlg = FindDialogState(dialog); 70 WebContentsModalDialogList::iterator dlg = FindDialogState(dialog);
73 71
74 // The Views tab contents modal dialog calls WillClose twice. Ignore the 72 // The Views tab contents modal dialog calls WillClose twice. Ignore the
75 // second invocation. 73 // second invocation.
76 if (dlg == child_dialogs_.end()) 74 if (dlg == child_dialogs_.end())
77 return; 75 return;
78 76
79 bool removed_topmost_dialog = dlg == child_dialogs_.begin(); 77 bool removed_topmost_dialog = dlg == child_dialogs_.begin();
80 scoped_ptr<DialogState> deleter(*dlg); 78 scoped_ptr<DialogState> deleter(*dlg);
81 child_dialogs_.erase(dlg); 79 child_dialogs_.erase(dlg);
82 if (!child_dialogs_.empty() && removed_topmost_dialog && 80 if (!child_dialogs_.empty() && removed_topmost_dialog &&
83 !closing_all_dialogs_) { 81 !closing_all_dialogs_) {
84 child_dialogs_.front()->manager->Show(); 82 child_dialogs_.front()->manager->Show();
85 } 83 }
86 84
87 BlockWebContentsInteraction(!child_dialogs_.empty()); 85 BlockWebContentsInteraction(!child_dialogs_.empty());
88 } 86 }
89 87
90 WebContentsModalDialogManager::WebContentsModalDialogManager( 88 WebContentsModalDialogManager::WebContentsModalDialogManager(
91 content::WebContents* web_contents) 89 content::WebContents* web_contents)
92 : content::WebContentsObserver(web_contents), 90 : content::WebContentsObserver(web_contents),
93 delegate_(NULL), 91 delegate_(NULL),
94 closing_all_dialogs_(false) { 92 closing_all_dialogs_(false) {
95 } 93 }
96 94
97 WebContentsModalDialogManager::DialogState::DialogState( 95 WebContentsModalDialogManager::DialogState::DialogState(
98 NativeWebContentsModalDialog dialog, 96 gfx::NativeWindow dialog,
99 scoped_ptr<SingleWebContentsDialogManager> mgr) 97 scoped_ptr<SingleWebContentsDialogManager> mgr)
100 : dialog(dialog), 98 : dialog(dialog),
101 manager(mgr.release()) { 99 manager(mgr.release()) {
102 } 100 }
103 101
104 WebContentsModalDialogManager::DialogState::~DialogState() {} 102 WebContentsModalDialogManager::DialogState::~DialogState() {}
105 103
106 WebContentsModalDialogManager::WebContentsModalDialogList::iterator 104 WebContentsModalDialogManager::WebContentsModalDialogList::iterator
107 WebContentsModalDialogManager::FindDialogState( 105 WebContentsModalDialogManager::FindDialogState(gfx::NativeWindow dialog) {
108 NativeWebContentsModalDialog dialog) {
109 WebContentsModalDialogList::iterator i; 106 WebContentsModalDialogList::iterator i;
110 for (i = child_dialogs_.begin(); i != child_dialogs_.end(); ++i) { 107 for (i = child_dialogs_.begin(); i != child_dialogs_.end(); ++i) {
111 if ((*i)->dialog == dialog) 108 if ((*i)->dialog == dialog)
112 break; 109 break;
113 } 110 }
114 111
115 return i; 112 return i;
116 } 113 }
117 114
118 // TODO(gbillock): Move this to Views impl within Show()? It would 115 // TODO(gbillock): Move this to Views impl within Show()? It would
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 } 177 }
181 178
182 void WebContentsModalDialogManager::DidAttachInterstitialPage() { 179 void WebContentsModalDialogManager::DidAttachInterstitialPage() {
183 // TODO(wittman): Test closing on interstitial webui works properly on Mac. 180 // TODO(wittman): Test closing on interstitial webui works properly on Mac.
184 #if defined(USE_AURA) 181 #if defined(USE_AURA)
185 CloseAllDialogs(); 182 CloseAllDialogs();
186 #endif 183 #endif
187 } 184 }
188 185
189 } // namespace web_modal 186 } // namespace web_modal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698