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/dom_ui/app_launcher_handler.h" | 5 #include "chrome/browser/dom_ui/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 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
417 CHECK(extension); | 417 CHECK(extension); |
418 | 418 |
419 Browser* browser = BrowserList::GetLastActive(); | 419 Browser* browser = BrowserList::GetLastActive(); |
420 if (!browser) | 420 if (!browser) |
421 return; | 421 return; |
422 browser->window()->ShowCreateChromeAppShortcutsDialog( | 422 browser->window()->ShowCreateChromeAppShortcutsDialog( |
423 browser->profile(), extension); | 423 browser->profile(), extension); |
424 } | 424 } |
425 | 425 |
426 void AppLauncherHandler::HandleReorderApps(const ListValue* args) { | 426 void AppLauncherHandler::HandleReorderApps(const ListValue* args) { |
| 427 CHECK(args->GetSize() == 2); |
| 428 |
| 429 std::string dragged_app_id; |
| 430 ListValue* app_order; |
| 431 CHECK(args->GetString(0, &dragged_app_id)); |
| 432 CHECK(args->GetList(1, &app_order)); |
| 433 |
427 std::vector<std::string> extension_ids; | 434 std::vector<std::string> extension_ids; |
428 for (size_t i = 0; i < args->GetSize(); ++i) { | 435 for (size_t i = 0; i < app_order->GetSize(); ++i) { |
429 std::string value; | 436 std::string value; |
430 if (args->GetString(i, &value)) | 437 if (app_order->GetString(i, &value)) |
431 extension_ids.push_back(value); | 438 extension_ids.push_back(value); |
432 } | 439 } |
433 | 440 |
| 441 extensions_service_->extension_prefs()->SetAppDraggedByUser(dragged_app_id); |
434 extensions_service_->extension_prefs()->SetAppLauncherOrder(extension_ids); | 442 extensions_service_->extension_prefs()->SetAppLauncherOrder(extension_ids); |
435 } | 443 } |
436 | 444 |
437 // static | 445 // static |
438 void AppLauncherHandler::RecordWebStoreLaunch(bool promo_active) { | 446 void AppLauncherHandler::RecordWebStoreLaunch(bool promo_active) { |
439 UMA_HISTOGRAM_ENUMERATION(extension_misc::kAppLaunchHistogram, | 447 UMA_HISTOGRAM_ENUMERATION(extension_misc::kAppLaunchHistogram, |
440 extension_misc::APP_LAUNCH_NTP_WEBSTORE, | 448 extension_misc::APP_LAUNCH_NTP_WEBSTORE, |
441 extension_misc::APP_LAUNCH_BUCKET_BOUNDARY); | 449 extension_misc::APP_LAUNCH_BUCKET_BOUNDARY); |
442 | 450 |
443 if (!promo_active) return; | 451 if (!promo_active) return; |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
504 | 512 |
505 void AppLauncherHandler::UninstallDefaultApps() { | 513 void AppLauncherHandler::UninstallDefaultApps() { |
506 DefaultApps* default_apps = extensions_service_->default_apps(); | 514 DefaultApps* default_apps = extensions_service_->default_apps(); |
507 const ExtensionIdSet& app_ids = default_apps->default_apps(); | 515 const ExtensionIdSet& app_ids = default_apps->default_apps(); |
508 for (ExtensionIdSet::const_iterator iter = app_ids.begin(); | 516 for (ExtensionIdSet::const_iterator iter = app_ids.begin(); |
509 iter != app_ids.end(); ++iter) { | 517 iter != app_ids.end(); ++iter) { |
510 if (extensions_service_->GetExtensionById(*iter, true)) | 518 if (extensions_service_->GetExtensionById(*iter, true)) |
511 extensions_service_->UninstallExtension(*iter, false); | 519 extensions_service_->UninstallExtension(*iter, false); |
512 } | 520 } |
513 } | 521 } |
OLD | NEW |