OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "extensions/browser/image_loader.h" | 5 #include "extensions/browser/image_loader.h" |
6 | 6 |
7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
8 #include "base/json/json_file_value_serializer.h" | 8 #include "base/json/json_file_value_serializer.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
| 12 #include "chrome/browser/chrome_notification_types.h" |
12 #include "chrome/common/chrome_paths.h" | 13 #include "chrome/common/chrome_paths.h" |
| 14 #include "content/public/browser/notification_service.h" |
13 #include "content/public/test/test_browser_thread.h" | 15 #include "content/public/test/test_browser_thread.h" |
14 #include "extensions/browser/component_extension_resource_manager.h" | 16 #include "extensions/browser/component_extension_resource_manager.h" |
15 #include "extensions/browser/extension_registry.h" | |
16 #include "extensions/browser/extensions_browser_client.h" | 17 #include "extensions/browser/extensions_browser_client.h" |
17 #include "extensions/browser/extensions_test_browser_context.h" | |
18 #include "extensions/common/constants.h" | 18 #include "extensions/common/constants.h" |
19 #include "extensions/common/extension.h" | 19 #include "extensions/common/extension.h" |
20 #include "extensions/common/extension_icon_set.h" | 20 #include "extensions/common/extension_icon_set.h" |
21 #include "extensions/common/extension_resource.h" | 21 #include "extensions/common/extension_resource.h" |
22 #include "extensions/common/manifest.h" | 22 #include "extensions/common/manifest.h" |
23 #include "extensions/common/manifest_handlers/icons_handler.h" | 23 #include "extensions/common/manifest_handlers/icons_handler.h" |
24 #include "testing/gtest/include/gtest/gtest.h" | 24 #include "testing/gtest/include/gtest/gtest.h" |
25 #include "third_party/skia/include/core/SkBitmap.h" | 25 #include "third_party/skia/include/core/SkBitmap.h" |
26 #include "ui/gfx/image/image.h" | 26 #include "ui/gfx/image/image.h" |
27 #include "ui/gfx/image/image_family.h" | 27 #include "ui/gfx/image/image_family.h" |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 sizes.insert(extension_misc::EXTENSION_ICON_SMALLISH); | 178 sizes.insert(extension_misc::EXTENSION_ICON_SMALLISH); |
179 loader.LoadImageAsync(extension.get(), | 179 loader.LoadImageAsync(extension.get(), |
180 image_resource, | 180 image_resource, |
181 max_size, | 181 max_size, |
182 base::Bind(&ImageLoaderTest::OnImageLoaded, | 182 base::Bind(&ImageLoaderTest::OnImageLoaded, |
183 base::Unretained(this))); | 183 base::Unretained(this))); |
184 | 184 |
185 // The image isn't cached, so we should not have received notification. | 185 // The image isn't cached, so we should not have received notification. |
186 EXPECT_EQ(0, image_loaded_count()); | 186 EXPECT_EQ(0, image_loaded_count()); |
187 | 187 |
188 extensions::ExtensionsTestBrowserContext browser_context; | |
189 // Send out notification the extension was uninstalled. | 188 // Send out notification the extension was uninstalled. |
190 extensions::ExtensionRegistry::Get(&browser_context)->TriggerOnUnloaded( | 189 UnloadedExtensionInfo details(extension.get(), |
191 extension.get(), UnloadedExtensionInfo::REASON_UNINSTALL); | 190 UnloadedExtensionInfo::REASON_UNINSTALL); |
| 191 content::NotificationService::current()->Notify( |
| 192 chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED, |
| 193 content::NotificationService::AllSources(), |
| 194 content::Details<UnloadedExtensionInfo>(&details)); |
192 | 195 |
193 // Chuck the extension, that way if anyone tries to access it we should crash | 196 // Chuck the extension, that way if anyone tries to access it we should crash |
194 // or get valgrind errors. | 197 // or get valgrind errors. |
195 extension = NULL; | 198 extension = NULL; |
196 | 199 |
197 WaitForImageLoad(); | 200 WaitForImageLoad(); |
198 | 201 |
199 // Even though we deleted the extension, we should still get the image. | 202 // Even though we deleted the extension, we should still get the image. |
200 // We should still have gotten the image. | 203 // We should still have gotten the image. |
201 EXPECT_EQ(1, image_loaded_count()); | 204 EXPECT_EQ(1, image_loaded_count()); |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
339 | 342 |
340 #if defined(OS_CHROMEOS) | 343 #if defined(OS_CHROMEOS) |
341 int resource_id; | 344 int resource_id; |
342 ASSERT_TRUE(resource_manager->IsComponentExtensionResource( | 345 ASSERT_TRUE(resource_manager->IsComponentExtensionResource( |
343 extension->path(), | 346 extension->path(), |
344 resource.relative_path(), | 347 resource.relative_path(), |
345 &resource_id)); | 348 &resource_id)); |
346 ASSERT_EQ(IDR_FILE_MANAGER_ICON_16, resource_id); | 349 ASSERT_EQ(IDR_FILE_MANAGER_ICON_16, resource_id); |
347 #endif | 350 #endif |
348 } | 351 } |
OLD | NEW |