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

Unified Diff: chrome/browser/android/preferences/clipboard_android.cc

Issue 2832263002: Clipboard Android - Store and Read Last Modified Time from Prefs (Closed)
Patch Set: final comments 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/android/preferences/clipboard_android.cc
diff --git a/chrome/browser/android/preferences/clipboard_android.cc b/chrome/browser/android/preferences/clipboard_android.cc
new file mode 100644
index 0000000000000000000000000000000000000000..9e5882f8bad43a47f2f3ed2eda7e99b5e3cc6350
--- /dev/null
+++ b/chrome/browser/android/preferences/clipboard_android.cc
@@ -0,0 +1,43 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/android/preferences/clipboard_android.h"
+
+#include "base/bind.h"
+#include "base/callback.h"
+#include "base/time/time.h"
+#include "chrome/common/pref_names.h"
+#include "components/prefs/pref_registry_simple.h"
+#include "components/prefs/pref_service.h"
+#include "ui/base/clipboard/clipboard.h"
+#include "ui/base/clipboard/clipboard_android.h"
+
+namespace {
+
+void HandleClipboardModified(PrefService* local_state, base::Time time) {
+ local_state->SetInt64(prefs::kClipboardLastModifiedTime,
+ time.ToInternalValue());
+}
+
+} // namespace
+
+namespace android {
+
+void RegisterClipboardAndroidPrefs(PrefRegistrySimple* registry) {
+ registry->RegisterInt64Pref(prefs::kClipboardLastModifiedTime, 0u);
+}
+
+void InitClipboardAndroidFromLocalState(PrefService* local_state) {
+ DCHECK(local_state);
+ // Given the context, the cast is guaranteed to succeed.
+ ui::ClipboardAndroid* clipboard =
+ static_cast<ui::ClipboardAndroid*>(ui::Clipboard::GetForCurrentThread());
+ clipboard->SetLastModifiedTimeWithoutRunningCallback(
+ base::Time::FromInternalValue(
+ local_state->GetInt64(prefs::kClipboardLastModifiedTime)));
+ clipboard->SetModifiedCallback(
+ base::Bind(&HandleClipboardModified, local_state));
+}
+
+} // namespace android
« no previous file with comments | « chrome/browser/android/preferences/clipboard_android.h ('k') | chrome/browser/chrome_browser_main_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698