This source file includes following definitions.
- CalculateSize
#include "chrome/browser/chromeos/app_mode/certificate_manager_dialog.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/chromeos/login/helper.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/ui/browser_dialogs.h"
#include "chrome/common/url_constants.h"
#include "content/public/browser/browser_thread.h"
#include "grit/generated_resources.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/gfx/rect.h"
#include "ui/gfx/size.h"
#include "ui/views/controls/webview/web_dialog_view.h"
namespace {
const int kCertificateManagerDialogReasonableWidth = 712;
const int kCertificateManagerDialogReasonableHeight = 412;
const float kCertificateManagerDialogReasonableWidthRatio = 0.4f;
const float kCertificateManagerDialogReasonableHeightRatio = 0.4f;
int CalculateSize(int screen_size, int min_comfortable, float desired_ratio) {
int desired_size = static_cast<int>(desired_ratio * screen_size);
desired_size = std::max(min_comfortable, desired_size);
return std::min(screen_size, desired_size);
}
}
namespace chromeos {
CertificateManagerDialog::CertificateManagerDialog(
Profile* profile,
LoginWebDialog::Delegate* delegate,
gfx::NativeWindow window)
: LoginWebDialog(profile,
delegate,
window,
base::string16(),
GURL(chrome::kChromeUICertificateManagerDialogURL),
LoginWebDialog::STYLE_BUBBLE) {
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
gfx::Rect screen_bounds(chromeos::CalculateScreenBounds(gfx::Size()));
SetDialogSize(CalculateSize(screen_bounds.width(),
kCertificateManagerDialogReasonableWidth,
kCertificateManagerDialogReasonableWidthRatio),
CalculateSize(screen_bounds.height(),
kCertificateManagerDialogReasonableHeight,
kCertificateManagerDialogReasonableHeightRatio));
SetDialogTitle(l10n_util::GetStringUTF16(IDS_CERTIFICATE_MANAGER_TITLE));
}
CertificateManagerDialog::~CertificateManagerDialog() {
}
}