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

Side by Side Diff: ash/launcher/launcher_delegate_proxy.cc

Issue 22429004: Refactor LauncherDelegate (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add some comments Created 7 years, 4 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 unified diff | Download patch
OLDNEW
(Empty)
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/launcher/launcher_delegate_proxy.h"
6
7 #include "ash/launcher/ash_launcher_delegate.h"
8 #include "ash/shell.h"
9 #include "ash/shell_delegate.h"
10 #include "ui/aura/window.h"
11
12 namespace ash {
13 namespace internal {
14
15 LauncherDelegateProxy::LauncherDelegateProxy() {
16 DCHECK(Shell::GetInstance()->launcher_model());
17 chrome_launcher_delegate_.reset(
18 Shell::GetInstance()->delegate()->CreateLauncherDelegate(
19 Shell::GetInstance()->launcher_model()));
20
21 ash_launcher_delegate_.reset(new AshLauncherDelegate);
22 }
23
24 LauncherDelegateProxy::~LauncherDelegateProxy() {
25 }
26
27 ash::LauncherID LauncherDelegateProxy::GetIDByWindow(aura::Window* window) {
28 ash::LauncherID id = chrome_launcher_delegate_->GetIDByWindow(window);
29 return id ? id : ash_launcher_delegate_->GetIDByWindow(window);
30 }
31
32 void LauncherDelegateProxy::OnLauncherCreated(Launcher* launcher) {
33 chrome_launcher_delegate_->OnLauncherCreated(launcher);
34 ash_launcher_delegate_->OnLauncherCreated(launcher);
35 }
36
37 void LauncherDelegateProxy::OnLauncherDestroyed(Launcher* launcher) {
38 chrome_launcher_delegate_->OnLauncherDestroyed(launcher);
39 ash_launcher_delegate_->OnLauncherDestroyed(launcher);
40 }
41
42 LauncherID LauncherDelegateProxy::GetLauncherIDForAppID(
43 const std::string& app_id) {
44 // Only ChromeLauncherDelegate can pin apps.
45 return chrome_launcher_delegate_->GetLauncherIDForAppID(app_id);
46 }
47
48 void LauncherDelegateProxy::PinAppWithID(const std::string& app_id) {
49 // Only ChromeLauncherDelegate can pin apps.
50 chrome_launcher_delegate_->PinAppWithID(app_id);
51 }
52
53 bool LauncherDelegateProxy::IsAppPinned(const std::string& app_id) {
54 // Only ChromeLauncherDelegate can pin apps.
55 return chrome_launcher_delegate_->IsAppPinned(app_id);
56 }
57
58 void LauncherDelegateProxy::UnpinAppsWithID(const std::string& app_id) {
59 // Only ChromeLauncherDelegate can pin apps.
60 chrome_launcher_delegate_->UnpinAppsWithID(app_id);
61 }
62
63 LauncherItemDelegate* LauncherDelegateProxy::GetLauncherItemDelegate(
64 const LauncherItem& item) {
65 switch(item.type) {
66 case TYPE_TABBED:
67 case TYPE_APP_PANEL:
68 case TYPE_APP_SHORTCUT:
69 case TYPE_BROWSER_SHORTCUT:
70 case TYPE_PLATFORM_APP:
71 case TYPE_WINDOWED_APP:
72 return chrome_launcher_delegate_->GetLauncherItemDelegate(item);
73 case TYPE_APP_LIST:
74 return ash_launcher_delegate_->GetLauncherItemDelegate(item);
75 default:
76 NOTREACHED();
77 }
78 return NULL;
79 }
80
81 } // namespace internal
82 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698