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

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

Issue 10900018: Introduce App Launcher for Windows. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase gyp file for ui extraction Created 8 years, 3 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/apps_model_builder.h" 5 #include "chrome/browser/ui/app_list/apps_model_builder.h"
6 6
7 #include "base/i18n/case_conversion.h" 7 #include "base/i18n/case_conversion.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "chrome/browser/browser_process.h" 9 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/extensions/extension_service.h" 10 #include "chrome/browser/extensions/extension_service.h"
11 #include "chrome/browser/profiles/profile.h" 11 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/browser/ui/app_list/extension_app_item.h" 12 #include "chrome/browser/ui/app_list/extension_app_item.h"
13 #include "chrome/common/chrome_notification_types.h" 13 #include "chrome/common/chrome_notification_types.h"
14 #include "chrome/common/extensions/extension.h" 14 #include "chrome/common/extensions/extension.h"
15 #include "content/public/browser/notification_service.h" 15 #include "content/public/browser/notification_service.h"
16 #include "ui/base/l10n/l10n_util_collator.h" 16 #include "ui/base/l10n/l10n_util_collator.h"
17 17
18 using extensions::Extension; 18 using extensions::Extension;
19 19
20 namespace { 20 namespace {
21 21
22 // TODO(benwells): Get the list of special apps from the controller.
22 const char* kSpecialApps[] = { 23 const char* kSpecialApps[] = {
23 extension_misc::kChromeAppId, 24 extension_misc::kChromeAppId,
24 extension_misc::kWebStoreAppId, 25 extension_misc::kWebStoreAppId,
25 }; 26 };
26 27
27 // ModelItemSortData provides a string key to sort with 28 // ModelItemSortData provides a string key to sort with
28 // l10n_util::StringComparator. 29 // l10n_util::StringComparator.
29 struct ModelItemSortData { 30 struct ModelItemSortData {
30 explicit ModelItemSortData(app_list::AppListItemModel* app) 31 explicit ModelItemSortData(app_list::AppListItemModel* app)
31 : app(app), 32 : app(app),
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 148
148 bool is_guest_session = Profile::IsGuestSession(); 149 bool is_guest_session = Profile::IsGuestSession();
149 ExtensionService* service = profile_->GetExtensionService(); 150 ExtensionService* service = profile_->GetExtensionService();
150 DCHECK(service); 151 DCHECK(service);
151 for (size_t i = 0; i < arraysize(kSpecialApps); ++i) { 152 for (size_t i = 0; i < arraysize(kSpecialApps); ++i) {
152 const std::string extension_id(kSpecialApps[i]); 153 const std::string extension_id(kSpecialApps[i]);
153 if (is_guest_session && extension_id == extension_misc::kWebStoreAppId) 154 if (is_guest_session && extension_id == extension_misc::kWebStoreAppId)
154 continue; 155 continue;
155 156
156 const Extension* extension = service->GetInstalledExtension(extension_id); 157 const Extension* extension = service->GetInstalledExtension(extension_id);
157 DCHECK(extension); 158 if (!extension)
159 continue;
158 160
159 model_->Add(new ExtensionAppItem(profile_, extension, controller_)); 161 model_->Add(new ExtensionAppItem(profile_, extension, controller_));
160 } 162 }
161 163
162 special_apps_count_ = model_->item_count(); 164 special_apps_count_ = model_->item_count();
163 } 165 }
164 166
165 int AppsModelBuilder::FindApp(const std::string& app_id) { 167 int AppsModelBuilder::FindApp(const std::string& app_id) {
166 DCHECK(model_); 168 DCHECK(model_);
167 for (size_t i = special_apps_count_; i < model_->item_count(); ++i) { 169 for (size_t i = special_apps_count_; i < model_->item_count(); ++i) {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 } 221 }
220 case chrome::NOTIFICATION_APP_INSTALLED_TO_APPLIST: { 222 case chrome::NOTIFICATION_APP_INSTALLED_TO_APPLIST: {
221 highlight_app_id_ = *content::Details<const std::string>(details).ptr(); 223 highlight_app_id_ = *content::Details<const std::string>(details).ptr();
222 HighlightApp(); 224 HighlightApp();
223 break; 225 break;
224 } 226 }
225 default: 227 default:
226 NOTREACHED(); 228 NOTREACHED();
227 } 229 }
228 } 230 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/app_list/app_list_view_delegate.cc ('k') | chrome/browser/ui/ash/app_list/app_list_controller_ash.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698