blob: e2fc24988dfc91f187fa8933520eecc570b2fa47 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/views/importer_lock_view.h"
#include "app/l10n_util.h"
#include "chrome/browser/importer/importer.h"
#include "chrome/browser/views/standard_layout.h"
#include "grit/chromium_strings.h"
#include "grit/generated_resources.h"
#include "grit/locale_settings.h"
#include "views/controls/label.h"
#include "views/window/window.h"
using views::ColumnSet;
using views::GridLayout;
// Default size of the dialog window.
static const int kDefaultWindowWidth = 320;
static const int kDefaultWindowHeight = 100;
ImporterLockView::ImporterLockView(ImporterHost* host)
: description_label_(NULL),
importer_host_(host) {
description_label_ = new views::Label(
l10n_util::GetString(IDS_IMPORTER_LOCK_TEXT));
description_label_->SetMultiLine(true);
description_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
AddChildView(description_label_);
}
ImporterLockView::~ImporterLockView() {
}
gfx::Size ImporterLockView::GetPreferredSize() {
return gfx::Size(views::Window::GetLocalizedContentsSize(
IDS_IMPORTLOCK_DIALOG_WIDTH_CHARS,
IDS_IMPORTLOCK_DIALOG_HEIGHT_LINES));
}
void ImporterLockView::Layout() {
description_label_->SetBounds(kPanelHorizMargin, kPanelVertMargin,
width() - 2 * kPanelHorizMargin,
height() - 2 * kPanelVertMargin);
}
std::wstring ImporterLockView::GetDialogButtonLabel(
MessageBoxFlags::DialogButton button) const {
if (button == MessageBoxFlags::DIALOGBUTTON_OK) {
return l10n_util::GetString(IDS_IMPORTER_LOCK_OK);
} else if (button == MessageBoxFlags::DIALOGBUTTON_CANCEL) {
return l10n_util::GetString(IDS_IMPORTER_LOCK_CANCEL);
}
return std::wstring();
}
bool ImporterLockView::IsModal() const {
return true;
}
std::wstring ImporterLockView::GetWindowTitle() const {
return l10n_util::GetString(IDS_IMPORTER_LOCK_TITLE);
}
bool ImporterLockView::Accept() {
MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod(
importer_host_, &ImporterHost::OnLockViewEnd, true));
return true;
}
bool ImporterLockView::Cancel() {
MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod(
importer_host_, &ImporterHost::OnLockViewEnd, false));
return true;
}
views::View* ImporterLockView::GetContentsView() {
return this;
}
|