| 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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 | 94 |
| 95 #if !defined(OS_CHROMEOS) | 95 #if !defined(OS_CHROMEOS) |
| 96 #include "chrome/browser/ui/views/first_run_bubble.h" | 96 #include "chrome/browser/ui/views/first_run_bubble.h" |
| 97 #endif | 97 #endif |
| 98 | 98 |
| 99 using content::WebContents; | 99 using content::WebContents; |
| 100 using views::View; | 100 using views::View; |
| 101 | 101 |
| 102 namespace { | 102 namespace { |
| 103 | 103 |
| 104 // The border color for MD windows, as well as non-MD popup windows. |
| 105 const SkColor kBorderColor = SkColorSetA(SK_ColorBLACK, 0x4D); |
| 106 |
| 104 int GetEditLeadingInternalSpace() { | 107 int GetEditLeadingInternalSpace() { |
| 105 // The textfield has 1 px of whitespace before the text in the RTL case only. | 108 // The textfield has 1 px of whitespace before the text in the RTL case only. |
| 106 return base::i18n::IsRTL() ? 1 : 0; | 109 return base::i18n::IsRTL() ? 1 : 0; |
| 107 } | 110 } |
| 108 | 111 |
| 109 } // namespace | 112 } // namespace |
| 110 | 113 |
| 111 | 114 |
| 112 // LocationBarView ----------------------------------------------------------- | 115 // LocationBarView ----------------------------------------------------------- |
| 113 | 116 |
| 114 // static | 117 // static |
| 115 | |
| 116 const char LocationBarView::kViewClassName[] = "LocationBarView"; | 118 const char LocationBarView::kViewClassName[] = "LocationBarView"; |
| 117 | 119 |
| 118 LocationBarView::LocationBarView(Browser* browser, | 120 LocationBarView::LocationBarView(Browser* browser, |
| 119 Profile* profile, | 121 Profile* profile, |
| 120 CommandUpdater* command_updater, | 122 CommandUpdater* command_updater, |
| 121 Delegate* delegate, | 123 Delegate* delegate, |
| 122 bool is_popup_mode) | 124 bool is_popup_mode) |
| 123 : LocationBar(profile), | 125 : LocationBar(profile), |
| 124 ChromeOmniboxEditController(command_updater), | 126 ChromeOmniboxEditController(command_updater), |
| 125 browser_(browser), | 127 browser_(browser), |
| (...skipping 650 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 776 location_bounds.right(), location_bounds.y(), | 778 location_bounds.right(), location_bounds.y(), |
| 777 std::min(width, entry_width), location_bounds.height()); | 779 std::min(width, entry_width), location_bounds.height()); |
| 778 } | 780 } |
| 779 omnibox_view_->SetBoundsRect(location_bounds); | 781 omnibox_view_->SetBoundsRect(location_bounds); |
| 780 } | 782 } |
| 781 | 783 |
| 782 void LocationBarView::OnNativeThemeChanged(const ui::NativeTheme* theme) { | 784 void LocationBarView::OnNativeThemeChanged(const ui::NativeTheme* theme) { |
| 783 if (ui::MaterialDesignController::IsModeMaterial()) { | 785 if (ui::MaterialDesignController::IsModeMaterial()) { |
| 784 RefreshLocationIcon(); | 786 RefreshLocationIcon(); |
| 785 if (!is_popup_mode_) { | 787 if (!is_popup_mode_) { |
| 786 set_background(new BackgroundWith1PxBorder( | 788 set_background(new BackgroundWith1PxBorder(GetColor(BACKGROUND), |
| 787 GetColor(BACKGROUND), SkColorSetARGB(0x4D, 0x00, 0x00, 0x00))); | 789 kBorderColor)); |
| 788 } | 790 } |
| 789 } | 791 } |
| 790 } | 792 } |
| 791 | 793 |
| 792 void LocationBarView::Update(const WebContents* contents) { | 794 void LocationBarView::Update(const WebContents* contents) { |
| 793 RefreshContentSettingViews(); | 795 RefreshContentSettingViews(); |
| 794 RefreshZoomView(); | 796 RefreshZoomView(); |
| 795 RefreshPageActionViews(); | 797 RefreshPageActionViews(); |
| 796 RefreshTranslateIcon(); | 798 RefreshTranslateIcon(); |
| 797 RefreshSaveCreditCardIconView(); | 799 RefreshSaveCreditCardIconView(); |
| (...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1264 | 1266 |
| 1265 if (ui::MaterialDesignController::IsModeMaterial() && !is_popup_mode_) | 1267 if (ui::MaterialDesignController::IsModeMaterial() && !is_popup_mode_) |
| 1266 return; // The background and border are painted by our Background. | 1268 return; // The background and border are painted by our Background. |
| 1267 | 1269 |
| 1268 // Fill the location bar background color behind the border. Parts of the | 1270 // Fill the location bar background color behind the border. Parts of the |
| 1269 // border images are meant to rest atop the toolbar background and parts atop | 1271 // border images are meant to rest atop the toolbar background and parts atop |
| 1270 // the omnibox background, so we can't just blindly fill our entire bounds. | 1272 // the omnibox background, so we can't just blindly fill our entire bounds. |
| 1271 gfx::Rect bounds(GetContentsBounds()); | 1273 gfx::Rect bounds(GetContentsBounds()); |
| 1272 const int edge_thickness = GetEdgeThickness(); | 1274 const int edge_thickness = GetEdgeThickness(); |
| 1273 bounds.Inset(edge_thickness, edge_thickness); | 1275 bounds.Inset(edge_thickness, edge_thickness); |
| 1274 SkColor color(GetColor(BACKGROUND)); | 1276 SkColor background_color(GetColor(BACKGROUND)); |
| 1275 if (is_popup_mode_) { | 1277 if (is_popup_mode_) { |
| 1276 canvas->FillRect(bounds, color); | 1278 canvas->FillRect(bounds, background_color); |
| 1277 } else { | 1279 } else { |
| 1278 SkPaint paint; | 1280 SkPaint paint; |
| 1279 paint.setStyle(SkPaint::kFill_Style); | 1281 paint.setStyle(SkPaint::kFill_Style); |
| 1280 paint.setColor(color); | 1282 paint.setColor(background_color); |
| 1281 const int kBorderCornerRadius = 2; | 1283 const int kBorderCornerRadius = 2; |
| 1282 canvas->DrawRoundRect(bounds, kBorderCornerRadius, paint); | 1284 canvas->DrawRoundRect(bounds, kBorderCornerRadius, paint); |
| 1285 // The border itself will be drawn in PaintChildren() since it includes an |
| 1286 // inner shadow which should be drawn over the contents. |
| 1283 } | 1287 } |
| 1284 | |
| 1285 // The border itself will be drawn in PaintChildren() since it includes an | |
| 1286 // inner shadow which should be drawn over the contents. | |
| 1287 } | 1288 } |
| 1288 | 1289 |
| 1289 void LocationBarView::PaintChildren(const ui::PaintContext& context) { | 1290 void LocationBarView::PaintChildren(const ui::PaintContext& context) { |
| 1290 View::PaintChildren(context); | 1291 View::PaintChildren(context); |
| 1291 | 1292 |
| 1292 ui::PaintRecorder recorder(context, size()); | 1293 ui::PaintRecorder recorder(context, size()); |
| 1293 | 1294 |
| 1294 // For non-InstantExtendedAPI cases, if necessary, show focus rect. As we need | 1295 // For non-InstantExtendedAPI cases, if necessary, show focus rect. As we need |
| 1295 // the focus rect to appear on top of children we paint here rather than | 1296 // the focus rect to appear on top of children we paint here rather than |
| 1296 // OnPaint(). | 1297 // OnPaint(). |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1377 // LocationBarView, private TemplateURLServiceObserver implementation: | 1378 // LocationBarView, private TemplateURLServiceObserver implementation: |
| 1378 | 1379 |
| 1379 void LocationBarView::OnTemplateURLServiceChanged() { | 1380 void LocationBarView::OnTemplateURLServiceChanged() { |
| 1380 template_url_service_->RemoveObserver(this); | 1381 template_url_service_->RemoveObserver(this); |
| 1381 template_url_service_ = nullptr; | 1382 template_url_service_ = nullptr; |
| 1382 // If the browser is no longer active, let's not show the info bubble, as this | 1383 // If the browser is no longer active, let's not show the info bubble, as this |
| 1383 // would make the browser the active window again. | 1384 // would make the browser the active window again. |
| 1384 if (omnibox_view_ && omnibox_view_->GetWidget()->IsActive()) | 1385 if (omnibox_view_ && omnibox_view_->GetWidget()->IsActive()) |
| 1385 ShowFirstRunBubble(); | 1386 ShowFirstRunBubble(); |
| 1386 } | 1387 } |
| OLD | NEW |