| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "base/path_service.h" | 7 #include "base/path_service.h" |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "chrome/app/chrome_dll_resource.h" | 9 #include "chrome/app/chrome_dll_resource.h" |
| 10 #include "chrome/browser/alternate_nav_url_fetcher.h" | 10 #include "chrome/browser/alternate_nav_url_fetcher.h" |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 profile_ = profile; | 193 profile_ = profile; |
| 194 location_entry_->model()->SetProfile(profile); | 194 location_entry_->model()->SetProfile(profile); |
| 195 selected_keyword_view_.set_profile(profile); | 195 selected_keyword_view_.set_profile(profile); |
| 196 keyword_hint_view_.set_profile(profile); | 196 keyword_hint_view_.set_profile(profile); |
| 197 security_image_view_.set_profile(profile); | 197 security_image_view_.set_profile(profile); |
| 198 } | 198 } |
| 199 } | 199 } |
| 200 | 200 |
| 201 gfx::Size LocationBarView::GetPreferredSize() { | 201 gfx::Size LocationBarView::GetPreferredSize() { |
| 202 return gfx::Size(0, | 202 return gfx::Size(0, |
| 203 (popup_window_mode_ ? kPopupBackground : kBackground)->height() - | 203 (popup_window_mode_ ? kPopupBackground : kBackground)->height()); |
| 204 TopOffset()); | |
| 205 } | 204 } |
| 206 | 205 |
| 207 void LocationBarView::Layout() { | 206 void LocationBarView::Layout() { |
| 208 DoLayout(true); | 207 DoLayout(true); |
| 209 } | 208 } |
| 210 | 209 |
| 211 void LocationBarView::Paint(ChromeCanvas* canvas) { | 210 void LocationBarView::Paint(ChromeCanvas* canvas) { |
| 212 View::Paint(canvas); | 211 View::Paint(canvas); |
| 213 | 212 |
| 214 SkColor bg = SkColorSetRGB( | 213 SkColor bg = SkColorSetRGB( |
| 215 GetRValue(kBackgroundColorByLevel[model_->GetSchemeSecurityLevel()]), | 214 GetRValue(kBackgroundColorByLevel[model_->GetSchemeSecurityLevel()]), |
| 216 GetGValue(kBackgroundColorByLevel[model_->GetSchemeSecurityLevel()]), | 215 GetGValue(kBackgroundColorByLevel[model_->GetSchemeSecurityLevel()]), |
| 217 GetBValue(kBackgroundColorByLevel[model_->GetSchemeSecurityLevel()])); | 216 GetBValue(kBackgroundColorByLevel[model_->GetSchemeSecurityLevel()])); |
| 218 | 217 |
| 219 const SkBitmap* background = | 218 const SkBitmap* background = |
| 220 popup_window_mode_ ? kPopupBackground : kBackground; | 219 popup_window_mode_ ? kPopupBackground : kBackground; |
| 221 int top_offset = std::min(TopOffset(), height()); | 220 canvas->TileImageInt(*background, 0, 0, 0, 0, width(), height()); |
| 222 canvas->TileImageInt(*background, 0, top_offset, 0, 0, width(), height()); | |
| 223 int top_margin = TopMargin(); | 221 int top_margin = TopMargin(); |
| 224 canvas->FillRectInt(bg, 0, top_margin, width(), | 222 canvas->FillRectInt(bg, 0, top_margin, width(), |
| 225 std::max(height() - top_margin - kVertMargin, 0)); | 223 std::max(height() - top_margin - kVertMargin, 0)); |
| 226 } | 224 } |
| 227 | 225 |
| 228 bool LocationBarView::CanProcessTabKeyEvents() { | 226 bool LocationBarView::CanProcessTabKeyEvents() { |
| 229 // We want to receive tab key events when the hint is showing. | 227 // We want to receive tab key events when the hint is showing. |
| 230 return keyword_hint_view_.IsVisible(); | 228 return keyword_hint_view_.IsVisible(); |
| 231 } | 229 } |
| 232 | 230 |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 391 location_bounds.y(), | 389 location_bounds.y(), |
| 392 location_bounds.width(), | 390 location_bounds.width(), |
| 393 location_bounds.height()); | 391 location_bounds.height()); |
| 394 if (!force_layout) { | 392 if (!force_layout) { |
| 395 // If force_layout is false and we got this far it means one of the views | 393 // If force_layout is false and we got this far it means one of the views |
| 396 // was added/removed or changed in size. We need to paint ourselves. | 394 // was added/removed or changed in size. We need to paint ourselves. |
| 397 SchedulePaint(); | 395 SchedulePaint(); |
| 398 } | 396 } |
| 399 } | 397 } |
| 400 | 398 |
| 401 int LocationBarView::TopOffset() const { | |
| 402 return (popup_window_mode_ && win_util::ShouldUseVistaFrame()) ? 1 : 0; | |
| 403 } | |
| 404 | |
| 405 int LocationBarView::TopMargin() const { | 399 int LocationBarView::TopMargin() const { |
| 406 return std::min(kVertMargin - TopOffset(), height()); | 400 return std::min(kVertMargin, height()); |
| 407 } | 401 } |
| 408 | 402 |
| 409 int LocationBarView::TextDisplayWidth() { | 403 int LocationBarView::TextDisplayWidth() { |
| 410 POINT last_char_position = | 404 POINT last_char_position = |
| 411 location_entry_->PosFromChar(location_entry_->GetTextLength()); | 405 location_entry_->PosFromChar(location_entry_->GetTextLength()); |
| 412 POINT scroll_position; | 406 POINT scroll_position; |
| 413 location_entry_->GetScrollPos(&scroll_position); | 407 location_entry_->GetScrollPos(&scroll_position); |
| 414 const int position_x = last_char_position.x + scroll_position.x; | 408 const int position_x = last_char_position.x + scroll_position.x; |
| 415 return UILayoutIsRightToLeft() ? width() - position_x : position_x; | 409 return UILayoutIsRightToLeft() ? width() - position_x : position_x; |
| 416 } | 410 } |
| (...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1005 } | 999 } |
| 1006 | 1000 |
| 1007 void LocationBarView::FocusSearch() { | 1001 void LocationBarView::FocusSearch() { |
| 1008 location_entry_->SetUserText(L"?"); | 1002 location_entry_->SetUserText(L"?"); |
| 1009 location_entry_->SetFocus(); | 1003 location_entry_->SetFocus(); |
| 1010 } | 1004 } |
| 1011 | 1005 |
| 1012 void LocationBarView::SaveStateToContents(TabContents* contents) { | 1006 void LocationBarView::SaveStateToContents(TabContents* contents) { |
| 1013 location_entry_->SaveStateToTab(contents); | 1007 location_entry_->SaveStateToTab(contents); |
| 1014 } | 1008 } |
| OLD | NEW |