| 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 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 // anything, it just toggles the visible flag. | 151 // anything, it just toggles the visible flag. |
| 152 gtk_widget_show_all(location_entry_->widget()); | 152 gtk_widget_show_all(location_entry_->widget()); |
| 153 // Hide the widget. NativeViewHostGtk will make it visible again as | 153 // Hide the widget. NativeViewHostGtk will make it visible again as |
| 154 // necessary. | 154 // necessary. |
| 155 gtk_widget_hide(location_entry_->widget()); | 155 gtk_widget_hide(location_entry_->widget()); |
| 156 #endif | 156 #endif |
| 157 location_entry_view_ = new views::NativeViewHost; | 157 location_entry_view_ = new views::NativeViewHost; |
| 158 location_entry_view_->SetID(VIEW_ID_AUTOCOMPLETE); | 158 location_entry_view_->SetID(VIEW_ID_AUTOCOMPLETE); |
| 159 AddChildView(location_entry_view_); | 159 AddChildView(location_entry_view_); |
| 160 location_entry_view_->set_focus_view(this); | 160 location_entry_view_->set_focus_view(this); |
| 161 location_entry_view_->set_focus_native_view(location_entry_-> | |
| 162 GetFocusNativeView()); | |
| 163 location_entry_view_->Attach( | 161 location_entry_view_->Attach( |
| 164 #if defined(OS_WIN) | 162 #if defined(OS_WIN) |
| 165 location_entry_->m_hWnd | 163 location_entry_->m_hWnd |
| 166 #else | 164 #else |
| 167 location_entry_->widget() | 165 location_entry_->widget() |
| 168 #endif | 166 #endif |
| 169 ); | 167 ); |
| 170 | 168 |
| 171 AddChildView(&selected_keyword_view_); | 169 AddChildView(&selected_keyword_view_); |
| 172 selected_keyword_view_.SetFont(font_); | 170 selected_keyword_view_.SetFont(font_); |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 | 272 |
| 275 Layout(); | 273 Layout(); |
| 276 SchedulePaint(); | 274 SchedulePaint(); |
| 277 } | 275 } |
| 278 | 276 |
| 279 void LocationBarView::InvalidatePageActions() { | 277 void LocationBarView::InvalidatePageActions() { |
| 280 DeletePageActionViews(); | 278 DeletePageActionViews(); |
| 281 } | 279 } |
| 282 | 280 |
| 283 void LocationBarView::Focus() { | 281 void LocationBarView::Focus() { |
| 284 // Forward the focus to the NativeViewHost that will focus the right | 282 // Focus the location entry native view. |
| 285 // native-view. | 283 location_entry_->SetFocus(); |
| 286 location_entry_view_->Focus(); | |
| 287 } | 284 } |
| 288 | 285 |
| 289 void LocationBarView::SetProfile(Profile* profile) { | 286 void LocationBarView::SetProfile(Profile* profile) { |
| 290 DCHECK(profile); | 287 DCHECK(profile); |
| 291 if (profile_ != profile) { | 288 if (profile_ != profile) { |
| 292 profile_ = profile; | 289 profile_ = profile; |
| 293 location_entry_->model()->SetProfile(profile); | 290 location_entry_->model()->SetProfile(profile); |
| 294 selected_keyword_view_.set_profile(profile); | 291 selected_keyword_view_.set_profile(profile); |
| 295 keyword_hint_view_.set_profile(profile); | 292 keyword_hint_view_.set_profile(profile); |
| 296 security_image_view_.set_profile(profile); | 293 security_image_view_.set_profile(profile); |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 402 } else { | 399 } else { |
| 403 fetcher.release(); // The navigation controller will delete the fetcher. | 400 fetcher.release(); // The navigation controller will delete the fetcher. |
| 404 } | 401 } |
| 405 } | 402 } |
| 406 } | 403 } |
| 407 | 404 |
| 408 void LocationBarView::OnChanged() { | 405 void LocationBarView::OnChanged() { |
| 409 DoLayout(false); | 406 DoLayout(false); |
| 410 } | 407 } |
| 411 | 408 |
| 409 void LocationBarView::OnSetFocus() { |
| 410 views::FocusManager* focus_manager = GetFocusManager(); |
| 411 if (!focus_manager) { |
| 412 NOTREACHED(); |
| 413 return; |
| 414 } |
| 415 focus_manager->SetFocusedView(this); |
| 416 } |
| 417 |
| 412 SkBitmap LocationBarView::GetFavIcon() const { | 418 SkBitmap LocationBarView::GetFavIcon() const { |
| 413 DCHECK(delegate_); | 419 DCHECK(delegate_); |
| 414 DCHECK(delegate_->GetTabContents()); | 420 DCHECK(delegate_->GetTabContents()); |
| 415 return delegate_->GetTabContents()->GetFavIcon(); | 421 return delegate_->GetTabContents()->GetFavIcon(); |
| 416 } | 422 } |
| 417 | 423 |
| 418 std::wstring LocationBarView::GetTitle() const { | 424 std::wstring LocationBarView::GetTitle() const { |
| 419 DCHECK(delegate_); | 425 DCHECK(delegate_); |
| 420 DCHECK(delegate_->GetTabContents()); | 426 DCHECK(delegate_->GetTabContents()); |
| 421 return UTF16ToWideHack(delegate_->GetTabContents()->GetTitle()); | 427 return UTF16ToWideHack(delegate_->GetTabContents()->GetTitle()); |
| (...skipping 890 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1312 } | 1318 } |
| 1313 | 1319 |
| 1314 int LocationBarView::PageActionVisibleCount() { | 1320 int LocationBarView::PageActionVisibleCount() { |
| 1315 int result = 0; | 1321 int result = 0; |
| 1316 for (size_t i = 0; i < page_action_image_views_.size(); i++) { | 1322 for (size_t i = 0; i < page_action_image_views_.size(); i++) { |
| 1317 if (page_action_image_views_[i]->IsVisible()) | 1323 if (page_action_image_views_[i]->IsVisible()) |
| 1318 ++result; | 1324 ++result; |
| 1319 } | 1325 } |
| 1320 return result; | 1326 return result; |
| 1321 } | 1327 } |
| OLD | NEW |