OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/ui/views/dom_view.h" | 5 #include "chrome/browser/ui/views/dom_view.h" |
6 | 6 |
7 #include "chrome/browser/profiles/profile.h" | 7 #include "chrome/browser/profiles/profile.h" |
8 #include "chrome/browser/renderer_preferences_util.h" | 8 #include "chrome/browser/renderer_preferences_util.h" |
9 #include "chrome/browser/ui/views/tab_contents/tab_contents_view_views.h" | 9 #include "chrome/browser/ui/views/tab_contents/tab_contents_view_views.h" |
10 #include "content/public/browser/web_contents.h" | 10 #include "content/public/browser/web_contents.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 | 22 |
23 DOMView::~DOMView() { | 23 DOMView::~DOMView() { |
24 if (native_view()) | 24 if (native_view()) |
25 Detach(); | 25 Detach(); |
26 } | 26 } |
27 | 27 |
28 std::string DOMView::GetClassName() const { | 28 std::string DOMView::GetClassName() const { |
29 return kViewClassName; | 29 return kViewClassName; |
30 } | 30 } |
31 | 31 |
32 bool DOMView::Init(Profile* profile, SiteInstance* instance) { | 32 bool DOMView::Init(Profile* profile, content::SiteInstance* instance) { |
33 if (initialized_) | 33 if (initialized_) |
34 return true; | 34 return true; |
35 | 35 |
36 initialized_ = true; | 36 initialized_ = true; |
37 WebContents* web_contents = CreateTabContents(profile, instance); | 37 WebContents* web_contents = CreateTabContents(profile, instance); |
38 dom_contents_.reset(new TabContentsWrapper(web_contents)); | 38 dom_contents_.reset(new TabContentsWrapper(web_contents)); |
39 | 39 |
40 renderer_preferences_util::UpdateFromSystemSettings( | 40 renderer_preferences_util::UpdateFromSystemSettings( |
41 web_contents->GetMutableRendererPrefs(), profile); | 41 web_contents->GetMutableRendererPrefs(), profile); |
42 | 42 |
43 // Attach the native_view now if the view is already added to Widget. | 43 // Attach the native_view now if the view is already added to Widget. |
44 if (GetWidget()) | 44 if (GetWidget()) |
45 AttachTabContents(); | 45 AttachTabContents(); |
46 | 46 |
47 return true; | 47 return true; |
48 } | 48 } |
49 | 49 |
50 WebContents* DOMView::CreateTabContents(Profile* profile, | 50 WebContents* DOMView::CreateTabContents(Profile* profile, |
51 SiteInstance* instance) { | 51 content::SiteInstance* instance) { |
52 return WebContents::Create(profile, instance, MSG_ROUTING_NONE, NULL, NULL); | 52 return WebContents::Create(profile, instance, MSG_ROUTING_NONE, NULL, NULL); |
53 } | 53 } |
54 | 54 |
55 void DOMView::LoadURL(const GURL& url) { | 55 void DOMView::LoadURL(const GURL& url) { |
56 DCHECK(initialized_); | 56 DCHECK(initialized_); |
57 dom_contents_->web_contents()->GetController().LoadURL( | 57 dom_contents_->web_contents()->GetController().LoadURL( |
58 url, content::Referrer(), content::PAGE_TRANSITION_START_PAGE, | 58 url, content::Referrer(), content::PAGE_TRANSITION_START_PAGE, |
59 std::string()); | 59 std::string()); |
60 } | 60 } |
61 | 61 |
(...skipping 15 matching lines...) Expand all Loading... |
77 views::NativeViewHost::ViewHierarchyChanged(is_add, parent, child); | 77 views::NativeViewHost::ViewHierarchyChanged(is_add, parent, child); |
78 if (is_add && GetWidget() && !native_view() && dom_contents_.get()) | 78 if (is_add && GetWidget() && !native_view() && dom_contents_.get()) |
79 AttachTabContents(); | 79 AttachTabContents(); |
80 else if (!is_add && child == this && native_view()) | 80 else if (!is_add && child == this && native_view()) |
81 Detach(); | 81 Detach(); |
82 } | 82 } |
83 | 83 |
84 void DOMView::AttachTabContents() { | 84 void DOMView::AttachTabContents() { |
85 Attach(dom_contents_->web_contents()->GetNativeView()); | 85 Attach(dom_contents_->web_contents()->GetNativeView()); |
86 } | 86 } |
OLD | NEW |