summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui/views/javascript_app_modal_dialog_views_x11.cc
blob: aeb72d5f060fcecaa72d8199a297a0f2b9e5b518 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/ui/views/javascript_app_modal_dialog_views_x11.h"

#include "chrome/browser/ui/blocked_content/app_modal_dialog_helper.h"
#include "chrome/browser/ui/views/javascript_app_modal_event_blocker_x11.h"
#include "components/app_modal/javascript_app_modal_dialog.h"
#include "ui/views/widget/widget.h"

JavaScriptAppModalDialogViewsX11::JavaScriptAppModalDialogViewsX11(
    app_modal::JavaScriptAppModalDialog* parent)
    : app_modal::JavaScriptAppModalDialogViews(parent),
      helper_(new AppModalDialogHelper(parent->web_contents())) {
}

JavaScriptAppModalDialogViewsX11::~JavaScriptAppModalDialogViewsX11() {
}

void JavaScriptAppModalDialogViewsX11::ShowAppModalDialog() {
  // BrowserView::CanActivate() ensures that other browser windows cannot be
  // activated for long while the dialog is visible. Block events to other
  // browser windows so that the user cannot interact with other browser windows
  // in the short time that the other browser windows are active. This hack is
  // unnecessary on Windows and Chrome OS.
  // TODO(pkotwicz): Find a better way of doing this and remove this hack.
  if (!event_blocker_x11_.get()) {
    event_blocker_x11_.reset(
        new JavascriptAppModalEventBlockerX11(GetWidget()->GetNativeView()));
  }
  GetWidget()->Show();
}

void JavaScriptAppModalDialogViewsX11::WindowClosing() {
  event_blocker_x11_.reset();
}