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

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

Issue 7256001: Fix a few issues with Chrome-in-Views-Desktop: (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 6 months 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
Property Changes:
Added: svn:eol-style
+ LF
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 "views/focus/focus_manager.h"
16 #include "views/layout/fill_layout.h"
17 #include "views/widget/native_widget_views.h"
18
19 ////////////////////////////////////////////////////////////////////////////////
20 // NativeTabContentsContainerViews, public:
21
22 NativeTabContentsContainerViews::NativeTabContentsContainerViews(
23 TabContentsContainer* container)
24 : container_(container) {
25 set_id(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW);
26 SetLayoutManager(new views::FillLayout);
27 }
28
29 NativeTabContentsContainerViews::~NativeTabContentsContainerViews() {
30 }
31
32 ////////////////////////////////////////////////////////////////////////////////
33 // NativeTabContentsContainerViews, NativeTabContentsContainer overrides:
34
35 void NativeTabContentsContainerViews::AttachContents(TabContents* contents) {
36 TabContentsViewViews* widget =
37 static_cast<TabContentsViewViews*>(contents->view());
38 views::NativeWidgetViews* nwv =
39 static_cast<views::NativeWidgetViews*>(widget->native_widget());
40 AddChildView(nwv->GetView());
41 Layout();
42 }
43
44 void NativeTabContentsContainerViews::DetachContents(TabContents* contents) {
45 TabContentsViewViews* widget =
46 static_cast<TabContentsViewViews*>(contents->view());
47 views::NativeWidgetViews* nwv =
48 static_cast<views::NativeWidgetViews*>(widget->native_widget());
49 RemoveChildView(nwv->GetView());
50 }
51
52 void NativeTabContentsContainerViews::SetFastResize(bool fast_resize) {
53 }
54
55 void NativeTabContentsContainerViews::RenderViewHostChanged(
56 RenderViewHost* old_host,
57 RenderViewHost* new_host) {
58 // If we are focused, we need to pass the focus to the new RenderViewHost.
59 if (GetFocusManager()->GetFocusedView() == this)
60 OnFocus();
61 }
62
63 views::View* NativeTabContentsContainerViews::GetView() {
64 return this;
65 }
66
67 void NativeTabContentsContainerViews::TabContentsFocused(
68 TabContents* tab_contents) {
69 views::FocusManager* focus_manager = GetFocusManager();
70 if (!focus_manager) {
71 NOTREACHED();
72 return;
73 }
74 focus_manager->SetFocusedView(this);
75 }
76
77 ////////////////////////////////////////////////////////////////////////////////
78 // NativeTabContentsContainerWin, views::View overrides:
79
80 bool NativeTabContentsContainerViews::SkipDefaultKeyEventProcessing(
81 const views::KeyEvent& e) {
82 // Don't look-up accelerators or tab-traversal if we are showing a non-crashed
83 // TabContents.
84 // We'll first give the page a chance to process the key events. If it does
85 // not process them, they'll be returned to us and we'll treat them as
86 // accelerators then.
87 return container_->tab_contents() &&
88 !container_->tab_contents()->is_crashed();
89 }
90
91 bool NativeTabContentsContainerViews::IsFocusable() const {
92 // We need to be focusable when our contents is not a view hierarchy, as
93 // clicking on the contents needs to focus us.
94 return container_->tab_contents() != NULL;
95 }
96
97 void NativeTabContentsContainerViews::OnFocus() {
98 if (container_->tab_contents())
99 container_->tab_contents()->Focus();
100 }
101
102 void NativeTabContentsContainerViews::RequestFocus() {
103 // This is a hack to circumvent the fact that a the OnFocus() method is not
104 // invoked when RequestFocus() is called on an already focused view.
105 // The TabContentsContainer is the view focused when the TabContents has
106 // focus. When switching between from one tab that has focus to another tab
107 // that should also have focus, RequestFocus() is invoked one the
108 // TabContentsContainer. In order to make sure OnFocus() is invoked we need
109 // to clear the focus before hands.
110 {
111 // Disable notifications. Clear focus will assign the focus to the main
112 // browser window. Because this change of focus was not user requested,
113 // don't send it to listeners.
114 views::AutoNativeNotificationDisabler local_notification_disabler;
115 GetFocusManager()->ClearFocus();
116 }
117 View::RequestFocus();
118 }
119
120 void NativeTabContentsContainerViews::AboutToRequestFocusFromTabTraversal(
121 bool reverse) {
122 container_->tab_contents()->FocusThroughTabTraversal(reverse);
123 }
124
125 void NativeTabContentsContainerViews::GetAccessibleState(
126 ui::AccessibleViewState* state) {
127 state->role = ui::AccessibilityTypes::ROLE_GROUPING;
128 }
129
130 gfx::NativeViewAccessible
131 NativeTabContentsContainerViews::GetNativeViewAccessible() {
132 return View::GetNativeViewAccessible();
133 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698