| 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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 | 98 |
| 99 #if !defined(OS_CHROMEOS) | 99 #if !defined(OS_CHROMEOS) |
| 100 #include "chrome/browser/ui/views/first_run_bubble.h" | 100 #include "chrome/browser/ui/views/first_run_bubble.h" |
| 101 #endif | 101 #endif |
| 102 | 102 |
| 103 using content::WebContents; | 103 using content::WebContents; |
| 104 using views::View; | 104 using views::View; |
| 105 | 105 |
| 106 namespace { | 106 namespace { |
| 107 | 107 |
| 108 // The border color for MD windows, as well as non-MD popup windows. | 108 // The border color, drawn on top of the toolbar. |
| 109 const SkColor kBorderColor = SkColorSetA(SK_ColorBLACK, 0x4D); | 109 const SkColor kBorderColor = SkColorSetA(SK_ColorBLACK, 0x4D); |
| 110 | 110 |
| 111 } // namespace | 111 } // namespace |
| 112 | 112 |
| 113 | 113 |
| 114 // LocationBarView ----------------------------------------------------------- | 114 // LocationBarView ----------------------------------------------------------- |
| 115 | 115 |
| 116 // static | 116 // static |
| 117 const char LocationBarView::kViewClassName[] = "LocationBarView"; | 117 const char LocationBarView::kViewClassName[] = "LocationBarView"; |
| 118 | 118 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 template_url_service_->RemoveObserver(this); | 155 template_url_service_->RemoveObserver(this); |
| 156 | 156 |
| 157 zoom::ZoomEventManager::GetForBrowserContext(profile()) | 157 zoom::ZoomEventManager::GetForBrowserContext(profile()) |
| 158 ->RemoveZoomEventManagerObserver(this); | 158 ->RemoveZoomEventManagerObserver(this); |
| 159 } | 159 } |
| 160 | 160 |
| 161 //////////////////////////////////////////////////////////////////////////////// | 161 //////////////////////////////////////////////////////////////////////////////// |
| 162 // LocationBarView, public: | 162 // LocationBarView, public: |
| 163 | 163 |
| 164 // static | 164 // static |
| 165 SkColor LocationBarView::GetBorderColor(bool incognito) { | 165 SkColor LocationBarView::GetOpaqueBorderColor(bool incognito) { |
| 166 return color_utils::AlphaBlend( | 166 return color_utils::GetResultingPaintColor( |
| 167 SkColorSetA(kBorderColor, SK_AlphaOPAQUE), | 167 kBorderColor, ThemeProperties::GetDefaultColor( |
| 168 ThemeProperties::GetDefaultColor(ThemeProperties::COLOR_TOOLBAR, | 168 ThemeProperties::COLOR_TOOLBAR, incognito)); |
| 169 incognito), | |
| 170 SkColorGetA(kBorderColor)); | |
| 171 } | 169 } |
| 172 | 170 |
| 173 void LocationBarView::Init() { | 171 void LocationBarView::Init() { |
| 174 // We need to be in a Widget, otherwise GetNativeTheme() may change and we're | 172 // We need to be in a Widget, otherwise GetNativeTheme() may change and we're |
| 175 // not prepared for that. | 173 // not prepared for that. |
| 176 DCHECK(GetWidget()); | 174 DCHECK(GetWidget()); |
| 177 | 175 |
| 178 // Make sure children with layers are clipped. See http://crbug.com/589497 | 176 // Make sure children with layers are clipped. See http://crbug.com/589497 |
| 179 SetPaintToLayer(); | 177 SetPaintToLayer(); |
| 180 layer()->SetFillsBoundsOpaquely(false); | 178 layer()->SetFillsBoundsOpaquely(false); |
| (...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 633 location_bounds.set_width(x); | 631 location_bounds.set_width(x); |
| 634 ime_inline_autocomplete_view_->SetBounds( | 632 ime_inline_autocomplete_view_->SetBounds( |
| 635 location_bounds.right(), location_bounds.y(), | 633 location_bounds.right(), location_bounds.y(), |
| 636 std::min(width, entry_width), location_bounds.height()); | 634 std::min(width, entry_width), location_bounds.height()); |
| 637 } | 635 } |
| 638 omnibox_view_->SetBoundsRect(location_bounds); | 636 omnibox_view_->SetBoundsRect(location_bounds); |
| 639 } | 637 } |
| 640 | 638 |
| 641 void LocationBarView::OnNativeThemeChanged(const ui::NativeTheme* theme) { | 639 void LocationBarView::OnNativeThemeChanged(const ui::NativeTheme* theme) { |
| 642 RefreshLocationIcon(); | 640 RefreshLocationIcon(); |
| 643 if (!is_popup_mode_) { | 641 if (is_popup_mode_) { |
| 642 set_background( |
| 643 views::Background::CreateSolidBackground(GetColor(BACKGROUND))); |
| 644 } else { |
| 645 // This border color will be blended on top of the toolbar (which may use an |
| 646 // image in the case of themes). |
| 644 set_background( | 647 set_background( |
| 645 new BackgroundWith1PxBorder(GetColor(BACKGROUND), kBorderColor)); | 648 new BackgroundWith1PxBorder(GetColor(BACKGROUND), kBorderColor)); |
| 646 SchedulePaint(); | |
| 647 } | 649 } |
| 650 SchedulePaint(); |
| 648 } | 651 } |
| 649 | 652 |
| 650 void LocationBarView::Update(const WebContents* contents) { | 653 void LocationBarView::Update(const WebContents* contents) { |
| 651 RefreshContentSettingViews(); | 654 RefreshContentSettingViews(); |
| 652 RefreshZoomView(); | 655 RefreshZoomView(); |
| 653 RefreshPageActionViews(); | 656 RefreshPageActionViews(); |
| 654 RefreshTranslateIcon(); | 657 RefreshTranslateIcon(); |
| 655 RefreshSaveCreditCardIconView(); | 658 RefreshSaveCreditCardIconView(); |
| 656 RefreshManagePasswordsIconView(); | 659 RefreshManagePasswordsIconView(); |
| 657 WebContents* web_contents_for_sub_views = | 660 WebContents* web_contents_for_sub_views = |
| (...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1141 paint.setAntiAlias(true); | 1144 paint.setAntiAlias(true); |
| 1142 paint.setColor(GetNativeTheme()->GetSystemColor( | 1145 paint.setColor(GetNativeTheme()->GetSystemColor( |
| 1143 ui::NativeTheme::NativeTheme::kColorId_FocusedBorderColor)); | 1146 ui::NativeTheme::NativeTheme::kColorId_FocusedBorderColor)); |
| 1144 paint.setStyle(SkPaint::kStroke_Style); | 1147 paint.setStyle(SkPaint::kStroke_Style); |
| 1145 paint.setStrokeWidth(1); | 1148 paint.setStrokeWidth(1); |
| 1146 gfx::RectF focus_rect(GetLocalBounds()); | 1149 gfx::RectF focus_rect(GetLocalBounds()); |
| 1147 focus_rect.Inset(gfx::InsetsF(0.5f)); | 1150 focus_rect.Inset(gfx::InsetsF(0.5f)); |
| 1148 canvas->DrawRoundRect(focus_rect, | 1151 canvas->DrawRoundRect(focus_rect, |
| 1149 BackgroundWith1PxBorder::kCornerRadius + 0.5f, paint); | 1152 BackgroundWith1PxBorder::kCornerRadius + 0.5f, paint); |
| 1150 } | 1153 } |
| 1154 } |
| 1155 |
| 1156 void LocationBarView::OnPaintBorder(gfx::Canvas* canvas) { |
| 1151 if (!is_popup_mode_) | 1157 if (!is_popup_mode_) |
| 1152 return; // The background and border are painted by our Background. | 1158 return; // The border is painted by our Background. |
| 1153 | 1159 |
| 1154 // Fill the location bar background color behind the border. Parts of the | |
| 1155 // border images are meant to rest atop the toolbar background and parts atop | |
| 1156 // the omnibox background, so we can't just blindly fill our entire bounds. | |
| 1157 gfx::Rect bounds(GetContentsBounds()); | 1160 gfx::Rect bounds(GetContentsBounds()); |
| 1158 bounds.Inset(GetHorizontalEdgeThickness(), | 1161 const SkColor border_color = |
| 1159 is_popup_mode_ | 1162 GetOpaqueBorderColor(profile()->IsOffTheRecord()); |
| 1160 ? 0 | |
| 1161 : BackgroundWith1PxBorder::kLocationBarBorderThicknessDip); | |
| 1162 SkColor background_color(GetColor(BACKGROUND)); | |
| 1163 canvas->FillRect(bounds, background_color); | |
| 1164 const SkColor border_color = GetBorderColor(profile()->IsOffTheRecord()); | |
| 1165 BrowserView::Paint1pxHorizontalLine(canvas, border_color, bounds, false); | 1163 BrowserView::Paint1pxHorizontalLine(canvas, border_color, bounds, false); |
| 1166 BrowserView::Paint1pxHorizontalLine(canvas, border_color, bounds, true); | 1164 BrowserView::Paint1pxHorizontalLine(canvas, border_color, bounds, true); |
| 1167 } | 1165 } |
| 1168 | 1166 |
| 1169 //////////////////////////////////////////////////////////////////////////////// | 1167 //////////////////////////////////////////////////////////////////////////////// |
| 1170 // LocationBarView, private views::DragController implementation: | 1168 // LocationBarView, private views::DragController implementation: |
| 1171 | 1169 |
| 1172 void LocationBarView::WriteDragDataForView(views::View* sender, | 1170 void LocationBarView::WriteDragDataForView(views::View* sender, |
| 1173 const gfx::Point& press_pt, | 1171 const gfx::Point& press_pt, |
| 1174 OSExchangeData* data) { | 1172 OSExchangeData* data) { |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1235 // LocationBarView, private TemplateURLServiceObserver implementation: | 1233 // LocationBarView, private TemplateURLServiceObserver implementation: |
| 1236 | 1234 |
| 1237 void LocationBarView::OnTemplateURLServiceChanged() { | 1235 void LocationBarView::OnTemplateURLServiceChanged() { |
| 1238 template_url_service_->RemoveObserver(this); | 1236 template_url_service_->RemoveObserver(this); |
| 1239 template_url_service_ = nullptr; | 1237 template_url_service_ = nullptr; |
| 1240 // If the browser is no longer active, let's not show the info bubble, as this | 1238 // If the browser is no longer active, let's not show the info bubble, as this |
| 1241 // would make the browser the active window again. | 1239 // would make the browser the active window again. |
| 1242 if (omnibox_view_ && omnibox_view_->GetWidget()->IsActive()) | 1240 if (omnibox_view_ && omnibox_view_->GetWidget()->IsActive()) |
| 1243 ShowFirstRunBubble(); | 1241 ShowFirstRunBubble(); |
| 1244 } | 1242 } |
| OLD | NEW |