blob: e40749eda4e81392c1248ccc7af2189e70e1fad9 (
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
81
82
83
84
85
86
87
88
89
90
|
// Copyright (c) 2012 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/ui/views/keyboard_overlay_delegate.h"
#include <algorithm>
#include "base/memory/scoped_ptr.h"
#include "base/utf_string_conversions.h"
#include "chrome/browser/chromeos/input_method/input_method_manager.h"
#include "chrome/browser/ui/views/html_dialog_view.h"
#include "chrome/browser/ui/webui/html_dialog_ui.h"
#include "chrome/common/url_constants.h"
#include "grit/generated_resources.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/gfx/screen.h"
#include "ui/views/widget/widget.h"
using content::WebContents;
using content::WebUIMessageHandler;
namespace {
const int kBaseWidth = 1252;
const int kBaseHeight = 516;
const int kHorizontalMargin = 28;
} // namespace
KeyboardOverlayDelegate::KeyboardOverlayDelegate(const string16& title)
: title_(title),
view_(NULL) {
}
KeyboardOverlayDelegate::~KeyboardOverlayDelegate() {
}
ui::ModalType KeyboardOverlayDelegate::GetDialogModalType() const {
return ui::MODAL_TYPE_SYSTEM;
}
string16 KeyboardOverlayDelegate::GetDialogTitle() const {
return title_;
}
GURL KeyboardOverlayDelegate::GetDialogContentURL() const {
std::string url_string(chrome::kChromeUIKeyboardOverlayURL);
return GURL(url_string);
}
void KeyboardOverlayDelegate::GetWebUIMessageHandlers(
std::vector<WebUIMessageHandler*>* handlers) const {
}
void KeyboardOverlayDelegate::GetDialogSize(
gfx::Size* size) const {
using std::min;
DCHECK(view_);
gfx::Rect rect = gfx::Screen::GetMonitorAreaNearestWindow(
view_->GetWidget()->GetNativeView());
const int width = min(kBaseWidth, rect.width() - kHorizontalMargin);
const int height = width * kBaseHeight / kBaseWidth;
size->SetSize(width, height);
}
std::string KeyboardOverlayDelegate::GetDialogArgs() const {
return "[]";
}
void KeyboardOverlayDelegate::OnDialogClosed(
const std::string& json_retval) {
// Re-enable Shift+Alt. crosbug.com/17208.
chromeos::input_method::InputMethodManager::GetInstance()->EnableHotkeys();
delete this;
return;
}
void KeyboardOverlayDelegate::OnCloseContents(WebContents* source,
bool* out_close_dialog) {
}
bool KeyboardOverlayDelegate::ShouldShowDialogTitle() const {
return false;
}
bool KeyboardOverlayDelegate::HandleContextMenu(
const content::ContextMenuParams& params) {
return true;
}
|