| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 "chrome/browser/ui/ash/launcher/launcher_item_controller.h" | 5 #include "chrome/browser/ui/ash/launcher/launcher_item_controller.h" |
| 6 | 6 |
| 7 #include "base/strings/utf_string_conversions.h" | |
| 8 #include "chrome/browser/profiles/profile.h" | |
| 9 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" | 7 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" |
| 10 #include "extensions/browser/extension_registry.h" | |
| 11 #include "extensions/common/extension.h" | |
| 12 | |
| 13 #if defined(OS_CHROMEOS) | |
| 14 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" | |
| 15 #endif // defined(OS_CHROMEOS) | |
| 16 | 8 |
| 17 LauncherItemController::LauncherItemController( | 9 LauncherItemController::LauncherItemController( |
| 18 Type type, | 10 Type type, |
| 19 const std::string& app_id, | 11 const std::string& app_id, |
| 20 ChromeLauncherController* launcher_controller) | 12 ChromeLauncherController* launcher_controller) |
| 21 : type_(type), | 13 : type_(type), |
| 22 app_id_(app_id), | 14 app_id_(app_id), |
| 23 shelf_id_(0), | 15 shelf_id_(0), |
| 24 launcher_controller_(launcher_controller), | 16 launcher_controller_(launcher_controller), |
| 25 locked_(0), | 17 locked_(0), |
| 26 image_set_by_controller_(false) { | 18 image_set_by_controller_(false) {} |
| 27 } | |
| 28 | 19 |
| 29 LauncherItemController::~LauncherItemController() { | 20 LauncherItemController::~LauncherItemController() {} |
| 30 } | |
| 31 | |
| 32 const std::string& LauncherItemController::app_id() const { | |
| 33 return app_id_; | |
| 34 } | |
| 35 | |
| 36 base::string16 LauncherItemController::GetAppTitle() const { | |
| 37 base::string16 title; | |
| 38 if (app_id_.empty()) | |
| 39 return title; | |
| 40 | |
| 41 #if defined(OS_CHROMEOS) | |
| 42 // Get title if the app is an Arc app | |
| 43 ArcAppListPrefs* arc_prefs = | |
| 44 ArcAppListPrefs::Get(launcher_controller_->profile()); | |
| 45 DCHECK(arc_prefs); | |
| 46 if (arc_prefs->IsRegistered(app_id_)) { | |
| 47 std::unique_ptr<ArcAppListPrefs::AppInfo> app_info = | |
| 48 arc_prefs->GetApp(app_id_); | |
| 49 DCHECK(app_info.get()); | |
| 50 if (app_info) | |
| 51 title = base::UTF8ToUTF16(app_info->name); | |
| 52 return title; | |
| 53 } | |
| 54 #endif // defined(OS_CHROMEOS) | |
| 55 | |
| 56 const extensions::Extension* extension = | |
| 57 extensions::ExtensionRegistry::Get( | |
| 58 launcher_controller_->profile())->GetExtensionById( | |
| 59 app_id_, extensions::ExtensionRegistry::EVERYTHING); | |
| 60 if (extension) | |
| 61 title = base::UTF8ToUTF16(extension->name()); | |
| 62 return title; | |
| 63 } | |
| 64 | 21 |
| 65 ash::ShelfItemType LauncherItemController::GetShelfItemType() const { | 22 ash::ShelfItemType LauncherItemController::GetShelfItemType() const { |
| 66 switch (type_) { | 23 switch (type_) { |
| 67 case LauncherItemController::TYPE_SHORTCUT: | 24 case LauncherItemController::TYPE_SHORTCUT: |
| 68 case LauncherItemController::TYPE_WINDOWED_APP: | 25 case LauncherItemController::TYPE_WINDOWED_APP: |
| 69 return ash::TYPE_APP_SHORTCUT; | 26 return ash::TYPE_APP_SHORTCUT; |
| 70 case LauncherItemController::TYPE_APP: | 27 case LauncherItemController::TYPE_APP: |
| 71 return ash::TYPE_PLATFORM_APP; | 28 return ash::TYPE_PLATFORM_APP; |
| 72 case LauncherItemController::TYPE_APP_PANEL: | 29 case LauncherItemController::TYPE_APP_PANEL: |
| 73 return ash::TYPE_APP_PANEL; | 30 return ash::TYPE_APP_PANEL; |
| 74 } | 31 } |
| 75 NOTREACHED(); | 32 NOTREACHED(); |
| 76 return ash::TYPE_APP_SHORTCUT; | 33 return ash::TYPE_APP_SHORTCUT; |
| 77 } | 34 } |
| OLD | NEW |