Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(413)

Unified Diff: ash/shelf/shelf_view.cc

Issue 614653002: ash::ShelfView: CHECK against potentially bad static_casts. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/shelf/shelf_view.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/shelf/shelf_view.cc
diff --git a/ash/shelf/shelf_view.cc b/ash/shelf/shelf_view.cc
index 0fd7a01774cdd96990fabb58ba4de2be130a7933..42545c714b8dacc1fcda101f61be301d24ad2b5f 100644
--- a/ash/shelf/shelf_view.cc
+++ b/ash/shelf/shelf_view.cc
@@ -462,7 +462,9 @@ gfx::Rect ShelfView::GetIdealBoundsOfItemIcon(ShelfID id) {
index = last_visible_index_ + 1;
const gfx::Rect& ideal_bounds(view_model_->ideal_bounds(index));
DCHECK_NE(TYPE_APP_LIST, model_->items()[index].type);
- ShelfButton* button = static_cast<ShelfButton*>(view_model_->view_at(index));
+ views::View* view = view_model_->view_at(index);
+ CHECK_EQ(ShelfButton::kViewClassName, view->GetClassName());
+ ShelfButton* button = static_cast<ShelfButton*>(view);
gfx::Rect icon_bounds = button->GetIconBounds();
return gfx::Rect(GetMirroredXWithWidthInView(
ideal_bounds.x() + icon_bounds.x(), icon_bounds.width()),
@@ -1068,9 +1070,8 @@ bool ShelfView::HandleRipOffDrag(const ui::LocatedEvent& event) {
int delta = CalculateShelfDistance(screen_location);
if (delta > kRipOffDistance) {
// Create a proxy view item which can be moved anywhere.
- ShelfButton* button = static_cast<ShelfButton*>(drag_view_);
CreateDragIconProxy(event.root_location(),
- button->GetImage(),
+ drag_view_->GetImage(),
drag_view_,
gfx::Vector2d(0, 0),
kDragAndDropProxyScale);
@@ -1152,8 +1153,7 @@ void ShelfView::FinalizeRipOffDrag(bool cancel) {
// animation end the flag gets cleared if |snap_back_from_rip_off_view_|
// is set.
snap_back_from_rip_off_view_ = drag_view_;
- ShelfButton* button = static_cast<ShelfButton*>(drag_view_);
- button->AddState(ShelfButton::STATE_HIDDEN);
+ drag_view_->AddState(ShelfButton::STATE_HIDDEN);
// When a canceling drag model is happening, the view model is diverged
// from the menu model and movements / animations should not be done.
model_->Move(current_index, start_drag_index_);
@@ -1528,6 +1528,7 @@ void ShelfView::ShelfItemChanged(int model_index, const ShelfItem& old_item) {
case TYPE_PLATFORM_APP:
case TYPE_DIALOG:
case TYPE_APP_PANEL: {
+ CHECK_EQ(ShelfButton::kViewClassName, view->GetClassName());
ShelfButton* button = static_cast<ShelfButton*>(view);
ReflectItemStatus(item, button);
// The browser shortcut is currently not a "real" item and as such the
@@ -1572,7 +1573,8 @@ void ShelfView::PointerPressedOnButton(views::View* view,
if (view_model_->view_size() <= 1 || !item_delegate->IsDraggable())
return; // View is being deleted or not draggable, ignore request.
- drag_view_ = view;
+ CHECK_EQ(ShelfButton::kViewClassName, view->GetClassName());
+ drag_view_ = static_cast<ShelfButton*>(view);
drag_origin_ = gfx::Point(event.x(), event.y());
UMA_HISTOGRAM_ENUMERATION("Ash.ShelfAlignmentUsage",
layout_manager_->SelectValueForShelfAlignment(
@@ -1866,6 +1868,7 @@ void ShelfView::OnBoundsAnimatorDone(views::BoundsAnimator* animator) {
for (int index = 0; index < view_model_->view_size(); index++) {
views::View* view = view_model_->view_at(index);
if (view == snap_back_from_rip_off_view_) {
+ CHECK_EQ(ShelfButton::kViewClassName, view->GetClassName());
ShelfButton* button = static_cast<ShelfButton*>(view);
button->ClearState(ShelfButton::STATE_HIDDEN);
break;
« no previous file with comments | « ash/shelf/shelf_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698