Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(275)

Side by Side Diff: chrome/browser/views/location_bar_view.cc

Issue 18862: Extend the popup-mode location bar out into the nonclient view. This makes p... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/views/frame/opaque_non_client_view.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/app/theme/theme_resources.h" 10 #include "chrome/app/theme/theme_resources.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 static const int kBackgroundHoriMargin = 0; 46 static const int kBackgroundHoriMargin = 0;
47 47
48 // Padding on the right and left of the entry field. 48 // Padding on the right and left of the entry field.
49 static const int kEntryPadding = 3; 49 static const int kEntryPadding = 3;
50 50
51 // Padding between the entry and the leading/trailing views. 51 // Padding between the entry and the leading/trailing views.
52 static const int kInnerPadding = 3; 52 static const int kInnerPadding = 3;
53 53
54 static const SkBitmap* kBackground = NULL; 54 static const SkBitmap* kBackground = NULL;
55 55
56 static const SkBitmap* kPopupBackgroundLeft = NULL; 56 static const SkBitmap* kPopupBackground = NULL;
57 static const SkBitmap* kPopupBackgroundCenter = NULL;
58 static const SkBitmap* kPopupBackgroundRight = NULL;
59 static const int kPopupBackgroundVertMargin = 2; 57 static const int kPopupBackgroundVertMargin = 2;
60 static const int kPopupBackgroundHorzMargin = 2;
61 58
62 // The delay the mouse has to be hovering over the lock/warning icon before the 59 // The delay the mouse has to be hovering over the lock/warning icon before the
63 // info bubble is shown. 60 // info bubble is shown.
64 static const int kInfoBubbleHoverDelayMs = 500; 61 static const int kInfoBubbleHoverDelayMs = 500;
65 62
66 // The tab key image. 63 // The tab key image.
67 static const SkBitmap* kTabButtonBitmap = NULL; 64 static const SkBitmap* kTabButtonBitmap = NULL;
68 65
69 // Returns the description for a keyword. 66 // Returns the description for a keyword.
70 static std::wstring GetKeywordDescription(Profile* profile, 67 static std::wstring GetKeywordDescription(Profile* profile,
(...skipping 23 matching lines...) Expand all
94 security_image_view_(profile, model), 91 security_image_view_(profile, model),
95 popup_window_mode_(popup_window_mode), 92 popup_window_mode_(popup_window_mode),
96 first_run_bubble_(this) { 93 first_run_bubble_(this) {
97 DCHECK(profile_); 94 DCHECK(profile_);
98 SetID(VIEW_ID_LOCATION_BAR); 95 SetID(VIEW_ID_LOCATION_BAR);
99 SetFocusable(true); 96 SetFocusable(true);
100 97
101 if (!kBackground) { 98 if (!kBackground) {
102 ResourceBundle &rb = ResourceBundle::GetSharedInstance(); 99 ResourceBundle &rb = ResourceBundle::GetSharedInstance();
103 kBackground = rb.GetBitmapNamed(IDR_LOCATIONBG); 100 kBackground = rb.GetBitmapNamed(IDR_LOCATIONBG);
104 kPopupBackgroundLeft = 101 kPopupBackground = rb.GetBitmapNamed(IDR_LOCATIONBG_POPUPMODE_CENTER);
105 rb.GetBitmapNamed(IDR_LOCATIONBG_POPUPMODE_LEFT);
106 kPopupBackgroundCenter =
107 rb.GetBitmapNamed(IDR_LOCATIONBG_POPUPMODE_CENTER);
108 kPopupBackgroundRight =
109 rb.GetBitmapNamed(IDR_LOCATIONBG_POPUPMODE_RIGHT);
110 } 102 }
111 } 103 }
112 104
113 bool LocationBarView::IsInitialized() const { 105 bool LocationBarView::IsInitialized() const {
114 return location_entry_view_ != NULL; 106 return location_entry_view_ != NULL;
115 } 107 }
116 108
117 void LocationBarView::Init() { 109 void LocationBarView::Init() {
118 if (popup_window_mode_) { 110 if (popup_window_mode_) {
119 font_ = ResourceBundle::GetSharedInstance().GetFont( 111 font_ = ResourceBundle::GetSharedInstance().GetFont(
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 if (profile_ != profile) { 190 if (profile_ != profile) {
199 profile_ = profile; 191 profile_ = profile;
200 location_entry_->model()->SetProfile(profile); 192 location_entry_->model()->SetProfile(profile);
201 selected_keyword_view_.set_profile(profile); 193 selected_keyword_view_.set_profile(profile);
202 keyword_hint_view_.set_profile(profile); 194 keyword_hint_view_.set_profile(profile);
203 security_image_view_.set_profile(profile); 195 security_image_view_.set_profile(profile);
204 } 196 }
205 } 197 }
206 198
207 gfx::Size LocationBarView::GetPreferredSize() { 199 gfx::Size LocationBarView::GetPreferredSize() {
208 return gfx::Size( 200 return gfx::Size(0,
209 0, 201 std::max((popup_window_mode_ ? kPopupBackground : kBackground)->height(),
210 std::max( 202 security_image_view_.GetPreferredSize().height()));
211 (popup_window_mode_ ? kPopupBackgroundCenter
212 : kBackground)->height(),
213 security_image_view_.GetPreferredSize().width()));
214 } 203 }
215 204
216 void LocationBarView::Layout() { 205 void LocationBarView::Layout() {
217 DoLayout(true); 206 DoLayout(true);
218 } 207 }
219 208
220 void LocationBarView::Paint(ChromeCanvas* canvas) { 209 void LocationBarView::Paint(ChromeCanvas* canvas) {
221 View::Paint(canvas); 210 View::Paint(canvas);
222 211
223 SkColor bg = SkColorSetRGB( 212 SkColor bg = SkColorSetRGB(
224 GetRValue(kBackgroundColorByLevel[model_->GetSchemeSecurityLevel()]), 213 GetRValue(kBackgroundColorByLevel[model_->GetSchemeSecurityLevel()]),
225 GetGValue(kBackgroundColorByLevel[model_->GetSchemeSecurityLevel()]), 214 GetGValue(kBackgroundColorByLevel[model_->GetSchemeSecurityLevel()]),
226 GetBValue(kBackgroundColorByLevel[model_->GetSchemeSecurityLevel()])); 215 GetBValue(kBackgroundColorByLevel[model_->GetSchemeSecurityLevel()]));
227 216
228 if (popup_window_mode_ == false) { 217 if (popup_window_mode_) {
218 canvas->TileImageInt(*kPopupBackground, 0, 0, width(),
219 kPopupBackground->height());
220 canvas->FillRectInt(bg, 0, kPopupBackgroundVertMargin, width(),
221 kPopupBackground->height() - (kPopupBackgroundVertMargin * 2));
222 } else {
229 int bh = kBackground->height(); 223 int bh = kBackground->height();
230
231 canvas->TileImageInt(*kBackground, 0, (height() - bh) / 2, width(), 224 canvas->TileImageInt(*kBackground, 0, (height() - bh) / 2, width(),
232 bh); 225 bh);
233
234 canvas->FillRectInt(bg, kBackgroundHoriMargin, kBackgroundVertMargin, 226 canvas->FillRectInt(bg, kBackgroundHoriMargin, kBackgroundVertMargin,
235 width() - 2 * kBackgroundHoriMargin, 227 width() - 2 * kBackgroundHoriMargin,
236 bh - kBackgroundVertMargin * 2); 228 bh - kBackgroundVertMargin * 2);
237 } else {
238 canvas->TileImageInt(*kPopupBackgroundLeft, 0, 0,
239 kPopupBackgroundLeft->width(),
240 kPopupBackgroundLeft->height());
241 canvas->TileImageInt(*kPopupBackgroundCenter,
242 kPopupBackgroundLeft->width(), 0,
243 width() -
244 kPopupBackgroundLeft->width() -
245 kPopupBackgroundRight->width(),
246 kPopupBackgroundCenter->height());
247 canvas->TileImageInt(*kPopupBackgroundRight,
248 width() - kPopupBackgroundRight->width(),
249 0, kPopupBackgroundRight->width(),
250 kPopupBackgroundRight->height());
251
252 canvas->FillRectInt(bg, kPopupBackgroundHorzMargin,
253 kPopupBackgroundVertMargin,
254 width() - kPopupBackgroundHorzMargin * 2,
255 kPopupBackgroundCenter->height() -
256 kPopupBackgroundVertMargin * 2);
257 } 229 }
258 } 230 }
259 231
260 bool LocationBarView::CanProcessTabKeyEvents() { 232 bool LocationBarView::CanProcessTabKeyEvents() {
261 // We want to receive tab key events when the hint is showing. 233 // We want to receive tab key events when the hint is showing.
262 return keyword_hint_view_.IsVisible(); 234 return keyword_hint_view_.IsVisible();
263 } 235 }
264 236
265 void LocationBarView::VisibleBoundsInRootChanged() { 237 void LocationBarView::VisibleBoundsInRootChanged() {
266 location_entry_->ClosePopup(); 238 location_entry_->ClosePopup();
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 if (max_edit_width < 0) 357 if (max_edit_width < 0)
386 return; 358 return;
387 const int text_width = TextDisplayWidth(); 359 const int text_width = TextDisplayWidth();
388 bool needs_layout = force_layout; 360 bool needs_layout = force_layout;
389 needs_layout |= AdjustHints(text_width, max_edit_width); 361 needs_layout |= AdjustHints(text_width, max_edit_width);
390 362
391 if (!needs_layout) 363 if (!needs_layout)
392 return; 364 return;
393 365
394 // TODO(sky): baseline layout. 366 // TODO(sky): baseline layout.
395 const SkBitmap* background = popup_window_mode_ ? kPopupBackgroundCenter 367 const SkBitmap* background =
396 : kBackground; 368 popup_window_mode_ ? kPopupBackground : kBackground;
397 int bh = background->height(); 369 int bh = background->height();
398 int location_y = ((height() - bh) / 2) + kTextVertMargin; 370 int location_y = ((height() - bh) / 2) + kTextVertMargin;
399 int location_height = bh - (2 * kTextVertMargin); 371 int location_height = bh - (2 * kTextVertMargin);
400 if (info_label_.IsVisible()) { 372 if (info_label_.IsVisible()) {
401 info_label_.SetBounds(width() - kEntryPadding - info_label_size.width(), 373 info_label_.SetBounds(width() - kEntryPadding - info_label_size.width(),
402 location_y, 374 location_y,
403 info_label_size.width(), location_height); 375 info_label_size.width(), location_height);
404 } 376 }
405 if (security_image_view_.IsVisible()) { 377 if (security_image_view_.IsVisible()) {
406 const int info_label_width = info_label_size.width() ? 378 const int info_label_width = info_label_size.width() ?
(...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after
998 InfoBubble* info_bubble, 970 InfoBubble* info_bubble,
999 bool closed_by_escape) { 971 bool closed_by_escape) {
1000 info_bubble_ = NULL; 972 info_bubble_ = NULL;
1001 } 973 }
1002 974
1003 bool LocationBarView::OverrideAccelerator( 975 bool LocationBarView::OverrideAccelerator(
1004 const views::Accelerator& accelerator) { 976 const views::Accelerator& accelerator) {
1005 return location_entry_->OverrideAccelerator(accelerator); 977 return location_entry_->OverrideAccelerator(accelerator);
1006 } 978 }
1007 979
OLDNEW
« no previous file with comments | « chrome/browser/views/frame/opaque_non_client_view.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698