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

Side by Side Diff: ash/common/shelf/shelf_view.cc

Issue 2545923004: Remove LauncherItemController::type; use ShelfItems::type. (Closed)
Patch Set: Rebase; remove new LauncherItemController::TYPE_APP check. Created 4 years 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 unified diff | Download patch
OLDNEW
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 "ash/common/shelf/shelf_view.h" 5 #include "ash/common/shelf/shelf_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <memory> 8 #include <memory>
9 9
10 #include "ash/common/ash_constants.h" 10 #include "ash/common/ash_constants.h"
(...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after
590 WmShell::Get()->RecordUserMetricsAction(UMA_LAUNCHER_CLICK_ON_APP); 590 WmShell::Get()->RecordUserMetricsAction(UMA_LAUNCHER_CLICK_ON_APP);
591 break; 591 break;
592 592
593 case TYPE_APP_LIST: 593 case TYPE_APP_LIST:
594 WmShell::Get()->RecordUserMetricsAction( 594 WmShell::Get()->RecordUserMetricsAction(
595 UMA_LAUNCHER_CLICK_ON_APPLIST_BUTTON); 595 UMA_LAUNCHER_CLICK_ON_APPLIST_BUTTON);
596 break; 596 break;
597 597
598 case TYPE_APP_PANEL: 598 case TYPE_APP_PANEL:
599 case TYPE_DIALOG: 599 case TYPE_DIALOG:
600 case TYPE_IME_MENU:
601 break; 600 break;
602 601
603 case TYPE_UNDEFINED: 602 case TYPE_UNDEFINED:
604 NOTREACHED() << "ShelfItemType must be set."; 603 NOTREACHED() << "ShelfItemType must be set.";
605 break; 604 break;
606 } 605 }
607 606
608 ShelfItemDelegate::PerformedAction performed_action = 607 ShelfItemDelegate::PerformedAction performed_action =
609 model_->GetShelfItemDelegate(model_->items()[last_pressed_index_].id) 608 model_->GetShelfItemDelegate(model_->items()[last_pressed_index_].id)
610 ->ItemSelected(event); 609 ->ItemSelected(event);
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after
1068 overflow_button_->SetBoundsRect(ideal_bounds.overflow_bounds); 1067 overflow_button_->SetBoundsRect(ideal_bounds.overflow_bounds);
1069 } 1068 }
1070 1069
1071 views::View* ShelfView::CreateViewForItem(const ShelfItem& item) { 1070 views::View* ShelfView::CreateViewForItem(const ShelfItem& item) {
1072 views::View* view = nullptr; 1071 views::View* view = nullptr;
1073 switch (item.type) { 1072 switch (item.type) {
1074 case TYPE_APP_PANEL: 1073 case TYPE_APP_PANEL:
1075 case TYPE_APP_SHORTCUT: 1074 case TYPE_APP_SHORTCUT:
1076 case TYPE_BROWSER_SHORTCUT: 1075 case TYPE_BROWSER_SHORTCUT:
1077 case TYPE_APP: 1076 case TYPE_APP:
1078 case TYPE_DIALOG: 1077 case TYPE_DIALOG: {
1079 case TYPE_IME_MENU: {
1080 ShelfButton* button = new ShelfButton(this, this); 1078 ShelfButton* button = new ShelfButton(this, this);
1081 button->SetImage(item.image); 1079 button->SetImage(item.image);
1082 ReflectItemStatus(item, button); 1080 ReflectItemStatus(item, button);
1083 view = button; 1081 view = button;
1084 break; 1082 break;
1085 } 1083 }
1086 1084
1087 case TYPE_APP_LIST: { 1085 case TYPE_APP_LIST: {
1088 view = new AppListButton(this, this, wm_shelf_); 1086 view = new AppListButton(this, this, wm_shelf_);
1089 break; 1087 break;
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
1396 1394
1397 bool ShelfView::SameDragType(ShelfItemType typea, ShelfItemType typeb) const { 1395 bool ShelfView::SameDragType(ShelfItemType typea, ShelfItemType typeb) const {
1398 switch (typea) { 1396 switch (typea) {
1399 case TYPE_APP_SHORTCUT: 1397 case TYPE_APP_SHORTCUT:
1400 case TYPE_BROWSER_SHORTCUT: 1398 case TYPE_BROWSER_SHORTCUT:
1401 return (typeb == TYPE_APP_SHORTCUT || typeb == TYPE_BROWSER_SHORTCUT); 1399 return (typeb == TYPE_APP_SHORTCUT || typeb == TYPE_BROWSER_SHORTCUT);
1402 case TYPE_APP_PANEL: 1400 case TYPE_APP_PANEL:
1403 case TYPE_APP_LIST: 1401 case TYPE_APP_LIST:
1404 case TYPE_APP: 1402 case TYPE_APP:
1405 case TYPE_DIALOG: 1403 case TYPE_DIALOG:
1406 case TYPE_IME_MENU:
1407 return typeb == typea; 1404 return typeb == typea;
1408 case TYPE_UNDEFINED: 1405 case TYPE_UNDEFINED:
1409 NOTREACHED() << "ShelfItemType must be set."; 1406 NOTREACHED() << "ShelfItemType must be set.";
1410 return false; 1407 return false;
1411 } 1408 }
1412 NOTREACHED(); 1409 NOTREACHED();
1413 return false; 1410 return false;
1414 } 1411 }
1415 1412
1416 std::pair<int, int> ShelfView::GetDragRange(int index) { 1413 std::pair<int, int> ShelfView::GetDragRange(int index) {
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
1719 bounds_animator_->AnimateViewTo(new_view, old_ideal_bounds); 1716 bounds_animator_->AnimateViewTo(new_view, old_ideal_bounds);
1720 return; 1717 return;
1721 } 1718 }
1722 1719
1723 views::View* view = view_model_->view_at(model_index); 1720 views::View* view = view_model_->view_at(model_index);
1724 switch (item.type) { 1721 switch (item.type) {
1725 case TYPE_APP_PANEL: 1722 case TYPE_APP_PANEL:
1726 case TYPE_APP_SHORTCUT: 1723 case TYPE_APP_SHORTCUT:
1727 case TYPE_BROWSER_SHORTCUT: 1724 case TYPE_BROWSER_SHORTCUT:
1728 case TYPE_APP: 1725 case TYPE_APP:
1729 case TYPE_DIALOG: 1726 case TYPE_DIALOG: {
1730 case TYPE_IME_MENU: {
1731 CHECK_EQ(ShelfButton::kViewClassName, view->GetClassName()); 1727 CHECK_EQ(ShelfButton::kViewClassName, view->GetClassName());
1732 ShelfButton* button = static_cast<ShelfButton*>(view); 1728 ShelfButton* button = static_cast<ShelfButton*>(view);
1733 ReflectItemStatus(item, button); 1729 ReflectItemStatus(item, button);
1734 button->SetImage(item.image); 1730 button->SetImage(item.image);
1735 button->SchedulePaint(); 1731 button->SchedulePaint();
1736 break; 1732 break;
1737 } 1733 }
1738 1734
1739 default: 1735 default:
1740 break; 1736 break;
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
1917 1913
1918 int ShelfView::CalculateShelfDistance(const gfx::Point& coordinate) const { 1914 int ShelfView::CalculateShelfDistance(const gfx::Point& coordinate) const {
1919 const gfx::Rect bounds = GetBoundsInScreen(); 1915 const gfx::Rect bounds = GetBoundsInScreen();
1920 int distance = wm_shelf_->SelectValueForShelfAlignment( 1916 int distance = wm_shelf_->SelectValueForShelfAlignment(
1921 bounds.y() - coordinate.y(), coordinate.x() - bounds.right(), 1917 bounds.y() - coordinate.y(), coordinate.x() - bounds.right(),
1922 bounds.x() - coordinate.x()); 1918 bounds.x() - coordinate.x());
1923 return distance > 0 ? distance : 0; 1919 return distance > 0 ? distance : 0;
1924 } 1920 }
1925 1921
1926 } // namespace ash 1922 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/shelf/shelf_model.cc ('k') | chrome/browser/ui/ash/launcher/app_shortcut_launcher_item_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698