• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2011 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/login/proxy_settings_dialog.h"
6 
7 #include "chrome/browser/chromeos/login/helper.h"
8 #include "chrome/common/url_constants.h"
9 #include "ui/gfx/rect.h"
10 #include "ui/gfx/size.h"
11 
12 namespace {
13 
14 // Hints for size of proxy settings dialog.
15 const int kProxySettingsDialogReasonableWidth = 750;
16 const int kProxySettingsDialogReasonableHeight = 550;
17 const float kProxySettingsDialogReasonableWidthRatio = 0.4f;
18 const float kProxySettingsDialogReasonableHeightRatio = 0.4f;
19 
CalculateSize(int screen_size,int min_comfortable,float desired_ratio)20 int CalculateSize(int screen_size, int min_comfortable, float desired_ratio) {
21   int desired_size = static_cast<int>(desired_ratio * screen_size);
22   desired_size = std::max(min_comfortable, desired_size);
23   return std::min(screen_size, desired_size);
24 }
25 
26 }  // namespace
27 
28 namespace chromeos {
29 
ProxySettingsDialog(LoginHtmlDialog::Delegate * delegate,gfx::NativeWindow window)30 ProxySettingsDialog::ProxySettingsDialog(LoginHtmlDialog::Delegate* delegate,
31                                          gfx::NativeWindow window)
32     : LoginHtmlDialog(
33           delegate,
34           window,
35           std::wstring(),
36           GURL(chrome::kChromeUIProxySettingsURL),
37           LoginHtmlDialog::STYLE_BUBBLE) {
38   gfx::Rect screen_bounds(chromeos::CalculateScreenBounds(gfx::Size()));
39   SetDialogSize(CalculateSize(screen_bounds.width(),
40                                kProxySettingsDialogReasonableWidth,
41                                kProxySettingsDialogReasonableWidthRatio),
42                 CalculateSize(screen_bounds.height(),
43                                kProxySettingsDialogReasonableHeight,
44                                kProxySettingsDialogReasonableHeightRatio));
45 }
46 
47 }  // namespace chromeos
48