1 // Copyright 2014 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.
5 #include "chrome/browser/chromeos/net/network_portal_web_dialog.h"
8 #include "chrome/grit/generated_resources.h"
9 #include "components/captive_portal/captive_portal_detector.h"
10 #include "ui/base/l10n/l10n_util.h"
11 #include "ui/base/ui_base_types.h"
12 #include "ui/gfx/display.h"
13 #include "ui/gfx/geometry/size.h"
14 #include "ui/views/widget/widget.h"
19 const float kNetworkPortalWebDialogWidthFraction
= .8;
20 const float kNetworkPortalWebDialogHeightFraction
= .8;
22 gfx::Size
GetPortalDialogSize() {
23 const gfx::Display display
= ash::Shell::GetScreen()->GetPrimaryDisplay();
25 gfx::Size display_size
= display
.size();
27 if (display
.rotation() == gfx::Display::ROTATE_90
||
28 display
.rotation() == gfx::Display::ROTATE_270
) {
29 display_size
= gfx::Size(display_size
.height(), display_size
.width());
33 gfx::Size(display_size
.width() * kNetworkPortalWebDialogWidthFraction
,
34 display_size
.height() * kNetworkPortalWebDialogHeightFraction
);
43 NetworkPortalWebDialog::NetworkPortalWebDialog(
44 base::WeakPtr
<NetworkPortalNotificationController
> controller
)
45 : controller_(controller
), widget_(nullptr) {
48 NetworkPortalWebDialog::~NetworkPortalWebDialog() {
50 controller_
->OnDialogDestroyed(this);
53 void NetworkPortalWebDialog::Close() {
58 void NetworkPortalWebDialog::SetWidget(views::Widget
* widget
) {
62 ui::ModalType
NetworkPortalWebDialog::GetDialogModalType() const {
63 return ui::MODAL_TYPE_SYSTEM
;
66 base::string16
NetworkPortalWebDialog::GetDialogTitle() const {
67 return l10n_util::GetStringUTF16(
68 IDS_CAPTIVE_PORTAL_AUTHORIZATION_DIALOG_NAME
);
71 GURL
NetworkPortalWebDialog::GetDialogContentURL() const {
72 return GURL(captive_portal::CaptivePortalDetector::kDefaultURL
);
75 void NetworkPortalWebDialog::GetWebUIMessageHandlers(
76 std::vector
<content::WebUIMessageHandler
*>* handlers
) const {
79 void NetworkPortalWebDialog::GetDialogSize(gfx::Size
* size
) const {
80 *size
= GetPortalDialogSize();
83 std::string
NetworkPortalWebDialog::GetDialogArgs() const {
87 bool NetworkPortalWebDialog::CanResizeDialog() const {
91 void NetworkPortalWebDialog::OnDialogClosed(const std::string
& json_retval
) {
95 void NetworkPortalWebDialog::OnCloseContents(content::WebContents
* /* source */,
96 bool* out_close_dialog
) {
97 *out_close_dialog
= true;
100 bool NetworkPortalWebDialog::ShouldShowDialogTitle() const {
104 } // namespace chromeos