Chromium Code Reviews| 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/i18n/rtl.h" | 10 #include "base/i18n/rtl.h" |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 154 edit_bookmarks_enabled_.Init( | 154 edit_bookmarks_enabled_.Init( |
| 155 bookmarks::prefs::kEditBookmarksEnabled, profile->GetPrefs(), | 155 bookmarks::prefs::kEditBookmarksEnabled, profile->GetPrefs(), |
| 156 base::Bind(&LocationBarView::UpdateWithoutTabRestore, | 156 base::Bind(&LocationBarView::UpdateWithoutTabRestore, |
| 157 base::Unretained(this))); | 157 base::Unretained(this))); |
| 158 | 158 |
| 159 if (browser_) | 159 if (browser_) |
| 160 browser_->search_model()->AddObserver(this); | 160 browser_->search_model()->AddObserver(this); |
| 161 | 161 |
| 162 ui_zoom::ZoomEventManager::GetForBrowserContext(profile) | 162 ui_zoom::ZoomEventManager::GetForBrowserContext(profile) |
| 163 ->AddZoomEventManagerObserver(this); | 163 ->AddZoomEventManagerObserver(this); |
| 164 if (ui::MaterialDesignController::IsModeMaterial()) { | |
|
Peter Kasting
2015/10/19 21:09:44
Nit: Blank line above.
jonross
2015/10/20 18:54:53
Done.
| |
| 165 set_background(views::Background::CreateSolidScaledBackground( | |
| 166 GetColor(SecurityStateModel::NONE, BACKGROUND), | |
| 167 SkColorSetARGB(0x4D, 0x00, 0x00, 0x00), !is_popup_mode_)); | |
| 168 } | |
| 164 } | 169 } |
| 165 | 170 |
| 166 LocationBarView::~LocationBarView() { | 171 LocationBarView::~LocationBarView() { |
| 167 if (template_url_service_) | 172 if (template_url_service_) |
| 168 template_url_service_->RemoveObserver(this); | 173 template_url_service_->RemoveObserver(this); |
| 169 if (browser_) | 174 if (browser_) |
| 170 browser_->search_model()->RemoveObserver(this); | 175 browser_->search_model()->RemoveObserver(this); |
| 171 | 176 |
| 172 ui_zoom::ZoomEventManager::GetForBrowserContext(profile()) | 177 ui_zoom::ZoomEventManager::GetForBrowserContext(profile()) |
| 173 ->RemoveZoomEventManagerObserver(this); | 178 ->RemoveZoomEventManagerObserver(this); |
| (...skipping 1069 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1243 | 1248 |
| 1244 void LocationBarView::OnFocus() { | 1249 void LocationBarView::OnFocus() { |
| 1245 // Explicitly focus the omnibox so a focus ring will be displayed around it on | 1250 // Explicitly focus the omnibox so a focus ring will be displayed around it on |
| 1246 // Windows. | 1251 // Windows. |
| 1247 omnibox_view_->SetFocus(); | 1252 omnibox_view_->SetFocus(); |
| 1248 } | 1253 } |
| 1249 | 1254 |
| 1250 void LocationBarView::OnPaint(gfx::Canvas* canvas) { | 1255 void LocationBarView::OnPaint(gfx::Canvas* canvas) { |
| 1251 View::OnPaint(canvas); | 1256 View::OnPaint(canvas); |
| 1252 | 1257 |
| 1258 // SolidScaledBackground is used in Material Design | |
|
Peter Kasting
2015/10/19 21:09:44
Nit: Comments should have periods.
Maybe this:
jonross
2015/10/20 18:54:53
Done.
| |
| 1259 if (ui::MaterialDesignController::IsModeMaterial()) | |
| 1260 return; | |
| 1261 | |
| 1253 // Fill the location bar background color behind the border. Parts of the | 1262 // Fill the location bar background color behind the border. Parts of the |
| 1254 // border images are meant to rest atop the toolbar background and parts atop | 1263 // border images are meant to rest atop the toolbar background and parts atop |
| 1255 // the omnibox background, so we can't just blindly fill our entire bounds. | 1264 // the omnibox background, so we can't just blindly fill our entire bounds. |
| 1256 gfx::Rect bounds(GetContentsBounds()); | 1265 gfx::Rect bounds(GetContentsBounds()); |
| 1257 bounds.Inset(GetHorizontalEdgeThickness(), GetVerticalEdgeThickness()); | 1266 bounds.Inset(GetHorizontalEdgeThickness(), GetVerticalEdgeThickness()); |
| 1258 SkColor color(GetColor(SecurityStateModel::NONE, BACKGROUND)); | 1267 SkColor color(GetColor(SecurityStateModel::NONE, BACKGROUND)); |
| 1259 if (is_popup_mode_) { | 1268 if (is_popup_mode_) { |
| 1260 canvas->FillRect(bounds, color); | 1269 canvas->FillRect(bounds, color); |
| 1261 } else { | 1270 } else { |
| 1262 SkPaint paint; | 1271 SkPaint paint; |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 1275 | 1284 |
| 1276 ui::PaintRecorder recorder(context, size()); | 1285 ui::PaintRecorder recorder(context, size()); |
| 1277 | 1286 |
| 1278 // For non-InstantExtendedAPI cases, if necessary, show focus rect. As we need | 1287 // For non-InstantExtendedAPI cases, if necessary, show focus rect. As we need |
| 1279 // the focus rect to appear on top of children we paint here rather than | 1288 // the focus rect to appear on top of children we paint here rather than |
| 1280 // OnPaint(). | 1289 // OnPaint(). |
| 1281 // Note: |Canvas::DrawFocusRect| paints a dashed rect with gray color. | 1290 // Note: |Canvas::DrawFocusRect| paints a dashed rect with gray color. |
| 1282 if (show_focus_rect_ && HasFocus()) | 1291 if (show_focus_rect_ && HasFocus()) |
| 1283 recorder.canvas()->DrawFocusRect(omnibox_view_->bounds()); | 1292 recorder.canvas()->DrawFocusRect(omnibox_view_->bounds()); |
| 1284 | 1293 |
| 1294 // SolidScaledBackground used for Material Design | |
|
Peter Kasting
2015/10/19 21:09:44
See above
jonross
2015/10/20 18:54:53
Done.
| |
| 1295 if (ui::MaterialDesignController::IsModeMaterial()) | |
| 1296 return; | |
| 1297 | |
| 1285 // Maximized popup windows don't draw the horizontal edges. We implement this | 1298 // Maximized popup windows don't draw the horizontal edges. We implement this |
| 1286 // by simply expanding the paint area outside the view by the edge thickness. | 1299 // by simply expanding the paint area outside the view by the edge thickness. |
| 1287 gfx::Rect border_rect(GetContentsBounds()); | 1300 gfx::Rect border_rect(GetContentsBounds()); |
| 1288 if (is_popup_mode_ && (GetHorizontalEdgeThickness() == 0)) | 1301 if (is_popup_mode_ && (GetHorizontalEdgeThickness() == 0)) |
| 1289 border_rect.Inset(-kPopupEdgeThickness, 0); | 1302 border_rect.Inset(-kPopupEdgeThickness, 0); |
| 1290 | 1303 |
| 1291 if (ui::MaterialDesignController::IsModeMaterial()) { | 1304 views::Painter::PaintPainterAt(recorder.canvas(), border_painter_.get(), |
| 1292 gfx::Canvas* canvas = recorder.canvas(); | 1305 border_rect); |
| 1293 const float scale = canvas->SaveAndUnscale(); | |
| 1294 | |
| 1295 SkPaint paint; | |
| 1296 paint.setStyle(SkPaint::Style::kStroke_Style); | |
| 1297 paint.setColor(SkColorSetARGB(0x40, 0x00, 0x00, 0x00)); | |
| 1298 paint.setStrokeWidth(1); | |
| 1299 paint.setAntiAlias(true); | |
| 1300 | |
| 1301 const float kOffset = 0.5f; | |
| 1302 gfx::RectF border_rect_f(border_rect); | |
| 1303 border_rect_f.Scale(scale); | |
| 1304 gfx::InsetsF insets(kOffset, kOffset, kOffset, kOffset); | |
| 1305 border_rect_f.Inset(insets); | |
| 1306 | |
| 1307 const SkScalar kCornerRadius = SkDoubleToScalar(2.5f * scale); | |
| 1308 canvas->sk_canvas()->drawRoundRect(gfx::RectFToSkRect(border_rect_f), | |
| 1309 kCornerRadius, kCornerRadius, paint); | |
| 1310 recorder.canvas()->Restore(); | |
| 1311 } else { | |
| 1312 views::Painter::PaintPainterAt(recorder.canvas(), border_painter_.get(), | |
| 1313 border_rect); | |
| 1314 } | |
| 1315 } | 1306 } |
| 1316 | 1307 |
| 1317 //////////////////////////////////////////////////////////////////////////////// | 1308 //////////////////////////////////////////////////////////////////////////////// |
| 1318 // LocationBarView, private views::ButtonListener implementation: | 1309 // LocationBarView, private views::ButtonListener implementation: |
| 1319 | 1310 |
| 1320 void LocationBarView::ButtonPressed(views::Button* sender, | 1311 void LocationBarView::ButtonPressed(views::Button* sender, |
| 1321 const ui::Event& event) { | 1312 const ui::Event& event) { |
| 1322 DCHECK_EQ(mic_search_view_, sender); | 1313 DCHECK_EQ(mic_search_view_, sender); |
| 1323 command_updater()->ExecuteCommand(IDC_TOGGLE_SPEECH_INPUT); | 1314 command_updater()->ExecuteCommand(IDC_TOGGLE_SPEECH_INPUT); |
| 1324 } | 1315 } |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1418 | 1409 |
| 1419 void LocationBarView::ModelChanged(const SearchModel::State& old_state, | 1410 void LocationBarView::ModelChanged(const SearchModel::State& old_state, |
| 1420 const SearchModel::State& new_state) { | 1411 const SearchModel::State& new_state) { |
| 1421 const bool visible = !GetToolbarModel()->input_in_progress() && | 1412 const bool visible = !GetToolbarModel()->input_in_progress() && |
| 1422 new_state.voice_search_supported; | 1413 new_state.voice_search_supported; |
| 1423 if (mic_search_view_->visible() != visible) { | 1414 if (mic_search_view_->visible() != visible) { |
| 1424 mic_search_view_->SetVisible(visible); | 1415 mic_search_view_->SetVisible(visible); |
| 1425 Layout(); | 1416 Layout(); |
| 1426 } | 1417 } |
| 1427 } | 1418 } |
| OLD | NEW |