Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / browser / chromeos / app_mode / certificate_manager_dialog.cc
blob7546ae30ee31a657d87cd4fa3d5ab79beab3e6f0
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/app_mode/certificate_manager_dialog.h"
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/geometry/rect.h"
16 #include "ui/gfx/geometry/size.h"
17 #include "ui/views/controls/webview/web_dialog_view.h"
19 namespace {
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;
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);
33 } // namespace
35 namespace chromeos {
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 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
48 gfx::Rect screen_bounds(chromeos::CalculateScreenBounds(gfx::Size()));
49 SetDialogSize(CalculateSize(screen_bounds.width(),
50 kCertificateManagerDialogReasonableWidth,
51 kCertificateManagerDialogReasonableWidthRatio),
52 CalculateSize(screen_bounds.height(),
53 kCertificateManagerDialogReasonableHeight,
54 kCertificateManagerDialogReasonableHeightRatio));
56 SetDialogTitle(l10n_util::GetStringUTF16(IDS_CERTIFICATE_MANAGER_TITLE));
59 CertificateManagerDialog::~CertificateManagerDialog() {
63 } // namespace chromeos