blob: bd7f7dfc67b0303feb306b28989d4bd8e6b86be5 (
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
|
// 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/dom_view.h"
#include "chrome/browser/dom_ui/dom_ui_host.h"
DOMView::DOMView(const GURL& contents)
: contents_(contents), initialized_(false), host_(NULL) {
SetFocusable(true);
}
DOMView::~DOMView() {
if (host_) {
Detach();
host_->Destroy();
host_ = NULL;
}
}
bool DOMView::Init(Profile* profile, SiteInstance* instance) {
if (initialized_)
return true;
initialized_ = true;
// TODO(timsteele): This should use a separate factory method; e.g
// a DOMUIHostFactory rather than TabContentsFactory, because DOMView's
// should only be associated with instances of DOMUIHost.
TabContentsType type = TabContents::TypeForURL(&contents_);
TabContents* tab_contents = TabContents::CreateWithType(type, profile,
instance);
host_ = tab_contents->AsDOMUIHost();
DCHECK(host_);
views::HWNDView::Attach(host_->GetNativeView());
host_->SetupController(profile);
host_->controller()->LoadURL(contents_, GURL(), PageTransition::START_PAGE);
return true;
}
|