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

Unified Diff: chrome/browser/android/provider/chrome_browser_provider.cc

Issue 651193002: Remove NOTIFICATION_HISTORY_URL_VISITED (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@373326.2
Patch Set: Address comments Created 6 years, 2 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/provider/chrome_browser_provider.cc
diff --git a/chrome/browser/android/provider/chrome_browser_provider.cc b/chrome/browser/android/provider/chrome_browser_provider.cc
index ef625f143e000db783fad587a02c918af2250566..39b2fc5ccd414d08c908c9c1968a0998526e8c4b 100644
--- a/chrome/browser/android/provider/chrome_browser_provider.cc
+++ b/chrome/browser/android/provider/chrome_browser_provider.cc
@@ -1158,6 +1158,8 @@ ChromeBrowserProvider::ChromeBrowserProvider(JNIEnv* env, jobject obj)
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
profile_ = g_browser_process->profile_manager()->GetLastUsedProfile();
bookmark_model_ = BookmarkModelFactory::GetForProfile(profile_);
+ history_service_ =
+ HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS);
top_sites_ = profile_->GetTopSites();
service_.reset(new AndroidHistoryProviderService(profile_));
favicon_service_.reset(FaviconServiceFactory::GetForProfile(profile_,
@@ -1165,8 +1167,7 @@ ChromeBrowserProvider::ChromeBrowserProvider(JNIEnv* env, jobject obj)
// Registers the notifications we are interested.
bookmark_model_->AddObserver(this);
- notification_registrar_.Add(this, chrome::NOTIFICATION_HISTORY_URL_VISITED,
- content::NotificationService::AllSources());
+ history_service_->AddObserver(this);
notification_registrar_.Add(this, chrome::NOTIFICATION_HISTORY_URLS_DELETED,
content::NotificationService::AllSources());
notification_registrar_.Add(this,
@@ -1180,6 +1181,7 @@ ChromeBrowserProvider::ChromeBrowserProvider(JNIEnv* env, jobject obj)
ChromeBrowserProvider::~ChromeBrowserProvider() {
bookmark_model_->RemoveObserver(this);
+ history_service_->RemoveObserver(this);
Bernhard Bauer 2014/10/15 12:24:52 Maybe you could use a ScopedObserver to take care
sdefresne 2014/10/17 14:32:38 Done.
}
void ChromeBrowserProvider::Destroy(JNIEnv*, jobject) {
@@ -1603,17 +1605,28 @@ void ChromeBrowserProvider::BookmarkModelChanged() {
Java_ChromeBrowserProvider_onBookmarkChanged(env, obj.obj());
}
+void ChromeBrowserProvider::OnHistoryChanged() {
+ JNIEnv* env = AttachCurrentThread();
+ ScopedJavaLocalRef<jobject> obj = weak_java_provider_.get(env);
+ if (obj.is_null())
+ return;
+ Java_ChromeBrowserProvider_onHistoryChanged(env, obj.obj());
+}
+
+void ChromeBrowserProvider::OnURLVisited(HistoryService* history_service,
+ ui::PageTransition transition,
+ const history::URLRow& row,
+ const history::RedirectList& redirects,
+ base::Time visit_time) {
+ OnHistoryChanged();
+}
+
void ChromeBrowserProvider::Observe(
int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) {
- if (type == chrome::NOTIFICATION_HISTORY_URL_VISITED ||
- type == chrome::NOTIFICATION_HISTORY_URLS_DELETED) {
- JNIEnv* env = AttachCurrentThread();
- ScopedJavaLocalRef<jobject> obj = weak_java_provider_.get(env);
- if (obj.is_null())
- return;
- Java_ChromeBrowserProvider_onHistoryChanged(env, obj.obj());
+ if (type == chrome::NOTIFICATION_HISTORY_URLS_DELETED) {
+ OnHistoryChanged();
} else if (type ==
chrome::NOTIFICATION_HISTORY_KEYWORD_SEARCH_TERM_UPDATED) {
JNIEnv* env = AttachCurrentThread();

Powered by Google App Engine
This is Rietveld 408576698