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

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

Issue 7888047: Added Instant preference syncing and tests. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Add ability for applications to sync position on NTP Created 9 years, 2 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 | « chrome/browser/sync/protocol/proto_value_conversions.cc ('k') | 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 488 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 pref_change_registrar_.Add(prefs::kNTPAppPageNames, this); 499 pref_change_registrar_.Add(prefs::kNTPAppPageNames, this);
500 500
501 registrar_.Add(this, chrome::NOTIFICATION_APP_NOTIFICATION_STATE_CHANGED, 501 registrar_.Add(this, chrome::NOTIFICATION_APP_NOTIFICATION_STATE_CHANGED,
502 NotificationService::AllSources()); 502 NotificationService::AllSources());
503 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, 503 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED,
504 Source<Profile>(profile)); 504 Source<Profile>(profile));
505 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, 505 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED,
506 Source<Profile>(profile)); 506 Source<Profile>(profile));
507 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LAUNCHER_REORDERED, 507 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LAUNCHER_REORDERED,
508 Source<ExtensionPrefs>(extension_service_->extension_prefs())); 508 Source<ExtensionPrefs>(extension_service_->extension_prefs()));
509 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LAUNCHER_REORDERED,
510 Source<ExtensionService>(extension_service_));
509 registrar_.Add(this, chrome::NOTIFICATION_WEB_STORE_PROMO_LOADED, 511 registrar_.Add(this, chrome::NOTIFICATION_WEB_STORE_PROMO_LOADED,
510 Source<Profile>(profile)); 512 Source<Profile>(profile));
511 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_INSTALL_ERROR, 513 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_INSTALL_ERROR,
512 Source<Profile>(profile)); 514 Source<Profile>(profile));
513 } 515 }
514 516
515 has_loaded_apps_ = true; 517 has_loaded_apps_ = true;
516 } 518 }
517 519
518 void AppLauncherHandler::HandleLaunchApp(const ListValue* args) { 520 void AppLauncherHandler::HandleLaunchApp(const ListValue* args) {
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
701 if (app_order->GetString(i, &value)) 703 if (app_order->GetString(i, &value))
702 extension_ids.push_back(value); 704 extension_ids.push_back(value);
703 } 705 }
704 706
705 // Don't update the page; it already knows the apps have been reordered. 707 // Don't update the page; it already knows the apps have been reordered.
706 scoped_ptr<AutoReset<bool> > auto_reset; 708 scoped_ptr<AutoReset<bool> > auto_reset;
707 if (NewTabUI::NTP4Enabled()) 709 if (NewTabUI::NTP4Enabled())
708 auto_reset.reset(new AutoReset<bool>(&ignore_changes_, true)); 710 auto_reset.reset(new AutoReset<bool>(&ignore_changes_, true));
709 711
710 extension_service_->extension_prefs()->SetAppDraggedByUser(dragged_app_id); 712 extension_service_->extension_prefs()->SetAppDraggedByUser(dragged_app_id);
711 extension_service_->extension_prefs()->SetAppLauncherOrder(extension_ids); 713 extension_service_->SetAppLauncherOrder(extension_ids);
712 } 714 }
713 715
714 void AppLauncherHandler::HandleSetPageIndex(const ListValue* args) { 716 void AppLauncherHandler::HandleSetPageIndex(const ListValue* args) {
715 std::string extension_id; 717 std::string extension_id;
716 double page_index; 718 double page_index;
717 CHECK(args->GetString(0, &extension_id)); 719 CHECK(args->GetString(0, &extension_id));
718 CHECK(args->GetDouble(1, &page_index)); 720 CHECK(args->GetDouble(1, &page_index));
719 721
720 // Don't update the page; it already knows the apps have been reordered. 722 // Don't update the page; it already knows the apps have been reordered.
721 scoped_ptr<AutoReset<bool> > auto_reset; 723 scoped_ptr<AutoReset<bool> > auto_reset;
722 if (NewTabUI::NTP4Enabled()) 724 if (NewTabUI::NTP4Enabled())
723 auto_reset.reset(new AutoReset<bool>(&ignore_changes_, true)); 725 auto_reset.reset(new AutoReset<bool>(&ignore_changes_, true));
724 726
725 extension_service_->extension_prefs()->SetPageIndex(extension_id, 727 extension_service_->SetPageIndex(extension_id,
726 static_cast<int>(page_index)); 728 static_cast<int32>(page_index));
727 } 729 }
728 730
729 void AppLauncherHandler::HandlePromoSeen(const ListValue* args) { 731 void AppLauncherHandler::HandlePromoSeen(const ListValue* args) {
730 UMA_HISTOGRAM_ENUMERATION(extension_misc::kAppsPromoHistogram, 732 UMA_HISTOGRAM_ENUMERATION(extension_misc::kAppsPromoHistogram,
731 extension_misc::PROMO_SEEN, 733 extension_misc::PROMO_SEEN,
732 extension_misc::PROMO_BUCKET_BOUNDARY); 734 extension_misc::PROMO_BUCKET_BOUNDARY);
733 } 735 }
734 736
735 void AppLauncherHandler::HandleSaveAppPageName(const ListValue* args) { 737 void AppLauncherHandler::HandleSaveAppPageName(const ListValue* args) {
736 string16 name; 738 string16 name;
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
990 992
991 void AppLauncherHandler::UninstallDefaultApps() { 993 void AppLauncherHandler::UninstallDefaultApps() {
992 AppsPromo* apps_promo = extension_service_->apps_promo(); 994 AppsPromo* apps_promo = extension_service_->apps_promo();
993 const ExtensionIdSet& app_ids = apps_promo->old_default_apps(); 995 const ExtensionIdSet& app_ids = apps_promo->old_default_apps();
994 for (ExtensionIdSet::const_iterator iter = app_ids.begin(); 996 for (ExtensionIdSet::const_iterator iter = app_ids.begin();
995 iter != app_ids.end(); ++iter) { 997 iter != app_ids.end(); ++iter) {
996 if (extension_service_->GetExtensionById(*iter, true)) 998 if (extension_service_->GetExtensionById(*iter, true))
997 extension_service_->UninstallExtension(*iter, false, NULL); 999 extension_service_->UninstallExtension(*iter, false, NULL);
998 } 1000 }
999 } 1001 }
OLDNEW
« no previous file with comments | « chrome/browser/sync/protocol/proto_value_conversions.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698