| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/views/modal_dialog_delegate.h" | |
| 6 | |
| 7 #include "base/logging.h" | |
| 8 #include "chrome/browser/views/window.h" | |
| 9 #include "views/window/window.h" | |
| 10 | |
| 11 void ModalDialogDelegate::ShowModalDialog() { | |
| 12 gfx::NativeWindow root_hwnd = GetDialogRootWindow(); | |
| 13 // GetMessageBoxRootWindow() will be NULL if there's no selected tab (e.g., | |
| 14 // during shutdown), in which case we simply skip showing this dialog. | |
| 15 if (!root_hwnd) { | |
| 16 Cancel(); | |
| 17 } else { | |
| 18 dialog_ = browser::CreateViewsWindow(root_hwnd, gfx::Rect(), this); | |
| 19 dialog_->Show(); | |
| 20 } | |
| 21 } | |
| 22 | |
| 23 void ModalDialogDelegate::ActivateModalDialog() { | |
| 24 DCHECK(dialog_); | |
| 25 // Ensure that the dialog is visible and at the top of the z-order. These | |
| 26 // conditions may not be true if the dialog was opened on a different virtual | |
| 27 // desktop to the one the browser window is on. | |
| 28 dialog_->Show(); | |
| 29 dialog_->Activate(); | |
| 30 } | |
| 31 | |
| 32 void ModalDialogDelegate::CloseModalDialog() { | |
| 33 // If the dialog is visible close it. | |
| 34 if (dialog_) | |
| 35 dialog_->Close(); | |
| 36 } | |
| 37 | |
| 38 ModalDialogDelegate::ModalDialogDelegate() : dialog_(NULL) { | |
| 39 } | |
| 40 | |
| OLD | NEW |