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

Side by Side Diff: chrome/browser/ui/ash/launcher/launcher_item_controller.cc

Issue 1921403002: Pin apps from prefs on the mash shelf. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Only include arc for cros. Created 4 years, 7 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
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" 7 #include "base/strings/utf_string_conversions.h"
8 #include "chrome/browser/profiles/profile.h" 8 #include "chrome/browser/profiles/profile.h"
9 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" 9 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h"
10 #include "extensions/browser/extension_registry.h" 10 #include "extensions/browser/extension_registry.h"
11 #include "extensions/common/extension.h" 11 #include "extensions/common/extension.h"
12 12
13 #if defined(OS_CHROMEOS) 13 #if defined(OS_CHROMEOS)
14 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" 14 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h"
15 #endif // defined(OS_CHROMEOS) 15 #endif // defined(OS_CHROMEOS)
16 16
17 LauncherItemController::LauncherItemController( 17 LauncherItemController::LauncherItemController(
18 Type type, 18 Type type,
19 const std::string& app_id, 19 const std::string& app_id,
20 ChromeLauncherController* launcher_controller) 20 ChromeLauncherController* launcher_controller)
21 : type_(type), 21 : type_(type),
22 app_id_(app_id), 22 app_id_(app_id),
23 shelf_id_(0), 23 shelf_id_(0),
24 launcher_controller_(launcher_controller), 24 launcher_controller_(launcher_controller),
25 locked_(0), 25 locked_(0),
26 image_set_by_controller_(false) { 26 image_set_by_controller_(false) {}
27 }
28 27
29 LauncherItemController::~LauncherItemController() { 28 LauncherItemController::~LauncherItemController() {}
30 }
31 29
32 const std::string& LauncherItemController::app_id() const { 30 // static
33 return app_id_; 31 base::string16 LauncherItemController::GetAppTitle(Profile* profile,
34 } 32 const std::string& app_id) {
35
36 base::string16 LauncherItemController::GetAppTitle() const {
37 base::string16 title; 33 base::string16 title;
38 if (app_id_.empty()) 34 if (app_id.empty())
39 return title; 35 return title;
40 36
41 #if defined(OS_CHROMEOS) 37 #if defined(OS_CHROMEOS)
42 // Get title if the app is an Arc app 38 // Get title if the app is an Arc app
43 ArcAppListPrefs* arc_prefs = 39 ArcAppListPrefs* arc_prefs = ArcAppListPrefs::Get(profile);
44 ArcAppListPrefs::Get(launcher_controller_->profile());
45 DCHECK(arc_prefs); 40 DCHECK(arc_prefs);
46 if (arc_prefs->IsRegistered(app_id_)) { 41 if (arc_prefs->IsRegistered(app_id)) {
47 std::unique_ptr<ArcAppListPrefs::AppInfo> app_info = 42 std::unique_ptr<ArcAppListPrefs::AppInfo> app_info =
48 arc_prefs->GetApp(app_id_); 43 arc_prefs->GetApp(app_id);
49 DCHECK(app_info.get()); 44 DCHECK(app_info.get());
50 if (app_info) 45 if (app_info)
51 title = base::UTF8ToUTF16(app_info->name); 46 title = base::UTF8ToUTF16(app_info->name);
52 return title; 47 return title;
53 } 48 }
54 #endif // defined(OS_CHROMEOS) 49 #endif // defined(OS_CHROMEOS)
55 50
56 const extensions::Extension* extension = 51 const extensions::Extension* extension =
57 extensions::ExtensionRegistry::Get( 52 extensions::ExtensionRegistry::Get(profile)->GetExtensionById(
58 launcher_controller_->profile())->GetExtensionById( 53 app_id, extensions::ExtensionRegistry::EVERYTHING);
59 app_id_, extensions::ExtensionRegistry::EVERYTHING);
60 if (extension) 54 if (extension)
61 title = base::UTF8ToUTF16(extension->name()); 55 title = base::UTF8ToUTF16(extension->name());
62 return title; 56 return title;
63 } 57 }
64 58
65 ash::ShelfItemType LauncherItemController::GetShelfItemType() const { 59 ash::ShelfItemType LauncherItemController::GetShelfItemType() const {
66 switch (type_) { 60 switch (type_) {
67 case LauncherItemController::TYPE_SHORTCUT: 61 case LauncherItemController::TYPE_SHORTCUT:
68 case LauncherItemController::TYPE_WINDOWED_APP: 62 case LauncherItemController::TYPE_WINDOWED_APP:
69 return ash::TYPE_APP_SHORTCUT; 63 return ash::TYPE_APP_SHORTCUT;
70 case LauncherItemController::TYPE_APP: 64 case LauncherItemController::TYPE_APP:
71 return ash::TYPE_PLATFORM_APP; 65 return ash::TYPE_PLATFORM_APP;
72 case LauncherItemController::TYPE_APP_PANEL: 66 case LauncherItemController::TYPE_APP_PANEL:
73 return ash::TYPE_APP_PANEL; 67 return ash::TYPE_APP_PANEL;
74 } 68 }
75 NOTREACHED(); 69 NOTREACHED();
76 return ash::TYPE_APP_SHORTCUT; 70 return ash::TYPE_APP_SHORTCUT;
77 } 71 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698