| 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/infobars/infobar_view.h" | 5 #include "chrome/browser/ui/views/infobars/infobar_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 | 77 |
| 78 InfoBarView::InfoBarView(scoped_ptr<infobars::InfoBarDelegate> delegate) | 78 InfoBarView::InfoBarView(scoped_ptr<infobars::InfoBarDelegate> delegate) |
| 79 : infobars::InfoBar(std::move(delegate)), | 79 : infobars::InfoBar(std::move(delegate)), |
| 80 views::ExternalFocusTracker(this, nullptr), | 80 views::ExternalFocusTracker(this, nullptr), |
| 81 child_container_(new views::View()), | 81 child_container_(new views::View()), |
| 82 icon_(nullptr), | 82 icon_(nullptr), |
| 83 close_button_(nullptr) { | 83 close_button_(nullptr) { |
| 84 set_owned_by_client(); // InfoBar deletes itself at the appropriate time. | 84 set_owned_by_client(); // InfoBar deletes itself at the appropriate time. |
| 85 set_background( | 85 set_background( |
| 86 new InfoBarBackground(infobars::InfoBar::delegate()->GetInfoBarType())); | 86 new InfoBarBackground(infobars::InfoBar::delegate()->GetInfoBarType())); |
| 87 SetEventTargeter(make_scoped_ptr(new views::ViewTargeter(this))); |
| 87 | 88 |
| 88 AddChildView(child_container_); | 89 AddChildView(child_container_); |
| 89 | 90 |
| 90 if (ui::MaterialDesignController::IsModeMaterial()) { | 91 if (ui::MaterialDesignController::IsModeMaterial()) { |
| 92 SetPaintToLayer(true); |
| 93 layer()->SetFillsBoundsOpaquely(false); |
| 94 |
| 91 child_container_->SetPaintToLayer(true); | 95 child_container_->SetPaintToLayer(true); |
| 92 child_container_->layer()->SetMasksToBounds(true); | 96 child_container_->layer()->SetMasksToBounds(true); |
| 93 // Since MD doesn't use a gradient, we can set a solid bg color. | 97 // Since MD doesn't use a gradient, we can set a solid bg color. |
| 94 child_container_->set_background( | 98 child_container_->set_background( |
| 95 views::Background::CreateSolidBackground(infobars::InfoBar::GetTopColor( | 99 views::Background::CreateSolidBackground(infobars::InfoBar::GetTopColor( |
| 96 infobars::InfoBar::delegate()->GetInfoBarType()))); | 100 infobars::InfoBar::delegate()->GetInfoBarType()))); |
| 97 } | 101 } |
| 98 } | 102 } |
| 99 | 103 |
| 100 InfoBarView::~InfoBarView() { | 104 InfoBarView::~InfoBarView() { |
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 422 void InfoBarView::OnWillChangeFocus(View* focused_before, View* focused_now) { | 426 void InfoBarView::OnWillChangeFocus(View* focused_before, View* focused_now) { |
| 423 views::ExternalFocusTracker::OnWillChangeFocus(focused_before, focused_now); | 427 views::ExternalFocusTracker::OnWillChangeFocus(focused_before, focused_now); |
| 424 | 428 |
| 425 // This will trigger some screen readers to read the entire contents of this | 429 // This will trigger some screen readers to read the entire contents of this |
| 426 // infobar. | 430 // infobar. |
| 427 if (focused_before && focused_now && !Contains(focused_before) && | 431 if (focused_before && focused_now && !Contains(focused_before) && |
| 428 Contains(focused_now)) { | 432 Contains(focused_now)) { |
| 429 NotifyAccessibilityEvent(ui::AX_EVENT_ALERT, true); | 433 NotifyAccessibilityEvent(ui::AX_EVENT_ALERT, true); |
| 430 } | 434 } |
| 431 } | 435 } |
| 436 |
| 437 bool InfoBarView::DoesIntersectRect(const View* target, |
| 438 const gfx::Rect& rect) const { |
| 439 DCHECK_EQ(this, target); |
| 440 // Only events that intersect the portion below the arrow are interesting. |
| 441 gfx::Rect non_arrow_bounds = GetLocalBounds(); |
| 442 non_arrow_bounds.Inset(0, arrow_height(), 0, 0); |
| 443 return rect.Intersects(non_arrow_bounds); |
| 444 } |
| OLD | NEW |