| 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 #include "app/gfx/chrome_canvas.h" | 7 #include "app/gfx/canvas.h" |
| 8 #include "app/l10n_util.h" | 8 #include "app/l10n_util.h" |
| 9 #include "app/resource_bundle.h" | 9 #include "app/resource_bundle.h" |
| 10 #include "app/win_util.h" | 10 #include "app/win_util.h" |
| 11 #include "base/path_service.h" | 11 #include "base/path_service.h" |
| 12 #include "base/string_util.h" | 12 #include "base/string_util.h" |
| 13 #include "chrome/app/chrome_dll_resource.h" | 13 #include "chrome/app/chrome_dll_resource.h" |
| 14 #include "chrome/browser/alternate_nav_url_fetcher.h" | 14 #include "chrome/browser/alternate_nav_url_fetcher.h" |
| 15 #include "chrome/browser/browser.h" | 15 #include "chrome/browser/browser.h" |
| 16 #include "chrome/browser/browser_list.h" | 16 #include "chrome/browser/browser_list.h" |
| 17 #include "chrome/browser/browser_process.h" | 17 #include "chrome/browser/browser_process.h" |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 | 216 |
| 217 gfx::Size LocationBarView::GetPreferredSize() { | 217 gfx::Size LocationBarView::GetPreferredSize() { |
| 218 return gfx::Size(0, | 218 return gfx::Size(0, |
| 219 (popup_window_mode_ ? kPopupBackground : kBackground)->height()); | 219 (popup_window_mode_ ? kPopupBackground : kBackground)->height()); |
| 220 } | 220 } |
| 221 | 221 |
| 222 void LocationBarView::Layout() { | 222 void LocationBarView::Layout() { |
| 223 DoLayout(true); | 223 DoLayout(true); |
| 224 } | 224 } |
| 225 | 225 |
| 226 void LocationBarView::Paint(ChromeCanvas* canvas) { | 226 void LocationBarView::Paint(gfx::Canvas* canvas) { |
| 227 View::Paint(canvas); | 227 View::Paint(canvas); |
| 228 | 228 |
| 229 SkColor bg = SkColorSetRGB( | 229 SkColor bg = SkColorSetRGB( |
| 230 GetRValue(kBackgroundColorByLevel[model_->GetSchemeSecurityLevel()]), | 230 GetRValue(kBackgroundColorByLevel[model_->GetSchemeSecurityLevel()]), |
| 231 GetGValue(kBackgroundColorByLevel[model_->GetSchemeSecurityLevel()]), | 231 GetGValue(kBackgroundColorByLevel[model_->GetSchemeSecurityLevel()]), |
| 232 GetBValue(kBackgroundColorByLevel[model_->GetSchemeSecurityLevel()])); | 232 GetBValue(kBackgroundColorByLevel[model_->GetSchemeSecurityLevel()])); |
| 233 | 233 |
| 234 const SkBitmap* background = | 234 const SkBitmap* background = |
| 235 popup_window_mode_ ? kPopupBackground : kBackground; | 235 popup_window_mode_ ? kPopupBackground : kBackground; |
| 236 canvas->TileImageInt(*background, 0, 0, 0, 0, width(), height()); | 236 canvas->TileImageInt(*background, 0, 0, 0, 0, width(), height()); |
| (...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 670 } | 670 } |
| 671 | 671 |
| 672 LocationBarView::SelectedKeywordView::~SelectedKeywordView() { | 672 LocationBarView::SelectedKeywordView::~SelectedKeywordView() { |
| 673 } | 673 } |
| 674 | 674 |
| 675 void LocationBarView::SelectedKeywordView::SetFont(const gfx::Font& font) { | 675 void LocationBarView::SelectedKeywordView::SetFont(const gfx::Font& font) { |
| 676 full_label_.SetFont(font); | 676 full_label_.SetFont(font); |
| 677 partial_label_.SetFont(font); | 677 partial_label_.SetFont(font); |
| 678 } | 678 } |
| 679 | 679 |
| 680 void LocationBarView::SelectedKeywordView::Paint(ChromeCanvas* canvas) { | 680 void LocationBarView::SelectedKeywordView::Paint(gfx::Canvas* canvas) { |
| 681 canvas->TranslateInt(0, kBackgroundYOffset); | 681 canvas->TranslateInt(0, kBackgroundYOffset); |
| 682 background_painter_.Paint(width(), height() - kTopInset, canvas); | 682 background_painter_.Paint(width(), height() - kTopInset, canvas); |
| 683 canvas->TranslateInt(0, -kBackgroundYOffset); | 683 canvas->TranslateInt(0, -kBackgroundYOffset); |
| 684 } | 684 } |
| 685 | 685 |
| 686 gfx::Size LocationBarView::SelectedKeywordView::GetPreferredSize() { | 686 gfx::Size LocationBarView::SelectedKeywordView::GetPreferredSize() { |
| 687 return full_label_.GetPreferredSize(); | 687 return full_label_.GetPreferredSize(); |
| 688 } | 688 } |
| 689 | 689 |
| 690 gfx::Size LocationBarView::SelectedKeywordView::GetMinimumSize() { | 690 gfx::Size LocationBarView::SelectedKeywordView::GetMinimumSize() { |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 788 if (content_param_offsets.size() == 2) { | 788 if (content_param_offsets.size() == 2) { |
| 789 leading_label_.SetText(keyword_hint.substr(0, | 789 leading_label_.SetText(keyword_hint.substr(0, |
| 790 content_param_offsets.front())); | 790 content_param_offsets.front())); |
| 791 trailing_label_.SetText(keyword_hint.substr(content_param_offsets.front())); | 791 trailing_label_.SetText(keyword_hint.substr(content_param_offsets.front())); |
| 792 } else { | 792 } else { |
| 793 // See comments on an identical NOTREACHED() in search_provider.cc. | 793 // See comments on an identical NOTREACHED() in search_provider.cc. |
| 794 NOTREACHED(); | 794 NOTREACHED(); |
| 795 } | 795 } |
| 796 } | 796 } |
| 797 | 797 |
| 798 void LocationBarView::KeywordHintView::Paint(ChromeCanvas* canvas) { | 798 void LocationBarView::KeywordHintView::Paint(gfx::Canvas* canvas) { |
| 799 int image_x = leading_label_.IsVisible() ? leading_label_.width() : 0; | 799 int image_x = leading_label_.IsVisible() ? leading_label_.width() : 0; |
| 800 | 800 |
| 801 // Since we paint the button image directly on the canvas (instead of using a | 801 // Since we paint the button image directly on the canvas (instead of using a |
| 802 // child view), we must mirror the button's position manually if the locale | 802 // child view), we must mirror the button's position manually if the locale |
| 803 // is right-to-left. | 803 // is right-to-left. |
| 804 gfx::Rect tab_button_bounds(image_x, | 804 gfx::Rect tab_button_bounds(image_x, |
| 805 kTabImageYOffset, | 805 kTabImageYOffset, |
| 806 kTabButtonBitmap->width(), | 806 kTabButtonBitmap->width(), |
| 807 kTabButtonBitmap->height()); | 807 kTabButtonBitmap->height()); |
| 808 tab_button_bounds.set_x(MirroredLeftPointForRect(tab_button_bounds)); | 808 tab_button_bounds.set_x(MirroredLeftPointForRect(tab_button_bounds)); |
| (...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1206 location_entry_->SetFocus(); | 1206 location_entry_->SetFocus(); |
| 1207 } | 1207 } |
| 1208 | 1208 |
| 1209 void LocationBarView::SaveStateToContents(TabContents* contents) { | 1209 void LocationBarView::SaveStateToContents(TabContents* contents) { |
| 1210 location_entry_->SaveStateToTab(contents); | 1210 location_entry_->SaveStateToTab(contents); |
| 1211 } | 1211 } |
| 1212 | 1212 |
| 1213 void LocationBarView::Revert() { | 1213 void LocationBarView::Revert() { |
| 1214 location_entry_->RevertAll(); | 1214 location_entry_->RevertAll(); |
| 1215 } | 1215 } |
| OLD | NEW |