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

Side by Side Diff: chrome/browser/ui/webui/ntp/app_launcher_handler.cc

Issue 7104065: [NTP] Fix identification of the web store app. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/webui/ntp/app_launcher_handler.h" 5 #include "chrome/browser/ui/webui/ntp/app_launcher_handler.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 #include "webkit/glue/window_open_disposition.h" 43 #include "webkit/glue/window_open_disposition.h"
44 44
45 namespace { 45 namespace {
46 46
47 // The URL prefixes used by the NTP to signal when the web store or an app 47 // The URL prefixes used by the NTP to signal when the web store or an app
48 // has launched so we can record the proper histogram. 48 // has launched so we can record the proper histogram.
49 const char* kPingLaunchAppByID = "record-app-launch-by-id"; 49 const char* kPingLaunchAppByID = "record-app-launch-by-id";
50 const char* kPingLaunchWebStore = "record-webstore-launch"; 50 const char* kPingLaunchWebStore = "record-webstore-launch";
51 const char* kPingLaunchAppByURL = "record-app-launch-by-url"; 51 const char* kPingLaunchAppByURL = "record-app-launch-by-url";
52 52
53 const char* kChromeWebStoreUrl = "https://chrome.google.com/webstore/";
54
55 const UnescapeRule::Type kUnescapeRules = 53 const UnescapeRule::Type kUnescapeRules =
56 UnescapeRule::NORMAL | UnescapeRule::URL_SPECIAL_CHARS; 54 UnescapeRule::NORMAL | UnescapeRule::URL_SPECIAL_CHARS;
57 55
58 extension_misc::AppLaunchBucket ParseLaunchSource( 56 extension_misc::AppLaunchBucket ParseLaunchSource(
59 const std::string& launch_source) { 57 const std::string& launch_source) {
60 int bucket_num = extension_misc::APP_LAUNCH_BUCKET_INVALID; 58 int bucket_num = extension_misc::APP_LAUNCH_BUCKET_INVALID;
61 base::StringToInt(launch_source, &bucket_num); 59 base::StringToInt(launch_source, &bucket_num);
62 extension_misc::AppLaunchBucket bucket = 60 extension_misc::AppLaunchBucket bucket =
63 static_cast<extension_misc::AppLaunchBucket>(bucket_num); 61 static_cast<extension_misc::AppLaunchBucket>(bucket_num);
64 CHECK(bucket < extension_misc::APP_LAUNCH_BUCKET_BOUNDARY); 62 CHECK(bucket < extension_misc::APP_LAUNCH_BUCKET_BOUNDARY);
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 } 222 }
225 223
226 void AppLauncherHandler::FillAppDictionary(DictionaryValue* dictionary) { 224 void AppLauncherHandler::FillAppDictionary(DictionaryValue* dictionary) {
227 ListValue* list = new ListValue(); 225 ListValue* list = new ListValue();
228 const ExtensionList* extensions = extensions_service_->extensions(); 226 const ExtensionList* extensions = extensions_service_->extensions();
229 ExtensionList::const_iterator it; 227 ExtensionList::const_iterator it;
230 for (it = extensions->begin(); it != extensions->end(); ++it) { 228 for (it = extensions->begin(); it != extensions->end(); ++it) {
231 // Don't include the WebStore. 229 // Don't include the WebStore.
232 // The WebStore launcher gets special treatment in ntp/apps.js. 230 // The WebStore launcher gets special treatment in ntp/apps.js.
233 if ((*it)->is_app() && 231 if ((*it)->is_app() &&
234 (*it)->GetFullLaunchURL().spec() != kChromeWebStoreUrl) { 232 (*it)->id() != extension_misc::kWebStoreAppId) {
235 DictionaryValue* app_info = new DictionaryValue(); 233 DictionaryValue* app_info = new DictionaryValue();
236 CreateAppInfo(*it, extensions_service_->extension_prefs(), app_info); 234 CreateAppInfo(*it, extensions_service_->extension_prefs(), app_info);
237 list->Append(app_info); 235 list->Append(app_info);
238 } 236 }
239 } 237 }
240 238
241 extensions = extensions_service_->disabled_extensions(); 239 extensions = extensions_service_->disabled_extensions();
242 for (it = extensions->begin(); it != extensions->end(); ++it) { 240 for (it = extensions->begin(); it != extensions->end(); ++it) {
243 if ((*it)->is_app() && 241 if ((*it)->is_app() &&
244 (*it)->GetFullLaunchURL().spec() != kChromeWebStoreUrl) { 242 (*it)->id() != extension_misc::kWebStoreAppId) {
245 DictionaryValue* app_info = new DictionaryValue(); 243 DictionaryValue* app_info = new DictionaryValue();
246 CreateAppInfo(*it, extensions_service_->extension_prefs(), app_info); 244 CreateAppInfo(*it, extensions_service_->extension_prefs(), app_info);
247 list->Append(app_info); 245 list->Append(app_info);
248 } 246 }
249 } 247 }
250 248
251 dictionary->Set("apps", list); 249 dictionary->Set("apps", list);
252 250
253 #if defined(OS_MACOSX) 251 #if defined(OS_MACOSX)
254 // App windows are not yet implemented on mac. 252 // App windows are not yet implemented on mac.
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
654 652
655 void AppLauncherHandler::UninstallDefaultApps() { 653 void AppLauncherHandler::UninstallDefaultApps() {
656 AppsPromo* apps_promo = extensions_service_->apps_promo(); 654 AppsPromo* apps_promo = extensions_service_->apps_promo();
657 const ExtensionIdSet& app_ids = apps_promo->old_default_apps(); 655 const ExtensionIdSet& app_ids = apps_promo->old_default_apps();
658 for (ExtensionIdSet::const_iterator iter = app_ids.begin(); 656 for (ExtensionIdSet::const_iterator iter = app_ids.begin();
659 iter != app_ids.end(); ++iter) { 657 iter != app_ids.end(); ++iter) {
660 if (extensions_service_->GetExtensionById(*iter, true)) 658 if (extensions_service_->GetExtensionById(*iter, true))
661 extensions_service_->UninstallExtension(*iter, false, NULL); 659 extensions_service_->UninstallExtension(*iter, false, NULL);
662 } 660 }
663 } 661 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698