| 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 "components/app_modal_dialogs/app_modal_dialog.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "chrome/browser/chrome_notification_types.h" | 8 #include "base/run_loop.h" |
| 9 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog_queue.h" | 9 #include "components/app_modal_dialogs/app_modal_dialog_queue.h" |
| 10 #include "chrome/browser/ui/app_modal_dialogs/native_app_modal_dialog.h" | 10 #include "components/app_modal_dialogs/native_app_modal_dialog.h" |
| 11 #include "content/public/browser/notification_service.h" | |
| 12 #include "content/public/browser/web_contents.h" | 11 #include "content/public/browser/web_contents.h" |
| 13 #include "content/public/browser/web_contents_delegate.h" | 12 #include "content/public/browser/web_contents_delegate.h" |
| 14 | 13 |
| 15 using content::WebContents; | 14 using content::WebContents; |
| 16 | 15 |
| 16 namespace { |
| 17 |
| 18 AppModalDialogWaiter* waiter_ = NULL; |
| 19 |
| 20 } // namespace |
| 21 |
| 22 AppModalDialogWaiter::AppModalDialogWaiter() { |
| 23 DCHECK(!waiter_); |
| 24 waiter_ = this; |
| 25 } |
| 26 |
| 27 AppModalDialogWaiter::~AppModalDialogWaiter() { |
| 28 DCHECK(waiter_); |
| 29 waiter_ = NULL; |
| 30 } |
| 31 |
| 17 AppModalDialog::AppModalDialog(WebContents* web_contents, | 32 AppModalDialog::AppModalDialog(WebContents* web_contents, |
| 18 const base::string16& title) | 33 const base::string16& title) |
| 19 : title_(title), | 34 : title_(title), |
| 20 completed_(false), | 35 completed_(false), |
| 21 valid_(true), | 36 valid_(true), |
| 22 native_dialog_(NULL), | 37 native_dialog_(NULL), |
| 23 web_contents_(web_contents) { | 38 web_contents_(web_contents) { |
| 24 } | 39 } |
| 25 | 40 |
| 26 AppModalDialog::~AppModalDialog() { | 41 AppModalDialog::~AppModalDialog() { |
| 27 CompleteDialog(); | 42 CompleteDialog(); |
| 28 } | 43 } |
| 29 | 44 |
| 30 void AppModalDialog::ShowModalDialog() { | 45 void AppModalDialog::ShowModalDialog() { |
| 31 web_contents_->GetDelegate()->ActivateContents(web_contents_); | 46 web_contents_->GetDelegate()->ActivateContents(web_contents_); |
| 32 CreateAndShowDialog(); | 47 CreateAndShowDialog(); |
| 33 | 48 if (waiter_) |
| 34 content::NotificationService::current()->Notify( | 49 waiter_->Notify(this); |
| 35 chrome::NOTIFICATION_APP_MODAL_DIALOG_SHOWN, | |
| 36 content::Source<AppModalDialog>(this), | |
| 37 content::NotificationService::NoDetails()); | |
| 38 } | 50 } |
| 39 | 51 |
| 40 void AppModalDialog::CreateAndShowDialog() { | 52 void AppModalDialog::CreateAndShowDialog() { |
| 41 native_dialog_ = CreateNativeDialog(); | 53 native_dialog_ = CreateNativeDialog(); |
| 42 native_dialog_->ShowAppModalDialog(); | 54 native_dialog_->ShowAppModalDialog(); |
| 43 } | 55 } |
| 44 | 56 |
| 45 bool AppModalDialog::IsValid() { | 57 bool AppModalDialog::IsValid() { |
| 46 return valid_; | 58 return valid_; |
| 47 } | 59 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 63 DCHECK(native_dialog_); | 75 DCHECK(native_dialog_); |
| 64 native_dialog_->CloseAppModalDialog(); | 76 native_dialog_->CloseAppModalDialog(); |
| 65 } | 77 } |
| 66 | 78 |
| 67 void AppModalDialog::CompleteDialog() { | 79 void AppModalDialog::CompleteDialog() { |
| 68 if (!completed_) { | 80 if (!completed_) { |
| 69 completed_ = true; | 81 completed_ = true; |
| 70 AppModalDialogQueue::GetInstance()->ShowNextDialog(); | 82 AppModalDialogQueue::GetInstance()->ShowNextDialog(); |
| 71 } | 83 } |
| 72 } | 84 } |
| OLD | NEW |