| 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 "chrome/browser/ui/app_modal_dialogs/app_modal_dialog_queue.h" | 7 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog_queue.h" |
| 8 #include "chrome/browser/ui/app_modal_dialogs/native_app_modal_dialog.h" | 8 #include "chrome/browser/ui/app_modal_dialogs/native_app_modal_dialog.h" |
| 9 #include "content/browser/javascript_dialogs.h" |
| 9 #include "content/browser/tab_contents/tab_contents.h" | 10 #include "content/browser/tab_contents/tab_contents.h" |
| 10 #include "content/common/notification_service.h" | 11 #include "content/common/notification_service.h" |
| 11 #include "content/common/notification_type.h" | 12 #include "content/common/notification_type.h" |
| 12 | 13 |
| 13 AppModalDialog::AppModalDialog(TabContents* tab_contents, | 14 AppModalDialog::AppModalDialog(content::DialogDelegate* delegate, |
| 14 const string16& title) | 15 const string16& title) |
| 15 : skip_this_dialog_(false), | 16 : valid_(true), |
| 16 tab_contents_(tab_contents), | 17 delegate_(delegate), |
| 17 native_dialog_(NULL), | 18 native_dialog_(NULL), |
| 18 title_(title) { | 19 title_(title) { |
| 19 } | 20 } |
| 20 | 21 |
| 21 AppModalDialog::~AppModalDialog() { | 22 AppModalDialog::~AppModalDialog() { |
| 22 } | 23 } |
| 23 | 24 |
| 24 void AppModalDialog::ShowModalDialog() { | 25 void AppModalDialog::ShowModalDialog() { |
| 25 if (tab_contents_) | 26 if (delegate_) |
| 26 tab_contents_->Activate(); | 27 delegate_->OnDialogShown(); |
| 27 | 28 |
| 28 CreateAndShowDialog(); | 29 CreateAndShowDialog(); |
| 29 | 30 |
| 30 NotificationService::current()->Notify( | 31 NotificationService::current()->Notify( |
| 31 NotificationType::APP_MODAL_DIALOG_SHOWN, | 32 NotificationType::APP_MODAL_DIALOG_SHOWN, |
| 32 Source<AppModalDialog>(this), | 33 Source<AppModalDialog>(this), |
| 33 NotificationService::NoDetails()); | 34 NotificationService::NoDetails()); |
| 34 } | 35 } |
| 35 | 36 |
| 36 void AppModalDialog::CreateAndShowDialog() { | 37 void AppModalDialog::CreateAndShowDialog() { |
| 37 native_dialog_ = CreateNativeDialog(); | 38 native_dialog_ = CreateNativeDialog(); |
| 38 native_dialog_->ShowAppModalDialog(); | 39 native_dialog_->ShowAppModalDialog(); |
| 39 } | 40 } |
| 40 | 41 |
| 41 bool AppModalDialog::IsValid() { | 42 bool AppModalDialog::IsValid() { |
| 42 return !skip_this_dialog_; | 43 return valid_; |
| 44 } |
| 45 |
| 46 void AppModalDialog::Invalidate() { |
| 47 valid_ = false; |
| 43 } | 48 } |
| 44 | 49 |
| 45 bool AppModalDialog::IsJavaScriptModalDialog() { | 50 bool AppModalDialog::IsJavaScriptModalDialog() { |
| 46 return false; | 51 return false; |
| 47 } | 52 } |
| 48 | 53 |
| 54 content::DialogDelegate* AppModalDialog::delegate() const { |
| 55 return delegate_; |
| 56 } |
| 57 |
| 49 void AppModalDialog::ActivateModalDialog() { | 58 void AppModalDialog::ActivateModalDialog() { |
| 50 DCHECK(native_dialog_); | 59 DCHECK(native_dialog_); |
| 51 native_dialog_->ActivateAppModalDialog(); | 60 native_dialog_->ActivateAppModalDialog(); |
| 52 } | 61 } |
| 53 | 62 |
| 54 void AppModalDialog::CloseModalDialog() { | 63 void AppModalDialog::CloseModalDialog() { |
| 55 DCHECK(native_dialog_); | 64 DCHECK(native_dialog_); |
| 56 native_dialog_->CloseAppModalDialog(); | 65 native_dialog_->CloseAppModalDialog(); |
| 57 } | 66 } |
| 58 | 67 |
| 59 void AppModalDialog::CompleteDialog() { | 68 void AppModalDialog::CompleteDialog() { |
| 60 AppModalDialogQueue::GetInstance()->ShowNextDialog(); | 69 AppModalDialogQueue::GetInstance()->ShowNextDialog(); |
| 61 } | 70 } |
| OLD | NEW |