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

Unified Diff: ui/base/clipboard/clipboard_android.cc

Issue 2901143002: Remove entry from map_ of ClipboardMap when jstr is null or empty (Closed)
Patch Set: remove entry from map Created 3 years, 7 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
}
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698