Chromium Code Reviews

Side by Side Diff: chrome/browser/views/location_bar_view.cc

Issue 214029: Adding focus to NaviteViewHost. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | | Annotate | Revision Log
« no previous file with comments | « chrome/browser/views/location_bar_view.h ('k') | views/controls/native/native_view_host.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/location_bar_view.h" 5 #include "chrome/browser/views/location_bar_view.h"
6 6
7 #if defined(OS_LINUX) 7 #if defined(OS_LINUX)
8 #include <gtk/gtk.h> 8 #include <gtk/gtk.h>
9 #endif 9 #endif
10 10
(...skipping 139 matching lines...)
150 // anything, it just toggles the visible flag. 150 // anything, it just toggles the visible flag.
151 gtk_widget_show_all(location_entry_->widget()); 151 gtk_widget_show_all(location_entry_->widget());
152 // Hide the widget. NativeViewHostGtk will make it visible again as 152 // Hide the widget. NativeViewHostGtk will make it visible again as
153 // necessary. 153 // necessary.
154 gtk_widget_hide(location_entry_->widget()); 154 gtk_widget_hide(location_entry_->widget());
155 #endif 155 #endif
156 location_entry_view_ = new views::NativeViewHost; 156 location_entry_view_ = new views::NativeViewHost;
157 location_entry_view_->SetID(VIEW_ID_AUTOCOMPLETE); 157 location_entry_view_->SetID(VIEW_ID_AUTOCOMPLETE);
158 AddChildView(location_entry_view_); 158 AddChildView(location_entry_view_);
159 location_entry_view_->set_focus_view(this); 159 location_entry_view_->set_focus_view(this);
160 location_entry_view_->set_focus_native_view(location_entry_->
161 GetFocusNativeView());
160 location_entry_view_->Attach( 162 location_entry_view_->Attach(
161 #if defined(OS_WIN) 163 #if defined(OS_WIN)
162 location_entry_->m_hWnd 164 location_entry_->m_hWnd
163 #else 165 #else
164 location_entry_->widget() 166 location_entry_->widget()
165 #endif 167 #endif
166 ); 168 );
167 169
168 AddChildView(&selected_keyword_view_); 170 AddChildView(&selected_keyword_view_);
169 selected_keyword_view_.SetFont(font_); 171 selected_keyword_view_.SetFont(font_);
(...skipping 113 matching lines...)
283 285
284 Layout(); 286 Layout();
285 SchedulePaint(); 287 SchedulePaint();
286 } 288 }
287 289
288 void LocationBarView::InvalidatePageActions() { 290 void LocationBarView::InvalidatePageActions() {
289 DeletePageActionViews(); 291 DeletePageActionViews();
290 } 292 }
291 293
292 void LocationBarView::Focus() { 294 void LocationBarView::Focus() {
293 // Focus the location entry native view. 295 // Forward the focus to the NativeViewHost that will focus the right
294 location_entry_->SetFocus(); 296 // native-view.
297 location_entry_view_->Focus();
295 } 298 }
296 299
297 void LocationBarView::SetProfile(Profile* profile) { 300 void LocationBarView::SetProfile(Profile* profile) {
298 DCHECK(profile); 301 DCHECK(profile);
299 if (profile_ != profile) { 302 if (profile_ != profile) {
300 profile_ = profile; 303 profile_ = profile;
301 location_entry_->model()->SetProfile(profile); 304 location_entry_->model()->SetProfile(profile);
302 selected_keyword_view_.set_profile(profile); 305 selected_keyword_view_.set_profile(profile);
303 keyword_hint_view_.set_profile(profile); 306 keyword_hint_view_.set_profile(profile);
304 security_image_view_.set_profile(profile); 307 security_image_view_.set_profile(profile);
(...skipping 105 matching lines...)
410 } else { 413 } else {
411 fetcher.release(); // The navigation controller will delete the fetcher. 414 fetcher.release(); // The navigation controller will delete the fetcher.
412 } 415 }
413 } 416 }
414 } 417 }
415 418
416 void LocationBarView::OnChanged() { 419 void LocationBarView::OnChanged() {
417 DoLayout(false); 420 DoLayout(false);
418 } 421 }
419 422
420 void LocationBarView::OnSetFocus() {
421 views::FocusManager* focus_manager = GetFocusManager();
422 if (!focus_manager) {
423 NOTREACHED();
424 return;
425 }
426 focus_manager->SetFocusedView(this);
427 }
428
429 SkBitmap LocationBarView::GetFavIcon() const { 423 SkBitmap LocationBarView::GetFavIcon() const {
430 DCHECK(delegate_); 424 DCHECK(delegate_);
431 DCHECK(delegate_->GetTabContents()); 425 DCHECK(delegate_->GetTabContents());
432 return delegate_->GetTabContents()->GetFavIcon(); 426 return delegate_->GetTabContents()->GetFavIcon();
433 } 427 }
434 428
435 std::wstring LocationBarView::GetTitle() const { 429 std::wstring LocationBarView::GetTitle() const {
436 DCHECK(delegate_); 430 DCHECK(delegate_);
437 DCHECK(delegate_->GetTabContents()); 431 DCHECK(delegate_->GetTabContents());
438 return UTF16ToWideHack(delegate_->GetTabContents()->GetTitle()); 432 return UTF16ToWideHack(delegate_->GetTabContents()->GetTitle());
(...skipping 887 matching lines...)
1326 } 1320 }
1327 1321
1328 int LocationBarView::PageActionVisibleCount() { 1322 int LocationBarView::PageActionVisibleCount() {
1329 int result = 0; 1323 int result = 0;
1330 for (size_t i = 0; i < page_action_image_views_.size(); i++) { 1324 for (size_t i = 0; i < page_action_image_views_.size(); i++) {
1331 if (page_action_image_views_[i]->IsVisible()) 1325 if (page_action_image_views_[i]->IsVisible())
1332 ++result; 1326 ++result;
1333 } 1327 }
1334 return result; 1328 return result;
1335 } 1329 }
OLDNEW
« no previous file with comments | « chrome/browser/views/location_bar_view.h ('k') | views/controls/native/native_view_host.h » ('j') | no next file with comments »

Powered by Google App Engine