| 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 "ash/display/display_manager.h" | 9 #include "ash/display/display_manager.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 | 288 |
| 289 private: | 289 private: |
| 290 DISALLOW_COPY_AND_ASSIGN(FailedJobInterceptor); | 290 DISALLOW_COPY_AND_ASSIGN(FailedJobInterceptor); |
| 291 }; | 291 }; |
| 292 | 292 |
| 293 // While |MakeRequestFail| is in scope URLRequests to |host| will fail. | 293 // While |MakeRequestFail| is in scope URLRequests to |host| will fail. |
| 294 class MakeRequestFail { | 294 class MakeRequestFail { |
| 295 public: | 295 public: |
| 296 // Sets up the filter on IO thread such that requests to |host| fail. | 296 // Sets up the filter on IO thread such that requests to |host| fail. |
| 297 explicit MakeRequestFail(const std::string& host) : host_(host) { | 297 explicit MakeRequestFail(const std::string& host) : host_(host) { |
| 298 BrowserThread::PostTaskAndReply( | 298 BrowserThread::PostTaskAndReply(BrowserThread::IO, FROM_HERE, |
| 299 BrowserThread::IO, FROM_HERE, | 299 base::Bind(MakeRequestFailOnIO, host_), |
| 300 base::Bind(MakeRequestFailOnIO, host_), | 300 base::MessageLoop::QuitWhenIdleClosure()); |
| 301 base::MessageLoop::QuitClosure()); | |
| 302 content::RunMessageLoop(); | 301 content::RunMessageLoop(); |
| 303 } | 302 } |
| 304 ~MakeRequestFail() { | 303 ~MakeRequestFail() { |
| 305 BrowserThread::PostTaskAndReply( | 304 BrowserThread::PostTaskAndReply(BrowserThread::IO, FROM_HERE, |
| 306 BrowserThread::IO, FROM_HERE, | 305 base::Bind(UndoMakeRequestFailOnIO, host_), |
| 307 base::Bind(UndoMakeRequestFailOnIO, host_), | 306 base::MessageLoop::QuitWhenIdleClosure()); |
| 308 base::MessageLoop::QuitClosure()); | |
| 309 content::RunMessageLoop(); | 307 content::RunMessageLoop(); |
| 310 } | 308 } |
| 311 | 309 |
| 312 private: | 310 private: |
| 313 // Filters requests to the |host| such that they fail. Run on IO thread. | 311 // Filters requests to the |host| such that they fail. Run on IO thread. |
| 314 static void MakeRequestFailOnIO(const std::string& host) { | 312 static void MakeRequestFailOnIO(const std::string& host) { |
| 315 net::URLRequestFilter* filter = net::URLRequestFilter::GetInstance(); | 313 net::URLRequestFilter* filter = net::URLRequestFilter::GetInstance(); |
| 316 filter->AddHostnameInterceptor( | 314 filter->AddHostnameInterceptor( |
| 317 "http", host, | 315 "http", host, |
| 318 scoped_ptr<net::URLRequestInterceptor>(new FailedJobInterceptor())); | 316 scoped_ptr<net::URLRequestInterceptor>(new FailedJobInterceptor())); |
| (...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 681 NULL); | 679 NULL); |
| 682 UpdateProviderPolicy(policies); | 680 UpdateProviderPolicy(policies); |
| 683 } | 681 } |
| 684 | 682 |
| 685 #if defined(OS_CHROMEOS) | 683 #if defined(OS_CHROMEOS) |
| 686 class QuitMessageLoopAfterScreenshot : public ui::ScreenshotGrabberObserver { | 684 class QuitMessageLoopAfterScreenshot : public ui::ScreenshotGrabberObserver { |
| 687 public: | 685 public: |
| 688 void OnScreenshotCompleted( | 686 void OnScreenshotCompleted( |
| 689 ScreenshotGrabberObserver::Result screenshot_result, | 687 ScreenshotGrabberObserver::Result screenshot_result, |
| 690 const base::FilePath& screenshot_path) override { | 688 const base::FilePath& screenshot_path) override { |
| 691 BrowserThread::PostTaskAndReply(BrowserThread::IO, | 689 BrowserThread::PostTaskAndReply(BrowserThread::IO, FROM_HERE, |
| 692 FROM_HERE, | |
| 693 base::Bind(base::DoNothing), | 690 base::Bind(base::DoNothing), |
| 694 base::MessageLoop::QuitClosure()); | 691 base::MessageLoop::QuitWhenIdleClosure()); |
| 695 } | 692 } |
| 696 | 693 |
| 697 ~QuitMessageLoopAfterScreenshot() override {} | 694 ~QuitMessageLoopAfterScreenshot() override {} |
| 698 }; | 695 }; |
| 699 | 696 |
| 700 void TestScreenshotFile(bool enabled) { | 697 void TestScreenshotFile(bool enabled) { |
| 701 // AddObserver is an ash-specific method, so just replace the screenshot | 698 // AddObserver is an ash-specific method, so just replace the screenshot |
| 702 // grabber with one we've created here. | 699 // grabber with one we've created here. |
| 703 scoped_ptr<ChromeScreenshotGrabber> chrome_screenshot_grabber( | 700 scoped_ptr<ChromeScreenshotGrabber> chrome_screenshot_grabber( |
| 704 new ChromeScreenshotGrabber); | 701 new ChromeScreenshotGrabber); |
| (...skipping 3296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4001 POLICY_SCOPE_USER, | 3998 POLICY_SCOPE_USER, |
| 4002 POLICY_SOURCE_CLOUD, | 3999 POLICY_SOURCE_CLOUD, |
| 4003 new base::FundamentalValue(false), | 4000 new base::FundamentalValue(false), |
| 4004 NULL); | 4001 NULL); |
| 4005 UpdateProviderPolicy(policies); | 4002 UpdateProviderPolicy(policies); |
| 4006 EXPECT_FALSE(display_manager->unified_desktop_enabled()); | 4003 EXPECT_FALSE(display_manager->unified_desktop_enabled()); |
| 4007 } | 4004 } |
| 4008 #endif // defined(OS_CHROMEOS) | 4005 #endif // defined(OS_CHROMEOS) |
| 4009 | 4006 |
| 4010 } // namespace policy | 4007 } // namespace policy |
| OLD | NEW |