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

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

Issue 6912024: Support for component extensions as apps on the new tab page. Added filebrowser. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 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 | Annotate | Revision Log
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/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 29 matching lines...) Expand all
40 #include "webkit/glue/window_open_disposition.h" 40 #include "webkit/glue/window_open_disposition.h"
41 41
42 namespace { 42 namespace {
43 43
44 // The URL prefixes used by the NTP to signal when the web store or an app 44 // The URL prefixes used by the NTP to signal when the web store or an app
45 // has launched so we can record the proper histogram. 45 // has launched so we can record the proper histogram.
46 const char* kPingLaunchAppByID = "record-app-launch-by-id"; 46 const char* kPingLaunchAppByID = "record-app-launch-by-id";
47 const char* kPingLaunchWebStore = "record-webstore-launch"; 47 const char* kPingLaunchWebStore = "record-webstore-launch";
48 const char* kPingLaunchAppByURL = "record-app-launch-by-url"; 48 const char* kPingLaunchAppByURL = "record-app-launch-by-url";
49 49
50 const char* kChromeWebStoreUrl = "https://chrome.google.com/webstore";
51
50 const UnescapeRule::Type kUnescapeRules = 52 const UnescapeRule::Type kUnescapeRules =
51 UnescapeRule::NORMAL | UnescapeRule::URL_SPECIAL_CHARS; 53 UnescapeRule::NORMAL | UnescapeRule::URL_SPECIAL_CHARS;
52 54
53 extension_misc::AppLaunchBucket ParseLaunchSource( 55 extension_misc::AppLaunchBucket ParseLaunchSource(
54 const std::string& launch_source) { 56 const std::string& launch_source) {
55 int bucket_num = extension_misc::APP_LAUNCH_BUCKET_INVALID; 57 int bucket_num = extension_misc::APP_LAUNCH_BUCKET_INVALID;
56 base::StringToInt(launch_source, &bucket_num); 58 base::StringToInt(launch_source, &bucket_num);
57 extension_misc::AppLaunchBucket bucket = 59 extension_misc::AppLaunchBucket bucket =
58 static_cast<extension_misc::AppLaunchBucket>(bucket_num); 60 static_cast<extension_misc::AppLaunchBucket>(bucket_num);
59 CHECK(bucket < extension_misc::APP_LAUNCH_BUCKET_BOUNDARY); 61 CHECK(bucket < extension_misc::APP_LAUNCH_BUCKET_BOUNDARY);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 value->SetString("launch_url", extension->GetFullLaunchURL().spec()); 96 value->SetString("launch_url", extension->GetFullLaunchURL().spec());
95 value->SetString("options_url", extension->options_url().spec()); 97 value->SetString("options_url", extension->options_url().spec());
96 value->SetBoolean("can_uninstall", 98 value->SetBoolean("can_uninstall",
97 Extension::UserMayDisable(extension->location())); 99 Extension::UserMayDisable(extension->location()));
98 value->SetString("icon_big", icon_big.spec()); 100 value->SetString("icon_big", icon_big.spec());
99 value->SetString("icon_small", icon_small.spec()); 101 value->SetString("icon_small", icon_small.spec());
100 value->SetInteger("launch_container", extension->launch_container()); 102 value->SetInteger("launch_container", extension->launch_container());
101 value->SetInteger("launch_type", 103 value->SetInteger("launch_type",
102 prefs->GetLaunchType(extension->id(), 104 prefs->GetLaunchType(extension->id(),
103 ExtensionPrefs::LAUNCH_DEFAULT)); 105 ExtensionPrefs::LAUNCH_DEFAULT));
106 value->SetBoolean("is_component",
107 extension->location() == Extension::COMPONENT);
104 108
105 int app_launch_index = prefs->GetAppLaunchIndex(extension->id()); 109 int app_launch_index = prefs->GetAppLaunchIndex(extension->id());
106 if (app_launch_index == -1) { 110 if (app_launch_index == -1) {
107 // Make sure every app has a launch index (some predate the launch index). 111 // Make sure every app has a launch index (some predate the launch index).
108 app_launch_index = prefs->GetNextAppLaunchIndex(); 112 app_launch_index = prefs->GetNextAppLaunchIndex();
109 prefs->SetAppLaunchIndex(extension->id(), app_launch_index); 113 prefs->SetAppLaunchIndex(extension->id(), app_launch_index);
110 } 114 }
111 value->SetInteger("app_launch_index", app_launch_index); 115 value->SetInteger("app_launch_index", app_launch_index);
112 116
113 int page_index = prefs->GetPageIndex(extension->id()); 117 int page_index = prefs->GetPageIndex(extension->id());
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 default: 216 default:
213 NOTREACHED(); 217 NOTREACHED();
214 } 218 }
215 } 219 }
216 220
217 void AppLauncherHandler::FillAppDictionary(DictionaryValue* dictionary) { 221 void AppLauncherHandler::FillAppDictionary(DictionaryValue* dictionary) {
218 ListValue* list = new ListValue(); 222 ListValue* list = new ListValue();
219 const ExtensionList* extensions = extensions_service_->extensions(); 223 const ExtensionList* extensions = extensions_service_->extensions();
220 ExtensionList::const_iterator it; 224 ExtensionList::const_iterator it;
221 for (it = extensions->begin(); it != extensions->end(); ++it) { 225 for (it = extensions->begin(); it != extensions->end(); ++it) {
222 // Don't include the WebStore and other component apps. 226 // Don't include the WebStore.
223 // The WebStore launcher gets special treatment in ntp/apps.js. 227 // The WebStore launcher gets special treatment in ntp/apps.js.
224 if ((*it)->is_app() && (*it)->location() != Extension::COMPONENT) { 228 if ((*it)->is_app() &&
229 (*it)->GetFullLaunchURL().spec() != kChromeWebStoreUrl) {
225 DictionaryValue* app_info = new DictionaryValue(); 230 DictionaryValue* app_info = new DictionaryValue();
226 CreateAppInfo(*it, extensions_service_->extension_prefs(), app_info); 231 CreateAppInfo(*it, extensions_service_->extension_prefs(), app_info);
227 list->Append(app_info); 232 list->Append(app_info);
228 } 233 }
229 } 234 }
230 235
231 extensions = extensions_service_->disabled_extensions(); 236 extensions = extensions_service_->disabled_extensions();
232 for (it = extensions->begin(); it != extensions->end(); ++it) { 237 for (it = extensions->begin(); it != extensions->end(); ++it) {
233 if ((*it)->is_app() && (*it)->location() != Extension::COMPONENT) { 238 if ((*it)->is_app() &&
239 (*it)->GetFullLaunchURL().spec() != kChromeWebStoreUrl) {
234 DictionaryValue* app_info = new DictionaryValue(); 240 DictionaryValue* app_info = new DictionaryValue();
235 CreateAppInfo(*it, extensions_service_->extension_prefs(), app_info); 241 CreateAppInfo(*it, extensions_service_->extension_prefs(), app_info);
236 list->Append(app_info); 242 list->Append(app_info);
237 } 243 }
238 } 244 }
239 245
240 dictionary->Set("apps", list); 246 dictionary->Set("apps", list);
241 247
242 #if defined(OS_MACOSX) 248 #if defined(OS_MACOSX)
243 // App windows are not yet implemented on mac. 249 // App windows are not yet implemented on mac.
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
638 644
639 void AppLauncherHandler::UninstallDefaultApps() { 645 void AppLauncherHandler::UninstallDefaultApps() {
640 AppsPromo* apps_promo = extensions_service_->apps_promo(); 646 AppsPromo* apps_promo = extensions_service_->apps_promo();
641 const ExtensionIdSet& app_ids = apps_promo->old_default_apps(); 647 const ExtensionIdSet& app_ids = apps_promo->old_default_apps();
642 for (ExtensionIdSet::const_iterator iter = app_ids.begin(); 648 for (ExtensionIdSet::const_iterator iter = app_ids.begin();
643 iter != app_ids.end(); ++iter) { 649 iter != app_ids.end(); ++iter) {
644 if (extensions_service_->GetExtensionById(*iter, true)) 650 if (extensions_service_->GetExtensionById(*iter, true))
645 extensions_service_->UninstallExtension(*iter, false, NULL); 651 extensions_service_->UninstallExtension(*iter, false, NULL);
646 } 652 }
647 } 653 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698