| 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 <algorithm> | 5 #include <algorithm> |
| 6 #include <string> | 6 #include <string> |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 #include "url/gurl.h" | 139 #include "url/gurl.h" |
| 140 | 140 |
| 141 #if defined(OS_CHROMEOS) | 141 #if defined(OS_CHROMEOS) |
| 142 #include "ash/accelerators/accelerator_controller.h" | 142 #include "ash/accelerators/accelerator_controller.h" |
| 143 #include "ash/accelerators/accelerator_table.h" | 143 #include "ash/accelerators/accelerator_table.h" |
| 144 #include "ash/magnifier/magnifier_constants.h" | 144 #include "ash/magnifier/magnifier_constants.h" |
| 145 #include "ash/shell.h" | 145 #include "ash/shell.h" |
| 146 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" | 146 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" |
| 147 #include "chrome/browser/chromeos/accessibility/magnification_manager.h" | 147 #include "chrome/browser/chromeos/accessibility/magnification_manager.h" |
| 148 #include "chrome/browser/profiles/profile_manager.h" | 148 #include "chrome/browser/profiles/profile_manager.h" |
| 149 #include "chrome/browser/ui/ash/screenshot_taker.h" |
| 149 #include "chromeos/audio/cras_audio_handler.h" | 150 #include "chromeos/audio/cras_audio_handler.h" |
| 150 #endif | 151 #endif |
| 151 | 152 |
| 152 #if !defined(OS_MACOSX) | 153 #if !defined(OS_MACOSX) |
| 153 #include "apps/shell_window.h" | 154 #include "apps/shell_window.h" |
| 154 #include "apps/shell_window_registry.h" | 155 #include "apps/shell_window_registry.h" |
| 155 #include "apps/ui/native_app_window.h" | 156 #include "apps/ui/native_app_window.h" |
| 156 #include "base/basictypes.h" | 157 #include "base/basictypes.h" |
| 157 #include "base/compiler_specific.h" | 158 #include "base/compiler_specific.h" |
| 158 #include "chrome/browser/ui/extensions/application_launch.h" | 159 #include "chrome/browser/ui/extensions/application_launch.h" |
| (...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 619 | 620 |
| 620 void SetScreenshotPolicy(bool enabled) { | 621 void SetScreenshotPolicy(bool enabled) { |
| 621 PolicyMap policies; | 622 PolicyMap policies; |
| 622 policies.Set(key::kDisableScreenshots, | 623 policies.Set(key::kDisableScreenshots, |
| 623 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, | 624 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, |
| 624 base::Value::CreateBooleanValue(!enabled), NULL); | 625 base::Value::CreateBooleanValue(!enabled), NULL); |
| 625 UpdateProviderPolicy(policies); | 626 UpdateProviderPolicy(policies); |
| 626 } | 627 } |
| 627 | 628 |
| 628 #if defined(OS_CHROMEOS) | 629 #if defined(OS_CHROMEOS) |
| 630 class QuitMessageLoopAfterScreenshot : public ScreenshotTakerObserver { |
| 631 public: |
| 632 virtual void OnScreenshotCompleted( |
| 633 ScreenshotTakerObserver::Result screenshot_result, |
| 634 const base::FilePath& screenshot_path) OVERRIDE { |
| 635 BrowserThread::PostTaskAndReply(BrowserThread::IO, |
| 636 FROM_HERE, |
| 637 base::Bind(base::DoNothing), |
| 638 base::MessageLoop::QuitClosure()); |
| 639 } |
| 640 |
| 641 virtual ~QuitMessageLoopAfterScreenshot() {} |
| 642 }; |
| 643 |
| 629 void TestScreenshotFile(bool enabled) { | 644 void TestScreenshotFile(bool enabled) { |
| 645 // AddObserver is an ash-specific method, so just replace the screenshot |
| 646 // taker with one we've created here. |
| 647 scoped_ptr<ScreenshotTaker> screenshot_taker(new ScreenshotTaker); |
| 648 // ScreenshotTaker doesn't own this observer, so the observer's lifetime |
| 649 // is tied to the test instead. |
| 650 screenshot_taker->AddObserver(&observer_); |
| 651 ash::Shell::GetInstance()->accelerator_controller()->SetScreenshotDelegate( |
| 652 screenshot_taker.PassAs<ash::ScreenshotDelegate>()); |
| 653 |
| 630 SetScreenshotPolicy(enabled); | 654 SetScreenshotPolicy(enabled); |
| 631 ash::Shell::GetInstance()->accelerator_controller()->PerformAction( | 655 ash::Shell::GetInstance()->accelerator_controller()->PerformAction( |
| 632 ash::TAKE_SCREENSHOT, ui::Accelerator()); | 656 ash::TAKE_SCREENSHOT, ui::Accelerator()); |
| 633 | 657 |
| 634 // TAKE_SCREENSHOT handler posts write file task on success, wait for it. | |
| 635 BrowserThread::PostTaskAndReply( | |
| 636 BrowserThread::IO, | |
| 637 FROM_HERE, | |
| 638 base::Bind(base::DoNothing), | |
| 639 base::MessageLoop::QuitClosure()); | |
| 640 content::RunMessageLoop(); | 658 content::RunMessageLoop(); |
| 641 } | 659 } |
| 642 #endif | 660 #endif |
| 643 | 661 |
| 644 ExtensionService* extension_service() { | 662 ExtensionService* extension_service() { |
| 645 extensions::ExtensionSystem* system = | 663 extensions::ExtensionSystem* system = |
| 646 extensions::ExtensionSystem::Get(browser()->profile()); | 664 extensions::ExtensionSystem::Get(browser()->profile()); |
| 647 return system->extension_service(); | 665 return system->extension_service(); |
| 648 } | 666 } |
| 649 | 667 |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 714 click_event.button = blink::WebMouseEvent::ButtonLeft; | 732 click_event.button = blink::WebMouseEvent::ButtonLeft; |
| 715 click_event.clickCount = 1; | 733 click_event.clickCount = 1; |
| 716 click_event.x = x; | 734 click_event.x = x; |
| 717 click_event.y = y; | 735 click_event.y = y; |
| 718 contents->GetRenderViewHost()->ForwardMouseEvent(click_event); | 736 contents->GetRenderViewHost()->ForwardMouseEvent(click_event); |
| 719 click_event.type = blink::WebInputEvent::MouseUp; | 737 click_event.type = blink::WebInputEvent::MouseUp; |
| 720 contents->GetRenderViewHost()->ForwardMouseEvent(click_event); | 738 contents->GetRenderViewHost()->ForwardMouseEvent(click_event); |
| 721 } | 739 } |
| 722 | 740 |
| 723 MockConfigurationPolicyProvider provider_; | 741 MockConfigurationPolicyProvider provider_; |
| 742 #if defined(OS_CHROMEOS) |
| 743 QuitMessageLoopAfterScreenshot observer_; |
| 744 #endif |
| 724 }; | 745 }; |
| 725 | 746 |
| 726 #if defined(OS_WIN) | 747 #if defined(OS_WIN) |
| 727 // This policy only exists on Windows. | 748 // This policy only exists on Windows. |
| 728 | 749 |
| 729 // Sets the locale policy before the browser is started. | 750 // Sets the locale policy before the browser is started. |
| 730 class LocalePolicyTest : public PolicyTest { | 751 class LocalePolicyTest : public PolicyTest { |
| 731 public: | 752 public: |
| 732 LocalePolicyTest() {} | 753 LocalePolicyTest() {} |
| 733 virtual ~LocalePolicyTest() {} | 754 virtual ~LocalePolicyTest() {} |
| (...skipping 2189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2923 PrefService* prefs = browser()->profile()->GetPrefs(); | 2944 PrefService* prefs = browser()->profile()->GetPrefs(); |
| 2924 EXPECT_TRUE(extensions::NativeMessageProcessHost::IsHostAllowed( | 2945 EXPECT_TRUE(extensions::NativeMessageProcessHost::IsHostAllowed( |
| 2925 prefs, "host.name")); | 2946 prefs, "host.name")); |
| 2926 EXPECT_FALSE(extensions::NativeMessageProcessHost::IsHostAllowed( | 2947 EXPECT_FALSE(extensions::NativeMessageProcessHost::IsHostAllowed( |
| 2927 prefs, "other.host.name")); | 2948 prefs, "other.host.name")); |
| 2928 } | 2949 } |
| 2929 | 2950 |
| 2930 #endif // !defined(CHROME_OS) | 2951 #endif // !defined(CHROME_OS) |
| 2931 | 2952 |
| 2932 } // namespace policy | 2953 } // namespace policy |
| OLD | NEW |