OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <string> | 5 #include <string> |
6 #include <utility> | 6 #include <utility> |
7 | 7 |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 // Bar is an app with name Bar and should appear first. | 188 // Bar is an app with name Bar and should appear first. |
189 const std::string kBarId = "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"; | 189 const std::string kBarId = "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"; |
190 | 190 |
191 // Baz is an app with name Baz and should not appear in the notifier list | 191 // Baz is an app with name Baz and should not appear in the notifier list |
192 // since it doesn't have notifications permission. | 192 // since it doesn't have notifications permission. |
193 const std::string kBazId = "cccccccccccccccccccccccccccccccc"; | 193 const std::string kBazId = "cccccccccccccccccccccccccccccccc"; |
194 | 194 |
195 // Baf is a hosted app which should not appear in the notifier list. | 195 // Baf is a hosted app which should not appear in the notifier list. |
196 const std::string kBafId = "dddddddddddddddddddddddddddddddd"; | 196 const std::string kBafId = "dddddddddddddddddddddddddddddddd"; |
197 | 197 |
198 foo_app.SetManifest(std::move( | 198 foo_app.SetManifest( |
199 extensions::DictionaryBuilder() | 199 extensions::DictionaryBuilder() |
200 .Set("name", "Foo") | 200 .Set("name", "Foo") |
201 .Set("version", "1.0.0") | 201 .Set("version", "1.0.0") |
202 .Set("manifest_version", 2) | 202 .Set("manifest_version", 2) |
203 .Set("app", | 203 .Set("app", extensions::DictionaryBuilder() |
204 std::move(extensions::DictionaryBuilder().Set( | 204 .Set("background", |
205 "background", | 205 extensions::DictionaryBuilder() |
206 std::move(extensions::DictionaryBuilder().Set( | 206 .Set("scripts", extensions::ListBuilder() |
207 "scripts", std::move(extensions::ListBuilder().Append( | 207 .Append("background.js") |
208 "background.js"))))))) | 208 .Build()) |
| 209 .Build()) |
| 210 .Build()) |
209 .Set("permissions", | 211 .Set("permissions", |
210 std::move(extensions::ListBuilder().Append("notifications"))))); | 212 extensions::ListBuilder().Append("notifications").Build()) |
| 213 .Build()); |
211 foo_app.SetID(kFooId); | 214 foo_app.SetID(kFooId); |
212 extension_service->AddExtension(foo_app.Build().get()); | 215 extension_service->AddExtension(foo_app.Build().get()); |
213 | 216 |
214 extensions::ExtensionBuilder bar_app; | 217 extensions::ExtensionBuilder bar_app; |
215 bar_app.SetManifest(std::move( | 218 bar_app.SetManifest( |
216 extensions::DictionaryBuilder() | 219 extensions::DictionaryBuilder() |
217 .Set("name", "Bar") | 220 .Set("name", "Bar") |
218 .Set("version", "1.0.0") | 221 .Set("version", "1.0.0") |
219 .Set("manifest_version", 2) | 222 .Set("manifest_version", 2) |
220 .Set("app", | 223 .Set("app", extensions::DictionaryBuilder() |
221 std::move(extensions::DictionaryBuilder().Set( | 224 .Set("background", |
222 "background", | 225 extensions::DictionaryBuilder() |
223 std::move(extensions::DictionaryBuilder().Set( | 226 .Set("scripts", extensions::ListBuilder() |
224 "scripts", std::move(extensions::ListBuilder().Append( | 227 .Append("background.js") |
225 "background.js"))))))) | 228 .Build()) |
| 229 .Build()) |
| 230 .Build()) |
226 .Set("permissions", | 231 .Set("permissions", |
227 std::move(extensions::ListBuilder().Append("notifications"))))); | 232 extensions::ListBuilder().Append("notifications").Build()) |
| 233 .Build()); |
228 bar_app.SetID(kBarId); | 234 bar_app.SetID(kBarId); |
229 extension_service->AddExtension(bar_app.Build().get()); | 235 extension_service->AddExtension(bar_app.Build().get()); |
230 | 236 |
231 extensions::ExtensionBuilder baz_app; | 237 extensions::ExtensionBuilder baz_app; |
232 baz_app.SetManifest(std::move( | 238 baz_app.SetManifest( |
233 extensions::DictionaryBuilder() | 239 extensions::DictionaryBuilder() |
234 .Set("name", "baz") | 240 .Set("name", "baz") |
235 .Set("version", "1.0.0") | 241 .Set("version", "1.0.0") |
236 .Set("manifest_version", 2) | 242 .Set("manifest_version", 2) |
237 .Set("app", | 243 .Set("app", extensions::DictionaryBuilder() |
238 std::move(extensions::DictionaryBuilder().Set( | 244 .Set("background", |
239 "background", | 245 extensions::DictionaryBuilder() |
240 std::move(extensions::DictionaryBuilder().Set( | 246 .Set("scripts", extensions::ListBuilder() |
241 "scripts", std::move(extensions::ListBuilder().Append( | 247 .Append("background.js") |
242 "background.js"))))))))); | 248 .Build()) |
| 249 .Build()) |
| 250 .Build()) |
| 251 .Build()); |
243 baz_app.SetID(kBazId); | 252 baz_app.SetID(kBazId); |
244 extension_service->AddExtension(baz_app.Build().get()); | 253 extension_service->AddExtension(baz_app.Build().get()); |
245 | 254 |
246 extensions::ExtensionBuilder baf_app; | 255 extensions::ExtensionBuilder baf_app; |
247 baf_app.SetManifest(std::move( | 256 baf_app.SetManifest( |
248 extensions::DictionaryBuilder() | 257 extensions::DictionaryBuilder() |
249 .Set("name", "baf") | 258 .Set("name", "baf") |
250 .Set("version", "1.0.0") | 259 .Set("version", "1.0.0") |
251 .Set("manifest_version", 2) | 260 .Set("manifest_version", 2) |
252 .Set("app", | 261 .Set("app", |
253 std::move(extensions::DictionaryBuilder().Set( | 262 extensions::DictionaryBuilder() |
254 "urls", | 263 .Set("urls", extensions::ListBuilder() |
255 std::move(extensions::ListBuilder().Append( | 264 .Append("http://localhost/extensions/" |
256 "http://localhost/extensions/hosted_app/main.html"))))) | 265 "hosted_app/main.html") |
257 .Set( | 266 .Build()) |
258 "launch", | 267 .Build()) |
259 std::move(extensions::DictionaryBuilder().Set( | 268 .Set("launch", |
260 "urls", | 269 extensions::DictionaryBuilder() |
261 std::move(extensions::ListBuilder().Append( | 270 .Set("urls", extensions::ListBuilder() |
262 "http://localhost/extensions/hosted_app/main.html"))))))); | 271 .Append("http://localhost/extensions/" |
| 272 "hosted_app/main.html") |
| 273 .Build()) |
| 274 .Build()) |
| 275 .Build()); |
263 | 276 |
264 baf_app.SetID(kBafId); | 277 baf_app.SetID(kBafId); |
265 extension_service->AddExtension(baf_app.Build().get()); | 278 extension_service->AddExtension(baf_app.Build().get()); |
266 CreateController(); | 279 CreateController(); |
267 | 280 |
268 std::vector<message_center::Notifier*> notifiers; | 281 std::vector<message_center::Notifier*> notifiers; |
269 controller()->GetNotifierList(¬ifiers); | 282 controller()->GetNotifierList(¬ifiers); |
270 | 283 |
271 #if !defined(OS_CHROMEOS) | 284 #if !defined(OS_CHROMEOS) |
272 EXPECT_EQ(2u, notifiers.size()); | 285 EXPECT_EQ(2u, notifiers.size()); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 // (5) Enable the permission when the default is blocked (expected to set). | 346 // (5) Enable the permission when the default is blocked (expected to set). |
334 controller()->SetNotifierEnabled(disabled_notifier, true); | 347 controller()->SetNotifierEnabled(disabled_notifier, true); |
335 EXPECT_EQ(CONTENT_SETTING_ALLOW, | 348 EXPECT_EQ(CONTENT_SETTING_ALLOW, |
336 DesktopNotificationProfileUtil::GetContentSetting(profile, origin)); | 349 DesktopNotificationProfileUtil::GetContentSetting(profile, origin)); |
337 | 350 |
338 // (6) Disable the permission when the default is blocked (expected to clear). | 351 // (6) Disable the permission when the default is blocked (expected to clear). |
339 controller()->SetNotifierEnabled(enabled_notifier, false); | 352 controller()->SetNotifierEnabled(enabled_notifier, false); |
340 EXPECT_EQ(CONTENT_SETTING_BLOCK, | 353 EXPECT_EQ(CONTENT_SETTING_BLOCK, |
341 DesktopNotificationProfileUtil::GetContentSetting(profile, origin)); | 354 DesktopNotificationProfileUtil::GetContentSetting(profile, origin)); |
342 } | 355 } |
OLD | NEW |