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

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

Issue 8036002: ntp: remove ntp3 resources (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 9 years, 3 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/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 dictionary->SetString("body", notification.body); 90 dictionary->SetString("body", notification.body);
91 if (!notification.linkUrl.is_empty()) { 91 if (!notification.linkUrl.is_empty()) {
92 dictionary->SetString("linkUrl", notification.linkUrl.spec()); 92 dictionary->SetString("linkUrl", notification.linkUrl.spec());
93 dictionary->SetString("linkText", notification.linkText); 93 dictionary->SetString("linkText", notification.linkText);
94 } 94 }
95 return dictionary; 95 return dictionary;
96 } 96 }
97 97
98 // static 98 // static
99 bool AppLauncherHandler::IsAppExcludedFromList(const Extension* extension) { 99 bool AppLauncherHandler::IsAppExcludedFromList(const Extension* extension) {
100 // Don't include the WebStore and the Cloud Print app. 100 // Don't include the WebStore and the Cloud Print app.
csilv 2011/09/26 22:25:47 You can remove this comment line.
Evan Stade 2011/09/26 22:32:05 yea
101 // The WebStore launcher gets special treatment in ntp/apps.js.
102 // The Cloud Print app should never be displayed in the NTP. 101 // The Cloud Print app should never be displayed in the NTP.
103 bool ntp3 = 102 return !extension->is_app() ||
104 !NewTabUI::NTP4Enabled(); 103 (extension->id() == extension_misc::kCloudPrintAppId);
105 if (!extension->is_app() ||
106 (ntp3 && extension->id() == extension_misc::kWebStoreAppId) ||
107 (extension->id() == extension_misc::kCloudPrintAppId)) {
108 return true;
109 }
110 return false;
111 } 104 }
112 105
113 void AppLauncherHandler::CreateAppInfo(const Extension* extension, 106 void AppLauncherHandler::CreateAppInfo(const Extension* extension,
114 const AppNotification* notification, 107 const AppNotification* notification,
115 ExtensionService* service, 108 ExtensionService* service,
116 DictionaryValue* value) { 109 DictionaryValue* value) {
117 bool enabled = service->IsExtensionEnabled(extension->id()) && 110 bool enabled = service->IsExtensionEnabled(extension->id()) &&
118 !service->GetTerminatedExtension(extension->id()); 111 !service->GetTerminatedExtension(extension->id());
119 bool icon_big_exists = true; 112 bool icon_big_exists = true;
120 // Instead of setting grayscale here, we do it in apps_page.js in NTP4. 113 // Instead of setting grayscale here, we do it in apps_page.js in NTP4.
121 bool grayscale = NewTabUI::NTP4Enabled() ? false : !enabled;
122 GURL icon_big = 114 GURL icon_big =
123 ExtensionIconSource::GetIconURL(extension, 115 ExtensionIconSource::GetIconURL(extension,
124 Extension::EXTENSION_ICON_LARGE, 116 Extension::EXTENSION_ICON_LARGE,
125 ExtensionIconSet::MATCH_EXACTLY, 117 ExtensionIconSet::MATCH_EXACTLY,
126 grayscale, &icon_big_exists); 118 false, &icon_big_exists);
127 bool icon_small_exists = true; 119 bool icon_small_exists = true;
128 GURL icon_small = 120 GURL icon_small =
129 ExtensionIconSource::GetIconURL(extension, 121 ExtensionIconSource::GetIconURL(extension,
130 Extension::EXTENSION_ICON_BITTY, 122 Extension::EXTENSION_ICON_BITTY,
131 ExtensionIconSet::MATCH_BIGGER, 123 ExtensionIconSet::MATCH_BIGGER,
132 grayscale, &icon_small_exists); 124 false, &icon_small_exists);
133 125
134 value->Clear(); 126 value->Clear();
135 value->SetString("id", extension->id()); 127 value->SetString("id", extension->id());
136 value->SetString("name", extension->name()); 128 value->SetString("name", extension->name());
137 value->SetString("description", extension->description()); 129 value->SetString("description", extension->description());
138 value->SetString("launch_url", extension->GetFullLaunchURL().spec()); 130 value->SetString("launch_url", extension->GetFullLaunchURL().spec());
139 value->SetBoolean("enabled", enabled); 131 value->SetBoolean("enabled", enabled);
140 if (NewTabUI::NTP4Enabled() || enabled) 132 value->SetString("options_url", extension->options_url().spec());
141 value->SetString("options_url", extension->options_url().spec());
142 value->SetBoolean("can_uninstall", 133 value->SetBoolean("can_uninstall",
143 Extension::UserMayDisable(extension->location())); 134 Extension::UserMayDisable(extension->location()));
144 value->SetString("icon_big", icon_big.spec()); 135 value->SetString("icon_big", icon_big.spec());
145 value->SetBoolean("icon_big_exists", icon_big_exists); 136 value->SetBoolean("icon_big_exists", icon_big_exists);
146 value->SetString("icon_small", icon_small.spec()); 137 value->SetString("icon_small", icon_small.spec());
147 value->SetBoolean("icon_small_exists", icon_small_exists); 138 value->SetBoolean("icon_small_exists", icon_small_exists);
148 value->SetInteger("launch_container", extension->launch_container()); 139 value->SetInteger("launch_container", extension->launch_container());
149 ExtensionPrefs* prefs = service->extension_prefs(); 140 ExtensionPrefs* prefs = service->extension_prefs();
150 value->SetInteger("launch_type", 141 value->SetInteger("launch_type",
151 prefs->GetLaunchType(extension->id(), 142 prefs->GetLaunchType(extension->id(),
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 NewCallback(this, &AppLauncherHandler::HandleSaveAppPageName)); 245 NewCallback(this, &AppLauncherHandler::HandleSaveAppPageName));
255 web_ui_->RegisterMessageCallback("generateAppForLink", 246 web_ui_->RegisterMessageCallback("generateAppForLink",
256 NewCallback(this, &AppLauncherHandler::HandleGenerateAppForLink)); 247 NewCallback(this, &AppLauncherHandler::HandleGenerateAppForLink));
257 web_ui_->RegisterMessageCallback("recordAppLaunchByURL", 248 web_ui_->RegisterMessageCallback("recordAppLaunchByURL",
258 NewCallback(this, &AppLauncherHandler::HandleRecordAppLaunchByURL)); 249 NewCallback(this, &AppLauncherHandler::HandleRecordAppLaunchByURL));
259 } 250 }
260 251
261 void AppLauncherHandler::Observe(int type, 252 void AppLauncherHandler::Observe(int type,
262 const NotificationSource& source, 253 const NotificationSource& source,
263 const NotificationDetails& details) { 254 const NotificationDetails& details) {
264 if (type == chrome::NOTIFICATION_APP_INSTALLED_TO_NTP && 255 if (type == chrome::NOTIFICATION_APP_INSTALLED_TO_NTP) {
265 NewTabUI::NTP4Enabled()) {
266 highlight_app_id_ = *Details<const std::string>(details).ptr(); 256 highlight_app_id_ = *Details<const std::string>(details).ptr();
267 if (has_loaded_apps_) 257 if (has_loaded_apps_)
268 SetAppToBeHighlighted(); 258 SetAppToBeHighlighted();
269 return; 259 return;
270 } 260 }
271 261
272 if (ignore_changes_ || !has_loaded_apps_) 262 if (ignore_changes_ || !has_loaded_apps_)
273 return; 263 return;
274 264
275 switch (type) { 265 switch (type) {
(...skipping 15 matching lines...) Expand all
291 web_ui_->CallJavascriptFunction("appNotificationChanged", id_value); 281 web_ui_->CallJavascriptFunction("appNotificationChanged", id_value);
292 } 282 }
293 break; 283 break;
294 } 284 }
295 285
296 case chrome::NOTIFICATION_EXTENSION_LOADED: { 286 case chrome::NOTIFICATION_EXTENSION_LOADED: {
297 const Extension* extension = Details<const Extension>(details).ptr(); 287 const Extension* extension = Details<const Extension>(details).ptr();
298 if (!extension->is_app()) 288 if (!extension->is_app())
299 return; 289 return;
300 290
301 if (!NewTabUI::NTP4Enabled()) { 291 #if defined(TOUCH_UI)
302 HandleGetApps(NULL); 292 HandleGetApps(NULL);
303 break; 293 #else
304 }
305
306 scoped_ptr<DictionaryValue> app_info(GetAppInfo(extension)); 294 scoped_ptr<DictionaryValue> app_info(GetAppInfo(extension));
307 if (app_info.get()) { 295 if (app_info.get()) {
308 ExtensionPrefs* prefs = extension_service_->extension_prefs(); 296 ExtensionPrefs* prefs = extension_service_->extension_prefs();
309 scoped_ptr<base::FundamentalValue> highlight(Value::CreateBooleanValue( 297 scoped_ptr<base::FundamentalValue> highlight(Value::CreateBooleanValue(
310 prefs->IsFromBookmark(extension->id()) && 298 prefs->IsFromBookmark(extension->id()) &&
311 attempted_bookmark_app_install_)); 299 attempted_bookmark_app_install_));
312 attempted_bookmark_app_install_ = false; 300 attempted_bookmark_app_install_ = false;
313 web_ui_->CallJavascriptFunction("ntp4.appAdded", *app_info, *highlight); 301 web_ui_->CallJavascriptFunction("ntp4.appAdded", *app_info, *highlight);
314 } 302 }
315 303 #endif
316 break; 304 break;
317 } 305 }
318 case chrome::NOTIFICATION_EXTENSION_UNLOADED: { 306 case chrome::NOTIFICATION_EXTENSION_UNLOADED: {
319 const Extension* extension = 307 const Extension* extension =
320 Details<UnloadedExtensionInfo>(details)->extension; 308 Details<UnloadedExtensionInfo>(details)->extension;
321 if (!extension->is_app()) 309 if (!extension->is_app())
322 return; 310 return;
323 311
324 if (!NewTabUI::NTP4Enabled()) { 312 #if defined(TOUCH_UI)
325 HandleGetApps(NULL); 313 HandleGetApps(NULL);
326 break; 314 #else
327 }
328
329 scoped_ptr<DictionaryValue> app_info(GetAppInfo(extension)); 315 scoped_ptr<DictionaryValue> app_info(GetAppInfo(extension));
330 scoped_ptr<base::FundamentalValue> uninstall_value( 316 scoped_ptr<base::FundamentalValue> uninstall_value(
331 Value::CreateBooleanValue( 317 Value::CreateBooleanValue(
332 Details<UnloadedExtensionInfo>(details)->reason == 318 Details<UnloadedExtensionInfo>(details)->reason ==
333 extension_misc::UNLOAD_REASON_UNINSTALL)); 319 extension_misc::UNLOAD_REASON_UNINSTALL));
334 if (app_info.get()) { 320 if (app_info.get()) {
335 web_ui_->CallJavascriptFunction( 321 web_ui_->CallJavascriptFunction(
336 "ntp4.appRemoved", *app_info, *uninstall_value); 322 "ntp4.appRemoved", *app_info, *uninstall_value);
337 } 323 }
324 #endif
338 break; 325 break;
339 } 326 }
340 case chrome::NOTIFICATION_EXTENSION_LAUNCHER_REORDERED: 327 case chrome::NOTIFICATION_EXTENSION_LAUNCHER_REORDERED:
341 // The promo may not load until a couple seconds after the first NTP view, 328 // The promo may not load until a couple seconds after the first NTP view,
342 // so we listen for the load notification and notify the NTP when ready. 329 // so we listen for the load notification and notify the NTP when ready.
343 case chrome::NOTIFICATION_WEB_STORE_PROMO_LOADED: 330 case chrome::NOTIFICATION_WEB_STORE_PROMO_LOADED:
344 // TODO(estade): try to get rid of this inefficient operation. 331 // TODO(estade): try to get rid of this inefficient operation.
345 HandleGetApps(NULL); 332 HandleGetApps(NULL);
346 break; 333 break;
347 case chrome::NOTIFICATION_PREF_CHANGED: { 334 case chrome::NOTIFICATION_PREF_CHANGED: {
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 // Making shortcut does not make sense on ChromeOS because it does not have 398 // Making shortcut does not make sense on ChromeOS because it does not have
412 // a desktop. 399 // a desktop.
413 dictionary->SetBoolean("disableCreateAppShortcut", true); 400 dictionary->SetBoolean("disableCreateAppShortcut", true);
414 #endif 401 #endif
415 402
416 dictionary->SetBoolean( 403 dictionary->SetBoolean(
417 "showLauncher", 404 "showLauncher",
418 extension_service_->apps_promo()->ShouldShowAppLauncher( 405 extension_service_->apps_promo()->ShouldShowAppLauncher(
419 extension_service_->GetAppIds())); 406 extension_service_->GetAppIds()));
420 407
421 if (NewTabUI::NTP4Enabled()) { 408 PrefService* prefs = Profile::FromWebUI(web_ui_)->GetPrefs();
422 PrefService* prefs = Profile::FromWebUI(web_ui_)->GetPrefs(); 409 const ListValue* app_page_names = prefs->GetList(prefs::kNTPAppPageNames);
423 const ListValue* app_page_names = prefs->GetList(prefs::kNTPAppPageNames); 410 if (app_page_names && app_page_names->GetSize()) {
424 if (app_page_names && app_page_names->GetSize()) { 411 dictionary->Set("appPageNames",
425 dictionary->Set("appPageNames", 412 static_cast<ListValue*>(app_page_names->DeepCopy()));
426 static_cast<ListValue*>(app_page_names->DeepCopy()));
427 }
428 } 413 }
429 } 414 }
430 415
431 DictionaryValue* AppLauncherHandler::GetAppInfo(const Extension* extension) { 416 DictionaryValue* AppLauncherHandler::GetAppInfo(const Extension* extension) {
432 AppNotificationManager* notification_manager = 417 AppNotificationManager* notification_manager =
433 extension_service_->app_notification_manager(); 418 extension_service_->app_notification_manager();
434 DictionaryValue* app_info = new DictionaryValue(); 419 DictionaryValue* app_info = new DictionaryValue();
435 // CreateAppInfo can change the extension prefs. 420 // CreateAppInfo can change the extension prefs.
436 AutoReset<bool> auto_reset(&ignore_changes_, true); 421 AutoReset<bool> auto_reset(&ignore_changes_, true);
437 CreateAppInfo(extension, 422 CreateAppInfo(extension,
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 // If the user pressed special keys when clicking, override the saved 538 // If the user pressed special keys when clicking, override the saved
554 // preference for launch container. 539 // preference for launch container.
555 bool middle_button = (button == 1.0); 540 bool middle_button = (button == 1.0);
556 WindowOpenDisposition disposition = 541 WindowOpenDisposition disposition =
557 disposition_utils::DispositionFromClick(middle_button, alt_key, 542 disposition_utils::DispositionFromClick(middle_button, alt_key,
558 ctrl_key, meta_key, shift_key); 543 ctrl_key, meta_key, shift_key);
559 544
560 if (extension_id != extension_misc::kWebStoreAppId) { 545 if (extension_id != extension_misc::kWebStoreAppId) {
561 RecordAppLaunchByID(promo_active_, launch_bucket); 546 RecordAppLaunchByID(promo_active_, launch_bucket);
562 extension_service_->apps_promo()->ExpireDefaultApps(); 547 extension_service_->apps_promo()->ExpireDefaultApps();
563 } else if (NewTabUI::NTP4Enabled()) { 548 } else {
564 RecordWebStoreLaunch(promo_active_); 549 RecordWebStoreLaunch(promo_active_);
565 } 550 }
566 551
567 if (disposition == NEW_FOREGROUND_TAB || disposition == NEW_BACKGROUND_TAB) { 552 if (disposition == NEW_FOREGROUND_TAB || disposition == NEW_BACKGROUND_TAB) {
568 // TODO(jamescook): Proper support for background tabs. 553 // TODO(jamescook): Proper support for background tabs.
569 Browser::OpenApplication( 554 Browser::OpenApplication(
570 profile, extension, extension_misc::LAUNCH_TAB, disposition); 555 profile, extension, extension_misc::LAUNCH_TAB, disposition);
571 } else if (disposition == NEW_WINDOW) { 556 } else if (disposition == NEW_WINDOW) {
572 // Force a new window open. 557 // Force a new window open.
573 Browser::OpenApplication( 558 Browser::OpenApplication(
(...skipping 27 matching lines...) Expand all
601 double launch_type; 586 double launch_type;
602 CHECK(args->GetString(0, &extension_id)); 587 CHECK(args->GetString(0, &extension_id));
603 CHECK(args->GetDouble(1, &launch_type)); 588 CHECK(args->GetDouble(1, &launch_type));
604 589
605 const Extension* extension = 590 const Extension* extension =
606 extension_service_->GetExtensionById(extension_id, true); 591 extension_service_->GetExtensionById(extension_id, true);
607 if (!extension) 592 if (!extension)
608 return; 593 return;
609 594
610 // Don't update the page; it already knows about the launch type change. 595 // Don't update the page; it already knows about the launch type change.
611 scoped_ptr<AutoReset<bool> > auto_reset; 596 AutoReset<bool> auto_reset(&ignore_changes_, true);
612 if (NewTabUI::NTP4Enabled())
613 auto_reset.reset(new AutoReset<bool>(&ignore_changes_, true));
614
615 extension_service_->extension_prefs()->SetLaunchType( 597 extension_service_->extension_prefs()->SetLaunchType(
616 extension_id, 598 extension_id,
617 static_cast<ExtensionPrefs::LaunchType>( 599 static_cast<ExtensionPrefs::LaunchType>(
618 static_cast<int>(launch_type))); 600 static_cast<int>(launch_type)));
619 } 601 }
620 602
621 void AppLauncherHandler::HandleUninstallApp(const ListValue* args) { 603 void AppLauncherHandler::HandleUninstallApp(const ListValue* args) {
622 std::string extension_id; 604 std::string extension_id;
623 CHECK(args->GetString(0, &extension_id)); 605 CHECK(args->GetString(0, &extension_id));
624 606
625 const Extension* extension = extension_service_->GetExtensionById( 607 const Extension* extension = extension_service_->GetExtensionById(
626 extension_id, true); 608 extension_id, true);
627 if (!extension) 609 if (!extension)
628 return; 610 return;
629 611
630 if (!Extension::UserMayDisable(extension->location())) { 612 if (!Extension::UserMayDisable(extension->location())) {
631 LOG(ERROR) << "Attempt to uninstall an extension that is non-usermanagable " 613 LOG(ERROR) << "Attempt to uninstall an extension that is non-usermanagable "
632 << "was made. Extension id : " << extension->id(); 614 << "was made. Extension id : " << extension->id();
633 return; 615 return;
634 } 616 }
635 if (!extension_id_prompting_.empty()) 617 if (!extension_id_prompting_.empty())
636 return; // Only one prompt at a time. 618 return; // Only one prompt at a time.
637 619
638 extension_id_prompting_ = extension_id; 620 extension_id_prompting_ = extension_id;
639 621
640 bool dont_confirm = false; 622 bool dont_confirm = false;
641 if (args->GetBoolean(1, &dont_confirm) && dont_confirm) { 623 if (args->GetBoolean(1, &dont_confirm) && dont_confirm) {
642 scoped_ptr<AutoReset<bool> > auto_reset; 624 AutoReset<bool> auto_reset(&ignore_changes_, true);
643 if (NewTabUI::NTP4Enabled())
644 auto_reset.reset(new AutoReset<bool>(&ignore_changes_, true));
645 ExtensionUninstallAccepted(); 625 ExtensionUninstallAccepted();
646 } else { 626 } else {
647 GetExtensionUninstallDialog()->ConfirmUninstall(extension); 627 GetExtensionUninstallDialog()->ConfirmUninstall(extension);
648 } 628 }
649 } 629 }
650 630
651 void AppLauncherHandler::HandleHideAppsPromo(const ListValue* args) { 631 void AppLauncherHandler::HandleHideAppsPromo(const ListValue* args) {
652 // If the user has intentionally hidden the promotion, we'll uninstall all the 632 // If the user has intentionally hidden the promotion, we'll uninstall all the
653 // default apps (we know the user hasn't installed any apps on their own at 633 // default apps (we know the user hasn't installed any apps on their own at
654 // this point, or the promotion wouldn't have been shown). 634 // this point, or the promotion wouldn't have been shown).
655 // TODO(estade): this isn't used right now as we sort out the future of the 635 // TODO(estade): this isn't used right now as we sort out the future of the
656 // apps promo on ntp4. 636 // apps promo on ntp4.
657 if (NewTabUI::NTP4Enabled()) { 637 UninstallDefaultApps();
658 UninstallDefaultApps(); 638 extension_service_->apps_promo()->HidePromo();
659 extension_service_->apps_promo()->HidePromo();
660 } else {
661 // TODO(estade): remove all this. NTP3 uninstalled all the default apps then
662 // refreshed the entire NTP, we don't have to jump through these hoops for
663 // NTP4 because each app uninstall is handled separately without reloading
664 // the entire page.
665 ignore_changes_ = true;
666 UninstallDefaultApps();
667 extension_service_->apps_promo()->HidePromo();
668 ignore_changes_ = false;
669 HandleGetApps(NULL);
670 }
671 } 639 }
672 640
673 void AppLauncherHandler::HandleCreateAppShortcut(const ListValue* args) { 641 void AppLauncherHandler::HandleCreateAppShortcut(const ListValue* args) {
674 std::string extension_id; 642 std::string extension_id;
675 CHECK(args->GetString(0, &extension_id)); 643 CHECK(args->GetString(0, &extension_id));
676 644
677 const Extension* extension = 645 const Extension* extension =
678 extension_service_->GetExtensionById(extension_id, true); 646 extension_service_->GetExtensionById(extension_id, true);
679 if (!extension) 647 if (!extension)
680 return; 648 return;
(...skipping 14 matching lines...) Expand all
695 CHECK(args->GetList(1, &app_order)); 663 CHECK(args->GetList(1, &app_order));
696 664
697 std::vector<std::string> extension_ids; 665 std::vector<std::string> extension_ids;
698 for (size_t i = 0; i < app_order->GetSize(); ++i) { 666 for (size_t i = 0; i < app_order->GetSize(); ++i) {
699 std::string value; 667 std::string value;
700 if (app_order->GetString(i, &value)) 668 if (app_order->GetString(i, &value))
701 extension_ids.push_back(value); 669 extension_ids.push_back(value);
702 } 670 }
703 671
704 // Don't update the page; it already knows the apps have been reordered. 672 // Don't update the page; it already knows the apps have been reordered.
705 scoped_ptr<AutoReset<bool> > auto_reset; 673 AutoReset<bool> auto_reset(&ignore_changes_, true);
706 if (NewTabUI::NTP4Enabled())
707 auto_reset.reset(new AutoReset<bool>(&ignore_changes_, true));
708
709 extension_service_->extension_prefs()->SetAppDraggedByUser(dragged_app_id); 674 extension_service_->extension_prefs()->SetAppDraggedByUser(dragged_app_id);
710 extension_service_->extension_prefs()->SetAppLauncherOrder(extension_ids); 675 extension_service_->extension_prefs()->SetAppLauncherOrder(extension_ids);
711 } 676 }
712 677
713 void AppLauncherHandler::HandleSetPageIndex(const ListValue* args) { 678 void AppLauncherHandler::HandleSetPageIndex(const ListValue* args) {
714 std::string extension_id; 679 std::string extension_id;
715 double page_index; 680 double page_index;
716 CHECK(args->GetString(0, &extension_id)); 681 CHECK(args->GetString(0, &extension_id));
717 CHECK(args->GetDouble(1, &page_index)); 682 CHECK(args->GetDouble(1, &page_index));
718 683
719 // Don't update the page; it already knows the apps have been reordered. 684 // Don't update the page; it already knows the apps have been reordered.
720 scoped_ptr<AutoReset<bool> > auto_reset; 685 AutoReset<bool> auto_reset(&ignore_changes_, true);
721 if (NewTabUI::NTP4Enabled())
722 auto_reset.reset(new AutoReset<bool>(&ignore_changes_, true));
723
724 extension_service_->extension_prefs()->SetPageIndex(extension_id, 686 extension_service_->extension_prefs()->SetPageIndex(extension_id,
725 static_cast<int>(page_index)); 687 static_cast<int>(page_index));
726 } 688 }
727 689
728 void AppLauncherHandler::HandlePromoSeen(const ListValue* args) { 690 void AppLauncherHandler::HandlePromoSeen(const ListValue* args) {
729 UMA_HISTOGRAM_ENUMERATION(extension_misc::kAppsPromoHistogram, 691 UMA_HISTOGRAM_ENUMERATION(extension_misc::kAppsPromoHistogram,
730 extension_misc::PROMO_SEEN, 692 extension_misc::PROMO_SEEN,
731 extension_misc::PROMO_BUCKET_BOUNDARY); 693 extension_misc::PROMO_BUCKET_BOUNDARY);
732 } 694 }
733 695
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
989 951
990 void AppLauncherHandler::UninstallDefaultApps() { 952 void AppLauncherHandler::UninstallDefaultApps() {
991 AppsPromo* apps_promo = extension_service_->apps_promo(); 953 AppsPromo* apps_promo = extension_service_->apps_promo();
992 const ExtensionIdSet& app_ids = apps_promo->old_default_apps(); 954 const ExtensionIdSet& app_ids = apps_promo->old_default_apps();
993 for (ExtensionIdSet::const_iterator iter = app_ids.begin(); 955 for (ExtensionIdSet::const_iterator iter = app_ids.begin();
994 iter != app_ids.end(); ++iter) { 956 iter != app_ids.end(); ++iter) {
995 if (extension_service_->GetExtensionById(*iter, true)) 957 if (extension_service_->GetExtensionById(*iter, true))
996 extension_service_->UninstallExtension(*iter, false, NULL); 958 extension_service_->UninstallExtension(*iter, false, NULL);
997 } 959 }
998 } 960 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698