| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "extensions/shell/browser/shell_nacl_browser_delegate.h" | 5 #include "extensions/shell/browser/shell_nacl_browser_delegate.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/base_paths.h" | 9 #include "base/base_paths.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 const Extension* extension = | 152 const Extension* extension = |
| 153 info_map->extensions().GetExtensionOrAppByURL(file_url); | 153 info_map->extensions().GetExtensionOrAppByURL(file_url); |
| 154 if (!extension) | 154 if (!extension) |
| 155 return false; | 155 return false; |
| 156 | 156 |
| 157 // This is a short-cut which avoids calling a blocking file operation | 157 // This is a short-cut which avoids calling a blocking file operation |
| 158 // (GetFilePath()), so that this can be called on the IO thread. It only | 158 // (GetFilePath()), so that this can be called on the IO thread. It only |
| 159 // handles a subset of the urls. | 159 // handles a subset of the urls. |
| 160 if (!use_blocking_api) { | 160 if (!use_blocking_api) { |
| 161 if (file_url.SchemeIs(kExtensionScheme)) { | 161 if (file_url.SchemeIs(kExtensionScheme)) { |
| 162 std::string path = file_url.path(); | 162 std::string path = file_url.path().as_string(); |
| 163 base::TrimString(path, "/", &path); // Remove first slash | 163 base::TrimString(path, "/", &path); // Remove first slash |
| 164 *file_path = extension->path().AppendASCII(path); | 164 *file_path = extension->path().AppendASCII(path); |
| 165 return true; | 165 return true; |
| 166 } | 166 } |
| 167 return false; | 167 return false; |
| 168 } | 168 } |
| 169 | 169 |
| 170 // Check that the URL references a resource in the extension. | 170 // Check that the URL references a resource in the extension. |
| 171 // NOTE: app_shell does not support shared modules. | 171 // NOTE: app_shell does not support shared modules. |
| 172 ExtensionResource resource = extension->GetResource(file_url.path()); | 172 ExtensionResource resource = |
| 173 extension->GetResource(file_url.path().as_string()); |
| 173 if (resource.empty()) | 174 if (resource.empty()) |
| 174 return false; | 175 return false; |
| 175 | 176 |
| 176 // GetFilePath is a blocking function call. | 177 // GetFilePath is a blocking function call. |
| 177 const base::FilePath resource_file_path = resource.GetFilePath(); | 178 const base::FilePath resource_file_path = resource.GetFilePath(); |
| 178 if (resource_file_path.empty()) | 179 if (resource_file_path.empty()) |
| 179 return false; | 180 return false; |
| 180 | 181 |
| 181 *file_path = resource_file_path; | 182 *file_path = resource_file_path; |
| 182 return true; | 183 return true; |
| 183 } | 184 } |
| 184 | 185 |
| 185 content::BrowserPpapiHost::OnKeepaliveCallback | 186 content::BrowserPpapiHost::OnKeepaliveCallback |
| 186 ShellNaClBrowserDelegate::GetOnKeepaliveCallback() { | 187 ShellNaClBrowserDelegate::GetOnKeepaliveCallback() { |
| 187 return base::Bind(&OnKeepalive); | 188 return base::Bind(&OnKeepalive); |
| 188 } | 189 } |
| 189 | 190 |
| 190 bool ShellNaClBrowserDelegate::IsNonSfiModeAllowed( | 191 bool ShellNaClBrowserDelegate::IsNonSfiModeAllowed( |
| 191 const base::FilePath& profile_directory, | 192 const base::FilePath& profile_directory, |
| 192 const GURL& manifest_url) { | 193 const GURL& manifest_url) { |
| 193 return false; | 194 return false; |
| 194 } | 195 } |
| 195 | 196 |
| 196 } // namespace extensions | 197 } // namespace extensions |
| OLD | NEW |