| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/location_bar/location_bar_view.h" | 5 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 location_entry_view_(NULL), | 164 location_entry_view_(NULL), |
| 165 selected_keyword_view_(NULL), | 165 selected_keyword_view_(NULL), |
| 166 suggested_text_view_(NULL), | 166 suggested_text_view_(NULL), |
| 167 keyword_hint_view_(NULL), | 167 keyword_hint_view_(NULL), |
| 168 star_view_(NULL), | 168 star_view_(NULL), |
| 169 action_box_button_view_(NULL), | 169 action_box_button_view_(NULL), |
| 170 chrome_to_mobile_view_(NULL), | 170 chrome_to_mobile_view_(NULL), |
| 171 mode_(mode), | 171 mode_(mode), |
| 172 show_focus_rect_(false), | 172 show_focus_rect_(false), |
| 173 template_url_service_(NULL), | 173 template_url_service_(NULL), |
| 174 animation_offset_(0) { | 174 animation_offset_(0), |
| 175 ALLOW_THIS_IN_INITIALIZER_LIST(view_to_focus_(this)) { |
| 175 set_id(VIEW_ID_LOCATION_BAR); | 176 set_id(VIEW_ID_LOCATION_BAR); |
| 176 | 177 |
| 177 if (mode_ == NORMAL) { | 178 if (mode_ == NORMAL) { |
| 178 painter_.reset( | 179 painter_.reset( |
| 179 views::Painter::CreateImagePainter( | 180 views::Painter::CreateImagePainter( |
| 180 *ui::ResourceBundle::GetSharedInstance().GetImageNamed( | 181 *ui::ResourceBundle::GetSharedInstance().GetImageNamed( |
| 181 IDR_LOCATION_BAR_BORDER).ToImageSkia(), | 182 IDR_LOCATION_BAR_BORDER).ToImageSkia(), |
| 182 gfx::Insets(kBorderRoundCornerHeight, kBorderRoundCornerWidth, | 183 gfx::Insets(kBorderRoundCornerHeight, kBorderRoundCornerWidth, |
| 183 kBorderRoundCornerHeight, kBorderRoundCornerWidth), | 184 kBorderRoundCornerHeight, kBorderRoundCornerWidth), |
| 184 true)); | 185 true)); |
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 506 | 507 |
| 507 string16 LocationBarView::GetInstantSuggestion() const { | 508 string16 LocationBarView::GetInstantSuggestion() const { |
| 508 return HasValidSuggestText() ? suggested_text_view_->text() : string16(); | 509 return HasValidSuggestText() ? suggested_text_view_->text() : string16(); |
| 509 } | 510 } |
| 510 | 511 |
| 511 void LocationBarView::SetLocationEntryFocusable(bool focusable) { | 512 void LocationBarView::SetLocationEntryFocusable(bool focusable) { |
| 512 OmniboxViewViews* omnibox_views = GetOmniboxViewViews(location_entry_.get()); | 513 OmniboxViewViews* omnibox_views = GetOmniboxViewViews(location_entry_.get()); |
| 513 if (omnibox_views) | 514 if (omnibox_views) |
| 514 omnibox_views->SetLocationEntryFocusable(focusable); | 515 omnibox_views->SetLocationEntryFocusable(focusable); |
| 515 else | 516 else |
| 516 set_focusable(focusable); | 517 view_to_focus_->set_focusable(focusable); |
| 517 } | 518 } |
| 518 | 519 |
| 519 bool LocationBarView::IsLocationEntryFocusableInRootView() const { | 520 bool LocationBarView::IsLocationEntryFocusableInRootView() const { |
| 520 OmniboxViewViews* omnibox_views = GetOmniboxViewViews(location_entry_.get()); | 521 OmniboxViewViews* omnibox_views = GetOmniboxViewViews(location_entry_.get()); |
| 521 if (omnibox_views) | 522 if (omnibox_views) |
| 522 return omnibox_views->IsLocationEntryFocusableInRootView(); | 523 return omnibox_views->IsLocationEntryFocusableInRootView(); |
| 523 return views::View::IsFocusable(); | 524 return view_to_focus_->IsFocusable(); |
| 524 } | 525 } |
| 525 | 526 |
| 526 gfx::Size LocationBarView::GetPreferredSize() { | 527 gfx::Size LocationBarView::GetPreferredSize() { |
| 527 return gfx::Size(0, GetThemeProvider()->GetImageSkiaNamed(mode_ == POPUP ? | 528 return gfx::Size(0, GetThemeProvider()->GetImageSkiaNamed(mode_ == POPUP ? |
| 528 IDR_LOCATIONBG_POPUPMODE_CENTER : IDR_LOCATIONBG_C)->height()); | 529 IDR_LOCATIONBG_POPUPMODE_CENTER : IDR_LOCATIONBG_C)->height()); |
| 529 } | 530 } |
| 530 | 531 |
| 531 void LocationBarView::Layout() { | 532 void LocationBarView::Layout() { |
| 532 if (!location_entry_.get()) | 533 if (!location_entry_.get()) |
| 533 return; | 534 return; |
| (...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 952 | 953 |
| 953 void LocationBarView::OnKillFocus() { | 954 void LocationBarView::OnKillFocus() { |
| 954 } | 955 } |
| 955 | 956 |
| 956 void LocationBarView::OnSetFocus() { | 957 void LocationBarView::OnSetFocus() { |
| 957 views::FocusManager* focus_manager = GetFocusManager(); | 958 views::FocusManager* focus_manager = GetFocusManager(); |
| 958 if (!focus_manager) { | 959 if (!focus_manager) { |
| 959 NOTREACHED(); | 960 NOTREACHED(); |
| 960 return; | 961 return; |
| 961 } | 962 } |
| 962 focus_manager->SetFocusedView(this); | 963 focus_manager->SetFocusedView(view_to_focus_); |
| 963 } | 964 } |
| 964 | 965 |
| 965 SkBitmap LocationBarView::GetFavicon() const { | 966 SkBitmap LocationBarView::GetFavicon() const { |
| 966 return delegate_->GetTabContents()->favicon_tab_helper()->GetFavicon(); | 967 return delegate_->GetTabContents()->favicon_tab_helper()->GetFavicon(); |
| 967 } | 968 } |
| 968 | 969 |
| 969 string16 LocationBarView::GetTitle() const { | 970 string16 LocationBarView::GetTitle() const { |
| 970 return GetWebContentsFromDelegate(delegate_)->GetTitle(); | 971 return GetWebContentsFromDelegate(delegate_)->GetTitle(); |
| 971 } | 972 } |
| 972 | 973 |
| (...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1367 int LocationBarView::GetInternalHeight(bool use_preferred_size) { | 1368 int LocationBarView::GetInternalHeight(bool use_preferred_size) { |
| 1368 int total_height = | 1369 int total_height = |
| 1369 use_preferred_size ? GetPreferredSize().height() : height(); | 1370 use_preferred_size ? GetPreferredSize().height() : height(); |
| 1370 return std::max(total_height - (kVerticalEdgeThickness * 2), 0); | 1371 return std::max(total_height - (kVerticalEdgeThickness * 2), 0); |
| 1371 } | 1372 } |
| 1372 | 1373 |
| 1373 bool LocationBarView::HasValidSuggestText() const { | 1374 bool LocationBarView::HasValidSuggestText() const { |
| 1374 return suggested_text_view_ && !suggested_text_view_->size().IsEmpty() && | 1375 return suggested_text_view_ && !suggested_text_view_->size().IsEmpty() && |
| 1375 !suggested_text_view_->text().empty(); | 1376 !suggested_text_view_->text().empty(); |
| 1376 } | 1377 } |
| OLD | NEW |