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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 #include "extensions/browser/extension_registry.h" | 68 #include "extensions/browser/extension_registry.h" |
69 #include "extensions/common/feature_switch.h" | 69 #include "extensions/common/feature_switch.h" |
70 #include "grit/components_scaled_resources.h" | 70 #include "grit/components_scaled_resources.h" |
71 #include "grit/theme_resources.h" | 71 #include "grit/theme_resources.h" |
72 #include "ui/accessibility/ax_view_state.h" | 72 #include "ui/accessibility/ax_view_state.h" |
73 #include "ui/base/dragdrop/drag_drop_types.h" | 73 #include "ui/base/dragdrop/drag_drop_types.h" |
74 #include "ui/base/l10n/l10n_util.h" | 74 #include "ui/base/l10n/l10n_util.h" |
75 #include "ui/base/resource/resource_bundle.h" | 75 #include "ui/base/resource/resource_bundle.h" |
76 #include "ui/base/theme_provider.h" | 76 #include "ui/base/theme_provider.h" |
77 #include "ui/compositor/paint_context.h" | 77 #include "ui/compositor/paint_context.h" |
| 78 #include "ui/compositor/paint_recorder.h" |
78 #include "ui/events/event.h" | 79 #include "ui/events/event.h" |
79 #include "ui/gfx/animation/slide_animation.h" | 80 #include "ui/gfx/animation/slide_animation.h" |
80 #include "ui/gfx/canvas.h" | 81 #include "ui/gfx/canvas.h" |
81 #include "ui/gfx/color_utils.h" | 82 #include "ui/gfx/color_utils.h" |
82 #include "ui/gfx/image/image.h" | 83 #include "ui/gfx/image/image.h" |
83 #include "ui/gfx/image/image_skia_operations.h" | 84 #include "ui/gfx/image/image_skia_operations.h" |
84 #include "ui/gfx/scoped_canvas.h" | 85 #include "ui/gfx/scoped_canvas.h" |
85 #include "ui/gfx/skia_util.h" | 86 #include "ui/gfx/skia_util.h" |
86 #include "ui/gfx/text_utils.h" | 87 #include "ui/gfx/text_utils.h" |
87 #include "ui/native_theme/native_theme.h" | 88 #include "ui/native_theme/native_theme.h" |
(...skipping 1126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1214 canvas->DrawRoundRect(bounds, kBorderCornerRadius, paint); | 1215 canvas->DrawRoundRect(bounds, kBorderCornerRadius, paint); |
1215 } | 1216 } |
1216 | 1217 |
1217 // The border itself will be drawn in PaintChildren() since it includes an | 1218 // The border itself will be drawn in PaintChildren() since it includes an |
1218 // inner shadow which should be drawn over the contents. | 1219 // inner shadow which should be drawn over the contents. |
1219 } | 1220 } |
1220 | 1221 |
1221 void LocationBarView::PaintChildren(const ui::PaintContext& context) { | 1222 void LocationBarView::PaintChildren(const ui::PaintContext& context) { |
1222 View::PaintChildren(context); | 1223 View::PaintChildren(context); |
1223 | 1224 |
1224 gfx::Canvas* canvas = context.canvas(); | 1225 ui::PaintRecorder recorder(context); |
1225 | 1226 |
1226 // For non-InstantExtendedAPI cases, if necessary, show focus rect. As we need | 1227 // For non-InstantExtendedAPI cases, if necessary, show focus rect. As we need |
1227 // the focus rect to appear on top of children we paint here rather than | 1228 // the focus rect to appear on top of children we paint here rather than |
1228 // OnPaint(). | 1229 // OnPaint(). |
1229 // Note: |Canvas::DrawFocusRect| paints a dashed rect with gray color. | 1230 // Note: |Canvas::DrawFocusRect| paints a dashed rect with gray color. |
1230 if (show_focus_rect_ && HasFocus()) | 1231 if (show_focus_rect_ && HasFocus()) |
1231 canvas->DrawFocusRect(omnibox_view_->bounds()); | 1232 recorder.canvas()->DrawFocusRect(omnibox_view_->bounds()); |
1232 | 1233 |
1233 // Maximized popup windows don't draw the horizontal edges. We implement this | 1234 // Maximized popup windows don't draw the horizontal edges. We implement this |
1234 // by simply expanding the paint area outside the view by the edge thickness. | 1235 // by simply expanding the paint area outside the view by the edge thickness. |
1235 gfx::Rect border_rect(GetContentsBounds()); | 1236 gfx::Rect border_rect(GetContentsBounds()); |
1236 if (is_popup_mode_ && (GetHorizontalEdgeThickness() == 0)) | 1237 if (is_popup_mode_ && (GetHorizontalEdgeThickness() == 0)) |
1237 border_rect.Inset(-kPopupEdgeThickness, 0); | 1238 border_rect.Inset(-kPopupEdgeThickness, 0); |
1238 views::Painter::PaintPainterAt(canvas, border_painter_.get(), border_rect); | 1239 views::Painter::PaintPainterAt(recorder.canvas(), border_painter_.get(), |
| 1240 border_rect); |
1239 } | 1241 } |
1240 | 1242 |
1241 //////////////////////////////////////////////////////////////////////////////// | 1243 //////////////////////////////////////////////////////////////////////////////// |
1242 // LocationBarView, private views::ButtonListener implementation: | 1244 // LocationBarView, private views::ButtonListener implementation: |
1243 | 1245 |
1244 void LocationBarView::ButtonPressed(views::Button* sender, | 1246 void LocationBarView::ButtonPressed(views::Button* sender, |
1245 const ui::Event& event) { | 1247 const ui::Event& event) { |
1246 DCHECK_EQ(mic_search_view_, sender); | 1248 DCHECK_EQ(mic_search_view_, sender); |
1247 command_updater()->ExecuteCommand(IDC_TOGGLE_SPEECH_INPUT); | 1249 command_updater()->ExecuteCommand(IDC_TOGGLE_SPEECH_INPUT); |
1248 } | 1250 } |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1336 | 1338 |
1337 void LocationBarView::ModelChanged(const SearchModel::State& old_state, | 1339 void LocationBarView::ModelChanged(const SearchModel::State& old_state, |
1338 const SearchModel::State& new_state) { | 1340 const SearchModel::State& new_state) { |
1339 const bool visible = !GetToolbarModel()->input_in_progress() && | 1341 const bool visible = !GetToolbarModel()->input_in_progress() && |
1340 new_state.voice_search_supported; | 1342 new_state.voice_search_supported; |
1341 if (mic_search_view_->visible() != visible) { | 1343 if (mic_search_view_->visible() != visible) { |
1342 mic_search_view_->SetVisible(visible); | 1344 mic_search_view_->SetVisible(visible); |
1343 Layout(); | 1345 Layout(); |
1344 } | 1346 } |
1345 } | 1347 } |
OLD | NEW |