Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
|
sky
2014/01/08 14:39:14
Don't change the year here.
simonhong
2014/01/09 00:38:24
Done.
| |
| 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/shelf/shelf_view.h" | 5 #include "ash/shelf/shelf_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "ash/ash_constants.h" | 9 #include "ash/ash_constants.h" |
| 10 #include "ash/ash_switches.h" | 10 #include "ash/ash_switches.h" |
| 11 #include "ash/drag_drop/drag_image_view.h" | 11 #include "ash/drag_drop/drag_image_view.h" |
| (...skipping 899 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 911 overflow_button_->SetBoundsRect(ideal_bounds.overflow_bounds); | 911 overflow_button_->SetBoundsRect(ideal_bounds.overflow_bounds); |
| 912 } | 912 } |
| 913 | 913 |
| 914 views::View* ShelfView::CreateViewForItem(const LauncherItem& item) { | 914 views::View* ShelfView::CreateViewForItem(const LauncherItem& item) { |
| 915 views::View* view = NULL; | 915 views::View* view = NULL; |
| 916 switch (item.type) { | 916 switch (item.type) { |
| 917 case TYPE_BROWSER_SHORTCUT: | 917 case TYPE_BROWSER_SHORTCUT: |
| 918 case TYPE_APP_SHORTCUT: | 918 case TYPE_APP_SHORTCUT: |
| 919 case TYPE_WINDOWED_APP: | 919 case TYPE_WINDOWED_APP: |
| 920 case TYPE_PLATFORM_APP: | 920 case TYPE_PLATFORM_APP: |
| 921 case TYPE_DIALOG: | |
| 921 case TYPE_APP_PANEL: { | 922 case TYPE_APP_PANEL: { |
| 922 ShelfButton* button = ShelfButton::Create(this, this, layout_manager_); | 923 ShelfButton* button = ShelfButton::Create(this, this, layout_manager_); |
| 923 button->SetImage(item.image); | 924 button->SetImage(item.image); |
| 924 ReflectItemStatus(item, button); | 925 ReflectItemStatus(item, button); |
| 925 view = button; | 926 view = button; |
| 926 break; | 927 break; |
| 927 } | 928 } |
| 928 | 929 |
| 929 case TYPE_APP_LIST: { | 930 case TYPE_APP_LIST: { |
| 930 if (ash::switches::UseAlternateShelfLayout()) { | 931 if (ash::switches::UseAlternateShelfLayout()) { |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1245 bool ShelfView::SameDragType(LauncherItemType typea, | 1246 bool ShelfView::SameDragType(LauncherItemType typea, |
| 1246 LauncherItemType typeb) const { | 1247 LauncherItemType typeb) const { |
| 1247 switch (typea) { | 1248 switch (typea) { |
| 1248 case TYPE_APP_SHORTCUT: | 1249 case TYPE_APP_SHORTCUT: |
| 1249 case TYPE_BROWSER_SHORTCUT: | 1250 case TYPE_BROWSER_SHORTCUT: |
| 1250 return (typeb == TYPE_APP_SHORTCUT || typeb == TYPE_BROWSER_SHORTCUT); | 1251 return (typeb == TYPE_APP_SHORTCUT || typeb == TYPE_BROWSER_SHORTCUT); |
| 1251 case TYPE_APP_LIST: | 1252 case TYPE_APP_LIST: |
| 1252 case TYPE_PLATFORM_APP: | 1253 case TYPE_PLATFORM_APP: |
| 1253 case TYPE_WINDOWED_APP: | 1254 case TYPE_WINDOWED_APP: |
| 1254 case TYPE_APP_PANEL: | 1255 case TYPE_APP_PANEL: |
| 1256 case TYPE_DIALOG: | |
| 1255 return typeb == typea; | 1257 return typeb == typea; |
| 1256 case TYPE_UNDEFINED: | 1258 case TYPE_UNDEFINED: |
| 1257 NOTREACHED() << "LauncherItemType must be set."; | 1259 NOTREACHED() << "LauncherItemType must be set."; |
| 1258 return false; | 1260 return false; |
| 1259 } | 1261 } |
| 1260 NOTREACHED(); | 1262 NOTREACHED(); |
| 1261 return false; | 1263 return false; |
| 1262 } | 1264 } |
| 1263 | 1265 |
| 1264 std::pair<int, int> ShelfView::GetDragRange(int index) { | 1266 std::pair<int, int> ShelfView::GetDragRange(int index) { |
| (...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1607 } | 1609 } |
| 1608 | 1610 |
| 1609 views::View* view = view_model_->view_at(model_index); | 1611 views::View* view = view_model_->view_at(model_index); |
| 1610 switch (item.type) { | 1612 switch (item.type) { |
| 1611 case TYPE_BROWSER_SHORTCUT: | 1613 case TYPE_BROWSER_SHORTCUT: |
| 1612 // Fallthrough for the new Shelf since it needs to show the activation | 1614 // Fallthrough for the new Shelf since it needs to show the activation |
| 1613 // change as well. | 1615 // change as well. |
| 1614 case TYPE_APP_SHORTCUT: | 1616 case TYPE_APP_SHORTCUT: |
| 1615 case TYPE_WINDOWED_APP: | 1617 case TYPE_WINDOWED_APP: |
| 1616 case TYPE_PLATFORM_APP: | 1618 case TYPE_PLATFORM_APP: |
| 1619 case TYPE_DIALOG: | |
| 1617 case TYPE_APP_PANEL: { | 1620 case TYPE_APP_PANEL: { |
| 1618 ShelfButton* button = static_cast<ShelfButton*>(view); | 1621 ShelfButton* button = static_cast<ShelfButton*>(view); |
| 1619 ReflectItemStatus(item, button); | 1622 ReflectItemStatus(item, button); |
| 1620 // The browser shortcut is currently not a "real" item and as such the | 1623 // The browser shortcut is currently not a "real" item and as such the |
| 1621 // the image is bogous as well. We therefore keep the image as is for it. | 1624 // the image is bogous as well. We therefore keep the image as is for it. |
| 1622 if (item.type != TYPE_BROWSER_SHORTCUT) | 1625 if (item.type != TYPE_BROWSER_SHORTCUT) |
| 1623 button->SetImage(item.image); | 1626 button->SetImage(item.image); |
| 1624 button->SchedulePaint(); | 1627 button->SchedulePaint(); |
| 1625 break; | 1628 break; |
| 1626 } | 1629 } |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1781 Shell::GetInstance()->metrics()->RecordUserMetricsAction( | 1784 Shell::GetInstance()->metrics()->RecordUserMetricsAction( |
| 1782 UMA_LAUNCHER_CLICK_ON_APP); | 1785 UMA_LAUNCHER_CLICK_ON_APP); |
| 1783 break; | 1786 break; |
| 1784 | 1787 |
| 1785 case TYPE_APP_LIST: | 1788 case TYPE_APP_LIST: |
| 1786 Shell::GetInstance()->metrics()->RecordUserMetricsAction( | 1789 Shell::GetInstance()->metrics()->RecordUserMetricsAction( |
| 1787 UMA_LAUNCHER_CLICK_ON_APPLIST_BUTTON); | 1790 UMA_LAUNCHER_CLICK_ON_APPLIST_BUTTON); |
| 1788 break; | 1791 break; |
| 1789 | 1792 |
| 1790 case TYPE_APP_PANEL: | 1793 case TYPE_APP_PANEL: |
| 1794 case TYPE_DIALOG: | |
| 1791 break; | 1795 break; |
| 1792 | 1796 |
| 1793 case TYPE_UNDEFINED: | 1797 case TYPE_UNDEFINED: |
| 1794 NOTREACHED() << "LauncherItemType must be set."; | 1798 NOTREACHED() << "LauncherItemType must be set."; |
| 1795 break; | 1799 break; |
| 1796 } | 1800 } |
| 1797 | 1801 |
| 1798 ShelfItemDelegate* item_delegate = | 1802 ShelfItemDelegate* item_delegate = |
| 1799 item_manager_->GetShelfItemDelegate(model_->items()[view_index].id); | 1803 item_manager_->GetShelfItemDelegate(model_->items()[view_index].id); |
| 1800 if (!item_delegate->ItemSelected(event)) | 1804 if (!item_delegate->ItemSelected(event)) |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2018 break; | 2022 break; |
| 2019 case ash::SHELF_ALIGNMENT_TOP: | 2023 case ash::SHELF_ALIGNMENT_TOP: |
| 2020 distance = coordinate.y() - bounds.bottom(); | 2024 distance = coordinate.y() - bounds.bottom(); |
| 2021 break; | 2025 break; |
| 2022 } | 2026 } |
| 2023 return distance > 0 ? distance : 0; | 2027 return distance > 0 ? distance : 0; |
| 2024 } | 2028 } |
| 2025 | 2029 |
| 2026 } // namespace internal | 2030 } // namespace internal |
| 2027 } // namespace ash | 2031 } // namespace ash |
| OLD | NEW |