blob: 33e2b71355e03d27744dc195f8dc238e2c38347b (
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
|
// Copyright (c) 2013 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 "ui/keyboard/keyboard_controller_proxy.h"
#include "content/public/browser/site_instance.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_delegate.h"
#include "content/public/browser/web_contents_observer.h"
#include "content/public/browser/web_contents_view.h"
#include "ui/aura/window.h"
#include "ui/keyboard/keyboard_constants.h"
namespace {
// The WebContentsDelegate for the keyboard.
// The delegate deletes itself when the keyboard is destroyed.
class KeyboardContentsDelegate : public content::WebContentsDelegate,
public content::WebContentsObserver {
public:
KeyboardContentsDelegate() {}
virtual ~KeyboardContentsDelegate() {}
private:
// Overridden from content::WebContentsDelegate:
virtual content::WebContents* OpenURLFromTab(
content::WebContents* source,
const content::OpenURLParams& params) OVERRIDE {
source->GetController().LoadURL(
params.url, params.referrer, params.transition, params.extra_headers);
Observe(source);
return source;
}
// Overridden from content::WebContentsObserver:
virtual void WebContentsDestroyed(content::WebContents* contents) OVERRIDE {
delete this;
}
DISALLOW_COPY_AND_ASSIGN(KeyboardContentsDelegate);
};
} // namespace
namespace keyboard {
KeyboardControllerProxy::KeyboardControllerProxy() {
}
KeyboardControllerProxy::~KeyboardControllerProxy() {
}
aura::Window* KeyboardControllerProxy::GetKeyboardWindow() {
if (!keyboard_contents_) {
content::BrowserContext* context = GetBrowserContext();
GURL url(kKeyboardWebUIURL);
keyboard_contents_.reset(content::WebContents::Create(
content::WebContents::CreateParams(context,
content::SiteInstance::CreateForURL(context, url))));
keyboard_contents_->SetDelegate(new KeyboardContentsDelegate);
SetupWebContents(keyboard_contents_.get());
content::OpenURLParams params(url,
content::Referrer(),
SINGLETON_TAB,
content::PAGE_TRANSITION_AUTO_TOPLEVEL,
false);
keyboard_contents_->OpenURL(params);
}
return keyboard_contents_->GetView()->GetNativeView();
}
void KeyboardControllerProxy::ShowKeyboardContainer(aura::Window* container) {
container->Show();
}
void KeyboardControllerProxy::HideKeyboardContainer(aura::Window* container) {
container->Hide();
}
void KeyboardControllerProxy::SetupWebContents(content::WebContents* contents) {
}
} // namespace keyboard
|