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

Side by Side Diff: chrome/browser/ui/app_modal_dialogs/app_modal_dialog_queue.cc

Issue 5519016: Add a new GetInstance() method for singleton classes used in chrome/browser files. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 10 years 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "chrome/browser/ui/app_modal_dialogs/app_modal_dialog_queue.h" 5 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog_queue.h"
6 6
7 #include "base/singleton.h"
8
7 void AppModalDialogQueue::AddDialog(AppModalDialog* dialog) { 9 void AppModalDialogQueue::AddDialog(AppModalDialog* dialog) {
8 if (!active_dialog_) { 10 if (!active_dialog_) {
9 ShowModalDialog(dialog); 11 ShowModalDialog(dialog);
10 return; 12 return;
11 } 13 }
12 app_modal_dialog_queue_.push(dialog); 14 app_modal_dialog_queue_.push(dialog);
13 } 15 }
14 16
15 void AppModalDialogQueue::ShowNextDialog() { 17 void AppModalDialogQueue::ShowNextDialog() {
16 AppModalDialog* dialog = GetNextDialog(); 18 AppModalDialog* dialog = GetNextDialog();
(...skipping 14 matching lines...) Expand all
31 if (active_dialog_) 33 if (active_dialog_)
32 active_dialog_->ActivateModalDialog(); 34 active_dialog_->ActivateModalDialog();
33 } 35 }
34 36
35 AppModalDialogQueue::AppModalDialogQueue() 37 AppModalDialogQueue::AppModalDialogQueue()
36 : active_dialog_(NULL), showing_modal_dialog_(false) { 38 : active_dialog_(NULL), showing_modal_dialog_(false) {
37 } 39 }
38 40
39 AppModalDialogQueue::~AppModalDialogQueue() {} 41 AppModalDialogQueue::~AppModalDialogQueue() {}
40 42
43 // static
44 AppModalDialogQueue* AppModalDialogQueue::GetInstance() {
45 return Singleton<AppModalDialogQueue>::get();
46 }
47
41 void AppModalDialogQueue::ShowModalDialog(AppModalDialog* dialog) { 48 void AppModalDialogQueue::ShowModalDialog(AppModalDialog* dialog) {
42 // Be sure and set the active_dialog_ field first, otherwise if 49 // Be sure and set the active_dialog_ field first, otherwise if
43 // ShowModalDialog triggers a call back to the queue they'll get the old 50 // ShowModalDialog triggers a call back to the queue they'll get the old
44 // dialog. Also, if the dialog calls |ShowNextDialog()| before returning, that 51 // dialog. Also, if the dialog calls |ShowNextDialog()| before returning, that
45 // would write NULL into |active_dialog_| and this function would then undo 52 // would write NULL into |active_dialog_| and this function would then undo
46 // that. 53 // that.
47 active_dialog_ = dialog; 54 active_dialog_ = dialog;
48 showing_modal_dialog_ = true; 55 showing_modal_dialog_ = true;
49 dialog->ShowModalDialog(); 56 dialog->ShowModalDialog();
50 showing_modal_dialog_ = false; 57 showing_modal_dialog_ = false;
51 } 58 }
52 59
53 AppModalDialog* AppModalDialogQueue::GetNextDialog() { 60 AppModalDialog* AppModalDialogQueue::GetNextDialog() {
54 while (!app_modal_dialog_queue_.empty()) { 61 while (!app_modal_dialog_queue_.empty()) {
55 AppModalDialog* dialog = app_modal_dialog_queue_.front(); 62 AppModalDialog* dialog = app_modal_dialog_queue_.front();
56 app_modal_dialog_queue_.pop(); 63 app_modal_dialog_queue_.pop();
57 if (dialog->IsValid()) 64 if (dialog->IsValid())
58 return dialog; 65 return dialog;
59 delete dialog; 66 delete dialog;
60 } 67 }
61 return NULL; 68 return NULL;
62 } 69 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698