| 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 30 matching lines...) Expand all Loading... |
| 41 #include "chrome/common/url_constants.h" | 41 #include "chrome/common/url_constants.h" |
| 42 #include "chrome/common/web_apps.h" | 42 #include "chrome/common/web_apps.h" |
| 43 #include "content/browser/disposition_utils.h" | 43 #include "content/browser/disposition_utils.h" |
| 44 #include "content/browser/tab_contents/tab_contents.h" | 44 #include "content/browser/tab_contents/tab_contents.h" |
| 45 #include "content/common/notification_service.h" | 45 #include "content/common/notification_service.h" |
| 46 #include "googleurl/src/gurl.h" | 46 #include "googleurl/src/gurl.h" |
| 47 #include "grit/browser_resources.h" | 47 #include "grit/browser_resources.h" |
| 48 #include "grit/generated_resources.h" | 48 #include "grit/generated_resources.h" |
| 49 #include "net/base/escape.h" | 49 #include "net/base/escape.h" |
| 50 #include "ui/base/animation/animation.h" | 50 #include "ui/base/animation/animation.h" |
| 51 #include "ui/base/l10n/l10n_util.h" |
| 51 #include "ui/gfx/codec/png_codec.h" | 52 #include "ui/gfx/codec/png_codec.h" |
| 52 #include "webkit/glue/window_open_disposition.h" | 53 #include "webkit/glue/window_open_disposition.h" |
| 53 | 54 |
| 54 namespace { | 55 namespace { |
| 55 | 56 |
| 56 // The URL prefixes used by the NTP to signal when the web store or an app | 57 // The URL prefixes used by the NTP to signal when the web store or an app |
| 57 // has launched so we can record the proper histogram. | 58 // has launched so we can record the proper histogram. |
| 58 const char* kPingLaunchAppByID = "record-app-launch-by-id"; | 59 const char* kPingLaunchAppByID = "record-app-launch-by-id"; |
| 59 const char* kPingLaunchWebStore = "record-webstore-launch"; | 60 const char* kPingLaunchWebStore = "record-webstore-launch"; |
| 60 const char* kPingLaunchAppByURL = "record-app-launch-by-url"; | 61 const char* kPingLaunchAppByURL = "record-app-launch-by-url"; |
| (...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 442 #endif | 443 #endif |
| 443 | 444 |
| 444 dictionary->SetBoolean( | 445 dictionary->SetBoolean( |
| 445 "showLauncher", | 446 "showLauncher", |
| 446 extension_service_->apps_promo()->ShouldShowAppLauncher( | 447 extension_service_->apps_promo()->ShouldShowAppLauncher( |
| 447 extension_service_->GetAppIds())); | 448 extension_service_->GetAppIds())); |
| 448 | 449 |
| 449 if (NewTabUI::NTP4Enabled()) { | 450 if (NewTabUI::NTP4Enabled()) { |
| 450 PrefService* prefs = Profile::FromWebUI(web_ui_)->GetPrefs(); | 451 PrefService* prefs = Profile::FromWebUI(web_ui_)->GetPrefs(); |
| 451 const ListValue* app_page_names = prefs->GetList(prefs::kNTPAppPageNames); | 452 const ListValue* app_page_names = prefs->GetList(prefs::kNTPAppPageNames); |
| 452 if (app_page_names && app_page_names->GetSize()) { | 453 if (!app_page_names || !app_page_names->GetSize()) { |
| 454 ListPrefUpdate update(prefs, prefs::kNTPAppPageNames); |
| 455 ListValue* list = update.Get(); |
| 456 list->Set(0, Value::CreateStringValue( |
| 457 l10n_util::GetStringUTF16(IDS_APP_DEFAULT_PAGE_NAME))); |
| 458 dictionary->Set("appPageNames", |
| 459 static_cast<ListValue*>(list->DeepCopy())); |
| 460 } else { |
| 453 dictionary->Set("appPageNames", | 461 dictionary->Set("appPageNames", |
| 454 static_cast<ListValue*>(app_page_names->DeepCopy())); | 462 static_cast<ListValue*>(app_page_names->DeepCopy())); |
| 455 } | 463 } |
| 456 } | 464 } |
| 457 } | 465 } |
| 458 | 466 |
| 459 DictionaryValue* AppLauncherHandler::GetAppInfo(const Extension* extension) { | 467 DictionaryValue* AppLauncherHandler::GetAppInfo(const Extension* extension) { |
| 460 AppNotificationManager* notification_manager = | 468 AppNotificationManager* notification_manager = |
| 461 extension_service_->app_notification_manager(); | 469 extension_service_->app_notification_manager(); |
| 462 DictionaryValue* app_info = new DictionaryValue(); | 470 DictionaryValue* app_info = new DictionaryValue(); |
| (...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1017 | 1025 |
| 1018 void AppLauncherHandler::UninstallDefaultApps() { | 1026 void AppLauncherHandler::UninstallDefaultApps() { |
| 1019 AppsPromo* apps_promo = extension_service_->apps_promo(); | 1027 AppsPromo* apps_promo = extension_service_->apps_promo(); |
| 1020 const ExtensionIdSet& app_ids = apps_promo->old_default_apps(); | 1028 const ExtensionIdSet& app_ids = apps_promo->old_default_apps(); |
| 1021 for (ExtensionIdSet::const_iterator iter = app_ids.begin(); | 1029 for (ExtensionIdSet::const_iterator iter = app_ids.begin(); |
| 1022 iter != app_ids.end(); ++iter) { | 1030 iter != app_ids.end(); ++iter) { |
| 1023 if (extension_service_->GetExtensionById(*iter, true)) | 1031 if (extension_service_->GetExtensionById(*iter, true)) |
| 1024 extension_service_->UninstallExtension(*iter, false, NULL); | 1032 extension_service_->UninstallExtension(*iter, false, NULL); |
| 1025 } | 1033 } |
| 1026 } | 1034 } |
| OLD | NEW |