Home | History | Annotate | Download | only in shelf
      1 // Copyright 2013 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 #include "ash/shelf/app_list_shelf_item_delegate.h"
      6 
      7 #include "ash/shelf/shelf_model.h"
      8 #include "ash/shell.h"
      9 #include "ash/shell_delegate.h"
     10 #include "grit/ash_strings.h"
     11 #include "ui/base/l10n/l10n_util.h"
     12 
     13 namespace ash {
     14 
     15 AppListShelfItemDelegate::AppListShelfItemDelegate() {
     16   ShelfItem app_list;
     17   app_list.type = TYPE_APP_LIST;
     18   Shell::GetInstance()->shelf_model()->Add(app_list);
     19 }
     20 
     21 AppListShelfItemDelegate::~AppListShelfItemDelegate() {
     22   // ShelfItemDelegateManager owns and destroys this class.
     23 }
     24 
     25 bool AppListShelfItemDelegate::ItemSelected(const ui::Event& event) {
     26   // Pass NULL here to show the app list in the currently active RootWindow.
     27   Shell::GetInstance()->ToggleAppList(NULL);
     28   return false;
     29 }
     30 
     31 base::string16 AppListShelfItemDelegate::GetTitle() {
     32   ShelfModel* model = Shell::GetInstance()->shelf_model();
     33   DCHECK(model);
     34   return model->status() == ShelfModel::STATUS_LOADING ?
     35       l10n_util::GetStringUTF16(IDS_ASH_SHELF_APP_LIST_SYNCING_TITLE) :
     36       l10n_util::GetStringUTF16(IDS_ASH_SHELF_APP_LIST_TITLE);
     37 }
     38 
     39 ui::MenuModel* AppListShelfItemDelegate::CreateContextMenu(
     40     aura::Window* root_window) {
     41   return Shell::GetInstance()->delegate()->CreateContextMenu(root_window,
     42                                                              NULL,
     43                                                              NULL);
     44 }
     45 
     46 ShelfMenuModel* AppListShelfItemDelegate::CreateApplicationMenu(
     47     int event_flags) {
     48   // AppList does not show an application menu.
     49   return NULL;
     50 }
     51 
     52 bool AppListShelfItemDelegate::IsDraggable() {
     53   return false;
     54 }
     55 
     56 bool AppListShelfItemDelegate::ShouldShowTooltip() {
     57   return true;
     58 }
     59 
     60 void AppListShelfItemDelegate::Close() {
     61 }
     62 
     63 }  // namespace ash
     64