| 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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 mode_(mode), | 153 mode_(mode), |
| 154 show_focus_rect_(false), | 154 show_focus_rect_(false), |
| 155 template_url_service_(NULL), | 155 template_url_service_(NULL), |
| 156 animation_offset_(0) { | 156 animation_offset_(0) { |
| 157 set_id(VIEW_ID_LOCATION_BAR); | 157 set_id(VIEW_ID_LOCATION_BAR); |
| 158 | 158 |
| 159 if (mode_ == NORMAL) { | 159 if (mode_ == NORMAL) { |
| 160 painter_.reset( | 160 painter_.reset( |
| 161 views::Painter::CreateImagePainter( | 161 views::Painter::CreateImagePainter( |
| 162 *ui::ResourceBundle::GetSharedInstance().GetImageNamed( | 162 *ui::ResourceBundle::GetSharedInstance().GetImageNamed( |
| 163 IDR_LOCATION_BAR_BORDER).ToSkBitmap(), | 163 IDR_LOCATION_BAR_BORDER).ToImageSkia(), |
| 164 gfx::Insets(kBorderRoundCornerHeight, kBorderRoundCornerWidth, | 164 gfx::Insets(kBorderRoundCornerHeight, kBorderRoundCornerWidth, |
| 165 kBorderRoundCornerHeight, kBorderRoundCornerWidth), | 165 kBorderRoundCornerHeight, kBorderRoundCornerWidth), |
| 166 true)); | 166 true)); |
| 167 } | 167 } |
| 168 | 168 |
| 169 edit_bookmarks_enabled_.Init(prefs::kEditBookmarksEnabled, | 169 edit_bookmarks_enabled_.Init(prefs::kEditBookmarksEnabled, |
| 170 profile_->GetPrefs(), this); | 170 profile_->GetPrefs(), this); |
| 171 } | 171 } |
| 172 | 172 |
| 173 LocationBarView::~LocationBarView() { | 173 LocationBarView::~LocationBarView() { |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 511 | 511 |
| 512 bool LocationBarView::IsLocationEntryFocusableInRootView() const { | 512 bool LocationBarView::IsLocationEntryFocusableInRootView() const { |
| 513 #if defined(USE_AURA) | 513 #if defined(USE_AURA) |
| 514 return AsViews(location_entry_.get())->IsLocationEntryFocusableInRootView(); | 514 return AsViews(location_entry_.get())->IsLocationEntryFocusableInRootView(); |
| 515 #else | 515 #else |
| 516 return views::View::IsFocusable(); | 516 return views::View::IsFocusable(); |
| 517 #endif | 517 #endif |
| 518 } | 518 } |
| 519 | 519 |
| 520 gfx::Size LocationBarView::GetPreferredSize() { | 520 gfx::Size LocationBarView::GetPreferredSize() { |
| 521 return gfx::Size(0, GetThemeProvider()->GetBitmapNamed(mode_ == POPUP ? | 521 return gfx::Size(0, GetThemeProvider()->GetImageSkiaNamed(mode_ == POPUP ? |
| 522 IDR_LOCATIONBG_POPUPMODE_CENTER : IDR_LOCATIONBG_C)->height()); | 522 IDR_LOCATIONBG_POPUPMODE_CENTER : IDR_LOCATIONBG_C)->height()); |
| 523 } | 523 } |
| 524 | 524 |
| 525 void LocationBarView::Layout() { | 525 void LocationBarView::Layout() { |
| 526 if (!location_entry_.get()) | 526 if (!location_entry_.get()) |
| 527 return; | 527 return; |
| 528 | 528 |
| 529 // TODO(jhawkins): Remove once crbug.com/101994 is fixed. | 529 // TODO(jhawkins): Remove once crbug.com/101994 is fixed. |
| 530 CHECK(location_icon_view_); | 530 CHECK(location_icon_view_); |
| 531 | 531 |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 774 | 774 |
| 775 location_entry_view_->SetBoundsRect(location_bounds); | 775 location_entry_view_->SetBoundsRect(location_bounds); |
| 776 } | 776 } |
| 777 | 777 |
| 778 void LocationBarView::OnPaint(gfx::Canvas* canvas) { | 778 void LocationBarView::OnPaint(gfx::Canvas* canvas) { |
| 779 View::OnPaint(canvas); | 779 View::OnPaint(canvas); |
| 780 | 780 |
| 781 if (painter_.get()) { | 781 if (painter_.get()) { |
| 782 painter_->Paint(canvas, size()); | 782 painter_->Paint(canvas, size()); |
| 783 } else if (mode_ == POPUP) { | 783 } else if (mode_ == POPUP) { |
| 784 canvas->TileImageInt(*GetThemeProvider()->GetBitmapNamed( | 784 canvas->TileImageInt(*GetThemeProvider()->GetImageSkiaNamed( |
| 785 IDR_LOCATIONBG_POPUPMODE_CENTER), 0, 0, 0, 0, width(), height()); | 785 IDR_LOCATIONBG_POPUPMODE_CENTER), 0, 0, 0, 0, width(), height()); |
| 786 } | 786 } |
| 787 // When used in the app launcher, don't draw a border, the LocationBarView has | 787 // When used in the app launcher, don't draw a border, the LocationBarView has |
| 788 // its own views::Border. | 788 // its own views::Border. |
| 789 | 789 |
| 790 // Draw the background color so that the graphical elements at the edges | 790 // Draw the background color so that the graphical elements at the edges |
| 791 // appear over the correct color. (The edit draws its own background, so this | 791 // appear over the correct color. (The edit draws its own background, so this |
| 792 // isn't important for that.) | 792 // isn't important for that.) |
| 793 // TODO(pkasting): We need images that are transparent in the middle, so we | 793 // TODO(pkasting): We need images that are transparent in the middle, so we |
| 794 // can draw the border images over the background color instead of the | 794 // can draw the border images over the background color instead of the |
| (...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1360 return suggested_text_view_ && !suggested_text_view_->size().IsEmpty() && | 1360 return suggested_text_view_ && !suggested_text_view_->size().IsEmpty() && |
| 1361 !suggested_text_view_->text().empty(); | 1361 !suggested_text_view_->text().empty(); |
| 1362 } | 1362 } |
| 1363 | 1363 |
| 1364 #if !defined(USE_AURA) | 1364 #if !defined(USE_AURA) |
| 1365 OmniboxViewWin* LocationBarView::GetOmniboxViewWin() { | 1365 OmniboxViewWin* LocationBarView::GetOmniboxViewWin() { |
| 1366 return static_cast<OmniboxViewWin*>(location_entry_.get()); | 1366 return static_cast<OmniboxViewWin*>(location_entry_.get()); |
| 1367 } | 1367 } |
| 1368 #endif | 1368 #endif |
| 1369 #endif | 1369 #endif |
| OLD | NEW |