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 package org.chromium.chrome.browser; | 5 package org.chromium.chrome.browser; |
6 | 6 |
7 import android.content.Context; | 7 import android.content.Context; |
8 import android.net.Uri; | 8 import android.net.Uri; |
9 import android.support.v4.content.FileProvider; | 9 import android.support.v4.content.FileProvider; |
10 | 10 |
11 import org.chromium.base.ContentUriUtils; | 11 import org.chromium.base.ContentUriUtils; |
| 12 import org.chromium.base.ContextUtils; |
12 | 13 |
13 import java.io.File; | 14 import java.io.File; |
14 | 15 |
15 /** | 16 /** |
16 * Utilities for translating a file into content URI. | 17 * Utilities for translating a file into content URI. |
17 */ | 18 */ |
18 public class FileProviderHelper implements ContentUriUtils.FileProviderUtil { | 19 public class FileProviderHelper implements ContentUriUtils.FileProviderUtil { |
19 // Keep this variable in sync with the value defined in file_paths.xml. | 20 // Keep this variable in sync with the value defined in file_paths.xml. |
20 private static final String API_AUTHORITY_SUFFIX = ".FileProvider"; | 21 private static final String API_AUTHORITY_SUFFIX = ".FileProvider"; |
21 | 22 |
22 @Override | 23 @Override |
23 public Uri getContentUriFromFile(Context context, File file) { | 24 public Uri getContentUriFromFile(File file) { |
24 return FileProvider.getUriForFile(context, | 25 Context appContext = ContextUtils.getApplicationContext(); |
25 context.getPackageName() + API_AUTHORITY_SUFFIX, file); | 26 return FileProvider.getUriForFile( |
| 27 appContext, appContext.getPackageName() + API_AUTHORITY_SUFFIX,
file); |
26 } | 28 } |
27 } | 29 } |
OLD | NEW |