summaryrefslogtreecommitdiffstats
path: root/ash/shell/launcher_delegate_impl.cc
blob: c53dec7aa8161a16f70481dde6a3ec7f7a58f41b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "ash/shell/launcher_delegate_impl.h"

#include "ash/launcher/launcher_context_menu.h"
#include "ash/shell/toplevel_window.h"
#include "ash/shell/window_watcher.h"
#include "ash/wm/window_util.h"
#include "grit/ui_resources.h"
#include "ui/aura/window.h"

namespace ash {
namespace shell {

LauncherDelegateImpl::LauncherDelegateImpl(WindowWatcher* watcher)
    : watcher_(watcher) {
}

LauncherDelegateImpl::~LauncherDelegateImpl() {
}

// In the shell we'll create a window all the time.
void LauncherDelegateImpl::CreateNewTab() {
  CreateNewWindow();
}

void LauncherDelegateImpl::CreateNewWindow() {
  ash::shell::ToplevelWindow::CreateParams create_params;
  create_params.can_resize = true;
  create_params.can_maximize = true;
  ash::shell::ToplevelWindow::CreateToplevelWindow(create_params);
}

void LauncherDelegateImpl::ItemClicked(const ash::LauncherItem& item,
                                       int event_flags) {
  aura::Window* window = watcher_->GetWindowByID(item.id);
  window->Show();
  ash::wm::ActivateWindow(window);
}

int LauncherDelegateImpl::GetBrowserShortcutResourceId() {
  return IDR_AURA_LAUNCHER_BROWSER_SHORTCUT;
}

string16 LauncherDelegateImpl::GetTitle(const ash::LauncherItem& item) {
  return watcher_->GetWindowByID(item.id)->title();
}

ui::MenuModel* LauncherDelegateImpl::CreateContextMenu(
    const ash::LauncherItem& item) {
  return NULL;
}

ui::MenuModel* LauncherDelegateImpl::CreateContextMenuForLauncher() {
  return new LauncherContextMenu;
}

ash::LauncherID LauncherDelegateImpl::GetIDByWindow(aura::Window* window) {
  return watcher_->GetIDByWindow(window);
}

bool LauncherDelegateImpl::IsDraggable(const ash::LauncherItem& item) {
  return true;
}

}  // namespace shell
}  // namespace ash