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

Side by Side 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, 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/android/preferences/clipboard_android.h"
6
7 #include "base/bind.h"
8 #include "base/callback.h"
9 #include "base/time/time.h"
10 #include "chrome/common/pref_names.h"
11 #include "components/prefs/pref_registry_simple.h"
12 #include "components/prefs/pref_service.h"
13 #include "ui/base/clipboard/clipboard.h"
14 #include "ui/base/clipboard/clipboard_android.h"
15
16 namespace {
17
18 void HandleClipboardModified(PrefService* local_state, base::Time time) {
19 local_state->SetInt64(prefs::kClipboardLastModifiedTime,
20 time.ToInternalValue());
21 }
22
23 } // namespace
24
25 namespace android {
26
27 void RegisterClipboardAndroidPrefs(PrefRegistrySimple* registry) {
28 registry->RegisterInt64Pref(prefs::kClipboardLastModifiedTime, 0u);
29 }
30
31 void InitClipboardAndroidFromLocalState(PrefService* local_state) {
32 DCHECK(local_state);
33 // Given the context, the cast is guaranteed to succeed.
34 ui::ClipboardAndroid* clipboard =
35 static_cast<ui::ClipboardAndroid*>(ui::Clipboard::GetForCurrentThread());
36 clipboard->SetLastModifiedTimeWithoutRunningCallback(
37 base::Time::FromInternalValue(
38 local_state->GetInt64(prefs::kClipboardLastModifiedTime)));
39 clipboard->SetModifiedCallback(
40 base::Bind(&HandleClipboardModified, local_state));
41 }
42
43 } // namespace android
OLDNEW
« 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