proxy_settings_dialog.cc revision 201ade2fbba22bfb27ae029f4d23fca6ded109a0
1// Copyright (c) 2010 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 "gfx/rect.h" 9#include "gfx/size.h" 10 11namespace { 12 13// Hints for size of proxy settings dialog. 14const int kProxySettingsDialogReasonableWidth = 750; 15const int kProxySettingsDialogReasonableHeight = 550; 16const float kProxySettingsDialogReasonableWidthRatio = 0.4f; 17const float kProxySettingsDialogReasonableHeightRatio = 0.4f; 18 19const char kProxySettingsURL[] = "chrome://settings/proxy?menu=off"; 20 21int calculate_size(int screen_size, int min_comfortable, float desired_ratio) { 22 int desired_size = static_cast<int>(desired_ratio * screen_size); 23 desired_size = std::max(min_comfortable, desired_size); 24 return std::min(screen_size, desired_size); 25} 26 27} // namespace 28 29namespace chromeos { 30 31ProxySettingsDialog::ProxySettingsDialog(LoginHtmlDialog::Delegate* delegate, 32 gfx::NativeWindow window) 33 : LoginHtmlDialog( 34 delegate, 35 window, 36 std::wstring(), 37 GURL(kProxySettingsURL), 38 LoginHtmlDialog::STYLE_BUBBLE) { 39 gfx::Rect screen_bounds(chromeos::CalculateScreenBounds(gfx::Size())); 40 SetDialogSize(calculate_size(screen_bounds.width(), 41 kProxySettingsDialogReasonableWidth, 42 kProxySettingsDialogReasonableWidthRatio), 43 calculate_size(screen_bounds.height(), 44 kProxySettingsDialogReasonableHeight, 45 kProxySettingsDialogReasonableHeightRatio)); 46} 47 48} // namespace chromeos 49