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/memory/ref_counted.h" | 5 #include "base/memory/ref_counted.h" |
6 #include "chrome/browser/download/download_crx_util.h" | 6 #include "chrome/browser/download/download_crx_util.h" |
7 #include "chrome/browser/extensions/crx_installer.h" | 7 #include "chrome/browser/extensions/crx_installer.h" |
8 #include "chrome/browser/extensions/extension_browsertest.h" | 8 #include "chrome/browser/extensions/extension_browsertest.h" |
9 #include "chrome/browser/extensions/extension_install_prompt.h" | 9 #include "chrome/browser/extensions/extension_install_prompt.h" |
10 #include "chrome/browser/extensions/extension_service.h" | 10 #include "chrome/browser/extensions/extension_service.h" |
11 #include "chrome/browser/extensions/extension_system.h" | 11 #include "chrome/browser/extensions/extension_system.h" |
12 #include "chrome/browser/extensions/fake_safe_browsing_database_manager.h" | 12 #include "chrome/browser/extensions/fake_safe_browsing_database_manager.h" |
13 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
14 #include "chrome/browser/ui/browser.h" | 14 #include "chrome/browser/ui/browser.h" |
15 #include "chrome/browser/ui/browser_window.h" | 15 #include "chrome/browser/ui/browser_window.h" |
16 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 16 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
17 #include "chrome/common/extensions/extension.h" | 17 #include "chrome/common/extensions/extension.h" |
18 #include "chrome/common/extensions/extension_file_util.h" | 18 #include "chrome/common/extensions/extension_file_util.h" |
19 #include "chrome/common/extensions/feature_switch.h" | 19 #include "chrome/common/extensions/feature_switch.h" |
20 #include "chrome/common/extensions/permissions/permission_set.h" | 20 #include "chrome/common/extensions/permissions/permission_set.h" |
21 #include "chrome/test/base/ui_test_utils.h" | 21 #include "chrome/test/base/ui_test_utils.h" |
22 #include "content/public/browser/download_manager.h" | 22 #include "content/public/browser/download_manager.h" |
23 #include "content/public/test/download_test_observer.h" | 23 #include "content/public/test/download_test_observer.h" |
24 #include "extensions/common/switches.h" | 24 #include "extensions/common/switches.h" |
25 #include "grit/generated_resources.h" | 25 #include "grit/generated_resources.h" |
26 #include "ui/base/l10n/l10n_util.h" | 26 #include "ui/base/l10n/l10n_util.h" |
27 | 27 |
| 28 #if defined(OS_CHROMEOS) |
| 29 #include "chrome/browser/chromeos/login/fake_user_manager.h" |
| 30 #include "chrome/browser/chromeos/login/user_manager.h" |
| 31 #endif |
| 32 |
28 class SkBitmap; | 33 class SkBitmap; |
29 | 34 |
30 namespace extensions { | 35 namespace extensions { |
31 | 36 |
32 namespace { | 37 namespace { |
33 | 38 |
34 class MockInstallPrompt; | 39 class MockInstallPrompt; |
35 | 40 |
36 // This class holds information about things that happen with a | 41 // This class holds information about things that happen with a |
37 // MockInstallPrompt. We create the MockInstallPrompt but need to pass | 42 // MockInstallPrompt. We create the MockInstallPrompt but need to pass |
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
470 std::string id = "lhnaeclnpobnlbjbgogdanmhadigfnjp"; | 475 std::string id = "lhnaeclnpobnlbjbgogdanmhadigfnjp"; |
471 scoped_ptr<WebstoreInstaller::Approval> approval = | 476 scoped_ptr<WebstoreInstaller::Approval> approval = |
472 GetApproval("crx_installer/v2_no_permission_change/", id, false); | 477 GetApproval("crx_installer/v2_no_permission_change/", id, false); |
473 | 478 |
474 RunCrxInstaller(approval.get(), mock_prompt->CreatePrompt(), | 479 RunCrxInstaller(approval.get(), mock_prompt->CreatePrompt(), |
475 test_data_dir_.AppendASCII("crx_installer/v1.crx")); | 480 test_data_dir_.AppendASCII("crx_installer/v1.crx")); |
476 | 481 |
477 EXPECT_TRUE(mock_prompt->did_succeed()); | 482 EXPECT_TRUE(mock_prompt->did_succeed()); |
478 } | 483 } |
479 | 484 |
| 485 IN_PROC_BROWSER_TEST_F(ExtensionCrxInstallerTest, KioskOnlyTest) { |
| 486 base::FilePath crx_path = |
| 487 test_data_dir_.AppendASCII("kiosk/kiosk_only.crx"); |
| 488 EXPECT_FALSE(InstallExtension(crx_path, 0)); |
| 489 #if defined(OS_CHROMEOS) |
| 490 // Simulate ChromeOS kiosk mode. |scoped_user_manager| will take over |
| 491 // lifetime of |user_manager|. |
| 492 chromeos::FakeUserManager* fake_user_manager = |
| 493 new chromeos::FakeUserManager(); |
| 494 fake_user_manager->AddKioskAppUser("example@example.com"); |
| 495 fake_user_manager->LoginUser("example@example.com"); |
| 496 chromeos::ScopedUserManagerEnabler scoped_user_manager(fake_user_manager); |
| 497 EXPECT_TRUE(InstallExtension(crx_path, 1)); |
| 498 #endif |
| 499 } |
| 500 |
480 } // namespace extensions | 501 } // namespace extensions |
OLD | NEW |