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