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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 | 75 |
74 // Returns a barebones test Extension object with the specified |name|. The | 76 // Returns a barebones test Extension object with the specified |name|. The |
75 // returned extension will include background permission if | 77 // returned extension will include background permission if |
76 // |background_permission| is true. | 78 // |background_permission| is true. |
77 static scoped_refptr<Extension> CreateExtension( | 79 static scoped_refptr<Extension> CreateExtension( |
78 const std::string& name, | 80 const std::string& name, |
79 bool background_permission) { | 81 bool background_permission) { |
80 base::DictionaryValue manifest; | 82 base::DictionaryValue manifest; |
81 manifest.SetString(extensions::manifest_keys::kVersion, "1.0.0.0"); | 83 manifest.SetString(extensions::manifest_keys::kVersion, "1.0.0.0"); |
82 manifest.SetString(extensions::manifest_keys::kName, name); | 84 manifest.SetString(extensions::manifest_keys::kName, name); |
83 base::ListValue* permissions = new base::ListValue(); | 85 auto permissions = base::MakeUnique<base::ListValue>(); |
84 manifest.Set(extensions::manifest_keys::kPermissions, permissions); | |
85 if (background_permission) { | 86 if (background_permission) { |
86 permissions->AppendString("background"); | 87 permissions->AppendString("background"); |
87 } | 88 } |
| 89 manifest.Set(extensions::manifest_keys::kPermissions, std::move(permissions)); |
88 | 90 |
89 std::string error; | 91 std::string error; |
90 scoped_refptr<Extension> extension; | 92 scoped_refptr<Extension> extension; |
91 | 93 |
92 extension = Extension::Create(bogus_file_pathname(name), | 94 extension = Extension::Create(bogus_file_pathname(name), |
93 extensions::Manifest::INTERNAL, manifest, | 95 extensions::Manifest::INTERNAL, manifest, |
94 Extension::NO_FLAGS, &error); | 96 Extension::NO_FLAGS, &error); |
95 | 97 |
96 // Cannot ASSERT_* here because that attempts an illegitimate return. | 98 // Cannot ASSERT_* here because that attempts an illegitimate return. |
97 // Cannot EXPECT_NE here because that assumes non-pointers unlike EXPECT_EQ | 99 // Cannot EXPECT_NE here because that assumes non-pointers unlike EXPECT_EQ |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 case 2: | 394 case 2: |
393 TogglePermission(service(), &extensions, model.get(), &expected, | 395 TogglePermission(service(), &extensions, model.get(), &expected, |
394 &count); | 396 &count); |
395 break; | 397 break; |
396 default: | 398 default: |
397 NOTREACHED(); | 399 NOTREACHED(); |
398 break; | 400 break; |
399 } | 401 } |
400 } | 402 } |
401 } | 403 } |
OLD | NEW |