Chromium Code Reviews| 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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 153 ExtensionPrefs::LAUNCH_DEFAULT)); | 153 ExtensionPrefs::LAUNCH_DEFAULT)); |
| 154 value->SetBoolean("offline_enabled", extension->offline_enabled()); | 154 value->SetBoolean("offline_enabled", extension->offline_enabled()); |
| 155 value->SetBoolean("is_component", | 155 value->SetBoolean("is_component", |
| 156 extension->location() == Extension::COMPONENT); | 156 extension->location() == Extension::COMPONENT); |
| 157 value->SetBoolean("is_webstore", | 157 value->SetBoolean("is_webstore", |
| 158 extension->id() == extension_misc::kWebStoreAppId); | 158 extension->id() == extension_misc::kWebStoreAppId); |
| 159 | 159 |
| 160 if (notification) | 160 if (notification) |
| 161 value->Set("notification", SerializeNotification(*notification)); | 161 value->Set("notification", SerializeNotification(*notification)); |
| 162 | 162 |
| 163 int app_launch_index = prefs->GetAppLaunchIndex(extension->id()); | 163 StringOrdinal page_ordinal = prefs->GetPageOrdinal(extension->id()); |
| 164 if (app_launch_index == -1) { | 164 if (!page_ordinal.IsValid()) { |
| 165 // Make sure every app has a launch index (some predate the launch index). | 165 // Make sure every app has a page ordinal (some predate the page ordinal). |
| 166 // The webstore's app launch index is set to -2 to make sure it's first. | 166 // The webstore app should be on the first page. |
| 167 // The next time the user drags (any) app this will be set to something | 167 page_ordinal = extension->id() == extension_misc::kWebStoreAppId ? |
| 168 // sane (i.e. >= 0). | 168 prefs->GetFirstAppPage() : prefs->GetNaturalAppPageOrdinal(); |
| 169 app_launch_index = extension->id() == extension_misc::kWebStoreAppId ? | 169 prefs->SetPageOrdinal(extension->id(), page_ordinal); |
| 170 -2 : prefs->GetNextAppLaunchIndex(0); | |
| 171 prefs->SetAppLaunchIndex(extension->id(), app_launch_index); | |
| 172 } | 170 } |
| 173 value->SetInteger("app_launch_index", app_launch_index); | 171 // We convert the page_ordinal to an integer becuase the pages are referenced |
| 172 // from within an array in the javascript code, which can't be easily | |
| 173 // changed to handle the StringOrdinal values, so we do the conversion here. | |
| 174 value->SetInteger("page_index", | |
| 175 prefs->PageStringOrdinalAsInteger(page_ordinal)); | |
| 174 | 176 |
| 175 int page_index = prefs->GetPageIndex(extension->id()); | 177 StringOrdinal app_launch_ordinal = |
| 176 if (page_index < 0) { | 178 prefs->GetAppLaunchOrdinal(extension->id()); |
| 177 // Make sure every app has a page index (some predate the page index). | 179 if (!app_launch_ordinal.IsValid()) { |
| 178 // The webstore app should be on the first page. | 180 // Make sure every app has a launch ordinal (some predate the launch |
| 179 page_index = extension->id() == extension_misc::kWebStoreAppId ? | 181 // ordinal). The webstore's app launch ordinal is always set to the first |
| 180 0 : prefs->GetNaturalAppPageIndex(); | 182 // position. |
| 181 prefs->SetPageIndex(extension->id(), page_index); | 183 app_launch_ordinal = extension->id() == extension_misc::kWebStoreAppId ? |
| 184 prefs->CreateFirstAppLaunchOrdinal(page_ordinal) : | |
| 185 prefs->GetNextAppLaunchOrdinal(page_ordinal); | |
| 186 prefs->SetAppLaunchOrdinal(extension->id(), app_launch_ordinal); | |
| 182 } | 187 } |
| 183 value->SetInteger("page_index", page_index); | 188 value->SetString("app_launch_ordinal", app_launch_ordinal.ToString()); |
| 184 } | 189 } |
| 185 | 190 |
| 186 WebUIMessageHandler* AppLauncherHandler::Attach(WebUI* web_ui) { | 191 WebUIMessageHandler* AppLauncherHandler::Attach(WebUI* web_ui) { |
| 187 registrar_.Add(this, chrome::NOTIFICATION_APP_INSTALLED_TO_NTP, | 192 registrar_.Add(this, chrome::NOTIFICATION_APP_INSTALLED_TO_NTP, |
| 188 content::Source<TabContents>(web_ui->tab_contents())); | 193 content::Source<TabContents>(web_ui->tab_contents())); |
| 189 return WebUIMessageHandler::Attach(web_ui); | 194 return WebUIMessageHandler::Attach(web_ui); |
| 190 } | 195 } |
| 191 | 196 |
| 192 void AppLauncherHandler::RegisterMessages() { | 197 void AppLauncherHandler::RegisterMessages() { |
| 193 web_ui_->RegisterMessageCallback("getApps", | 198 web_ui_->RegisterMessageCallback("getApps", |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 334 case chrome::NOTIFICATION_EXTENSION_LOAD_ERROR: { | 339 case chrome::NOTIFICATION_EXTENSION_LOAD_ERROR: { |
| 335 attempted_bookmark_app_install_ = false; | 340 attempted_bookmark_app_install_ = false; |
| 336 break; | 341 break; |
| 337 } | 342 } |
| 338 default: | 343 default: |
| 339 NOTREACHED(); | 344 NOTREACHED(); |
| 340 } | 345 } |
| 341 } | 346 } |
| 342 | 347 |
| 343 void AppLauncherHandler::FillAppDictionary(DictionaryValue* dictionary) { | 348 void AppLauncherHandler::FillAppDictionary(DictionaryValue* dictionary) { |
| 344 // CreateAppInfo and ClearPageIndex can change the extension prefs. | 349 // CreateAppInfo and ClearPageOrdinal can change the extension prefs. |
| 345 AutoReset<bool> auto_reset(&ignore_changes_, true); | 350 AutoReset<bool> auto_reset(&ignore_changes_, true); |
| 346 | 351 |
| 347 ListValue* list = new ListValue(); | 352 ListValue* list = new ListValue(); |
| 348 const ExtensionList* extensions = extension_service_->extensions(); | 353 const ExtensionList* extensions = extension_service_->extensions(); |
| 349 ExtensionList::const_iterator it; | 354 ExtensionList::const_iterator it; |
| 350 for (it = extensions->begin(); it != extensions->end(); ++it) { | 355 for (it = extensions->begin(); it != extensions->end(); ++it) { |
| 351 if (!IsAppExcludedFromList(*it)) { | 356 if (!IsAppExcludedFromList(*it)) { |
| 352 DictionaryValue* app_info = GetAppInfo(*it); | 357 DictionaryValue* app_info = GetAppInfo(*it); |
| 353 list->Append(app_info); | 358 list->Append(app_info); |
| 354 } else { | 359 } else { |
| 355 // This is necessary because in some previous versions of chrome, we set a | 360 // This is necessary because in some previous versions of chrome, we set a |
| 356 // page index for non-app extensions. Old profiles can persist this error, | 361 // page index for non-app extensions. Old profiles can persist this error, |
| 357 // and this fixes it. If we don't fix it, GetNaturalAppPageIndex() doesn't | 362 // and this fixes it. This caused GetNaturalAppPageIndex() to break |
| 358 // work. See http://crbug.com/98325 | 363 // (see http://crbug.com/98325) before it was an ordinal value. |
| 359 ExtensionPrefs* prefs = extension_service_->extension_prefs(); | 364 ExtensionPrefs* prefs = extension_service_->extension_prefs(); |
| 360 if (prefs->GetPageIndex((*it)->id()) != -1) | 365 if (prefs->GetPageOrdinal((*it)->id()).IsValid()) |
| 361 prefs->ClearPageIndex((*it)->id()); | 366 prefs->ClearPageOrdinal((*it)->id()); |
| 362 } | 367 } |
| 363 } | 368 } |
| 364 | 369 |
| 365 extensions = extension_service_->disabled_extensions(); | 370 extensions = extension_service_->disabled_extensions(); |
| 366 for (it = extensions->begin(); it != extensions->end(); ++it) { | 371 for (it = extensions->begin(); it != extensions->end(); ++it) { |
| 367 if (!IsAppExcludedFromList(*it)) { | 372 if (!IsAppExcludedFromList(*it)) { |
| 368 DictionaryValue* app_info = new DictionaryValue(); | 373 DictionaryValue* app_info = new DictionaryValue(); |
| 369 CreateAppInfo(*it, | 374 CreateAppInfo(*it, |
| 370 NULL, | 375 NULL, |
| 371 extension_service_, | 376 extension_service_, |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 402 dictionary->SetBoolean("disableCreateAppShortcut", true); | 407 dictionary->SetBoolean("disableCreateAppShortcut", true); |
| 403 #endif | 408 #endif |
| 404 | 409 |
| 405 dictionary->SetBoolean( | 410 dictionary->SetBoolean( |
| 406 "showLauncher", | 411 "showLauncher", |
| 407 extension_service_->apps_promo()->ShouldShowAppLauncher( | 412 extension_service_->apps_promo()->ShouldShowAppLauncher( |
| 408 extension_service_->GetAppIds())); | 413 extension_service_->GetAppIds())); |
| 409 | 414 |
| 410 if (NewTabUI::NTP4Enabled()) { | 415 if (NewTabUI::NTP4Enabled()) { |
| 411 PrefService* prefs = Profile::FromWebUI(web_ui_)->GetPrefs(); | 416 PrefService* prefs = Profile::FromWebUI(web_ui_)->GetPrefs(); |
| 412 const ListValue* app_page_names = prefs->GetList(prefs::kNTPAppPageNames); | 417 const DictionaryValue* app_page_names = |
| 413 if (!app_page_names || !app_page_names->GetSize()) { | 418 prefs->GetDictionary(prefs::kNTPAppPageNames); |
| 414 ListPrefUpdate update(prefs, prefs::kNTPAppPageNames); | 419 if (!app_page_names || !app_page_names->size()) { |
| 415 ListValue* list = update.Get(); | 420 DictionaryPrefUpdate update(prefs, prefs::kNTPAppPageNames); |
| 416 list->Set(0, Value::CreateStringValue( | 421 DictionaryValue* names_dictionary = update.Get(); |
| 422 const StringOrdinal& new_page = StringOrdinal::CreateInitialOrdinal(); | |
| 423 names_dictionary->Set(new_page.ToString(), Value::CreateStringValue( | |
| 417 l10n_util::GetStringUTF16(IDS_APP_DEFAULT_PAGE_NAME))); | 424 l10n_util::GetStringUTF16(IDS_APP_DEFAULT_PAGE_NAME))); |
| 418 dictionary->Set("appPageNames", | 425 app_page_names = names_dictionary; |
| 419 static_cast<ListValue*>(list->DeepCopy())); | |
| 420 } else { | |
| 421 dictionary->Set("appPageNames", | |
| 422 static_cast<ListValue*>(app_page_names->DeepCopy())); | |
| 423 } | 426 } |
| 427 | |
| 428 // Convert the app page names from a dictionary to a list because the | |
| 429 // javascript code requires this data in a list. | |
| 430 ListValue* list = new ListValue; | |
| 431 for (DictionaryValue::Iterator it(*app_page_names); | |
| 432 it.HasNext(); it.Advance()) { | |
| 433 list->Append(it.value().DeepCopy()); | |
| 434 } | |
| 435 dictionary->Set("appPageNames", list); | |
|
csharp
2011/11/23 15:38:07
This seems to be the best way I could find to conv
Evan Stade
2011/11/23 21:54:51
this seems fine, my original comment was concerned
csharp
2011/12/07 15:00:59
I'm not exactly sure where the json and c++ code m
| |
| 424 } | 436 } |
| 425 } | 437 } |
| 426 | 438 |
| 427 DictionaryValue* AppLauncherHandler::GetAppInfo(const Extension* extension) { | 439 DictionaryValue* AppLauncherHandler::GetAppInfo(const Extension* extension) { |
| 428 AppNotificationManager* notification_manager = | 440 AppNotificationManager* notification_manager = |
| 429 extension_service_->app_notification_manager(); | 441 extension_service_->app_notification_manager(); |
| 430 DictionaryValue* app_info = new DictionaryValue(); | 442 DictionaryValue* app_info = new DictionaryValue(); |
| 431 // CreateAppInfo can change the extension prefs. | 443 // CreateAppInfo can change the extension prefs. |
| 432 AutoReset<bool> auto_reset(&ignore_changes_, true); | 444 AutoReset<bool> auto_reset(&ignore_changes_, true); |
| 433 CreateAppInfo(extension, | 445 CreateAppInfo(extension, |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 698 if (app_order->GetString(i, &value)) | 710 if (app_order->GetString(i, &value)) |
| 699 extension_ids.push_back(value); | 711 extension_ids.push_back(value); |
| 700 } | 712 } |
| 701 | 713 |
| 702 // Don't update the page; it already knows the apps have been reordered. | 714 // Don't update the page; it already knows the apps have been reordered. |
| 703 scoped_ptr<AutoReset<bool> > auto_reset; | 715 scoped_ptr<AutoReset<bool> > auto_reset; |
| 704 if (NewTabUI::NTP4Enabled()) | 716 if (NewTabUI::NTP4Enabled()) |
| 705 auto_reset.reset(new AutoReset<bool>(&ignore_changes_, true)); | 717 auto_reset.reset(new AutoReset<bool>(&ignore_changes_, true)); |
| 706 | 718 |
| 707 extension_service_->extension_prefs()->SetAppDraggedByUser(dragged_app_id); | 719 extension_service_->extension_prefs()->SetAppDraggedByUser(dragged_app_id); |
| 708 extension_service_->extension_prefs()->SetAppLauncherOrder(extension_ids); | 720 extension_service_->extension_prefs()->SetAppLauncherOrder(extension_ids, |
| 721 dragged_app_id); | |
| 709 } | 722 } |
| 710 | 723 |
| 711 void AppLauncherHandler::HandleSetPageIndex(const ListValue* args) { | 724 void AppLauncherHandler::HandleSetPageIndex(const ListValue* args) { |
| 712 std::string extension_id; | 725 std::string extension_id; |
| 713 double page_index; | 726 double page_index; |
| 714 CHECK(args->GetString(0, &extension_id)); | 727 CHECK(args->GetString(0, &extension_id)); |
| 715 CHECK(args->GetDouble(1, &page_index)); | 728 CHECK(args->GetDouble(1, &page_index)); |
| 729 const StringOrdinal& page_ordinal = | |
| 730 extension_service_->extension_prefs()->PageIntegerAsStringOrdinal( | |
| 731 static_cast<size_t>(page_index)); | |
| 716 | 732 |
| 717 // Don't update the page; it already knows the apps have been reordered. | 733 // Don't update the page; it already knows the apps have been reordered. |
| 718 scoped_ptr<AutoReset<bool> > auto_reset; | 734 scoped_ptr<AutoReset<bool> > auto_reset; |
| 719 if (NewTabUI::NTP4Enabled()) | 735 if (NewTabUI::NTP4Enabled()) |
| 720 auto_reset.reset(new AutoReset<bool>(&ignore_changes_, true)); | 736 auto_reset.reset(new AutoReset<bool>(&ignore_changes_, true)); |
| 721 | 737 |
| 722 extension_service_->extension_prefs()->SetPageIndex(extension_id, | 738 extension_service_->extension_prefs()->SetPageOrdinal(extension_id, |
| 723 static_cast<int>(page_index)); | 739 page_ordinal); |
| 724 } | 740 } |
| 725 | 741 |
| 726 void AppLauncherHandler::HandlePromoSeen(const ListValue* args) { | 742 void AppLauncherHandler::HandlePromoSeen(const ListValue* args) { |
| 727 UMA_HISTOGRAM_ENUMERATION(extension_misc::kAppsPromoHistogram, | 743 UMA_HISTOGRAM_ENUMERATION(extension_misc::kAppsPromoHistogram, |
| 728 extension_misc::PROMO_SEEN, | 744 extension_misc::PROMO_SEEN, |
| 729 extension_misc::PROMO_BUCKET_BOUNDARY); | 745 extension_misc::PROMO_BUCKET_BOUNDARY); |
| 730 } | 746 } |
| 731 | 747 |
| 732 void AppLauncherHandler::HandleSaveAppPageName(const ListValue* args) { | 748 void AppLauncherHandler::HandleSaveAppPageName(const ListValue* args) { |
| 733 string16 name; | 749 string16 name; |
| 734 CHECK(args->GetString(0, &name)); | 750 CHECK(args->GetString(0, &name)); |
| 735 | 751 |
| 736 double page_index; | 752 double page_index; |
| 737 CHECK(args->GetDouble(1, &page_index)); | 753 CHECK(args->GetDouble(1, &page_index)); |
| 754 const StringOrdinal& page_ordinal = | |
| 755 extension_service_->extension_prefs()->PageIntegerAsStringOrdinal( | |
| 756 static_cast<int>(page_index)); | |
| 738 | 757 |
| 739 AutoReset<bool> auto_reset(&ignore_changes_, true); | 758 AutoReset<bool> auto_reset(&ignore_changes_, true); |
| 740 PrefService* prefs = Profile::FromWebUI(web_ui_)->GetPrefs(); | 759 PrefService* prefs = Profile::FromWebUI(web_ui_)->GetPrefs(); |
| 741 ListPrefUpdate update(prefs, prefs::kNTPAppPageNames); | 760 DictionaryPrefUpdate update(prefs, prefs::kNTPAppPageNames); |
| 742 ListValue* list = update.Get(); | 761 DictionaryValue* dictionary = update.Get(); |
| 743 list->Set(static_cast<size_t>(page_index), Value::CreateStringValue(name)); | 762 dictionary->Set(page_ordinal.ToString(), Value::CreateStringValue(name)); |
| 744 } | 763 } |
| 745 | 764 |
| 746 void AppLauncherHandler::HandleGenerateAppForLink(const ListValue* args) { | 765 void AppLauncherHandler::HandleGenerateAppForLink(const ListValue* args) { |
| 747 std::string url; | 766 std::string url; |
| 748 CHECK(args->GetString(0, &url)); | 767 CHECK(args->GetString(0, &url)); |
| 749 GURL launch_url(url); | 768 GURL launch_url(url); |
| 750 | 769 |
| 751 string16 title; | 770 string16 title; |
| 752 CHECK(args->GetString(1, &title)); | 771 CHECK(args->GetString(1, &title)); |
| 753 | 772 |
| 754 double page_index; | 773 double page_index; |
| 755 CHECK(args->GetDouble(2, &page_index)); | 774 CHECK(args->GetDouble(2, &page_index)); |
| 775 const StringOrdinal& page_ordinal = | |
| 776 extension_service_->extension_prefs()->PageIntegerAsStringOrdinal( | |
| 777 static_cast<int>(page_index)); | |
| 756 | 778 |
| 757 Profile* profile = Profile::FromWebUI(web_ui_); | 779 Profile* profile = Profile::FromWebUI(web_ui_); |
| 758 FaviconService* favicon_service = | 780 FaviconService* favicon_service = |
| 759 profile->GetFaviconService(Profile::EXPLICIT_ACCESS); | 781 profile->GetFaviconService(Profile::EXPLICIT_ACCESS); |
| 760 if (!favicon_service) { | 782 if (!favicon_service) { |
| 761 LOG(ERROR) << "No favicon service"; | 783 LOG(ERROR) << "No favicon service"; |
| 762 return; | 784 return; |
| 763 } | 785 } |
| 764 | 786 |
| 765 scoped_ptr<AppInstallInfo> install_info(new AppInstallInfo()); | 787 scoped_ptr<AppInstallInfo> install_info(new AppInstallInfo()); |
| 766 install_info->is_bookmark_app = true; | 788 install_info->is_bookmark_app = true; |
| 767 install_info->title = title; | 789 install_info->title = title; |
| 768 install_info->app_url = launch_url; | 790 install_info->app_url = launch_url; |
| 769 install_info->page_index = static_cast<int>(page_index); | 791 install_info->page_ordinal = page_ordinal; |
| 770 | 792 |
| 771 FaviconService::Handle h = favicon_service->GetFaviconForURL( | 793 FaviconService::Handle h = favicon_service->GetFaviconForURL( |
| 772 launch_url, history::FAVICON, &favicon_consumer_, | 794 launch_url, history::FAVICON, &favicon_consumer_, |
| 773 base::Bind(&AppLauncherHandler::OnFaviconForApp, base::Unretained(this))); | 795 base::Bind(&AppLauncherHandler::OnFaviconForApp, base::Unretained(this))); |
| 774 favicon_consumer_.SetClientData(favicon_service, h, install_info.release()); | 796 favicon_consumer_.SetClientData(favicon_service, h, install_info.release()); |
| 775 } | 797 } |
| 776 | 798 |
| 777 void AppLauncherHandler::HandleRecordAppLaunchByURL( | 799 void AppLauncherHandler::HandleRecordAppLaunchByURL( |
| 778 const base::ListValue* args) { | 800 const base::ListValue* args) { |
| 779 std::string url; | 801 std::string url; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 819 &(web_app->icons[0].data))) { | 841 &(web_app->icons[0].data))) { |
| 820 web_app->icons[0].url = GURL(); | 842 web_app->icons[0].url = GURL(); |
| 821 web_app->icons[0].width = web_app->icons[0].data.width(); | 843 web_app->icons[0].width = web_app->icons[0].data.width(); |
| 822 web_app->icons[0].height = web_app->icons[0].data.height(); | 844 web_app->icons[0].height = web_app->icons[0].data.height(); |
| 823 } else { | 845 } else { |
| 824 web_app->icons.clear(); | 846 web_app->icons.clear(); |
| 825 } | 847 } |
| 826 | 848 |
| 827 scoped_refptr<CrxInstaller> installer( | 849 scoped_refptr<CrxInstaller> installer( |
| 828 CrxInstaller::Create(extension_service_, NULL)); | 850 CrxInstaller::Create(extension_service_, NULL)); |
| 829 installer->set_page_index(install_info->page_index); | 851 installer->set_page_ordinal(install_info->page_ordinal); |
| 830 installer->InstallWebApp(*web_app); | 852 installer->InstallWebApp(*web_app); |
| 831 attempted_bookmark_app_install_ = true; | 853 attempted_bookmark_app_install_ = true; |
| 832 } | 854 } |
| 833 | 855 |
| 834 void AppLauncherHandler::SetAppToBeHighlighted() { | 856 void AppLauncherHandler::SetAppToBeHighlighted() { |
| 835 if (highlight_app_id_.empty()) | 857 if (highlight_app_id_.empty()) |
| 836 return; | 858 return; |
| 837 | 859 |
| 838 StringValue app_id(highlight_app_id_); | 860 StringValue app_id(highlight_app_id_); |
| 839 web_ui_->CallJavascriptFunction("ntp4.setAppToBeHighlighted", app_id); | 861 web_ui_->CallJavascriptFunction("ntp4.setAppToBeHighlighted", app_id); |
| 840 highlight_app_id_.clear(); | 862 highlight_app_id_.clear(); |
| 841 } | 863 } |
| 842 | 864 |
| 843 // static | 865 // static |
| 844 void AppLauncherHandler::RegisterUserPrefs(PrefService* pref_service) { | 866 void AppLauncherHandler::RegisterUserPrefs(PrefService* pref_service) { |
| 845 // TODO(csilv): We will want this to be a syncable preference instead. | 867 // TODO(csilv): We will want this to be a syncable preference instead. |
| 846 pref_service->RegisterListPref(prefs::kNTPAppPageNames, | 868 pref_service->RegisterDictionaryPref(prefs::kNTPAppPageNames, |
| 847 PrefService::UNSYNCABLE_PREF); | 869 PrefService::UNSYNCABLE_PREF); |
| 848 } | 870 } |
| 849 | 871 |
| 850 // statiic | 872 // static |
| 851 void AppLauncherHandler::RecordWebStoreLaunch(bool promo_active) { | 873 void AppLauncherHandler::RecordWebStoreLaunch(bool promo_active) { |
| 852 UMA_HISTOGRAM_ENUMERATION(extension_misc::kAppLaunchHistogram, | 874 UMA_HISTOGRAM_ENUMERATION(extension_misc::kAppLaunchHistogram, |
| 853 extension_misc::APP_LAUNCH_NTP_WEBSTORE, | 875 extension_misc::APP_LAUNCH_NTP_WEBSTORE, |
| 854 extension_misc::APP_LAUNCH_BUCKET_BOUNDARY); | 876 extension_misc::APP_LAUNCH_BUCKET_BOUNDARY); |
| 855 | 877 |
| 856 if (!promo_active) return; | 878 if (!promo_active) return; |
| 857 | 879 |
| 858 UMA_HISTOGRAM_ENUMERATION(extension_misc::kAppsPromoHistogram, | 880 UMA_HISTOGRAM_ENUMERATION(extension_misc::kAppsPromoHistogram, |
| 859 extension_misc::PROMO_LAUNCH_WEB_STORE, | 881 extension_misc::PROMO_LAUNCH_WEB_STORE, |
| 860 extension_misc::PROMO_BUCKET_BOUNDARY); | 882 extension_misc::PROMO_BUCKET_BOUNDARY); |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 995 | 1017 |
| 996 void AppLauncherHandler::UninstallDefaultApps() { | 1018 void AppLauncherHandler::UninstallDefaultApps() { |
| 997 AppsPromo* apps_promo = extension_service_->apps_promo(); | 1019 AppsPromo* apps_promo = extension_service_->apps_promo(); |
| 998 const ExtensionIdSet& app_ids = apps_promo->old_default_apps(); | 1020 const ExtensionIdSet& app_ids = apps_promo->old_default_apps(); |
| 999 for (ExtensionIdSet::const_iterator iter = app_ids.begin(); | 1021 for (ExtensionIdSet::const_iterator iter = app_ids.begin(); |
| 1000 iter != app_ids.end(); ++iter) { | 1022 iter != app_ids.end(); ++iter) { |
| 1001 if (extension_service_->GetExtensionById(*iter, true)) | 1023 if (extension_service_->GetExtensionById(*iter, true)) |
| 1002 extension_service_->UninstallExtension(*iter, false, NULL); | 1024 extension_service_->UninstallExtension(*iter, false, NULL); |
| 1003 } | 1025 } |
| 1004 } | 1026 } |
| OLD | NEW |