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.share; | 5 package org.chromium.chrome.browser.share; |
6 | 6 |
7 import android.annotation.TargetApi; | 7 import android.annotation.TargetApi; |
8 import android.app.Activity; | 8 import android.app.Activity; |
9 import android.app.PendingIntent; | 9 import android.app.PendingIntent; |
10 import android.content.BroadcastReceiver; | 10 import android.content.BroadcastReceiver; |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 sFakeIntentReceiverForTesting.fireIntent(context, intent); | 112 sFakeIntentReceiverForTesting.fireIntent(context, intent); |
113 } else { | 113 } else { |
114 activity.startActivity(intent); | 114 activity.startActivity(intent); |
115 } | 115 } |
116 } | 116 } |
117 | 117 |
118 @SuppressFBWarnings("NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE") | 118 @SuppressFBWarnings("NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE") |
119 private static void deleteShareImageFiles(File file) { | 119 private static void deleteShareImageFiles(File file) { |
120 if (!file.exists()) return; | 120 if (!file.exists()) return; |
121 if (file.isDirectory()) { | 121 if (file.isDirectory()) { |
122 for (File f : file.listFiles()) deleteShareImageFiles(f); | 122 File[] file_list = file.listFiles(); |
| 123 if (file_list != null) { |
| 124 for (File f : file_list) deleteShareImageFiles(f); |
| 125 } |
123 } | 126 } |
124 if (!file.delete()) { | 127 if (!file.delete()) { |
125 Log.w(TAG, "Failed to delete share image file: %s", file.getAbsolute
Path()); | 128 Log.w(TAG, "Failed to delete share image file: %s", file.getAbsolute
Path()); |
126 } | 129 } |
127 } | 130 } |
128 | 131 |
129 /** | 132 /** |
130 * Force the use of a Chrome-specific intent chooser, not the system chooser
. | 133 * Force the use of a Chrome-specific intent chooser, not the system chooser
. |
131 * | 134 * |
132 * This emulates the behavior on pre Lollipop-MR1 systems, where the system
chooser is not | 135 * This emulates the behavior on pre Lollipop-MR1 systems, where the system
chooser is not |
(...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
700 */ | 703 */ |
701 @Nullable | 704 @Nullable |
702 public static ComponentName getLastShareComponentName() { | 705 public static ComponentName getLastShareComponentName() { |
703 SharedPreferences preferences = ContextUtils.getAppSharedPreferences(); | 706 SharedPreferences preferences = ContextUtils.getAppSharedPreferences(); |
704 String packageName = preferences.getString(PACKAGE_NAME_KEY, null); | 707 String packageName = preferences.getString(PACKAGE_NAME_KEY, null); |
705 String className = preferences.getString(CLASS_NAME_KEY, null); | 708 String className = preferences.getString(CLASS_NAME_KEY, null); |
706 if (packageName == null || className == null) return null; | 709 if (packageName == null || className == null) return null; |
707 return new ComponentName(packageName, className); | 710 return new ComponentName(packageName, className); |
708 } | 711 } |
709 } | 712 } |
OLD | NEW |