| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "chrome/browser/browser_thread.h" | 7 #include "chrome/browser/browser_thread.h" |
| 8 #include "chrome/browser/child_process_security_policy.h" | 8 #include "chrome/browser/child_process_security_policy.h" |
| 9 #include "chrome/browser/chromeos/login/account_screen.h" | 9 #include "chrome/browser/chromeos/login/account_screen.h" |
| 10 #include "chrome/browser/chromeos/login/wizard_controller.h" | 10 #include "chrome/browser/chromeos/login/wizard_controller.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 | 48 |
| 49 static void QuitUIMessageLoop() { | 49 static void QuitUIMessageLoop() { |
| 50 MessageLoopForUI::current()->Quit(); | 50 MessageLoopForUI::current()->Quit(); |
| 51 } | 51 } |
| 52 | 52 |
| 53 static bool inspector_called = false; // had to use global flag as | 53 static bool inspector_called = false; // had to use global flag as |
| 54 // InspectorHook() doesn't have context. | 54 // InspectorHook() doesn't have context. |
| 55 | 55 |
| 56 static URLRequestJob* InspectorHook(URLRequest* request, | 56 static URLRequestJob* InspectorHook(URLRequest* request, |
| 57 const std::string& scheme) { | 57 const std::string& scheme) { |
| 58 LOG(INFO) << "Intercepted: " << request->url() << ", scheme: " << scheme; | 58 VLOG(1) << "Intercepted: " << request->url() << ", scheme: " << scheme; |
| 59 | 59 |
| 60 // Expect that the parameters are the same as new_account.html gave us. | 60 // Expect that the parameters are the same as new_account.html gave us. |
| 61 EXPECT_STREQ("cros://inspector/?param1=value1+param2", | 61 EXPECT_STREQ("cros://inspector/?param1=value1+param2", |
| 62 request->url().spec().c_str()); | 62 request->url().spec().c_str()); |
| 63 inspector_called = true; | 63 inspector_called = true; |
| 64 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 64 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| 65 NewRunnableFunction(QuitUIMessageLoop)); | 65 NewRunnableFunction(QuitUIMessageLoop)); |
| 66 | 66 |
| 67 // Do not navigate to the given URL. Navigate to about:blank instead. | 67 // Do not navigate to the given URL. Navigate to about:blank instead. |
| 68 return new URLRequestAboutJob(request); | 68 return new URLRequestAboutJob(request); |
| 69 } | 69 } |
| 70 | 70 |
| 71 IN_PROC_BROWSER_TEST_F(AccountScreenTest, TestSchemeInspector) { | 71 IN_PROC_BROWSER_TEST_F(AccountScreenTest, TestSchemeInspector) { |
| 72 ChildProcessSecurityPolicy::GetInstance()->RegisterWebSafeScheme( | 72 ChildProcessSecurityPolicy::GetInstance()->RegisterWebSafeScheme( |
| 73 chrome::kCrosScheme); | 73 chrome::kCrosScheme); |
| 74 URLRequestFilter::GetInstance()->AddHostnameHandler(chrome::kCrosScheme, | 74 URLRequestFilter::GetInstance()->AddHostnameHandler(chrome::kCrosScheme, |
| 75 "inspector", | 75 "inspector", |
| 76 &InspectorHook); | 76 &InspectorHook); |
| 77 EXPECT_FALSE(inspector_called); | 77 EXPECT_FALSE(inspector_called); |
| 78 ui_test_utils::RunMessageLoop(); | 78 ui_test_utils::RunMessageLoop(); |
| 79 EXPECT_TRUE(inspector_called); | 79 EXPECT_TRUE(inspector_called); |
| 80 } | 80 } |
| 81 | 81 |
| 82 } // namespace chromeos | 82 } // namespace chromeos |
| OLD | NEW |