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/app_mode/certificate_manager_dialog.h" 6 7 #include "base/strings/utf_string_conversions.h" 8 #include "chrome/browser/chromeos/login/helper.h" 9 #include "chrome/browser/profiles/profile_manager.h" 10 #include "chrome/browser/ui/browser_dialogs.h" 11 #include "chrome/common/url_constants.h" 12 #include "chrome/grit/generated_resources.h" 13 #include "content/public/browser/browser_thread.h" 14 #include "ui/base/l10n/l10n_util.h" 15 #include "ui/gfx/rect.h" 16 #include "ui/gfx/size.h" 17 #include "ui/views/controls/webview/web_dialog_view.h" 18 19 namespace { 20 21 // Hints for size of certificate manager dialog. 22 const int kCertificateManagerDialogReasonableWidth = 712; 23 const int kCertificateManagerDialogReasonableHeight = 412; 24 const float kCertificateManagerDialogReasonableWidthRatio = 0.4f; 25 const float kCertificateManagerDialogReasonableHeightRatio = 0.4f; 26 27 int CalculateSize(int screen_size, int min_comfortable, float desired_ratio) { 28 int desired_size = static_cast<int>(desired_ratio * screen_size); 29 desired_size = std::max(min_comfortable, desired_size); 30 return std::min(screen_size, desired_size); 31 } 32 33 } // namespace 34 35 namespace chromeos { 36 37 CertificateManagerDialog::CertificateManagerDialog( 38 Profile* profile, 39 LoginWebDialog::Delegate* delegate, 40 gfx::NativeWindow window) 41 : LoginWebDialog(profile, 42 delegate, 43 window, 44 base::string16(), 45 GURL(chrome::kChromeUICertificateManagerDialogURL), 46 LoginWebDialog::STYLE_BUBBLE) { 47 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 48 49 gfx::Rect screen_bounds(chromeos::CalculateScreenBounds(gfx::Size())); 50 SetDialogSize(CalculateSize(screen_bounds.width(), 51 kCertificateManagerDialogReasonableWidth, 52 kCertificateManagerDialogReasonableWidthRatio), 53 CalculateSize(screen_bounds.height(), 54 kCertificateManagerDialogReasonableHeight, 55 kCertificateManagerDialogReasonableHeightRatio)); 56 57 SetDialogTitle(l10n_util::GetStringUTF16(IDS_CERTIFICATE_MANAGER_TITLE)); 58 } 59 60 CertificateManagerDialog::~CertificateManagerDialog() { 61 } 62 63 64 } // namespace chromeos 65