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

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/FileProviderHelper.java

Issue 2772343003: Android: Remove GetApplicationContext part 1 (Closed)
Patch Set: rebase Created 3 years, 8 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 unified diff | Download patch
OLDNEW
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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698