Check USB device path access when prompting users to select a device.
[chromium-blink-merge.git] / chrome / browser / chromeos / net / network_portal_web_dialog.cc
blobfd14550c7c8166e92c8cf7b303eccb028a4086fd
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"
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/geometry/size.h"
14 #include "ui/views/widget/widget.h"
15 #include "url/gurl.h"
17 namespace {
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());
32 display_size =
33 gfx::Size(display_size.width() * kNetworkPortalWebDialogWidthFraction,
34 display_size.height() * kNetworkPortalWebDialogHeightFraction);
36 return display_size;
39 } // namespace
41 namespace chromeos {
43 NetworkPortalWebDialog::NetworkPortalWebDialog(
44 base::WeakPtr<NetworkPortalNotificationController> controller)
45 : controller_(controller), widget_(nullptr) {
48 NetworkPortalWebDialog::~NetworkPortalWebDialog() {
49 if (controller_)
50 controller_->OnDialogDestroyed(this);
53 void NetworkPortalWebDialog::Close() {
54 if (widget_)
55 widget_->Close();
58 void NetworkPortalWebDialog::SetWidget(views::Widget* widget) {
59 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 {
84 return std::string();
87 bool NetworkPortalWebDialog::CanResizeDialog() const {
88 return false;
91 void NetworkPortalWebDialog::OnDialogClosed(const std::string& json_retval) {
92 delete this;
95 void NetworkPortalWebDialog::OnCloseContents(content::WebContents* /* source */,
96 bool* out_close_dialog) {
97 if (out_close_dialog)
98 *out_close_dialog = true;
101 bool NetworkPortalWebDialog::ShouldShowDialogTitle() const {
102 return true;
105 } // namespace chromeos