OLD | NEW |
---|---|
(Empty) | |
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. | |
4 | |
5 #include "chrome/browser/chromeos/net/network_portal_web_dialog.h" | |
6 | |
7 #include "ash/shell.h" | |
8 #include "components/captive_portal/captive_portal_detector.h" | |
9 #include "ui/base/ui_base_types.h" | |
10 #include "ui/gfx/display.h" | |
11 #include "ui/gfx/size.h" | |
12 #include "ui/views/widget/widget.h" | |
13 #include "url/gurl.h" | |
14 | |
15 namespace { | |
16 | |
17 const float kNetworkPortalWebDialogWidthFraction = .8; | |
18 const float kNetworkPortalWebDialogHeightFraction = .8; | |
19 | |
20 gfx::Size GetPortalDialogSize() { | |
21 const gfx::Display display = ash::Shell::GetScreen()->GetPrimaryDisplay(); | |
22 | |
23 gfx::Size display_size = display.size(); | |
24 | |
25 if (display.rotation() == gfx::Display::ROTATE_90 || | |
26 display.rotation() == gfx::Display::ROTATE_270) { | |
27 display_size = gfx::Size(display_size.height(), display_size.width()); | |
28 } | |
29 | |
30 display_size = | |
31 gfx::Size(display_size.width() * kNetworkPortalWebDialogWidthFraction, | |
32 display_size.height() * kNetworkPortalWebDialogHeightFraction); | |
33 | |
34 return display_size; | |
35 } | |
36 | |
37 } // namespace | |
38 | |
39 namespace chromeos { | |
40 | |
41 NetworkPortalWebDialog::NetworkPortalWebDialog( | |
42 base::WeakPtr<NetworkPortalNotificationController> controller) | |
43 : controller_(controller), widget_(nullptr) { | |
44 } | |
45 | |
46 NetworkPortalWebDialog::~NetworkPortalWebDialog() { | |
47 if (controller_) | |
48 controller_->OnDialogDestroyed(this); | |
49 } | |
50 | |
51 void NetworkPortalWebDialog::Close() { | |
52 if (widget_) | |
53 widget_->Close(); | |
54 } | |
55 | |
56 void NetworkPortalWebDialog::SetWidget(views::Widget* widget) { | |
57 widget_ = widget; | |
58 } | |
59 | |
60 ui::ModalType NetworkPortalWebDialog::GetDialogModalType() const { | |
61 return ui::MODAL_TYPE_SYSTEM; | |
62 } | |
63 | |
64 base::string16 NetworkPortalWebDialog::GetDialogTitle() const { | |
65 return base::string16(); | |
Nikita (slow)
2014/11/26 18:02:57
nit: I guess that this should contain a real strin
Alexander Alekseev
2014/11/26 19:42:42
Done.
| |
66 } | |
67 | |
68 GURL NetworkPortalWebDialog::GetDialogContentURL() const { | |
69 return GURL(captive_portal::CaptivePortalDetector::kDefaultURL); | |
70 } | |
71 | |
72 void NetworkPortalWebDialog::GetWebUIMessageHandlers( | |
73 std::vector<content::WebUIMessageHandler*>* handlers) const { | |
74 } | |
75 | |
76 void NetworkPortalWebDialog::GetDialogSize(gfx::Size* size) const { | |
77 *size = GetPortalDialogSize(); | |
78 } | |
79 | |
80 std::string NetworkPortalWebDialog::GetDialogArgs() const { | |
81 return std::string(); | |
82 } | |
83 | |
84 bool NetworkPortalWebDialog::CanResizeDialog() const { | |
85 return false; | |
86 } | |
87 | |
88 void NetworkPortalWebDialog::OnDialogClosed(const std::string& json_retval) { | |
89 delete this; | |
90 } | |
91 | |
92 void NetworkPortalWebDialog::OnCloseContents(content::WebContents* /* source */, | |
93 bool* out_close_dialog) { | |
94 if (out_close_dialog) | |
95 *out_close_dialog = true; | |
96 } | |
97 | |
98 bool NetworkPortalWebDialog::ShouldShowDialogTitle() const { | |
99 return true; | |
100 } | |
101 | |
102 } // namespace chromeos | |
OLD | NEW |