| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/chromeos/extensions/public_session_permission_helper.h" | 5 #include "chrome/browser/chromeos/extensions/public_session_permission_helper.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 base::WeakPtr<ProgrammableInstallPrompt> CallHandlePermissionRequest( | 112 base::WeakPtr<ProgrammableInstallPrompt> CallHandlePermissionRequest( |
| 113 const scoped_refptr<Extension>& extension, | 113 const scoped_refptr<Extension>& extension, |
| 114 const PermissionIDSet& permissions); | 114 const PermissionIDSet& permissions); |
| 115 | 115 |
| 116 protected: | 116 protected: |
| 117 scoped_refptr<Extension> extension_a_; | 117 scoped_refptr<Extension> extension_a_; |
| 118 scoped_refptr<Extension> extension_b_; | 118 scoped_refptr<Extension> extension_b_; |
| 119 | 119 |
| 120 std::vector<PermissionIDSet> allowed_permissions_; | 120 std::vector<PermissionIDSet> allowed_permissions_; |
| 121 | 121 |
| 122 chromeos::ScopedTestPublicSessionLoginState login_state_; | 122 std::unique_ptr<chromeos::ScopedTestPublicSessionLoginState> login_state_; |
| 123 | 123 |
| 124 private: | 124 private: |
| 125 DISALLOW_COPY_AND_ASSIGN(PublicSessionPermissionHelperTest); | 125 DISALLOW_COPY_AND_ASSIGN(PublicSessionPermissionHelperTest); |
| 126 }; | 126 }; |
| 127 | 127 |
| 128 void PublicSessionPermissionHelperTest::SetUp() { | 128 void PublicSessionPermissionHelperTest::SetUp() { |
| 129 ChromeRenderViewHostTestHarness::SetUp(); | 129 ChromeRenderViewHostTestHarness::SetUp(); |
| 130 login_state_.reset(new chromeos::ScopedTestPublicSessionLoginState()); |
| 130 extension_a_ = LoadManifestHelper("extension_a"); | 131 extension_a_ = LoadManifestHelper("extension_a"); |
| 131 extension_b_ = LoadManifestHelper("extension_b"); | 132 extension_b_ = LoadManifestHelper("extension_b"); |
| 132 } | 133 } |
| 133 | 134 |
| 134 void PublicSessionPermissionHelperTest::TearDown() { | 135 void PublicSessionPermissionHelperTest::TearDown() { |
| 136 login_state_.reset(); |
| 135 ResetPermissionsForTesting(); | 137 ResetPermissionsForTesting(); |
| 136 ChromeRenderViewHostTestHarness::TearDown(); | 138 ChromeRenderViewHostTestHarness::TearDown(); |
| 137 } | 139 } |
| 138 | 140 |
| 139 void PublicSessionPermissionHelperTest::RequestResolved( | 141 void PublicSessionPermissionHelperTest::RequestResolved( |
| 140 const PermissionIDSet& allowed_permissions) { | 142 const PermissionIDSet& allowed_permissions) { |
| 141 allowed_permissions_.push_back(allowed_permissions); | 143 allowed_permissions_.push_back(allowed_permissions); |
| 142 } | 144 } |
| 143 | 145 |
| 144 std::unique_ptr<ExtensionInstallPrompt> | 146 std::unique_ptr<ExtensionInstallPrompt> |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 EXPECT_FALSE(PermissionAllowed(extension.get(), permission_b)); | 311 EXPECT_FALSE(PermissionAllowed(extension.get(), permission_b)); |
| 310 } | 312 } |
| 311 // Already handled (deny), doesn't show a prompt. | 313 // Already handled (deny), doesn't show a prompt. |
| 312 EXPECT_TRUE(HandlePermissionRequest(*extension, {permission_b}, | 314 EXPECT_TRUE(HandlePermissionRequest(*extension, {permission_b}, |
| 313 web_contents(), RequestResolvedCallback(), | 315 web_contents(), RequestResolvedCallback(), |
| 314 PromptFactory())); | 316 PromptFactory())); |
| 315 } | 317 } |
| 316 | 318 |
| 317 } // namespace permission_helper | 319 } // namespace permission_helper |
| 318 } // namespace extensions | 320 } // namespace extensions |
| OLD | NEW |