| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/memory/ref_counted.h" | 6 #include "base/memory/ref_counted.h" |
| 7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
| 8 #include "chrome/browser/extensions/extension_install_prompt.h" | 8 #include "chrome/browser/extensions/extension_install_prompt.h" |
| 9 #include "chrome/browser/extensions/extension_install_prompt_show_params.h" | 9 #include "chrome/browser/extensions/extension_install_prompt_show_params.h" |
| 10 #include "content/public/test/test_browser_thread_bundle.h" | 10 #include "content/public/test/test_browser_thread_bundle.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 EXPECT_EQ(withheld_permissions_count, | 35 EXPECT_EQ(withheld_permissions_count, |
| 36 install_prompt->GetPermissionCount( | 36 install_prompt->GetPermissionCount( |
| 37 ExtensionInstallPrompt::WITHHELD_PERMISSIONS)); | 37 ExtensionInstallPrompt::WITHHELD_PERMISSIONS)); |
| 38 quit_closure.Run(); | 38 quit_closure.Run(); |
| 39 } | 39 } |
| 40 | 40 |
| 41 TEST(ExtensionInstallPromptUnittest, PromptShowsPermissionWarnings) { | 41 TEST(ExtensionInstallPromptUnittest, PromptShowsPermissionWarnings) { |
| 42 content::TestBrowserThreadBundle thread_bundle; | 42 content::TestBrowserThreadBundle thread_bundle; |
| 43 APIPermissionSet api_permissions; | 43 APIPermissionSet api_permissions; |
| 44 api_permissions.insert(APIPermission::kTab); | 44 api_permissions.insert(APIPermission::kTab); |
| 45 scoped_refptr<const PermissionSet> permission_set = | 45 scoped_ptr<const PermissionSet> permission_set( |
| 46 new PermissionSet(api_permissions, ManifestPermissionSet(), | 46 new PermissionSet(api_permissions, ManifestPermissionSet(), |
| 47 URLPatternSet(), URLPatternSet()); | 47 URLPatternSet(), URLPatternSet())); |
| 48 scoped_refptr<const Extension> extension = | 48 scoped_refptr<const Extension> extension = |
| 49 ExtensionBuilder().SetManifest( | 49 ExtensionBuilder().SetManifest( |
| 50 DictionaryBuilder().Set("name", "foo") | 50 DictionaryBuilder().Set("name", "foo") |
| 51 .Set("version", "1.0") | 51 .Set("version", "1.0") |
| 52 .Set("manifest_version", 2) | 52 .Set("manifest_version", 2) |
| 53 .Set("description", "Random Ext")).Build(); | 53 .Set("description", "Random Ext")).Build(); |
| 54 ExtensionInstallPrompt prompt(nullptr /* no web contents in this test */); | 54 ExtensionInstallPrompt prompt(nullptr /* no web contents in this test */); |
| 55 base::RunLoop run_loop; | 55 base::RunLoop run_loop; |
| 56 prompt.set_callback_for_test( | 56 prompt.set_callback_for_test( |
| 57 base::Bind(&VerifyPromptPermissionsCallback, | 57 base::Bind(&VerifyPromptPermissionsCallback, |
| 58 run_loop.QuitClosure(), | 58 run_loop.QuitClosure(), |
| 59 1u, // |regular_permissions_count|. | 59 1u, // |regular_permissions_count|. |
| 60 0u)); // |withheld_permissions_count|. | 60 0u)); // |withheld_permissions_count|. |
| 61 prompt.ConfirmPermissions(nullptr, // no delegate | 61 prompt.ConfirmPermissions(nullptr, // no delegate |
| 62 extension.get(), | 62 extension.get(), permission_set.Pass()); |
| 63 permission_set.get()); | |
| 64 run_loop.Run(); | 63 run_loop.Run(); |
| 65 } | 64 } |
| 66 | 65 |
| 67 TEST(ExtensionInstallPromptUnittest, PromptShowsWithheldPermissions) { | 66 TEST(ExtensionInstallPromptUnittest, PromptShowsWithheldPermissions) { |
| 68 content::TestBrowserThreadBundle thread_bundle; | 67 content::TestBrowserThreadBundle thread_bundle; |
| 69 | 68 |
| 70 // Enable consent flag so that <all_hosts> permissions get withheld. | 69 // Enable consent flag so that <all_hosts> permissions get withheld. |
| 71 FeatureSwitch::ScopedOverride enable_scripts_switch( | 70 FeatureSwitch::ScopedOverride enable_scripts_switch( |
| 72 FeatureSwitch::scripts_require_action(), true); | 71 FeatureSwitch::scripts_require_action(), true); |
| 73 | 72 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 2u, // |regular_permissions_count|. | 115 2u, // |regular_permissions_count|. |
| 117 0u)); // |withheld_permissions_count|. | 116 0u)); // |withheld_permissions_count|. |
| 118 prompt.ConfirmPermissionsForDelegatedInstall(nullptr, // no delegate | 117 prompt.ConfirmPermissionsForDelegatedInstall(nullptr, // no delegate |
| 119 extension.get(), | 118 extension.get(), |
| 120 "Username", | 119 "Username", |
| 121 nullptr); // no icon | 120 nullptr); // no icon |
| 122 run_loop.Run(); | 121 run_loop.Run(); |
| 123 } | 122 } |
| 124 | 123 |
| 125 } // namespace extensions | 124 } // namespace extensions |
| OLD | NEW |