OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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.h" | 5 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog_queue.h" | 8 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog_queue.h" |
9 #include "chrome/browser/ui/app_modal_dialogs/native_app_modal_dialog.h" | 9 #include "chrome/browser/ui/app_modal_dialogs/native_app_modal_dialog.h" |
10 #include "chrome/common/chrome_notification_types.h" | 10 #include "chrome/common/chrome_notification_types.h" |
11 #include "content/public/browser/notification_service.h" | 11 #include "content/public/browser/notification_service.h" |
12 #include "content/public/browser/web_contents.h" | 12 #include "content/public/browser/web_contents.h" |
13 #include "content/public/browser/web_contents_delegate.h" | 13 #include "content/public/browser/web_contents_delegate.h" |
14 | 14 |
15 using content::WebContents; | 15 using content::WebContents; |
16 | 16 |
17 AppModalDialog::AppModalDialog(WebContents* web_contents, const string16& title) | 17 AppModalDialog::AppModalDialog(WebContents* web_contents, const string16& title) |
18 : valid_(true), | 18 : valid_(true), |
19 native_dialog_(NULL), | 19 native_dialog_(NULL), |
20 title_(title), | 20 title_(title), |
21 web_contents_(web_contents) { | 21 web_contents_(web_contents), |
| 22 completed_(false) { |
22 } | 23 } |
23 | 24 |
24 AppModalDialog::~AppModalDialog() { | 25 AppModalDialog::~AppModalDialog() { |
| 26 CompleteDialog(); |
25 } | 27 } |
26 | 28 |
27 void AppModalDialog::ShowModalDialog() { | 29 void AppModalDialog::ShowModalDialog() { |
28 web_contents_->GetDelegate()->ActivateContents(web_contents_); | 30 web_contents_->GetDelegate()->ActivateContents(web_contents_); |
29 CreateAndShowDialog(); | 31 CreateAndShowDialog(); |
30 | 32 |
31 content::NotificationService::current()->Notify( | 33 content::NotificationService::current()->Notify( |
32 chrome::NOTIFICATION_APP_MODAL_DIALOG_SHOWN, | 34 chrome::NOTIFICATION_APP_MODAL_DIALOG_SHOWN, |
33 content::Source<AppModalDialog>(this), | 35 content::Source<AppModalDialog>(this), |
34 content::NotificationService::NoDetails()); | 36 content::NotificationService::NoDetails()); |
(...skipping 20 matching lines...) Expand all Loading... |
55 DCHECK(native_dialog_); | 57 DCHECK(native_dialog_); |
56 native_dialog_->ActivateAppModalDialog(); | 58 native_dialog_->ActivateAppModalDialog(); |
57 } | 59 } |
58 | 60 |
59 void AppModalDialog::CloseModalDialog() { | 61 void AppModalDialog::CloseModalDialog() { |
60 DCHECK(native_dialog_); | 62 DCHECK(native_dialog_); |
61 native_dialog_->CloseAppModalDialog(); | 63 native_dialog_->CloseAppModalDialog(); |
62 } | 64 } |
63 | 65 |
64 void AppModalDialog::CompleteDialog() { | 66 void AppModalDialog::CompleteDialog() { |
65 AppModalDialogQueue::GetInstance()->ShowNextDialog(); | 67 if (!completed_) { |
| 68 completed_ = true; |
| 69 AppModalDialogQueue::GetInstance()->ShowNextDialog(); |
| 70 } |
66 } | 71 } |
OLD | NEW |