OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 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/views/app_modal_dialog_queue_wrapper.h" |
| 6 |
| 7 #include <algorithm> |
| 8 |
| 9 #include "chrome/browser/ui/browser.h" |
| 10 #include "chrome/browser/ui/browser_finder.h" |
| 11 #include "chrome/browser/ui/browser_window.h" |
| 12 #include "components/app_modal/app_modal_dialog.h" |
| 13 #include "components/app_modal/app_modal_dialog_queue.h" |
| 14 #include "components/app_modal/native_app_modal_dialog.h" |
| 15 |
| 16 AppModalDialogQueueWrapper::AppModalDialogQueueWrapper() {} |
| 17 |
| 18 AppModalDialogQueueWrapper::~AppModalDialogQueueWrapper() {} |
| 19 |
| 20 void AppModalDialogQueueWrapper::ActivateModalDialog(Browser* browser) { |
| 21 app_modal::AppModalDialogQueue* queue = |
| 22 app_modal::AppModalDialogQueue::GetInstance(); |
| 23 // Javascript dialog will be activaed with PostTask on all platforms except |
| 24 // Aura. |
| 25 #if defined(USE_AURA) && defined(OS_CHROMEOS) |
| 26 queue->ActivateModalDialog(); |
| 27 #else |
| 28 // Flash and activate the modal browser. |
| 29 app_modal::AppModalDialog* active_dialog = |
| 30 app_modal::AppModalDialogQueue::GetInstance()->active_dialog(); |
| 31 if (!active_dialog) |
| 32 return; |
| 33 |
| 34 Browser* modal_browser = |
| 35 chrome::FindBrowserWithWebContents(active_dialog->web_contents()); |
| 36 if (modal_browser && (browser != modal_browser)) { |
| 37 modal_browser->window()->FlashFrame(true); |
| 38 modal_browser->window()->Activate(); |
| 39 } |
| 40 |
| 41 queue->ActivateModalDialog(); |
| 42 #endif |
| 43 } |
| 44 |
| 45 bool AppModalDialogQueueWrapper::IsShowing() { |
| 46 app_modal::AppModalDialogQueue* queue = |
| 47 app_modal::AppModalDialogQueue::GetInstance(); |
| 48 return queue->active_dialog() && queue->active_dialog()->native_dialog() && |
| 49 queue->active_dialog()->native_dialog()->IsShowing(); |
| 50 } |
OLD | NEW |