OLD | NEW |
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 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 if ((*it)->is_app() && | 241 if ((*it)->is_app() && |
242 (*it)->id() != extension_misc::kWebStoreAppId) { | 242 (*it)->id() != extension_misc::kWebStoreAppId) { |
243 DictionaryValue* app_info = new DictionaryValue(); | 243 DictionaryValue* app_info = new DictionaryValue(); |
244 CreateAppInfo(*it, extensions_service_->extension_prefs(), app_info); | 244 CreateAppInfo(*it, extensions_service_->extension_prefs(), app_info); |
245 list->Append(app_info); | 245 list->Append(app_info); |
246 } | 246 } |
247 } | 247 } |
248 | 248 |
249 dictionary->Set("apps", list); | 249 dictionary->Set("apps", list); |
250 | 250 |
| 251 // TODO(estade): remove these settings when the old NTP is removed. The new |
| 252 // NTP does it in js. |
251 #if defined(OS_MACOSX) | 253 #if defined(OS_MACOSX) |
252 // App windows are not yet implemented on mac. | 254 // App windows are not yet implemented on mac. |
253 dictionary->SetBoolean("disableAppWindowLaunch", true); | 255 dictionary->SetBoolean("disableAppWindowLaunch", true); |
254 dictionary->SetBoolean("disableCreateAppShortcut", true); | 256 dictionary->SetBoolean("disableCreateAppShortcut", true); |
255 #endif | 257 #endif |
256 | 258 |
257 #if defined(OS_CHROMEOS) | 259 #if defined(OS_CHROMEOS) |
258 // Making shortcut does not make sense on ChromeOS because it does not have | 260 // Making shortcut does not make sense on ChromeOS because it does not have |
259 // a desktop. | 261 // a desktop. |
260 dictionary->SetBoolean("disableCreateAppShortcut", true); | 262 dictionary->SetBoolean("disableCreateAppShortcut", true); |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
413 void AppLauncherHandler::HandleSetLaunchType(const ListValue* args) { | 415 void AppLauncherHandler::HandleSetLaunchType(const ListValue* args) { |
414 std::string extension_id; | 416 std::string extension_id; |
415 double launch_type; | 417 double launch_type; |
416 CHECK(args->GetString(0, &extension_id)); | 418 CHECK(args->GetString(0, &extension_id)); |
417 CHECK(args->GetDouble(1, &launch_type)); | 419 CHECK(args->GetDouble(1, &launch_type)); |
418 | 420 |
419 const Extension* extension = | 421 const Extension* extension = |
420 extensions_service_->GetExtensionById(extension_id, true); | 422 extensions_service_->GetExtensionById(extension_id, true); |
421 CHECK(extension); | 423 CHECK(extension); |
422 | 424 |
| 425 // Don't update the page; it already knows about the launch type change. |
| 426 scoped_ptr<AutoReset<bool> > auto_reset; |
| 427 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kNewTabPage4)) |
| 428 auto_reset.reset(new AutoReset<bool>(&ignore_changes_, true)); |
| 429 |
423 extensions_service_->extension_prefs()->SetLaunchType( | 430 extensions_service_->extension_prefs()->SetLaunchType( |
424 extension_id, | 431 extension_id, |
425 static_cast<ExtensionPrefs::LaunchType>( | 432 static_cast<ExtensionPrefs::LaunchType>( |
426 static_cast<int>(launch_type))); | 433 static_cast<int>(launch_type))); |
427 } | 434 } |
428 | 435 |
429 void AppLauncherHandler::HandleUninstallApp(const ListValue* args) { | 436 void AppLauncherHandler::HandleUninstallApp(const ListValue* args) { |
430 std::string extension_id = UTF16ToUTF8(ExtractStringValue(args)); | 437 std::string extension_id = UTF16ToUTF8(ExtractStringValue(args)); |
431 const Extension* extension = extensions_service_->GetExtensionById( | 438 const Extension* extension = extensions_service_->GetExtensionById( |
432 extension_id, false); | 439 extension_id, false); |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
652 | 659 |
653 void AppLauncherHandler::UninstallDefaultApps() { | 660 void AppLauncherHandler::UninstallDefaultApps() { |
654 AppsPromo* apps_promo = extensions_service_->apps_promo(); | 661 AppsPromo* apps_promo = extensions_service_->apps_promo(); |
655 const ExtensionIdSet& app_ids = apps_promo->old_default_apps(); | 662 const ExtensionIdSet& app_ids = apps_promo->old_default_apps(); |
656 for (ExtensionIdSet::const_iterator iter = app_ids.begin(); | 663 for (ExtensionIdSet::const_iterator iter = app_ids.begin(); |
657 iter != app_ids.end(); ++iter) { | 664 iter != app_ids.end(); ++iter) { |
658 if (extensions_service_->GetExtensionById(*iter, true)) | 665 if (extensions_service_->GetExtensionById(*iter, true)) |
659 extensions_service_->UninstallExtension(*iter, false, NULL); | 666 extensions_service_->UninstallExtension(*iter, false, NULL); |
660 } | 667 } |
661 } | 668 } |
OLD | NEW |