OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/extensions/extension_service.h" | 5 #include "chrome/browser/extensions/extension_service.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <iterator> | 8 #include <iterator> |
9 #include <set> | 9 #include <set> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/bind.h" | 12 #include "base/bind.h" |
13 #include "base/callback.h" | 13 #include "base/callback.h" |
14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
15 #include "base/file_util.h" | 15 #include "base/file_util.h" |
16 #include "base/logging.h" | 16 #include "base/logging.h" |
17 #include "base/metrics/histogram.h" | 17 #include "base/metrics/histogram.h" |
18 #include "base/path_service.h" | 18 #include "base/path_service.h" |
19 #include "base/prefs/pref_service.h" | 19 #include "base/prefs/pref_service.h" |
20 #include "base/stl_util.h" | 20 #include "base/stl_util.h" |
21 #include "base/string_util.h" | 21 #include "base/string_util.h" |
22 #include "base/stringprintf.h" | 22 #include "base/stringprintf.h" |
23 #include "base/strings/string_number_conversions.h" | 23 #include "base/strings/string_number_conversions.h" |
24 #include "base/threading/sequenced_worker_pool.h" | 24 #include "base/threading/sequenced_worker_pool.h" |
25 #include "base/threading/thread_restrictions.h" | 25 #include "base/threading/thread_restrictions.h" |
26 #include "base/time.h" | 26 #include "base/time.h" |
27 #include "base/utf_string_conversions.h" | 27 #include "base/utf_string_conversions.h" |
28 #include "base/values.h" | 28 #include "base/values.h" |
29 #include "base/version.h" | 29 #include "base/version.h" |
| 30 #include "chrome/browser/app_mode/app_mode_utils.h" |
30 #include "chrome/browser/browser_process.h" | 31 #include "chrome/browser/browser_process.h" |
31 #include "chrome/browser/devtools/devtools_window.h" | 32 #include "chrome/browser/devtools/devtools_window.h" |
32 #include "chrome/browser/extensions/api/app_runtime/app_runtime_api.h" | 33 #include "chrome/browser/extensions/api/app_runtime/app_runtime_api.h" |
33 #include "chrome/browser/extensions/api/declarative/rules_registry_service.h" | 34 #include "chrome/browser/extensions/api/declarative/rules_registry_service.h" |
34 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h" | 35 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h" |
35 #include "chrome/browser/extensions/api/profile_keyed_api_factory.h" | 36 #include "chrome/browser/extensions/api/profile_keyed_api_factory.h" |
36 #include "chrome/browser/extensions/api/runtime/runtime_api.h" | 37 #include "chrome/browser/extensions/api/runtime/runtime_api.h" |
37 #include "chrome/browser/extensions/api/storage/settings_frontend.h" | 38 #include "chrome/browser/extensions/api/storage/settings_frontend.h" |
38 #include "chrome/browser/extensions/app_sync_data.h" | 39 #include "chrome/browser/extensions/app_sync_data.h" |
39 #include "chrome/browser/extensions/browser_event_router.h" | 40 #include "chrome/browser/extensions/browser_event_router.h" |
(...skipping 2148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2188 // will record the permissions it recognized, not including "omnibox." | 2189 // will record the permissions it recognized, not including "omnibox." |
2189 // When upgrading to Chrome 10, "omnibox" will be recognized and Chrome | 2190 // When upgrading to Chrome 10, "omnibox" will be recognized and Chrome |
2190 // will disable the extension and prompt the user to approve the increase | 2191 // will disable the extension and prompt the user to approve the increase |
2191 // in privileges. The extension could then release a new version that | 2192 // in privileges. The extension could then release a new version that |
2192 // removes the "omnibox" permission. When the user upgrades, Chrome will | 2193 // removes the "omnibox" permission. When the user upgrades, Chrome will |
2193 // still remember that "omnibox" had been granted, so that if the | 2194 // still remember that "omnibox" had been granted, so that if the |
2194 // extension once again includes "omnibox" in an upgrade, the extension | 2195 // extension once again includes "omnibox" in an upgrade, the extension |
2195 // can upgrade without requiring this user's approval. | 2196 // can upgrade without requiring this user's approval. |
2196 int disable_reasons = extension_prefs_->GetDisableReasons(extension->id()); | 2197 int disable_reasons = extension_prefs_->GetDisableReasons(extension->id()); |
2197 | 2198 |
2198 bool is_default_app_install = | 2199 bool auto_grant_permission = |
2199 (!is_extension_upgrade && extension->was_installed_by_default()); | 2200 (!is_extension_upgrade && extension->was_installed_by_default()) || |
| 2201 chrome::IsRunningInForcedAppMode(); |
2200 // Silently grant all active permissions to default apps only on install. | 2202 // Silently grant all active permissions to default apps only on install. |
2201 // After install they should behave like other apps. | 2203 // After install they should behave like other apps. |
2202 if (is_default_app_install) | 2204 // Silently grant all active permissions to apps install in kiosk mode on both |
| 2205 // install and update. |
| 2206 if (auto_grant_permission) |
2203 GrantPermissions(extension); | 2207 GrantPermissions(extension); |
2204 | 2208 |
2205 bool is_privilege_increase = false; | 2209 bool is_privilege_increase = false; |
2206 // We only need to compare the granted permissions to the current permissions | 2210 // We only need to compare the granted permissions to the current permissions |
2207 // if the extension is not allowed to silently increase its permissions. | 2211 // if the extension is not allowed to silently increase its permissions. |
2208 if (!extensions::PermissionsData::CanSilentlyIncreasePermissions(extension) && | 2212 if (!extensions::PermissionsData::CanSilentlyIncreasePermissions(extension) && |
2209 !is_default_app_install) { | 2213 !auto_grant_permission) { |
2210 // Add all the recognized permissions if the granted permissions list | 2214 // Add all the recognized permissions if the granted permissions list |
2211 // hasn't been initialized yet. | 2215 // hasn't been initialized yet. |
2212 scoped_refptr<PermissionSet> granted_permissions = | 2216 scoped_refptr<PermissionSet> granted_permissions = |
2213 extension_prefs_->GetGrantedPermissions(extension->id()); | 2217 extension_prefs_->GetGrantedPermissions(extension->id()); |
2214 CHECK(granted_permissions.get()); | 2218 CHECK(granted_permissions.get()); |
2215 | 2219 |
2216 // Here, we check if an extension's privileges have increased in a manner | 2220 // Here, we check if an extension's privileges have increased in a manner |
2217 // that requires the user's approval. This could occur because the browser | 2221 // that requires the user's approval. This could occur because the browser |
2218 // upgraded and recognized additional privileges, or an extension upgrades | 2222 // upgraded and recognized additional privileges, or an extension upgrades |
2219 // to a version that requires additional privileges. | 2223 // to a version that requires additional privileges. |
(...skipping 882 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3102 } | 3106 } |
3103 | 3107 |
3104 void ExtensionService::AddUpdateObserver(extensions::UpdateObserver* observer) { | 3108 void ExtensionService::AddUpdateObserver(extensions::UpdateObserver* observer) { |
3105 update_observers_.AddObserver(observer); | 3109 update_observers_.AddObserver(observer); |
3106 } | 3110 } |
3107 | 3111 |
3108 void ExtensionService::RemoveUpdateObserver( | 3112 void ExtensionService::RemoveUpdateObserver( |
3109 extensions::UpdateObserver* observer) { | 3113 extensions::UpdateObserver* observer) { |
3110 update_observers_.RemoveObserver(observer); | 3114 update_observers_.RemoveObserver(observer); |
3111 } | 3115 } |
OLD | NEW |