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 // TODO(rickcam): Bug 73183: Add unit tests for image loading | 5 // TODO(rickcam): Bug 73183: Add unit tests for image loading |
6 | 6 |
7 #include "chrome/browser/background/background_application_list_model.h" | 7 #include "chrome/browser/background/background_application_list_model.h" |
8 | 8 |
9 #include <stddef.h> | 9 #include <stddef.h> |
10 | 10 |
11 #include <cstdlib> | 11 #include <cstdlib> |
12 #include <memory> | 12 #include <memory> |
13 #include <set> | 13 #include <set> |
14 #include <utility> | |
15 | 14 |
16 #include "base/command_line.h" | 15 #include "base/command_line.h" |
17 #include "base/files/file_path.h" | 16 #include "base/files/file_path.h" |
18 #include "base/memory/ptr_util.h" | |
19 #include "base/message_loop/message_loop.h" | 17 #include "base/message_loop/message_loop.h" |
20 #include "base/stl_util.h" | 18 #include "base/stl_util.h" |
21 #include "build/build_config.h" | 19 #include "build/build_config.h" |
22 #include "chrome/browser/extensions/extension_service.h" | 20 #include "chrome/browser/extensions/extension_service.h" |
23 #include "chrome/browser/extensions/extension_service_test_base.h" | 21 #include "chrome/browser/extensions/extension_service_test_base.h" |
24 #include "chrome/browser/extensions/permissions_updater.h" | 22 #include "chrome/browser/extensions/permissions_updater.h" |
25 #include "chrome/test/base/testing_profile.h" | 23 #include "chrome/test/base/testing_profile.h" |
26 #include "content/public/browser/notification_registrar.h" | 24 #include "content/public/browser/notification_registrar.h" |
27 #include "content/public/browser/notification_types.h" | 25 #include "content/public/browser/notification_types.h" |
28 #include "extensions/browser/extension_prefs.h" | 26 #include "extensions/browser/extension_prefs.h" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 | 80 |
83 // Returns a barebones test Extension object with the specified |name|. The | 81 // Returns a barebones test Extension object with the specified |name|. The |
84 // returned extension will include background permission if | 82 // returned extension will include background permission if |
85 // |background_permission| is true. | 83 // |background_permission| is true. |
86 static scoped_refptr<Extension> CreateExtension( | 84 static scoped_refptr<Extension> CreateExtension( |
87 const std::string& name, | 85 const std::string& name, |
88 bool background_permission) { | 86 bool background_permission) { |
89 base::DictionaryValue manifest; | 87 base::DictionaryValue manifest; |
90 manifest.SetString(extensions::manifest_keys::kVersion, "1.0.0.0"); | 88 manifest.SetString(extensions::manifest_keys::kVersion, "1.0.0.0"); |
91 manifest.SetString(extensions::manifest_keys::kName, name); | 89 manifest.SetString(extensions::manifest_keys::kName, name); |
92 auto permissions = base::MakeUnique<base::ListValue>(); | 90 base::ListValue* permissions = new base::ListValue(); |
| 91 manifest.Set(extensions::manifest_keys::kPermissions, permissions); |
93 if (background_permission) { | 92 if (background_permission) { |
94 permissions->AppendString("background"); | 93 permissions->AppendString("background"); |
95 } | 94 } |
96 manifest.Set(extensions::manifest_keys::kPermissions, std::move(permissions)); | |
97 | 95 |
98 std::string error; | 96 std::string error; |
99 scoped_refptr<Extension> extension; | 97 scoped_refptr<Extension> extension; |
100 | 98 |
101 extension = Extension::Create(bogus_file_pathname(name), | 99 extension = Extension::Create(bogus_file_pathname(name), |
102 extensions::Manifest::INTERNAL, manifest, | 100 extensions::Manifest::INTERNAL, manifest, |
103 Extension::NO_FLAGS, &error); | 101 Extension::NO_FLAGS, &error); |
104 | 102 |
105 // Cannot ASSERT_* here because that attempts an illegitimate return. | 103 // Cannot ASSERT_* here because that attempts an illegitimate return. |
106 // Cannot EXPECT_NE here because that assumes non-pointers unlike EXPECT_EQ | 104 // Cannot EXPECT_NE here because that assumes non-pointers unlike EXPECT_EQ |
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
457 break; | 455 break; |
458 case 2: | 456 case 2: |
459 TogglePermission(service(), &extensions, model(), &expected, &count); | 457 TogglePermission(service(), &extensions, model(), &expected, &count); |
460 break; | 458 break; |
461 default: | 459 default: |
462 NOTREACHED(); | 460 NOTREACHED(); |
463 break; | 461 break; |
464 } | 462 } |
465 } | 463 } |
466 } | 464 } |
OLD | NEW |