Chromium Code Reviews| Index: chrome/browser/android/chrome_backup_watcher.cc |
| diff --git a/chrome/browser/android/chrome_backup_watcher.cc b/chrome/browser/android/chrome_backup_watcher.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..321b137e559bd501db31fc530c4fb2408d114de2 |
| --- /dev/null |
| +++ b/chrome/browser/android/chrome_backup_watcher.cc |
| @@ -0,0 +1,36 @@ |
| +// Copyright 2016 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/chrome_backup_agent.h" |
| +#include "chrome/browser/android/chrome_backup_watcher.h" |
| +#include "chrome/browser/profiles/profile.h" |
| +#include "jni/ChromeBackupWatcher_jni.h" |
| + |
| +namespace chrome { |
| +namespace android { |
| + |
| +namespace { |
| + |
| +void BackupPrefsChanged( |
| + const base::android::ScopedJavaGlobalRef<jobject>& java_watcher) { |
| + Java_ChromeBackupWatcher_onBackupPrefsChanged( |
| + base::android::AttachCurrentThread(), java_watcher); |
| +} |
|
Bernhard Bauer
2016/11/14 10:05:39
Add an empty line after this one.
aberent
2016/11/14 17:23:40
Done.
|
| +} |
| + |
| +ChromeBackupWatcher::ChromeBackupWatcher(Profile* profile) |
| + : registrar_(new PrefChangeRegistrar) { |
| + JNIEnv* env = base::android::AttachCurrentThread(); |
| + // Create the Java class, and start watching the Android (Java) preferences |
| + java_watcher_.Reset(Java_ChromeBackupWatcher_createChromeBackupWatcher(env)); |
| + // Now watch the Chrome C++ preferences |
| + registrar_->Init(profile->GetPrefs()); |
| + base::Closure callback = base::Bind(&BackupPrefsChanged, java_watcher_); |
|
Bernhard Bauer
2016/11/14 10:05:39
In the interest of future-proofing the code, use a
aberent
2016/11/14 17:23:40
Done.
|
| + for (const std::string pref_name : GetBackupPrefNames()) { |
| + registrar_->Add(pref_name, callback); |
| + } |
| +} |
| + |
| +} // namespace android |
| +} // namespace chrome |