Chromium Code Reviews| 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/file_handlers/app_file_handler_util.h" | 36 #include "chrome/browser/extensions/api/file_handlers/app_file_handler_util.h" |
| 36 #include "chrome/browser/extensions/api/profile_keyed_api_factory.h" | 37 #include "chrome/browser/extensions/api/profile_keyed_api_factory.h" |
| 37 #include "chrome/browser/extensions/api/runtime/runtime_api.h" | 38 #include "chrome/browser/extensions/api/runtime/runtime_api.h" |
| 38 #include "chrome/browser/extensions/api/storage/settings_frontend.h" | 39 #include "chrome/browser/extensions/api/storage/settings_frontend.h" |
| 39 #include "chrome/browser/extensions/app_sync_data.h" | 40 #include "chrome/browser/extensions/app_sync_data.h" |
| (...skipping 2155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2195 // will record the permissions it recognized, not including "omnibox." | 2196 // will record the permissions it recognized, not including "omnibox." |
| 2196 // When upgrading to Chrome 10, "omnibox" will be recognized and Chrome | 2197 // When upgrading to Chrome 10, "omnibox" will be recognized and Chrome |
| 2197 // will disable the extension and prompt the user to approve the increase | 2198 // will disable the extension and prompt the user to approve the increase |
| 2198 // in privileges. The extension could then release a new version that | 2199 // in privileges. The extension could then release a new version that |
| 2199 // removes the "omnibox" permission. When the user upgrades, Chrome will | 2200 // removes the "omnibox" permission. When the user upgrades, Chrome will |
| 2200 // still remember that "omnibox" had been granted, so that if the | 2201 // still remember that "omnibox" had been granted, so that if the |
| 2201 // extension once again includes "omnibox" in an upgrade, the extension | 2202 // extension once again includes "omnibox" in an upgrade, the extension |
| 2202 // can upgrade without requiring this user's approval. | 2203 // can upgrade without requiring this user's approval. |
| 2203 int disable_reasons = extension_prefs_->GetDisableReasons(extension->id()); | 2204 int disable_reasons = extension_prefs_->GetDisableReasons(extension->id()); |
| 2204 | 2205 |
| 2205 bool is_default_app_install = | 2206 bool is_default_app_install = |
|
xiyuan
2013/05/23 03:05:39
nit: Give |is_default_app_install| a new name sinc
miket_OOO
2013/05/24 15:45:19
Yes.
zel
2013/05/24 22:10:05
Done.
| |
| 2206 (!is_extension_upgrade && extension->was_installed_by_default()); | 2207 (!is_extension_upgrade && extension->was_installed_by_default()) || |
| 2208 chrome::IsRunningInForcedAppMode(); | |
| 2207 // Silently grant all active permissions to default apps only on install. | 2209 // Silently grant all active permissions to default apps only on install. |
| 2208 // After install they should behave like other apps. | 2210 // After install they should behave like other apps. |
| 2211 // Silently grant all active permissions to apps install in kiosk mode on both | |
| 2212 // install and update. | |
| 2209 if (is_default_app_install) | 2213 if (is_default_app_install) |
| 2210 GrantPermissions(extension); | 2214 GrantPermissions(extension); |
| 2211 | 2215 |
| 2212 bool is_privilege_increase = false; | 2216 bool is_privilege_increase = false; |
| 2213 // We only need to compare the granted permissions to the current permissions | 2217 // We only need to compare the granted permissions to the current permissions |
| 2214 // if the extension is not allowed to silently increase its permissions. | 2218 // if the extension is not allowed to silently increase its permissions. |
| 2215 if (!extensions::PermissionsData::CanSilentlyIncreasePermissions(extension) && | 2219 if (!extensions::PermissionsData::CanSilentlyIncreasePermissions(extension) && |
| 2216 !is_default_app_install) { | 2220 !is_default_app_install) { |
| 2217 // Add all the recognized permissions if the granted permissions list | 2221 // Add all the recognized permissions if the granted permissions list |
| 2218 // hasn't been initialized yet. | 2222 // hasn't been initialized yet. |
| (...skipping 897 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3116 } | 3120 } |
| 3117 | 3121 |
| 3118 void ExtensionService::AddUpdateObserver(extensions::UpdateObserver* observer) { | 3122 void ExtensionService::AddUpdateObserver(extensions::UpdateObserver* observer) { |
| 3119 update_observers_.AddObserver(observer); | 3123 update_observers_.AddObserver(observer); |
| 3120 } | 3124 } |
| 3121 | 3125 |
| 3122 void ExtensionService::RemoveUpdateObserver( | 3126 void ExtensionService::RemoveUpdateObserver( |
| 3123 extensions::UpdateObserver* observer) { | 3127 extensions::UpdateObserver* observer) { |
| 3124 update_observers_.RemoveObserver(observer); | 3128 update_observers_.RemoveObserver(observer); |
| 3125 } | 3129 } |
| OLD | NEW |