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

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

Issue 2001433002: Update appearance of omnibox focus for MD. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: share constant Created 4 years, 7 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
OLDNEW
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/i18n/rtl.h" 10 #include "base/i18n/rtl.h"
(...skipping 1240 matching lines...) Expand 10 before | Expand all | Expand 10 after
1251 return kViewClassName; 1251 return kViewClassName;
1252 } 1252 }
1253 1253
1254 void LocationBarView::OnBoundsChanged(const gfx::Rect& previous_bounds) { 1254 void LocationBarView::OnBoundsChanged(const gfx::Rect& previous_bounds) {
1255 OmniboxPopupView* popup = omnibox_view_->model()->popup_model()->view(); 1255 OmniboxPopupView* popup = omnibox_view_->model()->popup_model()->view();
1256 if (popup->IsOpen()) 1256 if (popup->IsOpen())
1257 popup->UpdatePopupAppearance(); 1257 popup->UpdatePopupAppearance();
1258 } 1258 }
1259 1259
1260 void LocationBarView::OnFocus() { 1260 void LocationBarView::OnFocus() {
1261 // Explicitly focus the omnibox so a focus ring will be displayed around it on
1262 // Windows.
1263 omnibox_view_->SetFocus(); 1261 omnibox_view_->SetFocus();
1264 } 1262 }
1265 1263
1266 void LocationBarView::OnPaint(gfx::Canvas* canvas) { 1264 void LocationBarView::OnPaint(gfx::Canvas* canvas) {
1267 View::OnPaint(canvas); 1265 View::OnPaint(canvas);
1268 1266
1269 if (ui::MaterialDesignController::IsModeMaterial() && !is_popup_mode_) 1267 if (ui::MaterialDesignController::IsModeMaterial()) {
1270 return; // The background and border are painted by our Background. 1268 if (show_focus_rect_ && omnibox_view_->HasFocus()) {
1269 SkPaint paint;
1270 paint.setAntiAlias(true);
1271 paint.setColor(GetNativeTheme()->GetSystemColor(
1272 ui::NativeTheme::NativeTheme::kColorId_FocusedBorderColor));
1273 paint.setStyle(SkPaint::kStroke_Style);
1274 paint.setStrokeWidth(1);
1275 gfx::RectF focus_rect(GetLocalBounds());
1276 focus_rect.Inset(gfx::InsetsF(0.5f));
1277 canvas->DrawRoundRect(focus_rect, BackgroundWith1PxBorder::kCornerRadius,
1278 paint);
1279 }
1280 if (!is_popup_mode_)
1281 return; // The background and border are painted by our Background.
1282 }
1271 1283
1272 // Fill the location bar background color behind the border. Parts of the 1284 // Fill the location bar background color behind the border. Parts of the
1273 // border images are meant to rest atop the toolbar background and parts atop 1285 // border images are meant to rest atop the toolbar background and parts atop
1274 // the omnibox background, so we can't just blindly fill our entire bounds. 1286 // the omnibox background, so we can't just blindly fill our entire bounds.
1275 gfx::Rect bounds(GetContentsBounds()); 1287 gfx::Rect bounds(GetContentsBounds());
1276 bounds.Inset(GetHorizontalEdgeThickness(), 1288 bounds.Inset(GetHorizontalEdgeThickness(),
1277 is_popup_mode_ ? 0 : GetVerticalEdgeThickness()); 1289 is_popup_mode_ ? 0 : GetVerticalEdgeThickness());
1278 SkColor background_color(GetColor(BACKGROUND)); 1290 SkColor background_color(GetColor(BACKGROUND));
1279 if (!is_popup_mode_) { 1291 if (!is_popup_mode_) {
1280 SkPaint paint; 1292 SkPaint paint;
1281 paint.setStyle(SkPaint::kFill_Style); 1293 paint.setStyle(SkPaint::kFill_Style);
1282 paint.setColor(background_color); 1294 paint.setColor(background_color);
1283 const int kBorderCornerRadius = 2; 1295 const int kBorderCornerRadius = 2;
1284 canvas->DrawRoundRect(bounds, kBorderCornerRadius, paint); 1296 canvas->DrawRoundRect(bounds, kBorderCornerRadius, paint);
1285 // The border itself will be drawn in PaintChildren() since it includes an 1297 // The border itself will be drawn in PaintChildren() since it includes an
1286 // inner shadow which should be drawn over the contents. 1298 // inner shadow which should be drawn over the contents.
1287 return; 1299 return;
1288 } 1300 }
1289 1301
1290 canvas->FillRect(bounds, background_color); 1302 canvas->FillRect(bounds, background_color);
1291 const SkColor border_color = GetBorderColor(profile()->IsOffTheRecord()); 1303 const SkColor border_color = GetBorderColor(profile()->IsOffTheRecord());
1292 BrowserView::Paint1pxHorizontalLine(canvas, border_color, bounds, false); 1304 BrowserView::Paint1pxHorizontalLine(canvas, border_color, bounds, false);
1293 BrowserView::Paint1pxHorizontalLine(canvas, border_color, bounds, true); 1305 BrowserView::Paint1pxHorizontalLine(canvas, border_color, bounds, true);
1294 } 1306 }
1295 1307
1296 void LocationBarView::PaintChildren(const ui::PaintContext& context) { 1308 void LocationBarView::PaintChildren(const ui::PaintContext& context) {
1297 View::PaintChildren(context); 1309 View::PaintChildren(context);
1298
1299 ui::PaintRecorder recorder(context, size()); 1310 ui::PaintRecorder recorder(context, size());
1300 1311
1301 // For non-InstantExtendedAPI cases, if necessary, show focus rect. As we need 1312 // For non-InstantExtendedAPI cases, if necessary, show focus rect. As we need
1302 // the focus rect to appear on top of children we paint here rather than 1313 // the focus rect to appear on top of children we paint here rather than
1303 // OnPaint(). 1314 // OnPaint().
1304 // Note: |Canvas::DrawFocusRect| paints a dashed rect with gray color. 1315 // Note: |Canvas::DrawFocusRect| paints a dashed rect with gray color.
1305 if (show_focus_rect_ && HasFocus()) 1316 if (!ui::MaterialDesignController::IsModeMaterial() && show_focus_rect_ &&
1317 HasFocus())
1306 recorder.canvas()->DrawFocusRect(omnibox_view_->bounds()); 1318 recorder.canvas()->DrawFocusRect(omnibox_view_->bounds());
1307 1319
1308 if (!ui::MaterialDesignController::IsModeMaterial() && !is_popup_mode_) { 1320 if (!ui::MaterialDesignController::IsModeMaterial() && !is_popup_mode_) {
1309 views::Painter::PaintPainterAt(recorder.canvas(), border_painter_.get(), 1321 views::Painter::PaintPainterAt(recorder.canvas(), border_painter_.get(),
1310 GetContentsBounds()); 1322 GetContentsBounds());
1311 } 1323 }
1312 } 1324 }
1313 1325
1314 //////////////////////////////////////////////////////////////////////////////// 1326 ////////////////////////////////////////////////////////////////////////////////
1315 // LocationBarView, private views::DragController implementation: 1327 // LocationBarView, private views::DragController implementation:
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1358 //////////////////////////////////////////////////////////////////////////////// 1370 ////////////////////////////////////////////////////////////////////////////////
1359 // LocationBarView, private OmniboxEditController implementation: 1371 // LocationBarView, private OmniboxEditController implementation:
1360 1372
1361 void LocationBarView::OnChanged() { 1373 void LocationBarView::OnChanged() {
1362 RefreshLocationIcon(); 1374 RefreshLocationIcon();
1363 location_icon_view_->set_show_tooltip(!GetOmniboxView()->IsEditingOrEmpty()); 1375 location_icon_view_->set_show_tooltip(!GetOmniboxView()->IsEditingOrEmpty());
1364 Layout(); 1376 Layout();
1365 SchedulePaint(); 1377 SchedulePaint();
1366 } 1378 }
1367 1379
1368 void LocationBarView::OnSetFocus() {
1369 GetFocusManager()->SetFocusedView(this);
1370 }
1371
1372 const ToolbarModel* LocationBarView::GetToolbarModel() const { 1380 const ToolbarModel* LocationBarView::GetToolbarModel() const {
1373 return delegate_->GetToolbarModel(); 1381 return delegate_->GetToolbarModel();
1374 } 1382 }
1375 1383
1376 //////////////////////////////////////////////////////////////////////////////// 1384 ////////////////////////////////////////////////////////////////////////////////
1377 // LocationBarView, private DropdownBarHostDelegate implementation: 1385 // LocationBarView, private DropdownBarHostDelegate implementation:
1378 1386
1379 void LocationBarView::SetFocusAndSelection(bool select_all) { 1387 void LocationBarView::SetFocusAndSelection(bool select_all) {
1380 FocusLocation(select_all); 1388 FocusLocation(select_all);
1381 } 1389 }
1382 1390
1383 //////////////////////////////////////////////////////////////////////////////// 1391 ////////////////////////////////////////////////////////////////////////////////
1384 // LocationBarView, private TemplateURLServiceObserver implementation: 1392 // LocationBarView, private TemplateURLServiceObserver implementation:
1385 1393
1386 void LocationBarView::OnTemplateURLServiceChanged() { 1394 void LocationBarView::OnTemplateURLServiceChanged() {
1387 template_url_service_->RemoveObserver(this); 1395 template_url_service_->RemoveObserver(this);
1388 template_url_service_ = nullptr; 1396 template_url_service_ = nullptr;
1389 // If the browser is no longer active, let's not show the info bubble, as this 1397 // If the browser is no longer active, let's not show the info bubble, as this
1390 // would make the browser the active window again. 1398 // would make the browser the active window again.
1391 if (omnibox_view_ && omnibox_view_->GetWidget()->IsActive()) 1399 if (omnibox_view_ && omnibox_view_->GetWidget()->IsActive())
1392 ShowFirstRunBubble(); 1400 ShowFirstRunBubble();
1393 } 1401 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/location_bar/location_bar_view.h ('k') | chrome/browser/ui/views/omnibox/omnibox_view_views.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698