Popular sites on the NTP: check that experiment group StartsWith (rather than IS...
[chromium-blink-merge.git] / chrome / browser / ui / ash / launcher / launcher_item_controller.cc
blob1f0a30f44e780a2a8ff31ce506668d535c843f07
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
3 // found in the LICENSE file.
5 #include "chrome/browser/ui/ash/launcher/launcher_item_controller.h"
7 #include "base/basictypes.h"
8 #include "base/strings/utf_string_conversions.h"
9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h"
11 #include "extensions/browser/extension_registry.h"
12 #include "extensions/common/extension.h"
14 LauncherItemController::LauncherItemController(
15 Type type,
16 const std::string& app_id,
17 ChromeLauncherController* launcher_controller)
18 : type_(type),
19 app_id_(app_id),
20 shelf_id_(0),
21 launcher_controller_(launcher_controller),
22 locked_(0),
23 image_set_by_controller_(false) {
26 LauncherItemController::~LauncherItemController() {
29 const std::string& LauncherItemController::app_id() const {
30 return app_id_;
33 base::string16 LauncherItemController::GetAppTitle() const {
34 base::string16 title;
35 if (app_id_.empty())
36 return title;
38 const extensions::Extension* extension =
39 extensions::ExtensionRegistry::Get(
40 launcher_controller_->profile())->GetExtensionById(
41 app_id_, extensions::ExtensionRegistry::EVERYTHING);
42 if (extension)
43 title = base::UTF8ToUTF16(extension->name());
44 return title;
47 ash::ShelfItemType LauncherItemController::GetShelfItemType() const {
48 switch (type_) {
49 case LauncherItemController::TYPE_SHORTCUT:
50 case LauncherItemController::TYPE_WINDOWED_APP:
51 return ash::TYPE_APP_SHORTCUT;
52 case LauncherItemController::TYPE_APP:
53 return ash::TYPE_PLATFORM_APP;
54 case LauncherItemController::TYPE_APP_PANEL:
55 return ash::TYPE_APP_PANEL;
57 NOTREACHED();
58 return ash::TYPE_APP_SHORTCUT;