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 "url/gurl.h" | |
13 | |
14 namespace { | |
15 | |
16 const float kNetworkPortalWebDialogWidthFraction = .8; | |
17 const float kNetworkPortalWebDialogHeightFraction = .8; | |
18 | |
19 gfx::Size GetPortalDialogSize() { | |
20 const gfx::Display display = ash::Shell::GetScreen()->GetPrimaryDisplay(); | |
21 | |
22 gfx::Size display_size = display.size(); // work_area_size() ? | |
ygorshenin1
2014/11/24 15:02:09
Could you please add a TODO comment with a bug ref
Alexander Alekseev
2014/11/26 00:26:28
I've removed comment.
| |
23 | |
24 if (display.rotation() == gfx::Display::ROTATE_90 || | |
25 display.rotation() == gfx::Display::ROTATE_270) { | |
26 display_size = gfx::Size(display_size.height(), display_size.width()); | |
27 } | |
28 | |
29 display_size = | |
30 gfx::Size(display_size.width() * kNetworkPortalWebDialogWidthFraction, | |
31 display_size.height() * kNetworkPortalWebDialogHeightFraction); | |
32 | |
33 return display_size; | |
34 } | |
35 | |
36 } // namespace | |
37 | |
38 namespace chromeos { | |
39 | |
40 NetworkPortalWebDialog::NetworkPortalWebDialog( | |
41 NetworkPortalNotificationController* controller) | |
42 : controller_(controller->AsWeakPtr()), widget_(NULL) { | |
43 } | |
44 | |
45 NetworkPortalWebDialog::~NetworkPortalWebDialog() { | |
46 if (controller_) | |
47 controller_->OnDialogDestroyed(this); | |
48 } | |
49 | |
50 void NetworkPortalWebDialog::Close() { | |
51 if (widget_) | |
52 widget_->Close(); | |
53 } | |
54 | |
55 void NetworkPortalWebDialog::SetWidget(views::Widget* widget) { | |
56 widget_ = widget; | |
57 } | |
58 | |
59 ui::ModalType NetworkPortalWebDialog::GetDialogModalType() const { | |
60 return ui::MODAL_TYPE_SYSTEM; | |
61 } | |
62 | |
63 base::string16 NetworkPortalWebDialog::GetDialogTitle() const { | |
64 return base::string16(); | |
65 } | |
66 | |
67 GURL NetworkPortalWebDialog::GetDialogContentURL() const { | |
68 return GURL(captive_portal::CaptivePortalDetector::kDefaultURL); | |
69 } | |
70 | |
71 void NetworkPortalWebDialog::GetWebUIMessageHandlers( | |
72 std::vector<content::WebUIMessageHandler*>* handlers) const { | |
73 } | |
74 | |
75 void NetworkPortalWebDialog::GetDialogSize(gfx::Size* size) const { | |
76 *size = GetPortalDialogSize(); | |
77 } | |
78 | |
79 std::string NetworkPortalWebDialog::GetDialogArgs() const { | |
80 return ""; | |
ygorshenin1
2014/11/24 15:02:09
nit: s/""/string()/g
Alexander Alekseev
2014/11/26 00:26:28
Done.
| |
81 } | |
82 | |
83 bool NetworkPortalWebDialog::CanResizeDialog() const { | |
84 return false; | |
85 } | |
86 | |
87 void NetworkPortalWebDialog::OnDialogClosed(const std::string& json_retval) { | |
88 delete this; | |
89 } | |
90 | |
91 void NetworkPortalWebDialog::OnCloseContents(content::WebContents* source, | |
ygorshenin1
2014/11/24 15:02:09
nit: could you please surround |source| by /* and
Alexander Alekseev
2014/11/26 00:26:28
Done.
| |
92 bool* out_close_dialog) { | |
93 if (out_close_dialog) | |
94 *out_close_dialog = true; | |
95 } | |
96 | |
97 bool NetworkPortalWebDialog::ShouldShowDialogTitle() const { | |
98 return true; | |
99 } | |
100 | |
101 } // namespace chromeos | |
OLD | NEW |