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

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: Created 5 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 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" 17 #include "extensions/browser/extension_system.h"
(...skipping 15 matching lines...) Expand all
34 bool is_recommendation) 33 bool is_recommendation)
35 : profile_(profile), 34 : profile_(profile),
36 app_id_(app_id), 35 app_id_(app_id),
37 controller_(controller), 36 controller_(controller),
38 extension_registry_(NULL) { 37 extension_registry_(NULL) {
39 set_id(extensions::Extension::GetBaseURLFromExtensionId(app_id_).spec()); 38 set_id(extensions::Extension::GetBaseURLFromExtensionId(app_id_).spec());
40 if (app_list::switches::IsExperimentalAppListEnabled()) 39 if (app_list::switches::IsExperimentalAppListEnabled())
41 set_display_type(is_recommendation ? DISPLAY_RECOMMENDATION : DISPLAY_TILE); 40 set_display_type(is_recommendation ? DISPLAY_RECOMMENDATION : DISPLAY_TILE);
42 41
43 const extensions::Extension* extension = 42 const extensions::Extension* extension =
44 extensions::ExtensionSystem::Get(profile_)->extension_service() 43 extensions::ExtensionRegistry::Get(profile_)->GetExtensionById(
45 ->GetInstalledExtension(app_id_); 44 app_id_,
45 extensions::ExtensionRegistry::EVERYTHING);
46 DCHECK(extension); 46 DCHECK(extension);
47 47
48 is_platform_app_ = extension->is_platform_app(); 48 is_platform_app_ = extension->is_platform_app();
49 49
50 icon_.reset( 50 icon_.reset(
51 new extensions::IconImage(profile_, 51 new extensions::IconImage(profile_,
52 extension, 52 extension,
53 extensions::IconsInfo::GetIcons(extension), 53 extensions::IconsInfo::GetIcons(extension),
54 GetPreferredIconDimension(), 54 GetPreferredIconDimension(),
55 extensions::util::GetDefaultAppIcon(), 55 extensions::util::GetDefaultAppIcon(),
(...skipping 20 matching lines...) Expand all
76 const int kSecondsInWeek = 60 * 60 * 24 * 7; 76 const int kSecondsInWeek = 60 * 60 * 24 * 7;
77 77
78 // Set the relevance to a value between 0 and 1. This function decays as the 78 // 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. 79 // time delta increases and reaches a value of 0.5 at 1 week.
80 set_relevance(1 / (1 + delta.InSecondsF() / kSecondsInWeek)); 80 set_relevance(1 / (1 + delta.InSecondsF() / kSecondsInWeek));
81 } 81 }
82 82
83 void AppResult::Open(int event_flags) { 83 void AppResult::Open(int event_flags) {
84 RecordHistogram(APP_SEARCH_RESULT); 84 RecordHistogram(APP_SEARCH_RESULT);
85 const extensions::Extension* extension = 85 const extensions::Extension* extension =
86 extensions::ExtensionSystem::Get(profile_)->extension_service() 86 extensions::ExtensionRegistry::Get(profile_)->GetExtensionById(
87 ->GetInstalledExtension(app_id_); 87 app_id_,
88 extensions::ExtensionRegistry::EVERYTHING);
88 if (!extension) 89 if (!extension)
89 return; 90 return;
90 91
91 // Don't auto-enable apps that cannot be launched. 92 // Don't auto-enable apps that cannot be launched.
92 if (!extensions::util::IsAppLaunchable(app_id_, profile_)) 93 if (!extensions::util::IsAppLaunchable(app_id_, profile_))
93 return; 94 return;
94 95
95 // Check if enable flow is already running or should be started 96 // Check if enable flow is already running or should be started
96 if (RunExtensionEnableFlow()) 97 if (RunExtensionEnableFlow())
97 return; 98 return;
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 const extensions::Extension* extension) { 195 const extensions::Extension* extension) {
195 UpdateIcon(); 196 UpdateIcon();
196 } 197 }
197 198
198 void AppResult::OnShutdown(extensions::ExtensionRegistry* registry) { 199 void AppResult::OnShutdown(extensions::ExtensionRegistry* registry) {
199 DCHECK_EQ(extension_registry_, registry); 200 DCHECK_EQ(extension_registry_, registry);
200 StopObservingExtensionRegistry(); 201 StopObservingExtensionRegistry();
201 } 202 }
202 203
203 } // namespace app_list 204 } // namespace app_list
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698