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 <cstdlib> | 7 #include <cstdlib> |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "chrome/browser/background/background_application_list_model.h" | 10 #include "chrome/browser/background/background_application_list_model.h" |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 // Returns a barebones test Extension object with the specified |name|. The | 66 // Returns a barebones test Extension object with the specified |name|. The |
67 // returned extension will include background permission iff | 67 // returned extension will include background permission iff |
68 // |background_permission| is true and pushMessaging permission if requested | 68 // |background_permission| is true and pushMessaging permission if requested |
69 // by |push_messaging| value. Also the extension may have a specific id set | 69 // by |push_messaging| value. Also the extension may have a specific id set |
70 // to test the case when it has a pushMessaging permission but is not | 70 // to test the case when it has a pushMessaging permission but is not |
71 // considered a background app based on a whitelist. | 71 // considered a background app based on a whitelist. |
72 static scoped_refptr<Extension> CreateExtensionBase( | 72 static scoped_refptr<Extension> CreateExtensionBase( |
73 const std::string& name, | 73 const std::string& name, |
74 bool background_permission, | 74 bool background_permission, |
75 PushMessagingOption push_messaging) { | 75 PushMessagingOption push_messaging) { |
76 DictionaryValue manifest; | 76 base::DictionaryValue manifest; |
77 manifest.SetString(extensions::manifest_keys::kVersion, "1.0.0.0"); | 77 manifest.SetString(extensions::manifest_keys::kVersion, "1.0.0.0"); |
78 manifest.SetString(extensions::manifest_keys::kName, name); | 78 manifest.SetString(extensions::manifest_keys::kName, name); |
79 ListValue* permissions = new ListValue(); | 79 base::ListValue* permissions = new base::ListValue(); |
80 manifest.Set(extensions::manifest_keys::kPermissions, permissions); | 80 manifest.Set(extensions::manifest_keys::kPermissions, permissions); |
81 if (background_permission) { | 81 if (background_permission) { |
82 permissions->Append(Value::CreateStringValue("background")); | 82 permissions->Append(base::Value::CreateStringValue("background")); |
83 } | 83 } |
84 if (push_messaging == PUSH_MESSAGING_PERMISSION || | 84 if (push_messaging == PUSH_MESSAGING_PERMISSION || |
85 push_messaging == PUSH_MESSAGING_BUT_NOT_BACKGROUND) { | 85 push_messaging == PUSH_MESSAGING_BUT_NOT_BACKGROUND) { |
86 permissions->Append(Value::CreateStringValue("pushMessaging")); | 86 permissions->Append(base::Value::CreateStringValue("pushMessaging")); |
87 } | 87 } |
88 | 88 |
89 std::string error; | 89 std::string error; |
90 scoped_refptr<Extension> extension; | 90 scoped_refptr<Extension> extension; |
91 | 91 |
92 // There is a whitelist for extensions that have pushMessaging permission but | 92 // There is a whitelist for extensions that have pushMessaging permission but |
93 // are not considered a background app. Create a test extension with a known | 93 // are not considered a background app. Create a test extension with a known |
94 // test id if needed. | 94 // test id if needed. |
95 if (push_messaging == PUSH_MESSAGING_BUT_NOT_BACKGROUND) { | 95 if (push_messaging == PUSH_MESSAGING_BUT_NOT_BACKGROUND) { |
96 extension = Extension::Create( | 96 extension = Extension::Create( |
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
483 break; | 483 break; |
484 case 2: | 484 case 2: |
485 TogglePermission(service, &extensions, model.get(), &expected, &count); | 485 TogglePermission(service, &extensions, model.get(), &expected, &count); |
486 break; | 486 break; |
487 default: | 487 default: |
488 NOTREACHED(); | 488 NOTREACHED(); |
489 break; | 489 break; |
490 } | 490 } |
491 } | 491 } |
492 } | 492 } |
OLD | NEW |