Chromium Code Reviews| 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 75 | 75 |
| 76 scoped_refptr<const Extension> extension = | 76 scoped_refptr<const Extension> extension = |
| 77 ExtensionBuilder().SetManifest( | 77 ExtensionBuilder().SetManifest( |
| 78 DictionaryBuilder().Set("name", "foo") | 78 DictionaryBuilder().Set("name", "foo") |
| 79 .Set("version", "1.0") | 79 .Set("version", "1.0") |
| 80 .Set("manifest_version", 2) | 80 .Set("manifest_version", 2) |
| 81 .Set("description", "Random Ext") | 81 .Set("description", "Random Ext") |
| 82 .Set("permissions", | 82 .Set("permissions", |
| 83 ListBuilder().Append("http://*/*") | 83 ListBuilder().Append("http://*/*") |
| 84 .Append("http://www.google.com/") | 84 .Append("http://www.google.com/") |
| 85 .Append("tabs"))) | 85 .Append("tabs"))).Build(); |
| 86 .Build(); | |
| 87 ExtensionInstallPrompt prompt(nullptr /* no web contents in this test */); | 86 ExtensionInstallPrompt prompt(nullptr /* no web contents in this test */); |
| 88 base::RunLoop run_loop; | 87 base::RunLoop run_loop; |
| 89 | 88 |
| 90 // We expect <all_hosts> to be withheld, but http://www.google.com/ and tabs | 89 // We expect <all_hosts> to be withheld, but http://www.google.com/ and tabs |
| 91 // permissions should be granted as regular permissions. | 90 // permissions should be granted as regular permissions. |
| 92 prompt.ConfirmInstall( | 91 prompt.ConfirmInstall( |
| 93 nullptr, | 92 nullptr, |
| 94 extension.get(), | 93 extension.get(), |
| 95 base::Bind(&VerifyPromptPermissionsCallback, | 94 base::Bind(&VerifyPromptPermissionsCallback, |
| 96 run_loop.QuitClosure(), | 95 run_loop.QuitClosure(), |
| 97 2u, // |regular_permissions_count|. | 96 2u, // |regular_permissions_count|. |
| 98 1u)); // |withheld_permissions_count|. | 97 1u)); // |withheld_permissions_count|. |
| 99 run_loop.Run(); | 98 run_loop.Run(); |
| 100 } | 99 } |
| 101 | 100 |
| 102 TEST(ExtensionInstallPromptUnittest, DelegatedPromptShowsOptionalPermissions) { | 101 TEST(ExtensionInstallPromptUnittest, DelegatedPromptShowsOptionalPermissions) { |
| 103 content::TestBrowserThreadBundle thread_bundle; | 102 content::TestBrowserThreadBundle thread_bundle; |
| 104 scoped_refptr<const Extension> extension = | 103 scoped_refptr<const Extension> extension = |
| 105 ExtensionBuilder().SetManifest( | 104 ExtensionBuilder().SetManifest( |
| 106 DictionaryBuilder().Set("name", "foo") | 105 DictionaryBuilder().Set("name", "foo") |
| 107 .Set("version", "1.0") | 106 .Set("version", "1.0") |
| 108 .Set("manifest_version", 2) | 107 .Set("manifest_version", 2) |
| 109 .Set("description", "Random Ext") | 108 .Set("description", "Random Ext") |
| 110 .Set("permissions", ListBuilder().Append("tabs")) | 109 .Set("permissions", |
| 110 ListBuilder().Append("clipboardRead")) | |
| 111 .Set("optional_permissions", | 111 .Set("optional_permissions", |
| 112 ListBuilder().Append("location"))) | 112 ListBuilder().Append("tabs"))).Build(); |
|
Marc Treib
2015/03/09 14:05:59
For some reason, "location" does not result in any
not at google - send to devlin
2015/03/09 16:33:53
Well that's weird. Location is supposed to be a va
Marc Treib
2015/03/09 17:30:40
Yup, especially as it works fine on all the other
| |
| 113 .Build(); | |
| 114 ExtensionInstallPrompt prompt(nullptr /* no web contents in this test */); | 113 ExtensionInstallPrompt prompt(nullptr /* no web contents in this test */); |
| 115 base::RunLoop run_loop; | 114 base::RunLoop run_loop; |
| 116 prompt.set_callback_for_test( | 115 prompt.set_callback_for_test( |
| 117 base::Bind(&VerifyPromptPermissionsCallback, | 116 base::Bind(&VerifyPromptPermissionsCallback, |
| 118 run_loop.QuitClosure(), | 117 run_loop.QuitClosure(), |
| 119 2u, // |regular_permissions_count|. | 118 2u, // |regular_permissions_count|. |
| 120 0u)); // |withheld_permissions_count|. | 119 0u)); // |withheld_permissions_count|. |
| 121 prompt.ConfirmPermissionsForDelegatedInstall(nullptr, // no delegate | 120 prompt.ConfirmPermissionsForDelegatedInstall(nullptr, // no delegate |
| 122 extension.get(), | 121 extension.get(), |
| 123 "Username", | 122 "Username", |
| 124 nullptr); // no icon | 123 nullptr); // no icon |
| 125 run_loop.Run(); | 124 run_loop.Run(); |
| 126 } | 125 } |
| 127 | 126 |
| 128 } // namespace extensions | 127 } // namespace extensions |
| OLD | NEW |