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

Side by Side Diff: chrome/browser/ui/app_list/search/app_result.cc

Issue 1130353010: Remove deprecated ExtensionService::GetInstalledExtension() usage (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changed if to iff Created 5 years, 6 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 2013 The Chromium Authors. All rights reserved. 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 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/app_list/search/app_result.h" 5 #include "chrome/browser/ui/app_list/search/app_result.h"
6 6
7 #include "base/time/time.h" 7 #include "base/time/time.h"
8 #include "chrome/browser/extensions/extension_service.h"
9 #include "chrome/browser/extensions/extension_util.h" 8 #include "chrome/browser/extensions/extension_util.h"
10 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
11 #include "chrome/browser/ui/app_list/app_context_menu.h" 10 #include "chrome/browser/ui/app_list/app_context_menu.h"
12 #include "chrome/browser/ui/app_list/app_list_controller_delegate.h" 11 #include "chrome/browser/ui/app_list/app_list_controller_delegate.h"
13 #include "chrome/browser/ui/app_list/search/search_util.h" 12 #include "chrome/browser/ui/app_list/search/search_util.h"
14 #include "chrome/browser/ui/extensions/extension_enable_flow.h" 13 #include "chrome/browser/ui/extensions/extension_enable_flow.h"
15 #include "chrome/common/extensions/extension_metrics.h" 14 #include "chrome/common/extensions/extension_metrics.h"
16 #include "content/public/browser/user_metrics.h" 15 #include "content/public/browser/user_metrics.h"
17 #include "extensions/browser/extension_registry.h" 16 #include "extensions/browser/extension_registry.h"
18 #include "extensions/browser/extension_system.h"
19 #include "extensions/browser/extension_system_provider.h" 17 #include "extensions/browser/extension_system_provider.h"
20 #include "extensions/browser/extensions_browser_client.h" 18 #include "extensions/browser/extensions_browser_client.h"
21 #include "extensions/common/constants.h" 19 #include "extensions/common/constants.h"
22 #include "extensions/common/extension.h" 20 #include "extensions/common/extension.h"
23 #include "extensions/common/extension_icon_set.h" 21 #include "extensions/common/extension_icon_set.h"
24 #include "extensions/common/manifest_handlers/icons_handler.h" 22 #include "extensions/common/manifest_handlers/icons_handler.h"
25 #include "ui/app_list/app_list_switches.h" 23 #include "ui/app_list/app_list_switches.h"
26 #include "ui/gfx/color_utils.h" 24 #include "ui/gfx/color_utils.h"
27 #include "ui/gfx/image/image_skia_operations.h" 25 #include "ui/gfx/image/image_skia_operations.h"
28 26
29 namespace app_list { 27 namespace app_list {
30 28
31 AppResult::AppResult(Profile* profile, 29 AppResult::AppResult(Profile* profile,
32 const std::string& app_id, 30 const std::string& app_id,
33 AppListControllerDelegate* controller, 31 AppListControllerDelegate* controller,
34 bool is_recommendation) 32 bool is_recommendation)
35 : profile_(profile), 33 : profile_(profile),
36 app_id_(app_id), 34 app_id_(app_id),
37 controller_(controller), 35 controller_(controller),
38 extension_registry_(NULL) { 36 extension_registry_(NULL) {
39 set_id(extensions::Extension::GetBaseURLFromExtensionId(app_id_).spec()); 37 set_id(extensions::Extension::GetBaseURLFromExtensionId(app_id_).spec());
40 if (app_list::switches::IsExperimentalAppListEnabled()) 38 if (app_list::switches::IsExperimentalAppListEnabled())
41 set_display_type(is_recommendation ? DISPLAY_RECOMMENDATION : DISPLAY_TILE); 39 set_display_type(is_recommendation ? DISPLAY_RECOMMENDATION : DISPLAY_TILE);
42 40
43 const extensions::Extension* extension = 41 const extensions::Extension* extension =
44 extensions::ExtensionSystem::Get(profile_)->extension_service() 42 extensions::ExtensionRegistry::Get(profile_)->GetInstalledExtension(
45 ->GetInstalledExtension(app_id_); 43 app_id_);
46 DCHECK(extension); 44 DCHECK(extension);
47 45
48 is_platform_app_ = extension->is_platform_app(); 46 is_platform_app_ = extension->is_platform_app();
49 47
50 icon_.reset( 48 icon_.reset(
51 new extensions::IconImage(profile_, 49 new extensions::IconImage(profile_,
52 extension, 50 extension,
53 extensions::IconsInfo::GetIcons(extension), 51 extensions::IconsInfo::GetIcons(extension),
54 GetPreferredIconDimension(), 52 GetPreferredIconDimension(),
55 extensions::util::GetDefaultAppIcon(), 53 extensions::util::GetDefaultAppIcon(),
(...skipping 20 matching lines...) Expand all
76 const int kSecondsInWeek = 60 * 60 * 24 * 7; 74 const int kSecondsInWeek = 60 * 60 * 24 * 7;
77 75
78 // Set the relevance to a value between 0 and 1. This function decays as the 76 // Set the relevance to a value between 0 and 1. This function decays as the
79 // time delta increases and reaches a value of 0.5 at 1 week. 77 // time delta increases and reaches a value of 0.5 at 1 week.
80 set_relevance(1 / (1 + delta.InSecondsF() / kSecondsInWeek)); 78 set_relevance(1 / (1 + delta.InSecondsF() / kSecondsInWeek));
81 } 79 }
82 80
83 void AppResult::Open(int event_flags) { 81 void AppResult::Open(int event_flags) {
84 RecordHistogram(APP_SEARCH_RESULT); 82 RecordHistogram(APP_SEARCH_RESULT);
85 const extensions::Extension* extension = 83 const extensions::Extension* extension =
86 extensions::ExtensionSystem::Get(profile_)->extension_service() 84 extensions::ExtensionRegistry::Get(profile_)->GetInstalledExtension(
87 ->GetInstalledExtension(app_id_); 85 app_id_);
88 if (!extension) 86 if (!extension)
89 return; 87 return;
90 88
91 // Don't auto-enable apps that cannot be launched. 89 // Don't auto-enable apps that cannot be launched.
92 if (!extensions::util::IsAppLaunchable(app_id_, profile_)) 90 if (!extensions::util::IsAppLaunchable(app_id_, profile_))
93 return; 91 return;
94 92
95 // Check if enable flow is already running or should be started 93 // Check if enable flow is already running or should be started
96 if (RunExtensionEnableFlow()) 94 if (RunExtensionEnableFlow())
97 return; 95 return;
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 const extensions::Extension* extension) { 194 const extensions::Extension* extension) {
197 UpdateIcon(); 195 UpdateIcon();
198 } 196 }
199 197
200 void AppResult::OnShutdown(extensions::ExtensionRegistry* registry) { 198 void AppResult::OnShutdown(extensions::ExtensionRegistry* registry) {
201 DCHECK_EQ(extension_registry_, registry); 199 DCHECK_EQ(extension_registry_, registry);
202 StopObservingExtensionRegistry(); 200 StopObservingExtensionRegistry();
203 } 201 }
204 202
205 } // namespace app_list 203 } // namespace app_list
OLDNEW
« no previous file with comments | « chrome/browser/ui/app_list/extension_uninstaller.cc ('k') | extensions/browser/extension_registry.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698