| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #import "ios/web/webui/crw_web_ui_manager.h" | 5 #import "ios/web/webui/crw_web_ui_manager.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 completion_handler_([completion_handler copy]) {} | 72 completion_handler_([completion_handler copy]) {} |
| 73 | 73 |
| 74 void Start() override { | 74 void Start() override { |
| 75 if (url_.spec() == kFaviconUrl) { | 75 if (url_.spec() == kFaviconUrl) { |
| 76 base::FilePath favicon_path; | 76 base::FilePath favicon_path; |
| 77 ASSERT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &favicon_path)); | 77 ASSERT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &favicon_path)); |
| 78 favicon_path = favicon_path.AppendASCII(kFaviconPath); | 78 favicon_path = favicon_path.AppendASCII(kFaviconPath); |
| 79 NSData* favicon = [NSData | 79 NSData* favicon = [NSData |
| 80 dataWithContentsOfFile:base::SysUTF8ToNSString(favicon_path.value())]; | 80 dataWithContentsOfFile:base::SysUTF8ToNSString(favicon_path.value())]; |
| 81 completion_handler_.get()(favicon, this); | 81 completion_handler_.get()(favicon, this); |
| 82 } else if (url_.path().find(kMojoModuleName) != std::string::npos) { | 82 } else if (url_.path().find(kMojoModuleName) != base::StringPiece::npos) { |
| 83 completion_handler_.get()( | 83 completion_handler_.get()( |
| 84 [kMojoModule dataUsingEncoding:NSUTF8StringEncoding], this); | 84 [kMojoModule dataUsingEncoding:NSUTF8StringEncoding], this); |
| 85 | 85 |
| 86 } else if (url_.scheme().find("test") != std::string::npos) { | 86 } else if (url_.scheme().find("test") != std::string::npos) { |
| 87 completion_handler_.get()([kHtml dataUsingEncoding:NSUTF8StringEncoding], | 87 completion_handler_.get()([kHtml dataUsingEncoding:NSUTF8StringEncoding], |
| 88 this); | 88 this); |
| 89 } else { | 89 } else { |
| 90 NOTREACHED(); | 90 NOTREACHED(); |
| 91 } | 91 } |
| 92 } | 92 } |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 "%s__crWeb.webUIModuleLoadNotifier.moduleLoadCompleted(\"%s\", \"%s\");", | 195 "%s__crWeb.webUIModuleLoadNotifier.moduleLoadCompleted(\"%s\", \"%s\");", |
| 196 base::SysNSStringToUTF8(kMojoModule).c_str(), kMojoModuleName, | 196 base::SysNSStringToUTF8(kMojoModule).c_str(), kMojoModuleName, |
| 197 kTestLoadId); | 197 kTestLoadId); |
| 198 | 198 |
| 199 EXPECT_CALL(*web_state_impl_, | 199 EXPECT_CALL(*web_state_impl_, |
| 200 ExecuteJavaScript(base::UTF8ToUTF16(expected_javascript))); | 200 ExecuteJavaScript(base::UTF8ToUTF16(expected_javascript))); |
| 201 web_state_impl_->OnScriptCommandReceived("webui.loadMojo", message, | 201 web_state_impl_->OnScriptCommandReceived("webui.loadMojo", message, |
| 202 GURL(kTestWebUIUrl), false); | 202 GURL(kTestWebUIUrl), false); |
| 203 } | 203 } |
| 204 } // namespace web | 204 } // namespace web |
| OLD | NEW |