Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/ui/views/browser_modal_dialog.h" | |
| 6 | |
| 7 #include <algorithm> | |
| 8 | |
| 9 #include "base/memory/singleton.h" | |
| 10 | |
| 11 BrowserModalDialog::BrowserModalDialog() { | |
| 12 BrowserModalDialogList::GetInstance()->AddDialog(this); | |
| 13 } | |
| 14 | |
| 15 BrowserModalDialog::~BrowserModalDialog() { | |
| 16 BrowserModalDialogList::GetInstance()->RemoveDialog(this); | |
| 17 } | |
| 18 | |
| 19 // static | |
| 20 BrowserModalDialogList* BrowserModalDialogList::GetInstance() { | |
| 21 return base::Singleton<BrowserModalDialogList>::get(); | |
| 22 } | |
| 23 | |
| 24 void BrowserModalDialogList::AddDialog(BrowserModalDialog* dialog) { | |
| 25 dialogs_.push_back(dialog); | |
| 26 } | |
| 27 | |
| 28 void BrowserModalDialogList::RemoveDialog(BrowserModalDialog* dialog) { | |
| 29 auto it = std::find(dialogs_.begin(), dialogs_.end(), dialog); | |
| 30 if (it != dialogs_.end()) { | |
|
sky
2017/05/16 12:40:32
no {}
zmin
2017/05/16 22:22:02
Done.
| |
| 31 dialogs_.erase(it); | |
| 32 } | |
| 33 } | |
| 34 | |
| 35 bool BrowserModalDialogList::ActivateModalDialog() { | |
| 36 for (BrowserModalDialog* dialog : dialogs_) { | |
| 37 if (dialog->IsShowing()) { | |
| 38 dialog->ActivateModalDialog(); | |
| 39 return true; | |
| 40 } | |
| 41 } | |
| 42 return false; | |
| 43 } | |
| 44 | |
| 45 bool BrowserModalDialogList::IsShowing() { | |
| 46 for (BrowserModalDialog* dialog : dialogs_) { | |
| 47 if (dialog->IsShowing()) | |
| 48 return true; | |
| 49 } | |
| 50 return false; | |
| 51 } | |
| 52 | |
| 53 BrowserModalDialogList::BrowserModalDialogList() {} | |
| 54 | |
| 55 BrowserModalDialogList::~BrowserModalDialogList() {} | |
| OLD | NEW |