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/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 1392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1403 | 1403 |
1404 void LocationBarView::OnBoundsChanged(const gfx::Rect& previous_bounds) { | 1404 void LocationBarView::OnBoundsChanged(const gfx::Rect& previous_bounds) { |
1405 InstantServiceFactory::GetForProfile(profile())->OnOmniboxStartMarginChanged( | 1405 InstantServiceFactory::GetForProfile(profile())->OnOmniboxStartMarginChanged( |
1406 bounds().x()); | 1406 bounds().x()); |
1407 | 1407 |
1408 OmniboxPopupView* popup = omnibox_view_->model()->popup_model()->view(); | 1408 OmniboxPopupView* popup = omnibox_view_->model()->popup_model()->view(); |
1409 if (popup->IsOpen()) | 1409 if (popup->IsOpen()) |
1410 popup->UpdatePopupAppearance(); | 1410 popup->UpdatePopupAppearance(); |
1411 } | 1411 } |
1412 | 1412 |
1413 void LocationBarView::OnFocus() { | |
1414 // Focus the view widget first which implements accessibility for | |
1415 // Chrome OS. It is noop on Win. This should be removed once | |
1416 // Chrome OS migrates to aura, which uses Views' textfield that receives | |
1417 // focus. See crbug.com/106428. | |
1418 NotifyAccessibilityEvent(ui::AX_EVENT_FOCUS, false); | |
1419 | |
1420 // Then focus the native location view which implements accessibility for | |
1421 // Windows. | |
1422 omnibox_view_->SetFocus(); | |
1423 } | |
1424 | |
1425 void LocationBarView::OnPaint(gfx::Canvas* canvas) { | 1413 void LocationBarView::OnPaint(gfx::Canvas* canvas) { |
1426 View::OnPaint(canvas); | 1414 View::OnPaint(canvas); |
1427 | 1415 |
1428 // Fill the location bar background color behind the border. Parts of the | 1416 // Fill the location bar background color behind the border. Parts of the |
1429 // border images are meant to rest atop the toolbar background and parts atop | 1417 // border images are meant to rest atop the toolbar background and parts atop |
1430 // the omnibox background, so we can't just blindly fill our entire bounds. | 1418 // the omnibox background, so we can't just blindly fill our entire bounds. |
1431 gfx::Rect bounds(GetContentsBounds()); | 1419 gfx::Rect bounds(GetContentsBounds()); |
1432 bounds.Inset(GetHorizontalEdgeThickness(), vertical_edge_thickness()); | 1420 bounds.Inset(GetHorizontalEdgeThickness(), vertical_edge_thickness()); |
1433 SkColor color(GetColor(ToolbarModel::NONE, BACKGROUND)); | 1421 SkColor color(GetColor(ToolbarModel::NONE, BACKGROUND)); |
1434 if (is_popup_mode_) { | 1422 if (is_popup_mode_) { |
1435 canvas->FillRect(bounds, color); | 1423 canvas->FillRect(bounds, color); |
1436 } else { | 1424 } else { |
1437 SkPaint paint; | 1425 SkPaint paint; |
1438 paint.setStyle(SkPaint::kFill_Style); | 1426 paint.setStyle(SkPaint::kFill_Style); |
1439 paint.setColor(color); | 1427 paint.setColor(color); |
1440 const int kBorderCornerRadius = 2; | 1428 const int kBorderCornerRadius = 2; |
1441 canvas->DrawRoundRect(bounds, kBorderCornerRadius, paint); | 1429 canvas->DrawRoundRect(bounds, kBorderCornerRadius, paint); |
1442 } | 1430 } |
1443 | 1431 |
1444 // The border itself will be drawn in PaintChildren() since it includes an | 1432 // The border itself will be drawn in PaintChildren() since it includes an |
1445 // inner shadow which should be drawn over the contents. | 1433 // inner shadow which should be drawn over the contents. |
1446 } | 1434 } |
1447 | 1435 |
1448 void LocationBarView::PaintChildren(gfx::Canvas* canvas) { | 1436 void LocationBarView::PaintChildren(gfx::Canvas* canvas) { |
1449 // Paint all the children except for the origin chip and the search button, | 1437 // Paint all the children except for the origin chip and the search button, |
1450 // which will be painted after the border. | 1438 // which will be painted after the border. |
1451 for (int i = 0, count = child_count(); i < count; ++i) | 1439 for (int i = 0, count = child_count(); i < count; ++i) { |
1452 if (!child_at(i)->layer() && | 1440 if (!child_at(i)->layer() && |
1453 (child_at(i) != origin_chip_view_) && | 1441 (child_at(i) != origin_chip_view_) && |
1454 (child_at(i) != search_button_)) | 1442 (child_at(i) != search_button_)) |
1455 child_at(i)->Paint(canvas); | 1443 child_at(i)->Paint(canvas); |
| 1444 } |
1456 | 1445 |
1457 // For non-InstantExtendedAPI cases, if necessary, show focus rect. As we need | 1446 // For non-InstantExtendedAPI cases, if necessary, show focus rect. As we need |
1458 // the focus rect to appear on top of children we paint here rather than | 1447 // the focus rect to appear on top of children we paint here rather than |
1459 // OnPaint(). | 1448 // OnPaint(). |
1460 // Note: |Canvas::DrawFocusRect| paints a dashed rect with gray color. | 1449 // Note: |Canvas::DrawFocusRect| paints a dashed rect with gray color. |
1461 if (show_focus_rect_ && HasFocus()) | 1450 if (show_focus_rect_ && HasFocus()) |
1462 canvas->DrawFocusRect(omnibox_view_->bounds()); | 1451 canvas->DrawFocusRect(omnibox_view_->bounds()); |
1463 | 1452 |
1464 // Maximized popup windows don't draw the horizontal edges. We implement this | 1453 // Maximized popup windows don't draw the horizontal edges. We implement this |
1465 // by simply expanding the paint area outside the view by the edge thickness. | 1454 // by simply expanding the paint area outside the view by the edge thickness. |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1652 void LocationBarView::ModelChanged(const SearchModel::State& old_state, | 1641 void LocationBarView::ModelChanged(const SearchModel::State& old_state, |
1653 const SearchModel::State& new_state) { | 1642 const SearchModel::State& new_state) { |
1654 const bool visible = !GetToolbarModel()->input_in_progress() && | 1643 const bool visible = !GetToolbarModel()->input_in_progress() && |
1655 new_state.voice_search_supported; | 1644 new_state.voice_search_supported; |
1656 if (mic_search_view_->visible() != visible) { | 1645 if (mic_search_view_->visible() != visible) { |
1657 mic_search_view_->SetVisible(visible); | 1646 mic_search_view_->SetVisible(visible); |
1658 Layout(); | 1647 Layout(); |
1659 } | 1648 } |
1660 } | 1649 } |
1661 | 1650 |
OLD | NEW |