| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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" |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/bind_helpers.h" | 12 #include "base/bind_helpers.h" |
| 13 #include "base/i18n/rtl.h" | 13 #include "base/i18n/rtl.h" |
| 14 #include "base/metrics/field_trial.h" | 14 #include "base/metrics/field_trial.h" |
| 15 #include "base/metrics/histogram.h" | 15 #include "base/metrics/histogram.h" |
| 16 #include "base/string_number_conversions.h" | 16 #include "base/string_number_conversions.h" |
| 17 #include "base/string_split.h" | 17 #include "base/string_split.h" |
| 18 #include "base/string_util.h" | 18 #include "base/string_util.h" |
| 19 #include "base/utf_string_conversions.h" | 19 #include "base/utf_string_conversions.h" |
| 20 #include "base/values.h" | 20 #include "base/values.h" |
| 21 #include "chrome/browser/extensions/app_notification_manager.h" | 21 #include "chrome/browser/extensions/app_notification_manager.h" |
| 22 #include "chrome/browser/extensions/apps_promo.h" | 22 #include "chrome/browser/extensions/apps_promo.h" |
| 23 #include "chrome/browser/extensions/crx_installer.h" | 23 #include "chrome/browser/extensions/crx_installer.h" |
| 24 #include "chrome/browser/extensions/extension_prefs.h" | 24 #include "chrome/browser/extensions/extension_prefs.h" |
| 25 #include "chrome/browser/extensions/extension_service.h" | 25 #include "chrome/browser/extensions/extension_service.h" |
| 26 #include "chrome/browser/extensions/extension_sorting.h" | 26 #include "chrome/browser/extensions/extension_sorting.h" |
| 27 #include "chrome/browser/extensions/extension_system.h" |
| 27 #include "chrome/browser/prefs/pref_service.h" | 28 #include "chrome/browser/prefs/pref_service.h" |
| 28 #include "chrome/browser/prefs/scoped_user_pref_update.h" | 29 #include "chrome/browser/prefs/scoped_user_pref_update.h" |
| 29 #include "chrome/browser/profiles/profile.h" | 30 #include "chrome/browser/profiles/profile.h" |
| 30 #include "chrome/browser/ui/browser_finder.h" | 31 #include "chrome/browser/ui/browser_finder.h" |
| 31 #include "chrome/browser/ui/browser_window.h" | 32 #include "chrome/browser/ui/browser_window.h" |
| 32 #include "chrome/browser/ui/extensions/application_launch.h" | 33 #include "chrome/browser/ui/extensions/application_launch.h" |
| 33 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h" | 34 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h" |
| 34 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" | 35 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" |
| 35 #include "chrome/browser/ui/webui/web_ui_util.h" | 36 #include "chrome/browser/ui/webui/web_ui_util.h" |
| 36 #include "chrome/common/chrome_notification_types.h" | 37 #include "chrome/common/chrome_notification_types.h" |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 // The Extension class 'helpfully' wraps bidi control characters that | 108 // The Extension class 'helpfully' wraps bidi control characters that |
| 108 // impede our ability to determine directionality. | 109 // impede our ability to determine directionality. |
| 109 string16 name = UTF8ToUTF16(extension->name()); | 110 string16 name = UTF8ToUTF16(extension->name()); |
| 110 base::i18n::UnadjustStringForLocaleDirection(&name); | 111 base::i18n::UnadjustStringForLocaleDirection(&name); |
| 111 NewTabUI::SetURLTitleAndDirection(value, name, extension->GetFullLaunchURL()); | 112 NewTabUI::SetURLTitleAndDirection(value, name, extension->GetFullLaunchURL()); |
| 112 | 113 |
| 113 bool enabled = service->IsExtensionEnabled(extension->id()) && | 114 bool enabled = service->IsExtensionEnabled(extension->id()) && |
| 114 !service->GetTerminatedExtension(extension->id()); | 115 !service->GetTerminatedExtension(extension->id()); |
| 115 extension->GetBasicInfo(enabled, value); | 116 extension->GetBasicInfo(enabled, value); |
| 116 | 117 |
| 118 value->SetBoolean("mayDisable", ExtensionSystem::Get( |
| 119 service->profile())->management_policy()->UserMayModifySettings( |
| 120 extension, NULL)); |
| 121 |
| 117 bool icon_big_exists = true; | 122 bool icon_big_exists = true; |
| 118 // Instead of setting grayscale here, we do it in apps_page.js. | 123 // Instead of setting grayscale here, we do it in apps_page.js. |
| 119 GURL icon_big = | 124 GURL icon_big = |
| 120 ExtensionIconSource::GetIconURL(extension, | 125 ExtensionIconSource::GetIconURL(extension, |
| 121 ExtensionIconSet::EXTENSION_ICON_LARGE, | 126 ExtensionIconSet::EXTENSION_ICON_LARGE, |
| 122 ExtensionIconSet::MATCH_BIGGER, | 127 ExtensionIconSet::MATCH_BIGGER, |
| 123 false, &icon_big_exists); | 128 false, &icon_big_exists); |
| 124 value->SetString("icon_big", icon_big.spec()); | 129 value->SetString("icon_big", icon_big.spec()); |
| 125 value->SetBoolean("icon_big_exists", icon_big_exists); | 130 value->SetBoolean("icon_big_exists", icon_big_exists); |
| 126 bool icon_small_exists = true; | 131 bool icon_small_exists = true; |
| (...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 598 | 603 |
| 599 void AppLauncherHandler::HandleUninstallApp(const ListValue* args) { | 604 void AppLauncherHandler::HandleUninstallApp(const ListValue* args) { |
| 600 std::string extension_id; | 605 std::string extension_id; |
| 601 CHECK(args->GetString(0, &extension_id)); | 606 CHECK(args->GetString(0, &extension_id)); |
| 602 | 607 |
| 603 const Extension* extension = extension_service_->GetExtensionById( | 608 const Extension* extension = extension_service_->GetExtensionById( |
| 604 extension_id, true); | 609 extension_id, true); |
| 605 if (!extension) | 610 if (!extension) |
| 606 return; | 611 return; |
| 607 | 612 |
| 608 if (!Extension::UserMayDisable(extension->location())) { | 613 if (!ExtensionSystem::Get(extension_service_->profile())-> |
| 614 management_policy()->UserMayModifySettings(extension, NULL)) { |
| 609 LOG(ERROR) << "Attempt to uninstall an extension that is non-usermanagable " | 615 LOG(ERROR) << "Attempt to uninstall an extension that is non-usermanagable " |
| 610 << "was made. Extension id : " << extension->id(); | 616 << "was made. Extension id : " << extension->id(); |
| 611 return; | 617 return; |
| 612 } | 618 } |
| 613 if (!extension_id_prompting_.empty()) | 619 if (!extension_id_prompting_.empty()) |
| 614 return; // Only one prompt at a time. | 620 return; // Only one prompt at a time. |
| 615 | 621 |
| 616 extension_id_prompting_ = extension_id; | 622 extension_id_prompting_ = extension_id; |
| 617 | 623 |
| 618 bool dont_confirm = false; | 624 bool dont_confirm = false; |
| (...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 985 | 991 |
| 986 void AppLauncherHandler::UninstallDefaultApps() { | 992 void AppLauncherHandler::UninstallDefaultApps() { |
| 987 AppsPromo* apps_promo = extension_service_->apps_promo(); | 993 AppsPromo* apps_promo = extension_service_->apps_promo(); |
| 988 const extensions::ExtensionIdSet& app_ids = apps_promo->old_default_apps(); | 994 const extensions::ExtensionIdSet& app_ids = apps_promo->old_default_apps(); |
| 989 for (extensions::ExtensionIdSet::const_iterator iter = app_ids.begin(); | 995 for (extensions::ExtensionIdSet::const_iterator iter = app_ids.begin(); |
| 990 iter != app_ids.end(); ++iter) { | 996 iter != app_ids.end(); ++iter) { |
| 991 if (extension_service_->GetExtensionById(*iter, true)) | 997 if (extension_service_->GetExtensionById(*iter, true)) |
| 992 extension_service_->UninstallExtension(*iter, false, NULL); | 998 extension_service_->UninstallExtension(*iter, false, NULL); |
| 993 } | 999 } |
| 994 } | 1000 } |
| OLD | NEW |