OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/android/provider/chrome_browser_provider.h" | 5 #include "chrome/browser/android/provider/chrome_browser_provider.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 #include <list> | 8 #include <list> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 1154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1165 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1165 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
1166 profile_ = g_browser_process->profile_manager()->GetLastUsedProfile(); | 1166 profile_ = g_browser_process->profile_manager()->GetLastUsedProfile(); |
1167 bookmark_model_ = BookmarkModelFactory::GetForProfile(profile_); | 1167 bookmark_model_ = BookmarkModelFactory::GetForProfile(profile_); |
1168 top_sites_ = profile_->GetTopSites(); | 1168 top_sites_ = profile_->GetTopSites(); |
1169 service_.reset(new AndroidHistoryProviderService(profile_)); | 1169 service_.reset(new AndroidHistoryProviderService(profile_)); |
1170 | 1170 |
1171 // Registers the notifications we are interested. | 1171 // Registers the notifications we are interested. |
1172 bookmark_model_->AddObserver(this); | 1172 bookmark_model_->AddObserver(this); |
1173 history_service_observer_.Add( | 1173 history_service_observer_.Add( |
1174 HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS)); | 1174 HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS)); |
1175 notification_registrar_.Add(this, chrome::NOTIFICATION_HISTORY_URLS_DELETED, | |
1176 content::NotificationService::AllSources()); | |
1177 notification_registrar_.Add(this, | 1175 notification_registrar_.Add(this, |
1178 chrome::NOTIFICATION_HISTORY_KEYWORD_SEARCH_TERM_UPDATED, | 1176 chrome::NOTIFICATION_HISTORY_KEYWORD_SEARCH_TERM_UPDATED, |
1179 content::NotificationService::AllSources()); | 1177 content::NotificationService::AllSources()); |
1180 TemplateURLService* template_service = | 1178 TemplateURLService* template_service = |
1181 TemplateURLServiceFactory::GetForProfile(profile_); | 1179 TemplateURLServiceFactory::GetForProfile(profile_); |
1182 if (!template_service->loaded()) | 1180 if (!template_service->loaded()) |
1183 template_service->Load(); | 1181 template_service->Load(); |
1184 } | 1182 } |
1185 | 1183 |
1186 ChromeBrowserProvider::~ChromeBrowserProvider() { | 1184 ChromeBrowserProvider::~ChromeBrowserProvider() { |
1187 bookmark_model_->RemoveObserver(this); | 1185 bookmark_model_->RemoveObserver(this); |
1188 } | 1186 } |
1189 | 1187 |
1190 void ChromeBrowserProvider::Destroy(JNIEnv*, jobject) { | 1188 void ChromeBrowserProvider::Destroy(JNIEnv*, jobject) { |
1189 history_service_observer_.RemoveAll(); | |
1191 delete this; | 1190 delete this; |
1192 } | 1191 } |
1193 | 1192 |
1194 // ------------- Provider public APIs ------------- // | 1193 // ------------- Provider public APIs ------------- // |
1195 | 1194 |
1196 jlong ChromeBrowserProvider::AddBookmark(JNIEnv* env, | 1195 jlong ChromeBrowserProvider::AddBookmark(JNIEnv* env, |
1197 jobject, | 1196 jobject, |
1198 jstring jurl, | 1197 jstring jurl, |
1199 jstring jtitle, | 1198 jstring jtitle, |
1200 jboolean is_folder, | 1199 jboolean is_folder, |
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1616 } | 1615 } |
1617 | 1616 |
1618 void ChromeBrowserProvider::OnURLVisited(HistoryService* history_service, | 1617 void ChromeBrowserProvider::OnURLVisited(HistoryService* history_service, |
1619 ui::PageTransition transition, | 1618 ui::PageTransition transition, |
1620 const history::URLRow& row, | 1619 const history::URLRow& row, |
1621 const history::RedirectList& redirects, | 1620 const history::RedirectList& redirects, |
1622 base::Time visit_time) { | 1621 base::Time visit_time) { |
1623 OnHistoryChanged(); | 1622 OnHistoryChanged(); |
1624 } | 1623 } |
1625 | 1624 |
1625 void ChromeBrowserProvider::OnURLsDeleted( | |
1626 HistoryService* history_service, | |
1627 const history::URLsDeletedDetails& deleted_details) { | |
1628 OnHistoryChanged(); | |
1629 } | |
1630 | |
1626 void ChromeBrowserProvider::Observe( | 1631 void ChromeBrowserProvider::Observe( |
1627 int type, | 1632 int type, |
1628 const content::NotificationSource& source, | 1633 const content::NotificationSource& source, |
1629 const content::NotificationDetails& details) { | 1634 const content::NotificationDetails& details) { |
1630 if (type == chrome::NOTIFICATION_HISTORY_URLS_DELETED) { | 1635 if (type == chrome::NOTIFICATION_HISTORY_KEYWORD_SEARCH_TERM_UPDATED) { |
sdefresne
2014/12/04 17:21:12
Since this is now the last notification that use c
nshaik
2014/12/07 09:34:49
Done.
| |
1631 OnHistoryChanged(); | |
1632 } else if (type == | |
1633 chrome::NOTIFICATION_HISTORY_KEYWORD_SEARCH_TERM_UPDATED) { | |
1634 JNIEnv* env = AttachCurrentThread(); | 1636 JNIEnv* env = AttachCurrentThread(); |
1635 ScopedJavaLocalRef<jobject> obj = weak_java_provider_.get(env); | 1637 ScopedJavaLocalRef<jobject> obj = weak_java_provider_.get(env); |
1636 if (obj.is_null()) | 1638 if (obj.is_null()) |
1637 return; | 1639 return; |
1638 Java_ChromeBrowserProvider_onSearchTermChanged(env, obj.obj()); | 1640 Java_ChromeBrowserProvider_onSearchTermChanged(env, obj.obj()); |
1639 } | 1641 } |
1640 } | 1642 } |
OLD | NEW |