OLD | NEW |
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...) Expand 10 before | Expand all | Expand 10 after Loading... |
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()); | |
162 location_entry_view_->Attach( | 160 location_entry_view_->Attach( |
163 #if defined(OS_WIN) | 161 #if defined(OS_WIN) |
164 location_entry_->m_hWnd | 162 location_entry_->m_hWnd |
165 #else | 163 #else |
166 location_entry_->widget() | 164 location_entry_->widget() |
167 #endif | 165 #endif |
168 ); | 166 ); |
169 | 167 |
170 AddChildView(&selected_keyword_view_); | 168 AddChildView(&selected_keyword_view_); |
171 selected_keyword_view_.SetFont(font_); | 169 selected_keyword_view_.SetFont(font_); |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 | 283 |
286 Layout(); | 284 Layout(); |
287 SchedulePaint(); | 285 SchedulePaint(); |
288 } | 286 } |
289 | 287 |
290 void LocationBarView::InvalidatePageActions() { | 288 void LocationBarView::InvalidatePageActions() { |
291 DeletePageActionViews(); | 289 DeletePageActionViews(); |
292 } | 290 } |
293 | 291 |
294 void LocationBarView::Focus() { | 292 void LocationBarView::Focus() { |
295 // Forward the focus to the NativeViewHost that will focus the right | 293 // Focus the location entry native view. |
296 // native-view. | 294 location_entry_->SetFocus(); |
297 location_entry_view_->Focus(); | |
298 } | 295 } |
299 | 296 |
300 void LocationBarView::SetProfile(Profile* profile) { | 297 void LocationBarView::SetProfile(Profile* profile) { |
301 DCHECK(profile); | 298 DCHECK(profile); |
302 if (profile_ != profile) { | 299 if (profile_ != profile) { |
303 profile_ = profile; | 300 profile_ = profile; |
304 location_entry_->model()->SetProfile(profile); | 301 location_entry_->model()->SetProfile(profile); |
305 selected_keyword_view_.set_profile(profile); | 302 selected_keyword_view_.set_profile(profile); |
306 keyword_hint_view_.set_profile(profile); | 303 keyword_hint_view_.set_profile(profile); |
307 security_image_view_.set_profile(profile); | 304 security_image_view_.set_profile(profile); |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
413 } else { | 410 } else { |
414 fetcher.release(); // The navigation controller will delete the fetcher. | 411 fetcher.release(); // The navigation controller will delete the fetcher. |
415 } | 412 } |
416 } | 413 } |
417 } | 414 } |
418 | 415 |
419 void LocationBarView::OnChanged() { | 416 void LocationBarView::OnChanged() { |
420 DoLayout(false); | 417 DoLayout(false); |
421 } | 418 } |
422 | 419 |
| 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 |
423 SkBitmap LocationBarView::GetFavIcon() const { | 429 SkBitmap LocationBarView::GetFavIcon() const { |
424 DCHECK(delegate_); | 430 DCHECK(delegate_); |
425 DCHECK(delegate_->GetTabContents()); | 431 DCHECK(delegate_->GetTabContents()); |
426 return delegate_->GetTabContents()->GetFavIcon(); | 432 return delegate_->GetTabContents()->GetFavIcon(); |
427 } | 433 } |
428 | 434 |
429 std::wstring LocationBarView::GetTitle() const { | 435 std::wstring LocationBarView::GetTitle() const { |
430 DCHECK(delegate_); | 436 DCHECK(delegate_); |
431 DCHECK(delegate_->GetTabContents()); | 437 DCHECK(delegate_->GetTabContents()); |
432 return UTF16ToWideHack(delegate_->GetTabContents()->GetTitle()); | 438 return UTF16ToWideHack(delegate_->GetTabContents()->GetTitle()); |
(...skipping 887 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1320 } | 1326 } |
1321 | 1327 |
1322 int LocationBarView::PageActionVisibleCount() { | 1328 int LocationBarView::PageActionVisibleCount() { |
1323 int result = 0; | 1329 int result = 0; |
1324 for (size_t i = 0; i < page_action_image_views_.size(); i++) { | 1330 for (size_t i = 0; i < page_action_image_views_.size(); i++) { |
1325 if (page_action_image_views_[i]->IsVisible()) | 1331 if (page_action_image_views_[i]->IsVisible()) |
1326 ++result; | 1332 ++result; |
1327 } | 1333 } |
1328 return result; | 1334 return result; |
1329 } | 1335 } |
OLD | NEW |