| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog.h" | |
| 6 | |
| 7 #include "base/logging.h" | |
| 8 #include "chrome/browser/chrome_notification_types.h" | |
| 9 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog_queue.h" | |
| 10 #include "chrome/browser/ui/app_modal_dialogs/native_app_modal_dialog.h" | |
| 11 #include "content/public/browser/notification_service.h" | |
| 12 #include "content/public/browser/web_contents.h" | |
| 13 #include "content/public/browser/web_contents_delegate.h" | |
| 14 | |
| 15 using content::WebContents; | |
| 16 | |
| 17 AppModalDialog::AppModalDialog(WebContents* web_contents, | |
| 18 const base::string16& title) | |
| 19 : title_(title), | |
| 20 completed_(false), | |
| 21 valid_(true), | |
| 22 native_dialog_(NULL), | |
| 23 web_contents_(web_contents) { | |
| 24 } | |
| 25 | |
| 26 AppModalDialog::~AppModalDialog() { | |
| 27 CompleteDialog(); | |
| 28 } | |
| 29 | |
| 30 void AppModalDialog::ShowModalDialog() { | |
| 31 web_contents_->GetDelegate()->ActivateContents(web_contents_); | |
| 32 CreateAndShowDialog(); | |
| 33 | |
| 34 content::NotificationService::current()->Notify( | |
| 35 chrome::NOTIFICATION_APP_MODAL_DIALOG_SHOWN, | |
| 36 content::Source<AppModalDialog>(this), | |
| 37 content::NotificationService::NoDetails()); | |
| 38 } | |
| 39 | |
| 40 void AppModalDialog::CreateAndShowDialog() { | |
| 41 native_dialog_ = CreateNativeDialog(); | |
| 42 native_dialog_->ShowAppModalDialog(); | |
| 43 } | |
| 44 | |
| 45 bool AppModalDialog::IsValid() { | |
| 46 return valid_; | |
| 47 } | |
| 48 | |
| 49 void AppModalDialog::Invalidate() { | |
| 50 valid_ = false; | |
| 51 } | |
| 52 | |
| 53 bool AppModalDialog::IsJavaScriptModalDialog() { | |
| 54 return false; | |
| 55 } | |
| 56 | |
| 57 void AppModalDialog::ActivateModalDialog() { | |
| 58 DCHECK(native_dialog_); | |
| 59 native_dialog_->ActivateAppModalDialog(); | |
| 60 } | |
| 61 | |
| 62 void AppModalDialog::CloseModalDialog() { | |
| 63 DCHECK(native_dialog_); | |
| 64 native_dialog_->CloseAppModalDialog(); | |
| 65 } | |
| 66 | |
| 67 void AppModalDialog::CompleteDialog() { | |
| 68 if (!completed_) { | |
| 69 completed_ = true; | |
| 70 AppModalDialogQueue::GetInstance()->ShowNextDialog(); | |
| 71 } | |
| 72 } | |
| OLD | NEW |