Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(774)

Side by Side Diff: chrome/browser/chromeos/net/network_portal_web_dialog.cc

Issue 750153002: ChromeOS: bypass proxy for captive portal authorization. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased. Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 "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/size.h"
14 #include "ui/views/widget/widget.h"
15 #include "url/gurl.h"
16
17 namespace {
18
19 const float kNetworkPortalWebDialogWidthFraction = .8;
20 const float kNetworkPortalWebDialogHeightFraction = .8;
21
22 gfx::Size GetPortalDialogSize() {
23 const gfx::Display display = ash::Shell::GetScreen()->GetPrimaryDisplay();
24
25 gfx::Size display_size = display.size();
26
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());
30 }
31
32 display_size =
33 gfx::Size(display_size.width() * kNetworkPortalWebDialogWidthFraction,
34 display_size.height() * kNetworkPortalWebDialogHeightFraction);
35
36 return display_size;
37 }
38
39 } // namespace
40
41 namespace chromeos {
42
43 NetworkPortalWebDialog::NetworkPortalWebDialog(
44 base::WeakPtr<NetworkPortalNotificationController> controller)
45 : controller_(controller), widget_(nullptr) {
46 }
47
48 NetworkPortalWebDialog::~NetworkPortalWebDialog() {
49 if (controller_)
50 controller_->OnDialogDestroyed(this);
51 }
52
53 void NetworkPortalWebDialog::Close() {
54 if (widget_)
55 widget_->Close();
56 }
57
58 void NetworkPortalWebDialog::SetWidget(views::Widget* widget) {
59 widget_ = widget;
60 }
61
62 ui::ModalType NetworkPortalWebDialog::GetDialogModalType() const {
63 return ui::MODAL_TYPE_SYSTEM;
64 }
65
66 base::string16 NetworkPortalWebDialog::GetDialogTitle() const {
67 return l10n_util::GetStringUTF16(
68 IDS_CAPTIVE_PORTAL_AUTHORIZATION_DIALOG_NAME);
69 }
70
71 GURL NetworkPortalWebDialog::GetDialogContentURL() const {
72 return GURL(captive_portal::CaptivePortalDetector::kDefaultURL);
73 }
74
75 void NetworkPortalWebDialog::GetWebUIMessageHandlers(
76 std::vector<content::WebUIMessageHandler*>* handlers) const {
77 }
78
79 void NetworkPortalWebDialog::GetDialogSize(gfx::Size* size) const {
80 *size = GetPortalDialogSize();
81 }
82
83 std::string NetworkPortalWebDialog::GetDialogArgs() const {
84 return std::string();
85 }
86
87 bool NetworkPortalWebDialog::CanResizeDialog() const {
88 return false;
89 }
90
91 void NetworkPortalWebDialog::OnDialogClosed(const std::string& json_retval) {
92 delete this;
93 }
94
95 void NetworkPortalWebDialog::OnCloseContents(content::WebContents* /* source */,
96 bool* out_close_dialog) {
97 if (out_close_dialog)
98 *out_close_dialog = true;
99 }
100
101 bool NetworkPortalWebDialog::ShouldShowDialogTitle() const {
102 return true;
103 }
104
105 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/net/network_portal_web_dialog.h ('k') | chrome/chrome_browser_chromeos.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698