| 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 "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "chrome/browser/chrome_notification_types.h" | 6 #include "chrome/browser/chrome_notification_types.h" |
| 7 #include "chrome/browser/extensions/extension_host.h" | 7 #include "chrome/browser/extensions/extension_host.h" |
| 8 #include "chrome/browser/extensions/extension_install_ui.h" | 8 #include "chrome/browser/extensions/extension_install_ui.h" |
| 9 #include "chrome/browser/extensions/extension_service.h" | 9 #include "chrome/browser/extensions/extension_service.h" |
| 10 #include "chrome/browser/extensions/extension_system.h" | 10 #include "chrome/browser/extensions/extension_system.h" |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 extension_service->AddExtension(hosted_app.get()); | 164 extension_service->AddExtension(hosted_app.get()); |
| 165 EXPECT_TRUE(extension_service->extensions()->Contains(hosted_app->id())); | 165 EXPECT_TRUE(extension_service->extensions()->Contains(hosted_app->id())); |
| 166 | 166 |
| 167 ui_test_utils::NavigateToURL(browser(), kInstallUrl); | 167 ui_test_utils::NavigateToURL(browser(), kInstallUrl); |
| 168 | 168 |
| 169 EXPECT_FALSE(extension_service->extensions()->Contains(kTestExtensionId)); | 169 EXPECT_FALSE(extension_service->extensions()->Contains(kTestExtensionId)); |
| 170 RunTest("runTest"); | 170 RunTest("runTest"); |
| 171 EXPECT_TRUE(extension_service->extensions()->Contains(kTestExtensionId)); | 171 EXPECT_TRUE(extension_service->extensions()->Contains(kTestExtensionId)); |
| 172 } | 172 } |
| 173 | 173 |
| 174 IN_PROC_BROWSER_TEST_F(WebstoreStartupInstallerTest, | 174 class WebstoreStartupInstallerManagedUsersTest |
| 175 InstallProhibitedForManagedUsers) { | 175 : public WebstoreStartupInstallerTest { |
| 176 public: |
| 177 // InProcessBrowserTest overrides: |
| 178 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
| 179 WebstoreStartupInstallerTest::SetUpCommandLine(command_line); |
| 180 command_line->AppendSwitch(switches::kNewProfileIsSupervised); |
| 181 } |
| 182 }; |
| 183 |
| 184 IN_PROC_BROWSER_TEST_F(WebstoreStartupInstallerManagedUsersTest, |
| 185 InstallProhibited) { |
| 176 #if defined(OS_WIN) && defined(USE_ASH) | 186 #if defined(OS_WIN) && defined(USE_ASH) |
| 177 // Disable this test in Metro+Ash for now (http://crbug.com/262796). | 187 // Disable this test in Metro+Ash for now (http://crbug.com/262796). |
| 178 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) | 188 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) |
| 179 return; | 189 return; |
| 180 #endif | 190 #endif |
| 181 | 191 |
| 182 CommandLine::ForCurrentProcess()->AppendSwitchASCII( | 192 CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
| 183 switches::kAppsGalleryInstallAutoConfirmForTests, "accept"); | 193 switches::kAppsGalleryInstallAutoConfirmForTests, "accept"); |
| 184 | 194 |
| 185 // Make the profile managed such that no extension installs are allowed. | |
| 186 ManagedUserService* service = | |
| 187 ManagedUserServiceFactory::GetForProfile(browser()->profile()); | |
| 188 service->InitForTesting(); | |
| 189 | |
| 190 ui_test_utils::NavigateToURL( | 195 ui_test_utils::NavigateToURL( |
| 191 browser(), GenerateTestServerUrl(kAppDomain, "install_prohibited.html")); | 196 browser(), GenerateTestServerUrl(kAppDomain, "install_prohibited.html")); |
| 192 | 197 |
| 193 RunTest("runTest"); | 198 RunTest("runTest"); |
| 194 | 199 |
| 195 // No error infobar should show up. | 200 // No error infobar should show up. |
| 196 WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents(); | 201 WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents(); |
| 197 InfoBarService* info_bar_service = InfoBarService::FromWebContents(contents); | 202 InfoBarService* info_bar_service = InfoBarService::FromWebContents(contents); |
| 198 EXPECT_EQ(info_bar_service->infobar_count(), 0u); | 203 EXPECT_EQ(info_bar_service->infobar_count(), 0u); |
| 199 } | 204 } |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 324 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 320 command_line->AppendSwitchASCII( | 325 command_line->AppendSwitchASCII( |
| 321 switches::kLimitedInstallFromWebstore, "2"); | 326 switches::kLimitedInstallFromWebstore, "2"); |
| 322 helper.LimitedInstallFromWebstore(*command_line, browser()->profile(), | 327 helper.LimitedInstallFromWebstore(*command_line, browser()->profile(), |
| 323 base::MessageLoop::QuitWhenIdleClosure()); | 328 base::MessageLoop::QuitWhenIdleClosure()); |
| 324 base::MessageLoop::current()->Run(); | 329 base::MessageLoop::current()->Run(); |
| 325 | 330 |
| 326 EXPECT_TRUE(saw_install()); | 331 EXPECT_TRUE(saw_install()); |
| 327 EXPECT_EQ(0, browser_open_count()); | 332 EXPECT_EQ(0, browser_open_count()); |
| 328 } | 333 } |
| OLD | NEW |