Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1476)

Unified Diff: android_webview/native/aw_media_url_interceptor.cc

Issue 415043006: [Android WebView] AwMediaUrlInterceptor to handle media assets. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: android_webview/native/aw_media_url_interceptor.cc
diff --git a/android_webview/native/aw_media_url_interceptor.cc b/android_webview/native/aw_media_url_interceptor.cc
new file mode 100644
index 0000000000000000000000000000000000000000..e2f92554f04fdacbb157a4058308fab0ee04cc22
--- /dev/null
+++ b/android_webview/native/aw_media_url_interceptor.cc
@@ -0,0 +1,32 @@
+// Copyright (c) 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <string>
+
+#include "android_webview/common/url_constants.h"
+#include "android_webview/native/aw_assets.h"
+#include "android_webview/native/aw_media_url_interceptor.h"
+#include "base/strings/string_util.h"
+#include "content/public/common/url_constants.h"
+
+namespace android_webview {
+
+bool AwMediaUrlInterceptor::Intercept(const std::string& url,
+ int* fd, int64* offset, int64* size) const{
+ const std::string asset_file_prefix(
+ std::string(url::kFileScheme) +
+ std::string(url::kStandardSchemeSeparator) +
+ android_webview::kAndroidAssetPath);
+
+ if (StartsWithASCII(url, asset_file_prefix, true)) {
+ std::string filename(url);
+ ReplaceFirstSubstringAfterOffset(&filename, 0, asset_file_prefix, "");
+ return AwAssets::OpenAsset(filename, fd, offset, size);
+ }
+
+ return false;
+}
+
+} // namespace android_webview
+
« no previous file with comments | « android_webview/native/aw_media_url_interceptor.h ('k') | android_webview/native/aw_media_url_interceptor_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698