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

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

Issue 1917673002: Convert //components/[u-z]* from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 7 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 <utility> 7 #include <utility>
8 8
9 #include "components/web_modal/web_contents_modal_dialog_manager_delegate.h" 9 #include "components/web_modal/web_contents_modal_dialog_manager_delegate.h"
10 #include "content/public/browser/navigation_details.h" 10 #include "content/public/browser/navigation_details.h"
(...skipping 18 matching lines...) Expand all
29 delegate_ = d; 29 delegate_ = d;
30 30
31 for (WebContentsModalDialogList::iterator it = child_dialogs_.begin(); 31 for (WebContentsModalDialogList::iterator it = child_dialogs_.begin();
32 it != child_dialogs_.end(); it++) { 32 it != child_dialogs_.end(); it++) {
33 // Delegate can be NULL on Views/Win32 during tab drag. 33 // Delegate can be NULL on Views/Win32 during tab drag.
34 (*it)->manager->HostChanged(d ? d->GetWebContentsModalDialogHost() : NULL); 34 (*it)->manager->HostChanged(d ? d->GetWebContentsModalDialogHost() : NULL);
35 } 35 }
36 } 36 }
37 37
38 void WebContentsModalDialogManager::ShowModalDialog(gfx::NativeWindow dialog) { 38 void WebContentsModalDialogManager::ShowModalDialog(gfx::NativeWindow dialog) {
39 scoped_ptr<SingleWebContentsDialogManager> mgr( 39 std::unique_ptr<SingleWebContentsDialogManager> mgr(
40 CreateNativeWebModalManager(dialog, this)); 40 CreateNativeWebModalManager(dialog, this));
41 ShowDialogWithManager(dialog, std::move(mgr)); 41 ShowDialogWithManager(dialog, std::move(mgr));
42 } 42 }
43 43
44 // TODO(gbillock): Maybe "ShowBubbleWithManager"? 44 // TODO(gbillock): Maybe "ShowBubbleWithManager"?
45 void WebContentsModalDialogManager::ShowDialogWithManager( 45 void WebContentsModalDialogManager::ShowDialogWithManager(
46 gfx::NativeWindow dialog, 46 gfx::NativeWindow dialog,
47 scoped_ptr<SingleWebContentsDialogManager> manager) { 47 std::unique_ptr<SingleWebContentsDialogManager> manager) {
48 if (delegate_) 48 if (delegate_)
49 manager->HostChanged(delegate_->GetWebContentsModalDialogHost()); 49 manager->HostChanged(delegate_->GetWebContentsModalDialogHost());
50 child_dialogs_.push_back(new DialogState(dialog, std::move(manager))); 50 child_dialogs_.push_back(new DialogState(dialog, std::move(manager)));
51 51
52 if (child_dialogs_.size() == 1) { 52 if (child_dialogs_.size() == 1) {
53 BlockWebContentsInteraction(true); 53 BlockWebContentsInteraction(true);
54 if (delegate_ && delegate_->IsWebContentsVisible(web_contents())) 54 if (delegate_ && delegate_->IsWebContentsVisible(web_contents()))
55 child_dialogs_.back()->manager->Show(); 55 child_dialogs_.back()->manager->Show();
56 } 56 }
57 } 57 }
(...skipping 13 matching lines...) Expand all
71 71
72 void WebContentsModalDialogManager::WillClose(gfx::NativeWindow dialog) { 72 void WebContentsModalDialogManager::WillClose(gfx::NativeWindow dialog) {
73 WebContentsModalDialogList::iterator dlg = FindDialogState(dialog); 73 WebContentsModalDialogList::iterator dlg = FindDialogState(dialog);
74 74
75 // The Views tab contents modal dialog calls WillClose twice. Ignore the 75 // The Views tab contents modal dialog calls WillClose twice. Ignore the
76 // second invocation. 76 // second invocation.
77 if (dlg == child_dialogs_.end()) 77 if (dlg == child_dialogs_.end())
78 return; 78 return;
79 79
80 bool removed_topmost_dialog = dlg == child_dialogs_.begin(); 80 bool removed_topmost_dialog = dlg == child_dialogs_.begin();
81 scoped_ptr<DialogState> deleter(*dlg); 81 std::unique_ptr<DialogState> deleter(*dlg);
82 child_dialogs_.erase(dlg); 82 child_dialogs_.erase(dlg);
83 if (!child_dialogs_.empty() && removed_topmost_dialog && 83 if (!child_dialogs_.empty() && removed_topmost_dialog &&
84 !closing_all_dialogs_) { 84 !closing_all_dialogs_) {
85 child_dialogs_.front()->manager->Show(); 85 child_dialogs_.front()->manager->Show();
86 } 86 }
87 87
88 BlockWebContentsInteraction(!child_dialogs_.empty()); 88 BlockWebContentsInteraction(!child_dialogs_.empty());
89 } 89 }
90 90
91 WebContentsModalDialogManager::WebContentsModalDialogManager( 91 WebContentsModalDialogManager::WebContentsModalDialogManager(
92 content::WebContents* web_contents) 92 content::WebContents* web_contents)
93 : content::WebContentsObserver(web_contents), 93 : content::WebContentsObserver(web_contents),
94 delegate_(NULL), 94 delegate_(NULL),
95 closing_all_dialogs_(false) { 95 closing_all_dialogs_(false) {
96 } 96 }
97 97
98 WebContentsModalDialogManager::DialogState::DialogState( 98 WebContentsModalDialogManager::DialogState::DialogState(
99 gfx::NativeWindow dialog, 99 gfx::NativeWindow dialog,
100 scoped_ptr<SingleWebContentsDialogManager> mgr) 100 std::unique_ptr<SingleWebContentsDialogManager> mgr)
101 : dialog(dialog), 101 : dialog(dialog), manager(mgr.release()) {}
102 manager(mgr.release()) {
103 }
104 102
105 WebContentsModalDialogManager::DialogState::~DialogState() {} 103 WebContentsModalDialogManager::DialogState::~DialogState() {}
106 104
107 WebContentsModalDialogManager::WebContentsModalDialogList::iterator 105 WebContentsModalDialogManager::WebContentsModalDialogList::iterator
108 WebContentsModalDialogManager::FindDialogState(gfx::NativeWindow dialog) { 106 WebContentsModalDialogManager::FindDialogState(gfx::NativeWindow dialog) {
109 WebContentsModalDialogList::iterator i; 107 WebContentsModalDialogList::iterator i;
110 for (i = child_dialogs_.begin(); i != child_dialogs_.end(); ++i) { 108 for (i = child_dialogs_.begin(); i != child_dialogs_.end(); ++i) {
111 if ((*i)->dialog == dialog) 109 if ((*i)->dialog == dialog)
112 break; 110 break;
113 } 111 }
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 // some of these to close. CloseAllDialogs is async, so it might get called 175 // some of these to close. CloseAllDialogs is async, so it might get called
178 // twice before it runs. 176 // twice before it runs.
179 CloseAllDialogs(); 177 CloseAllDialogs();
180 } 178 }
181 179
182 void WebContentsModalDialogManager::DidAttachInterstitialPage() { 180 void WebContentsModalDialogManager::DidAttachInterstitialPage() {
183 CloseAllDialogs(); 181 CloseAllDialogs();
184 } 182 }
185 183
186 } // namespace web_modal 184 } // namespace web_modal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698