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 "base/file_path.h" | 5 #include "base/file_path.h" |
6 #include "base/scoped_temp_dir.h" | 6 #include "base/scoped_temp_dir.h" |
7 #include "chrome/app/chrome_command_ids.h" | 7 #include "chrome/app/chrome_command_ids.h" |
8 #include "chrome/browser/extensions/extension_browsertest.h" | 8 #include "chrome/browser/extensions/extension_browsertest.h" |
9 #include "chrome/browser/extensions/extension_prefs.h" | 9 #include "chrome/browser/extensions/extension_prefs.h" |
10 #include "chrome/browser/extensions/extension_service.h" | 10 #include "chrome/browser/extensions/extension_service.h" |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 ASSERT_FALSE(GetExtensionDisabledGlobalError()); | 125 ASSERT_FALSE(GetExtensionDisabledGlobalError()); |
126 } | 126 } |
127 | 127 |
128 // Test that no error appears if the disable reason is unknown | 128 // Test that no error appears if the disable reason is unknown |
129 // (but probably was by the user). | 129 // (but probably was by the user). |
130 IN_PROC_BROWSER_TEST_F(ExtensionDisabledGlobalErrorTest, | 130 IN_PROC_BROWSER_TEST_F(ExtensionDisabledGlobalErrorTest, |
131 UnknownReasonSamePermissions) { | 131 UnknownReasonSamePermissions) { |
132 const Extension* extension = InstallIncreasingPermissionExtensionV1(); | 132 const Extension* extension = InstallIncreasingPermissionExtensionV1(); |
133 DisableExtension(extension->id()); | 133 DisableExtension(extension->id()); |
134 // Clear disable reason to simulate legacy disables. | 134 // Clear disable reason to simulate legacy disables. |
135 service_->extension_prefs()->RemoveDisableReason(extension->id()); | 135 service_->extension_prefs()->ClearDisableReasons(extension->id()); |
136 // Upgrade to version 2. Infer from version 1 having the same permissions | 136 // Upgrade to version 2. Infer from version 1 having the same permissions |
137 // granted by the user that it was disabled by the user. | 137 // granted by the user that it was disabled by the user. |
138 extension = UpdateIncreasingPermissionExtension(extension, path_v2_, 0); | 138 extension = UpdateIncreasingPermissionExtension(extension, path_v2_, 0); |
139 ASSERT_TRUE(extension); | 139 ASSERT_TRUE(extension); |
140 ASSERT_FALSE(GetExtensionDisabledGlobalError()); | 140 ASSERT_FALSE(GetExtensionDisabledGlobalError()); |
141 } | 141 } |
142 | 142 |
143 // Test that an error appears if the disable reason is unknown | 143 // Test that an error appears if the disable reason is unknown |
144 // (but probably was for increased permissions). | 144 // (but probably was for increased permissions). |
145 IN_PROC_BROWSER_TEST_F(ExtensionDisabledGlobalErrorTest, | 145 IN_PROC_BROWSER_TEST_F(ExtensionDisabledGlobalErrorTest, |
146 UnknownReasonHigherPermissions) { | 146 UnknownReasonHigherPermissions) { |
147 const Extension* extension = InstallAndUpdateIncreasingPermissionsExtension(); | 147 const Extension* extension = InstallAndUpdateIncreasingPermissionsExtension(); |
148 // Clear disable reason to simulate legacy disables. | 148 // Clear disable reason to simulate legacy disables. |
149 service_->extension_prefs()->RemoveDisableReason(extension->id()); | 149 service_->extension_prefs()->ClearDisableReasons(extension->id()); |
150 // We now have version 2 but only accepted permissions for version 1. | 150 // We now have version 2 but only accepted permissions for version 1. |
151 GlobalError* error = GetExtensionDisabledGlobalError(); | 151 GlobalError* error = GetExtensionDisabledGlobalError(); |
152 ASSERT_TRUE(error); | 152 ASSERT_TRUE(error); |
153 // Also, remove the upgrade error for version 2. | 153 // Also, remove the upgrade error for version 2. |
154 GlobalErrorServiceFactory::GetForProfile(browser()->profile())-> | 154 GlobalErrorServiceFactory::GetForProfile(browser()->profile())-> |
155 RemoveGlobalError(error); | 155 RemoveGlobalError(error); |
156 delete error; | 156 delete error; |
157 // Upgrade to version 3, with even higher permissions. Infer from | 157 // Upgrade to version 3, with even higher permissions. Infer from |
158 // version 2 having higher-than-granted permissions that it was disabled | 158 // version 2 having higher-than-granted permissions that it was disabled |
159 // for permissions increase. | 159 // for permissions increase. |
160 extension = UpdateIncreasingPermissionExtension(extension, path_v3_, 0); | 160 extension = UpdateIncreasingPermissionExtension(extension, path_v3_, 0); |
161 ASSERT_TRUE(extension); | 161 ASSERT_TRUE(extension); |
162 ASSERT_TRUE(GetExtensionDisabledGlobalError()); | 162 ASSERT_TRUE(GetExtensionDisabledGlobalError()); |
163 } | 163 } |
OLD | NEW |