OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/views/dom_view.h" | 5 #include "chrome/browser/views/dom_view.h" |
6 | 6 |
7 #include "chrome/browser/tab_contents/tab_contents.h" | 7 #include "chrome/browser/tab_contents/tab_contents.h" |
8 #include "ipc/ipc_message.h" | 8 #include "ipc/ipc_message.h" |
9 #include "views/focus/focus_manager.h" | 9 #include "views/focus/focus_manager.h" |
10 | 10 |
(...skipping 13 matching lines...) Expand all Loading... |
24 initialized_ = true; | 24 initialized_ = true; |
25 tab_contents_.reset(CreateTabContents(profile, instance)); | 25 tab_contents_.reset(CreateTabContents(profile, instance)); |
26 // Attach the native_view now if the view is already added to Widget. | 26 // Attach the native_view now if the view is already added to Widget. |
27 if (GetWidget()) | 27 if (GetWidget()) |
28 Attach(tab_contents_->GetNativeView()); | 28 Attach(tab_contents_->GetNativeView()); |
29 return true; | 29 return true; |
30 } | 30 } |
31 | 31 |
32 TabContents* DOMView::CreateTabContents(Profile* profile, | 32 TabContents* DOMView::CreateTabContents(Profile* profile, |
33 SiteInstance* instance) { | 33 SiteInstance* instance) { |
34 return new TabContents(profile, instance, MSG_ROUTING_NONE, NULL); | 34 return new TabContents(profile, instance, MSG_ROUTING_NONE, NULL, NULL); |
35 } | 35 } |
36 | 36 |
37 void DOMView::LoadURL(const GURL& url) { | 37 void DOMView::LoadURL(const GURL& url) { |
38 DCHECK(initialized_); | 38 DCHECK(initialized_); |
39 tab_contents_->controller().LoadURL(url, GURL(), PageTransition::START_PAGE); | 39 tab_contents_->controller().LoadURL(url, GURL(), PageTransition::START_PAGE); |
40 } | 40 } |
41 | 41 |
42 bool DOMView::SkipDefaultKeyEventProcessing(const views::KeyEvent& e) { | 42 bool DOMView::SkipDefaultKeyEventProcessing(const views::KeyEvent& e) { |
43 // Don't move the focus to the next view when tab is pressed, we want the | 43 // Don't move the focus to the next view when tab is pressed, we want the |
44 // key event to be propagated to the render view for doing the tab traversal | 44 // key event to be propagated to the render view for doing the tab traversal |
45 // there. | 45 // there. |
46 return views::FocusManager::IsTabTraversalKeyEvent(e); | 46 return views::FocusManager::IsTabTraversalKeyEvent(e); |
47 } | 47 } |
48 | 48 |
49 void DOMView::Focus() { | 49 void DOMView::Focus() { |
50 tab_contents_->Focus(); | 50 tab_contents_->Focus(); |
51 } | 51 } |
52 | 52 |
53 void DOMView::ViewHierarchyChanged(bool is_add, views::View* parent, | 53 void DOMView::ViewHierarchyChanged(bool is_add, views::View* parent, |
54 views::View* child) { | 54 views::View* child) { |
55 // Attach the native_view when this is added to Widget if | 55 // Attach the native_view when this is added to Widget if |
56 // the native view has not been attached yet and tab_contents_ exists. | 56 // the native view has not been attached yet and tab_contents_ exists. |
57 views::NativeViewHost::ViewHierarchyChanged(is_add, parent, child); | 57 views::NativeViewHost::ViewHierarchyChanged(is_add, parent, child); |
58 if (is_add && GetWidget() && !native_view() && tab_contents_.get()) | 58 if (is_add && GetWidget() && !native_view() && tab_contents_.get()) |
59 Attach(tab_contents_->GetNativeView()); | 59 Attach(tab_contents_->GetNativeView()); |
60 else if (!is_add && child == this && native_view()) | 60 else if (!is_add && child == this && native_view()) |
61 Detach(); | 61 Detach(); |
62 } | 62 } |
OLD | NEW |