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

Side by Side Diff: chrome/browser/ui/app_list/extension_app_item.cc

Issue 156843004: Remove ExtensionService::extension_prefs() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: additional cleanup Created 6 years, 10 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 | Annotate | Revision Log
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/app_list/extension_app_item.h" 5 #include "chrome/browser/ui/app_list/extension_app_item.h"
6 6
7 #include "base/prefs/pref_service.h" 7 #include "base/prefs/pref_service.h"
8 #include "chrome/browser/extensions/extension_service.h" 8 #include "chrome/browser/extensions/extension_service.h"
9 #include "chrome/browser/extensions/extension_util.h" 9 #include "chrome/browser/extensions/extension_util.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 canvas->DrawImageInt( 94 canvas->DrawImageInt(
95 gfx::ImageSkia(masking_canvas->ExtractImageRep()), 0, 0, masking_paint); 95 gfx::ImageSkia(masking_canvas->ExtractImageRep()), 0, 0, masking_paint);
96 } 96 }
97 97
98 gfx::ImageSkia icon_; 98 gfx::ImageSkia icon_;
99 99
100 DISALLOW_COPY_AND_ASSIGN(RoundedCornersImageSource); 100 DISALLOW_COPY_AND_ASSIGN(RoundedCornersImageSource);
101 }; 101 };
102 102
103 extensions::AppSorting* GetAppSorting(Profile* profile) { 103 extensions::AppSorting* GetAppSorting(Profile* profile) {
104 ExtensionService* service = 104 return extensions::ExtensionPrefs::Get(profile)->app_sorting();
105 extensions::ExtensionSystem::Get(profile)->extension_service();
106 return service->extension_prefs()->app_sorting();
107 } 105 }
108 106
109 const color_utils::HSL shift = {-1, 0, 0.6}; 107 const color_utils::HSL shift = {-1, 0, 0.6};
110 108
111 } // namespace 109 } // namespace
112 110
113 ExtensionAppItem::ExtensionAppItem( 111 ExtensionAppItem::ExtensionAppItem(
114 Profile* profile, 112 Profile* profile,
115 const app_list::AppListSyncableService::SyncItem* sync_item, 113 const app_list::AppListSyncableService::SyncItem* sync_item,
116 const std::string& extension_id, 114 const std::string& extension_id,
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 SetIcon(icon, !HasOverlay()); 185 SetIcon(icon, !HasOverlay());
188 } 186 }
189 187
190 void ExtensionAppItem::Move(const ExtensionAppItem* prev, 188 void ExtensionAppItem::Move(const ExtensionAppItem* prev,
191 const ExtensionAppItem* next) { 189 const ExtensionAppItem* next) {
192 if (!prev && !next) 190 if (!prev && !next)
193 return; // No reordering necessary 191 return; // No reordering necessary
194 192
195 ExtensionService* service = 193 ExtensionService* service =
196 extensions::ExtensionSystem::Get(profile_)->extension_service(); 194 extensions::ExtensionSystem::Get(profile_)->extension_service();
197 extensions::AppSorting* sorting = service->extension_prefs()->app_sorting(); 195 extensions::ExtensionPrefs* prefs = extensions::ExtensionPrefs::Get(profile_);
196 extensions::AppSorting* sorting = GetAppSorting(profile_);
198 197
199 syncer::StringOrdinal page; 198 syncer::StringOrdinal page;
200 std::string prev_id, next_id; 199 std::string prev_id, next_id;
201 if (!prev) { 200 if (!prev) {
202 next_id = next->extension_id(); 201 next_id = next->extension_id();
203 page = sorting->GetPageOrdinal(next_id); 202 page = sorting->GetPageOrdinal(next_id);
204 } else if (!next) { 203 } else if (!next) {
205 prev_id = prev->extension_id(); 204 prev_id = prev->extension_id();
206 page = sorting->GetPageOrdinal(prev_id); 205 page = sorting->GetPageOrdinal(prev_id);
207 } else { 206 } else {
208 prev_id = prev->extension_id(); 207 prev_id = prev->extension_id();
209 page = sorting->GetPageOrdinal(prev_id); 208 page = sorting->GetPageOrdinal(prev_id);
210 // Only set |next_id| if on the same page, otherwise just insert after prev. 209 // Only set |next_id| if on the same page, otherwise just insert after prev.
211 if (page.Equals(sorting->GetPageOrdinal(next->extension_id()))) 210 if (page.Equals(sorting->GetPageOrdinal(next->extension_id())))
212 next_id = next->extension_id(); 211 next_id = next->extension_id();
213 } 212 }
214 service->extension_prefs()->SetAppDraggedByUser(extension_id_); 213 prefs->SetAppDraggedByUser(extension_id_);
215 sorting->SetPageOrdinal(extension_id_, page); 214 sorting->SetPageOrdinal(extension_id_, page);
216 service->OnExtensionMoved(extension_id_, prev_id, next_id); 215 service->OnExtensionMoved(extension_id_, prev_id, next_id);
217 UpdatePositionFromExtensionOrdering(); 216 UpdatePositionFromExtensionOrdering();
218 } 217 }
219 218
220 const Extension* ExtensionAppItem::GetExtension() const { 219 const Extension* ExtensionAppItem::GetExtension() const {
221 const ExtensionService* service = 220 const ExtensionService* service =
222 extensions::ExtensionSystem::Get(profile_)->extension_service(); 221 extensions::ExtensionSystem::Get(profile_)->extension_service();
223 const Extension* extension = service->GetInstalledExtension(extension_id_); 222 const Extension* extension = service->GetInstalledExtension(extension_id_);
224 return extension; 223 return extension;
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 const syncer::StringOrdinal& launch = 329 const syncer::StringOrdinal& launch =
331 GetAppSorting(profile_)->GetAppLaunchOrdinal(extension_id_); 330 GetAppSorting(profile_)->GetAppLaunchOrdinal(extension_id_);
332 set_position(syncer::StringOrdinal( 331 set_position(syncer::StringOrdinal(
333 page.ToInternalValue() + launch.ToInternalValue())); 332 page.ToInternalValue() + launch.ToInternalValue()));
334 } 333 }
335 334
336 AppListControllerDelegate* ExtensionAppItem::GetController() { 335 AppListControllerDelegate* ExtensionAppItem::GetController() {
337 return AppListService::Get(chrome::GetActiveDesktop())-> 336 return AppListService::Get(chrome::GetActiveDesktop())->
338 GetControllerDelegate(); 337 GetControllerDelegate();
339 } 338 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698