| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/run_loop.h" | 6 #include "base/run_loop.h" |
| 7 #include "chrome/browser/extensions/activity_log/activity_log.h" | 7 #include "chrome/browser/extensions/activity_log/activity_log.h" |
| 8 #include "chrome/browser/extensions/api/activity_log_private/activity_log_privat
e_api.h" | 8 #include "chrome/browser/extensions/api/activity_log_private/activity_log_privat
e_api.h" |
| 9 #include "chrome/browser/extensions/extension_service.h" | 9 #include "chrome/browser/extensions/extension_service.h" |
| 10 #include "chrome/browser/extensions/test_extension_system.h" | 10 #include "chrome/browser/extensions/test_extension_system.h" |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 // Allow Activity Log to install extension tracker. | 142 // Allow Activity Log to install extension tracker. |
| 143 base::RunLoop().RunUntilIdle(); | 143 base::RunLoop().RunUntilIdle(); |
| 144 | 144 |
| 145 EXPECT_EQ(0, | 145 EXPECT_EQ(0, |
| 146 profile1->GetPrefs()->GetInteger(prefs::kWatchdogExtensionActive)); | 146 profile1->GetPrefs()->GetInteger(prefs::kWatchdogExtensionActive)); |
| 147 EXPECT_EQ(0, | 147 EXPECT_EQ(0, |
| 148 profile2->GetPrefs()->GetInteger(prefs::kWatchdogExtensionActive)); | 148 profile2->GetPrefs()->GetInteger(prefs::kWatchdogExtensionActive)); |
| 149 | 149 |
| 150 scoped_refptr<Extension> extension = | 150 scoped_refptr<Extension> extension = |
| 151 ExtensionBuilder() | 151 ExtensionBuilder() |
| 152 .SetManifest(std::move(DictionaryBuilder() | 152 .SetManifest(DictionaryBuilder() |
| 153 .Set("name", "Watchdog Extension ") | 153 .Set("name", "Watchdog Extension ") |
| 154 .Set("version", "1.0.0") | 154 .Set("version", "1.0.0") |
| 155 .Set("manifest_version", 2))) | 155 .Set("manifest_version", 2) |
| 156 .Build()) |
| 156 .SetID(kExtensionID) | 157 .SetID(kExtensionID) |
| 157 .Build(); | 158 .Build(); |
| 158 extension_service1->AddExtension(extension.get()); | 159 extension_service1->AddExtension(extension.get()); |
| 159 | 160 |
| 160 EXPECT_EQ(1, | 161 EXPECT_EQ(1, |
| 161 profile1->GetPrefs()->GetInteger(prefs::kWatchdogExtensionActive)); | 162 profile1->GetPrefs()->GetInteger(prefs::kWatchdogExtensionActive)); |
| 162 EXPECT_EQ(0, | 163 EXPECT_EQ(0, |
| 163 profile2->GetPrefs()->GetInteger(prefs::kWatchdogExtensionActive)); | 164 profile2->GetPrefs()->GetInteger(prefs::kWatchdogExtensionActive)); |
| 164 EXPECT_TRUE(activity_log1->IsWatchdogAppActive()); | 165 EXPECT_TRUE(activity_log1->IsWatchdogAppActive()); |
| 165 EXPECT_FALSE(activity_log2->IsWatchdogAppActive()); | 166 EXPECT_FALSE(activity_log2->IsWatchdogAppActive()); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 profile1->GetPrefs()->GetInteger(prefs::kWatchdogExtensionActive)); | 200 profile1->GetPrefs()->GetInteger(prefs::kWatchdogExtensionActive)); |
| 200 EXPECT_EQ(0, | 201 EXPECT_EQ(0, |
| 201 profile2->GetPrefs()->GetInteger(prefs::kWatchdogExtensionActive)); | 202 profile2->GetPrefs()->GetInteger(prefs::kWatchdogExtensionActive)); |
| 202 EXPECT_FALSE(activity_log1->IsWatchdogAppActive()); | 203 EXPECT_FALSE(activity_log1->IsWatchdogAppActive()); |
| 203 EXPECT_FALSE(activity_log2->IsWatchdogAppActive()); | 204 EXPECT_FALSE(activity_log2->IsWatchdogAppActive()); |
| 204 EXPECT_FALSE(activity_log1->IsDatabaseEnabled()); | 205 EXPECT_FALSE(activity_log1->IsDatabaseEnabled()); |
| 205 EXPECT_FALSE(activity_log2->IsDatabaseEnabled()); | 206 EXPECT_FALSE(activity_log2->IsDatabaseEnabled()); |
| 206 | 207 |
| 207 scoped_refptr<Extension> extension2 = | 208 scoped_refptr<Extension> extension2 = |
| 208 ExtensionBuilder() | 209 ExtensionBuilder() |
| 209 .SetManifest(std::move(DictionaryBuilder() | 210 .SetManifest(DictionaryBuilder() |
| 210 .Set("name", "Watchdog Extension ") | 211 .Set("name", "Watchdog Extension ") |
| 211 .Set("version", "1.0.0") | 212 .Set("version", "1.0.0") |
| 212 .Set("manifest_version", 2))) | 213 .Set("manifest_version", 2) |
| 214 .Build()) |
| 213 .SetID("fpofdchlamddhnajleknffcbmnjfahpg") | 215 .SetID("fpofdchlamddhnajleknffcbmnjfahpg") |
| 214 .Build(); | 216 .Build(); |
| 215 extension_service1->AddExtension(extension.get()); | 217 extension_service1->AddExtension(extension.get()); |
| 216 extension_service1->AddExtension(extension2.get()); | 218 extension_service1->AddExtension(extension2.get()); |
| 217 EXPECT_EQ(2, | 219 EXPECT_EQ(2, |
| 218 profile1->GetPrefs()->GetInteger(prefs::kWatchdogExtensionActive)); | 220 profile1->GetPrefs()->GetInteger(prefs::kWatchdogExtensionActive)); |
| 219 EXPECT_TRUE(activity_log1->IsDatabaseEnabled()); | 221 EXPECT_TRUE(activity_log1->IsDatabaseEnabled()); |
| 220 extension_service1->DisableExtension(kExtensionID, | 222 extension_service1->DisableExtension(kExtensionID, |
| 221 Extension::DISABLE_USER_ACTION); | 223 Extension::DISABLE_USER_ACTION); |
| 222 extension_service1->DisableExtension("fpofdchlamddhnajleknffcbmnjfahpg", | 224 extension_service1->DisableExtension("fpofdchlamddhnajleknffcbmnjfahpg", |
| (...skipping 25 matching lines...) Expand all Loading... |
| 248 base::RunLoop().RunUntilIdle(); | 250 base::RunLoop().RunUntilIdle(); |
| 249 | 251 |
| 250 EXPECT_TRUE(activity_log->IsDatabaseEnabled()); | 252 EXPECT_TRUE(activity_log->IsDatabaseEnabled()); |
| 251 EXPECT_EQ(0, | 253 EXPECT_EQ(0, |
| 252 profile->GetPrefs()->GetInteger(prefs::kWatchdogExtensionActive)); | 254 profile->GetPrefs()->GetInteger(prefs::kWatchdogExtensionActive)); |
| 253 EXPECT_FALSE(activity_log->IsWatchdogAppActive()); | 255 EXPECT_FALSE(activity_log->IsWatchdogAppActive()); |
| 254 | 256 |
| 255 // Enable the extension. | 257 // Enable the extension. |
| 256 scoped_refptr<Extension> extension = | 258 scoped_refptr<Extension> extension = |
| 257 ExtensionBuilder() | 259 ExtensionBuilder() |
| 258 .SetManifest(std::move(DictionaryBuilder() | 260 .SetManifest(DictionaryBuilder() |
| 259 .Set("name", "Watchdog Extension ") | 261 .Set("name", "Watchdog Extension ") |
| 260 .Set("version", "1.0.0") | 262 .Set("version", "1.0.0") |
| 261 .Set("manifest_version", 2))) | 263 .Set("manifest_version", 2) |
| 264 .Build()) |
| 262 .SetID(kExtensionID) | 265 .SetID(kExtensionID) |
| 263 .Build(); | 266 .Build(); |
| 264 extension_service->AddExtension(extension.get()); | 267 extension_service->AddExtension(extension.get()); |
| 265 | 268 |
| 266 EXPECT_TRUE(activity_log->IsDatabaseEnabled()); | 269 EXPECT_TRUE(activity_log->IsDatabaseEnabled()); |
| 267 EXPECT_EQ(1, | 270 EXPECT_EQ(1, |
| 268 profile->GetPrefs()->GetInteger(prefs::kWatchdogExtensionActive)); | 271 profile->GetPrefs()->GetInteger(prefs::kWatchdogExtensionActive)); |
| 269 EXPECT_TRUE(activity_log->IsWatchdogAppActive()); | 272 EXPECT_TRUE(activity_log->IsWatchdogAppActive()); |
| 270 | 273 |
| 271 extension_service->UninstallExtension( | 274 extension_service->UninstallExtension( |
| 272 kExtensionID, | 275 kExtensionID, |
| 273 extensions::UNINSTALL_REASON_FOR_TESTING, | 276 extensions::UNINSTALL_REASON_FOR_TESTING, |
| 274 base::Bind(&base::DoNothing), | 277 base::Bind(&base::DoNothing), |
| 275 NULL); | 278 NULL); |
| 276 | 279 |
| 277 EXPECT_TRUE(activity_log->IsDatabaseEnabled()); | 280 EXPECT_TRUE(activity_log->IsDatabaseEnabled()); |
| 278 EXPECT_EQ(0, | 281 EXPECT_EQ(0, |
| 279 profile->GetPrefs()->GetInteger(prefs::kWatchdogExtensionActive)); | 282 profile->GetPrefs()->GetInteger(prefs::kWatchdogExtensionActive)); |
| 280 EXPECT_FALSE(activity_log->IsWatchdogAppActive()); | 283 EXPECT_FALSE(activity_log->IsWatchdogAppActive()); |
| 281 | 284 |
| 282 // Cleanup. | 285 // Cleanup. |
| 283 *base::CommandLine::ForCurrentProcess() = saved_cmdline_; | 286 *base::CommandLine::ForCurrentProcess() = saved_cmdline_; |
| 284 } | 287 } |
| 285 | 288 |
| 286 } // namespace extensions | 289 } // namespace extensions |
| OLD | NEW |