Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(177)

Side by Side Diff: chrome/browser/ui/views/tab_contents/native_tab_contents_container_views.cc

Issue 8598024: Now that we are doing a hard-cut-over to Aura, remove a bunch of *Views based classes that are ob... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/ui/views/tab_contents/native_tab_contents_container_vie ws.h"
6
7 #include "chrome/browser/renderer_host/render_widget_host_view_views.h"
8 #include "chrome/browser/ui/view_ids.h"
9 #include "chrome/browser/ui/views/tab_contents/tab_contents_container.h"
10 #include "chrome/browser/ui/views/tab_contents/tab_contents_view_views.h"
11 #include "content/browser/renderer_host/render_widget_host_view.h"
12 #include "content/browser/tab_contents/interstitial_page.h"
13 #include "content/browser/tab_contents/tab_contents.h"
14 #include "ui/base/accessibility/accessible_view_state.h"
15 #include "ui/views/focus/focus_manager.h"
16 #include "ui/views/focus/widget_focus_manager.h"
17 #include "ui/views/layout/fill_layout.h"
18 #include "views/widget/native_widget_views.h"
19
20 ////////////////////////////////////////////////////////////////////////////////
21 // NativeTabContentsContainerViews, public:
22
23 NativeTabContentsContainerViews::NativeTabContentsContainerViews(
24 TabContentsContainer* container)
25 : container_(container) {
26 set_id(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW);
27 SetLayoutManager(new views::FillLayout);
28 }
29
30 NativeTabContentsContainerViews::~NativeTabContentsContainerViews() {
31 }
32
33 ////////////////////////////////////////////////////////////////////////////////
34 // NativeTabContentsContainerViews, NativeTabContentsContainer overrides:
35
36 void NativeTabContentsContainerViews::AttachContents(TabContents* contents) {
37 TabContentsViewViews* widget =
38 static_cast<TabContentsViewViews*>(contents->view());
39 views::NativeWidgetViews* nwv =
40 static_cast<views::NativeWidgetViews*>(widget->native_widget());
41 AddChildView(nwv->GetView());
42 Layout();
43 }
44
45 void NativeTabContentsContainerViews::DetachContents(TabContents* contents) {
46 TabContentsViewViews* widget =
47 static_cast<TabContentsViewViews*>(contents->view());
48 views::NativeWidgetViews* nwv =
49 static_cast<views::NativeWidgetViews*>(widget->native_widget());
50 RemoveChildView(nwv->GetView());
51 }
52
53 void NativeTabContentsContainerViews::SetFastResize(bool fast_resize) {
54 }
55
56 bool NativeTabContentsContainerViews::GetFastResize() const {
57 return false;
58 }
59
60 bool NativeTabContentsContainerViews::FastResizeAtLastLayout() const {
61 return false;
62 }
63
64 void NativeTabContentsContainerViews::RenderViewHostChanged(
65 RenderViewHost* old_host,
66 RenderViewHost* new_host) {
67 // If we are focused, we need to pass the focus to the new RenderViewHost.
68 if (GetFocusManager()->GetFocusedView() == this)
69 OnFocus();
70 }
71
72 views::View* NativeTabContentsContainerViews::GetView() {
73 return this;
74 }
75
76 void NativeTabContentsContainerViews::TabContentsFocused(
77 TabContents* tab_contents) {
78 // This is called from RWHVViews::OnFocus, which means
79 // the focus manager already set focus to RWHVViews, so don't
80 // Update focus manager.
81 }
82
83 ////////////////////////////////////////////////////////////////////////////////
84 // NativeTabContentsContainerWin, views::View overrides:
85
86 bool NativeTabContentsContainerViews::SkipDefaultKeyEventProcessing(
87 const views::KeyEvent& e) {
88 // Don't look-up accelerators or tab-traversal if we are showing a non-crashed
89 // TabContents.
90 // We'll first give the page a chance to process the key events. If it does
91 // not process them, they'll be returned to us and we'll treat them as
92 // accelerators then.
93 return container_->tab_contents() &&
94 !container_->tab_contents()->is_crashed();
95 }
96
97 bool NativeTabContentsContainerViews::IsFocusable() const {
98 // We need to be focusable when our contents is not a view hierarchy, as
99 // clicking on the contents needs to focus us.
100 return container_->tab_contents() != NULL;
101 }
102
103 void NativeTabContentsContainerViews::OnFocus() {
104 if (container_->tab_contents())
105 container_->tab_contents()->Focus();
106 }
107
108 void NativeTabContentsContainerViews::RequestFocus() {
109 // This is a hack to circumvent the fact that a the OnFocus() method is not
110 // invoked when RequestFocus() is called on an already focused view.
111 // The TabContentsContainer is the view focused when the TabContents has
112 // focus. When switching between from one tab that has focus to another tab
113 // that should also have focus, RequestFocus() is invoked one the
114 // TabContentsContainer. In order to make sure OnFocus() is invoked we need
115 // to clear the focus before hands.
116 {
117 // Disable notifications. Clear focus will assign the focus to the main
118 // browser window. Because this change of focus was not user requested,
119 // don't send it to listeners.
120 views::AutoNativeNotificationDisabler local_notification_disabler;
121 GetFocusManager()->ClearFocus();
122 }
123 View::RequestFocus();
124 }
125
126 void NativeTabContentsContainerViews::AboutToRequestFocusFromTabTraversal(
127 bool reverse) {
128 container_->tab_contents()->FocusThroughTabTraversal(reverse);
129 }
130
131 void NativeTabContentsContainerViews::GetAccessibleState(
132 ui::AccessibleViewState* state) {
133 state->role = ui::AccessibilityTypes::ROLE_GROUPING;
134 }
135
136 gfx::NativeViewAccessible
137 NativeTabContentsContainerViews::GetNativeViewAccessible() {
138 return View::GetNativeViewAccessible();
139 }
140
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698