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

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

Issue 8964001: views: Convert IsFocusable() to just focusable() since it's just a simple accessor. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years 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
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/tab_contents/native_tab_contents_container_aur a.h" 5 #include "chrome/browser/ui/views/tab_contents/native_tab_contents_container_aur a.h"
6 6
7 #include "chrome/browser/ui/view_ids.h" 7 #include "chrome/browser/ui/view_ids.h"
8 #include "chrome/browser/ui/views/tab_contents/tab_contents_container.h" 8 #include "chrome/browser/ui/views/tab_contents/tab_contents_container.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/browser/tab_contents/interstitial_page.h" 10 #include "content/browser/tab_contents/interstitial_page.h"
11 #include "content/browser/tab_contents/tab_contents.h" 11 #include "content/browser/tab_contents/tab_contents.h"
12 #include "ui/aura/window.h" 12 #include "ui/aura/window.h"
13 #include "ui/base/accessibility/accessible_view_state.h" 13 #include "ui/base/accessibility/accessible_view_state.h"
14 #include "ui/views/focus/focus_manager.h" 14 #include "ui/views/focus/focus_manager.h"
15 #include "ui/views/focus/widget_focus_manager.h" 15 #include "ui/views/focus/widget_focus_manager.h"
16 #include "ui/views/views_delegate.h" 16 #include "ui/views/views_delegate.h"
17 17
18 //////////////////////////////////////////////////////////////////////////////// 18 ////////////////////////////////////////////////////////////////////////////////
19 // NativeTabContentsContainerAura, public: 19 // NativeTabContentsContainerAura, public:
20 20
21 NativeTabContentsContainerAura::NativeTabContentsContainerAura( 21 NativeTabContentsContainerAura::NativeTabContentsContainerAura(
22 TabContentsContainer* container) 22 TabContentsContainer* container)
23 : container_(container) { 23 : container_(container) {
24 set_id(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW); 24 set_id(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW);
25 // We need to be focusable when our contents is not a view hierarchy, as
26 // clicking on the contents needs to focus us.
27 set_focusable(container_->tab_contents() != NULL);
25 } 28 }
26 29
27 NativeTabContentsContainerAura::~NativeTabContentsContainerAura() { 30 NativeTabContentsContainerAura::~NativeTabContentsContainerAura() {
28 } 31 }
29 32
30 //////////////////////////////////////////////////////////////////////////////// 33 ////////////////////////////////////////////////////////////////////////////////
31 // NativeTabContentsContainerAura, NativeTabContentsContainer overrides: 34 // NativeTabContentsContainerAura, NativeTabContentsContainer overrides:
32 35
33 void NativeTabContentsContainerAura::AttachContents(TabContents* contents) { 36 void NativeTabContentsContainerAura::AttachContents(TabContents* contents) {
34 // We need to register the tab contents window with the BrowserContainer so 37 // We need to register the tab contents window with the BrowserContainer so
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 const views::KeyEvent& e) { 90 const views::KeyEvent& e) {
88 // Don't look-up accelerators or tab-traversal if we are showing a non-crashed 91 // Don't look-up accelerators or tab-traversal if we are showing a non-crashed
89 // TabContents. 92 // TabContents.
90 // We'll first give the page a chance to process the key events. If it does 93 // 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 94 // not process them, they'll be returned to us and we'll treat them as
92 // accelerators then. 95 // accelerators then.
93 return container_->tab_contents() && 96 return container_->tab_contents() &&
94 !container_->tab_contents()->is_crashed(); 97 !container_->tab_contents()->is_crashed();
95 } 98 }
96 99
97 bool NativeTabContentsContainerAura::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;
Ben Goodger (Google) 2011/12/15 21:21:41 But can the TabContents become NULL at some point
101 }
102
103 void NativeTabContentsContainerAura::OnFocus() { 100 void NativeTabContentsContainerAura::OnFocus() {
104 if (container_->tab_contents()) 101 if (container_->tab_contents())
105 container_->tab_contents()->Focus(); 102 container_->tab_contents()->Focus();
106 } 103 }
107 104
108 void NativeTabContentsContainerAura::RequestFocus() { 105 void NativeTabContentsContainerAura::RequestFocus() {
109 // This is a hack to circumvent the fact that a the OnFocus() method is not 106 // 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. 107 // invoked when RequestFocus() is called on an already focused view.
111 // The TabContentsContainer is the view focused when the TabContents has 108 // The TabContentsContainer is the view focused when the TabContents has
112 // focus. When switching between from one tab that has focus to another tab 109 // focus. When switching between from one tab that has focus to another tab
(...skipping 28 matching lines...) Expand all
141 } 138 }
142 139
143 //////////////////////////////////////////////////////////////////////////////// 140 ////////////////////////////////////////////////////////////////////////////////
144 // NativeTabContentsContainer, public: 141 // NativeTabContentsContainer, public:
145 142
146 // static 143 // static
147 NativeTabContentsContainer* NativeTabContentsContainer::CreateNativeContainer( 144 NativeTabContentsContainer* NativeTabContentsContainer::CreateNativeContainer(
148 TabContentsContainer* container) { 145 TabContentsContainer* container) {
149 return new NativeTabContentsContainerAura(container); 146 return new NativeTabContentsContainerAura(container);
150 } 147 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698