blob: 864ec1ddd1e650703f3431815375c2c90ce0a079 (
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
|
// 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 "ui/views/controls/webview/webview.h"
#include "content/public/browser/browser_context.h"
#include "ipc/ipc_message.h"
#include "ui/views/controls/native/native_view_host.h"
namespace views {
////////////////////////////////////////////////////////////////////////////////
// WebView, public:
WebView::WebView(content::BrowserContext* browser_context)
: wcv_holder_(new NativeViewHost),
browser_context_(browser_context) {
Init();
}
WebView::~WebView() {
}
////////////////////////////////////////////////////////////////////////////////
// WebView, private:
void WebView::Init() {
AddChildView(wcv_holder_);
web_contents_.reset(
content::WebContents::Create(browser_context_, NULL, MSG_ROUTING_NONE,
NULL, NULL));
}
////////////////////////////////////////////////////////////////////////////////
// WebView, View overrides:
void WebView::OnBoundsChanged(const gfx::Rect& previous_bounds) {
wcv_holder_->SetSize(bounds().size());
}
void WebView::ViewHierarchyChanged(bool is_add, View* parent, View* child) {
if (is_add && child == this)
wcv_holder_->Attach(web_contents_->GetNativeView());
}
} // namespace views
|