| 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 #include "chrome/browser/extensions/api/file_system/file_system_api.h" | 5 #include "chrome/browser/extensions/api/file_system/file_system_api.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| (...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 TEST_F(FileSystemApiConsentProviderTest, ForKioskApps) { | 359 TEST_F(FileSystemApiConsentProviderTest, ForKioskApps) { |
| 360 // Non-component apps in auto-launch kiosk mode will be granted access | 360 // Non-component apps in auto-launch kiosk mode will be granted access |
| 361 // instantly without asking for user consent, but with a notification. | 361 // instantly without asking for user consent, but with a notification. |
| 362 { | 362 { |
| 363 scoped_refptr<Extension> auto_launch_kiosk_app( | 363 scoped_refptr<Extension> auto_launch_kiosk_app( |
| 364 test_util::BuildApp(ExtensionBuilder().Pass()) | 364 test_util::BuildApp(ExtensionBuilder().Pass()) |
| 365 .MergeManifest(DictionaryBuilder() | 365 .MergeManifest(DictionaryBuilder() |
| 366 .SetBoolean("kiosk_enabled", true) | 366 .SetBoolean("kiosk_enabled", true) |
| 367 .SetBoolean("kiosk_only", true)) | 367 .SetBoolean("kiosk_only", true)) |
| 368 .Build()); | 368 .Build()); |
| 369 user_manager_->AddKioskAppUser(auto_launch_kiosk_app->id()); | 369 user_manager_->AddKioskAppUser( |
| 370 user_manager_->LoginUser(auto_launch_kiosk_app->id()); | 370 AccountId::FromUserEmail(auto_launch_kiosk_app->id())); |
| 371 user_manager_->LoginUser( |
| 372 AccountId::FromUserEmail(auto_launch_kiosk_app->id())); |
| 371 | 373 |
| 372 TestingConsentProviderDelegate delegate; | 374 TestingConsentProviderDelegate delegate; |
| 373 delegate.SetIsAutoLaunched(true); | 375 delegate.SetIsAutoLaunched(true); |
| 374 ConsentProvider provider(&delegate); | 376 ConsentProvider provider(&delegate); |
| 375 EXPECT_TRUE(provider.IsGrantable(*auto_launch_kiosk_app)); | 377 EXPECT_TRUE(provider.IsGrantable(*auto_launch_kiosk_app)); |
| 376 | 378 |
| 377 ConsentProvider::Consent result = ConsentProvider::CONSENT_IMPOSSIBLE; | 379 ConsentProvider::Consent result = ConsentProvider::CONSENT_IMPOSSIBLE; |
| 378 provider.RequestConsent(*auto_launch_kiosk_app.get(), volume_, | 380 provider.RequestConsent(*auto_launch_kiosk_app.get(), volume_, |
| 379 true /* writable */, | 381 true /* writable */, |
| 380 base::Bind(&OnConsentReceived, &result)); | 382 base::Bind(&OnConsentReceived, &result)); |
| 381 base::RunLoop().RunUntilIdle(); | 383 base::RunLoop().RunUntilIdle(); |
| 382 | 384 |
| 383 EXPECT_EQ(0, delegate.show_dialog_counter()); | 385 EXPECT_EQ(0, delegate.show_dialog_counter()); |
| 384 EXPECT_EQ(1, delegate.show_notification_counter()); | 386 EXPECT_EQ(1, delegate.show_notification_counter()); |
| 385 EXPECT_EQ(ConsentProvider::CONSENT_GRANTED, result); | 387 EXPECT_EQ(ConsentProvider::CONSENT_GRANTED, result); |
| 386 } | 388 } |
| 387 | 389 |
| 388 // Non-component apps in manual-launch kiosk mode will be granted access after | 390 // Non-component apps in manual-launch kiosk mode will be granted access after |
| 389 // receiving approval from the user. | 391 // receiving approval from the user. |
| 390 scoped_refptr<Extension> manual_launch_kiosk_app( | 392 scoped_refptr<Extension> manual_launch_kiosk_app( |
| 391 test_util::BuildApp(ExtensionBuilder().Pass()) | 393 test_util::BuildApp(ExtensionBuilder().Pass()) |
| 392 .MergeManifest(DictionaryBuilder() | 394 .MergeManifest(DictionaryBuilder() |
| 393 .SetBoolean("kiosk_enabled", true) | 395 .SetBoolean("kiosk_enabled", true) |
| 394 .SetBoolean("kiosk_only", true)) | 396 .SetBoolean("kiosk_only", true)) |
| 395 .Build()); | 397 .Build()); |
| 396 user_manager_->KioskAppLoggedIn(manual_launch_kiosk_app->id()); | 398 user_manager_->KioskAppLoggedIn( |
| 399 AccountId::FromUserEmail(manual_launch_kiosk_app->id())); |
| 397 { | 400 { |
| 398 TestingConsentProviderDelegate delegate; | 401 TestingConsentProviderDelegate delegate; |
| 399 delegate.SetDialogButton(ui::DIALOG_BUTTON_OK); | 402 delegate.SetDialogButton(ui::DIALOG_BUTTON_OK); |
| 400 ConsentProvider provider(&delegate); | 403 ConsentProvider provider(&delegate); |
| 401 EXPECT_TRUE(provider.IsGrantable(*manual_launch_kiosk_app)); | 404 EXPECT_TRUE(provider.IsGrantable(*manual_launch_kiosk_app)); |
| 402 | 405 |
| 403 ConsentProvider::Consent result = ConsentProvider::CONSENT_IMPOSSIBLE; | 406 ConsentProvider::Consent result = ConsentProvider::CONSENT_IMPOSSIBLE; |
| 404 provider.RequestConsent(*manual_launch_kiosk_app.get(), volume_, | 407 provider.RequestConsent(*manual_launch_kiosk_app.get(), volume_, |
| 405 true /* writable */, | 408 true /* writable */, |
| 406 base::Bind(&OnConsentReceived, &result)); | 409 base::Bind(&OnConsentReceived, &result)); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 426 base::RunLoop().RunUntilIdle(); | 429 base::RunLoop().RunUntilIdle(); |
| 427 | 430 |
| 428 EXPECT_EQ(1, delegate.show_dialog_counter()); | 431 EXPECT_EQ(1, delegate.show_dialog_counter()); |
| 429 EXPECT_EQ(0, delegate.show_notification_counter()); | 432 EXPECT_EQ(0, delegate.show_notification_counter()); |
| 430 EXPECT_EQ(ConsentProvider::CONSENT_REJECTED, result); | 433 EXPECT_EQ(ConsentProvider::CONSENT_REJECTED, result); |
| 431 } | 434 } |
| 432 } | 435 } |
| 433 #endif | 436 #endif |
| 434 | 437 |
| 435 } // namespace extensions | 438 } // namespace extensions |
| OLD | NEW |