Index: ui/base/clipboard/clipboard_android.cc |
diff --git a/ui/base/clipboard/clipboard_android.cc b/ui/base/clipboard/clipboard_android.cc |
index 141a0ac5e67847eec12c67eb2ee9a36eaa8117c9..849493e10feb8590a52ff1b29925024db3ddfc3f 100644 |
--- a/ui/base/clipboard/clipboard_android.cc |
+++ b/ui/base/clipboard/clipboard_android.cc |
@@ -184,16 +184,21 @@ void ClipboardMap::SetLastModifiedTimeWithoutRunningCallback(base::Time time) { |
last_modified_time_ = time; |
} |
-// Add a key:jstr pair to map, but only if jstr is not null, and also |
-// not empty. |
+// Add a key:jstr pair to map, if jstr is null or is empty, then remove that |
+// entry. |
void AddMapEntry(JNIEnv* env, |
std::map<std::string, std::string>* map, |
const char* key, |
const ScopedJavaLocalRef<jstring>& jstr) { |
- if (!jstr.is_null()) { |
- std::string str = ConvertJavaStringToUTF8(env, jstr.obj()); |
- if (!str.empty()) |
- (*map)[key] = str; |
+ if (jstr.is_null()) { |
+ map->erase(key); |
+ return; |
+ } |
+ std::string str = ConvertJavaStringToUTF8(env, jstr.obj()); |
+ if (!str.empty()) { |
+ (*map)[key] = str; |
+ } else { |
+ map->erase(key); |
} |
} |