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

Side by Side Diff: chrome/browser/android/provider/chrome_browser_provider.cc

Issue 773103004: Remove NOTIFICATION_HISTORY_URLS_DELETED (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address review comments Created 6 years 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
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
11 #include "base/android/jni_android.h" 11 #include "base/android/jni_android.h"
12 #include "base/android/jni_array.h" 12 #include "base/android/jni_array.h"
13 #include "base/android/jni_string.h" 13 #include "base/android/jni_string.h"
14 #include "base/logging.h" 14 #include "base/logging.h"
15 #include "base/memory/ref_counted_memory.h" 15 #include "base/memory/ref_counted_memory.h"
16 #include "base/strings/utf_string_conversions.h" 16 #include "base/strings/utf_string_conversions.h"
17 #include "base/task/cancelable_task_tracker.h" 17 #include "base/task/cancelable_task_tracker.h"
18 #include "base/time/time.h" 18 #include "base/time/time.h"
19 #include "chrome/browser/android/provider/blocking_ui_thread_async_request.h" 19 #include "chrome/browser/android/provider/blocking_ui_thread_async_request.h"
20 #include "chrome/browser/android/provider/bookmark_model_observer_task.h" 20 #include "chrome/browser/android/provider/bookmark_model_observer_task.h"
21 #include "chrome/browser/android/provider/run_on_ui_thread_blocking.h" 21 #include "chrome/browser/android/provider/run_on_ui_thread_blocking.h"
22 #include "chrome/browser/bookmarks/bookmark_model_factory.h" 22 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
23 #include "chrome/browser/bookmarks/chrome_bookmark_client.h" 23 #include "chrome/browser/bookmarks/chrome_bookmark_client.h"
24 #include "chrome/browser/bookmarks/chrome_bookmark_client_factory.h" 24 #include "chrome/browser/bookmarks/chrome_bookmark_client_factory.h"
25 #include "chrome/browser/browser_process.h" 25 #include "chrome/browser/browser_process.h"
26 #include "chrome/browser/chrome_notification_types.h" 26 #include "chrome/browser/chrome_notification_types.h"
27 #include "chrome/browser/favicon/favicon_service.h" 27 #include "chrome/browser/favicon/favicon_service.h"
28 #include "chrome/browser/favicon/favicon_service_factory.h" 28 #include "chrome/browser/favicon/favicon_service_factory.h"
29 #include "chrome/browser/history/android/sqlite_cursor.h" 29 #include "chrome/browser/history/android/sqlite_cursor.h"
30 #include "chrome/browser/history/history_service.h"
30 #include "chrome/browser/history/history_service_factory.h" 31 #include "chrome/browser/history/history_service_factory.h"
31 #include "chrome/browser/history/top_sites.h" 32 #include "chrome/browser/history/top_sites.h"
32 #include "chrome/browser/profiles/profile.h" 33 #include "chrome/browser/profiles/profile.h"
33 #include "chrome/browser/profiles/profile_manager.h" 34 #include "chrome/browser/profiles/profile_manager.h"
34 #include "chrome/browser/search_engines/template_url_service_factory.h" 35 #include "chrome/browser/search_engines/template_url_service_factory.h"
35 #include "components/bookmarks/browser/bookmark_model.h" 36 #include "components/bookmarks/browser/bookmark_model.h"
36 #include "components/bookmarks/browser/bookmark_utils.h" 37 #include "components/bookmarks/browser/bookmark_utils.h"
37 #include "components/history/core/android/android_history_types.h" 38 #include "components/history/core/android/android_history_types.h"
38 #include "components/search_engines/template_url.h" 39 #include "components/search_engines/template_url.h"
39 #include "components/search_engines/template_url_service.h" 40 #include "components/search_engines/template_url_service.h"
(...skipping 1125 matching lines...) Expand 10 before | Expand all | Expand 10 after
1165 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 1166 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1166 profile_ = g_browser_process->profile_manager()->GetLastUsedProfile(); 1167 profile_ = g_browser_process->profile_manager()->GetLastUsedProfile();
1167 bookmark_model_ = BookmarkModelFactory::GetForProfile(profile_); 1168 bookmark_model_ = BookmarkModelFactory::GetForProfile(profile_);
1168 top_sites_ = profile_->GetTopSites(); 1169 top_sites_ = profile_->GetTopSites();
1169 service_.reset(new AndroidHistoryProviderService(profile_)); 1170 service_.reset(new AndroidHistoryProviderService(profile_));
1170 1171
1171 // Registers the notifications we are interested. 1172 // Registers the notifications we are interested.
1172 bookmark_model_->AddObserver(this); 1173 bookmark_model_->AddObserver(this);
1173 history_service_observer_.Add( 1174 history_service_observer_.Add(
1174 HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS)); 1175 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, 1176 notification_registrar_.Add(this,
1178 chrome::NOTIFICATION_HISTORY_KEYWORD_SEARCH_TERM_UPDATED, 1177 chrome::NOTIFICATION_HISTORY_KEYWORD_SEARCH_TERM_UPDATED,
1179 content::NotificationService::AllSources()); 1178 content::NotificationService::AllSources());
1180 TemplateURLService* template_service = 1179 TemplateURLService* template_service =
1181 TemplateURLServiceFactory::GetForProfile(profile_); 1180 TemplateURLServiceFactory::GetForProfile(profile_);
1182 if (!template_service->loaded()) 1181 if (!template_service->loaded())
1183 template_service->Load(); 1182 template_service->Load();
1184 } 1183 }
1185 1184
1186 ChromeBrowserProvider::~ChromeBrowserProvider() { 1185 ChromeBrowserProvider::~ChromeBrowserProvider() {
1187 bookmark_model_->RemoveObserver(this); 1186 bookmark_model_->RemoveObserver(this);
1188 } 1187 }
1189 1188
1190 void ChromeBrowserProvider::Destroy(JNIEnv*, jobject) { 1189 void ChromeBrowserProvider::Destroy(JNIEnv*, jobject) {
1190 history_service_observer_.RemoveAll();
1191 delete this; 1191 delete this;
1192 } 1192 }
1193 1193
1194 // ------------- Provider public APIs ------------- // 1194 // ------------- Provider public APIs ------------- //
1195 1195
1196 jlong ChromeBrowserProvider::AddBookmark(JNIEnv* env, 1196 jlong ChromeBrowserProvider::AddBookmark(JNIEnv* env,
1197 jobject, 1197 jobject,
1198 jstring jurl, 1198 jstring jurl,
1199 jstring jtitle, 1199 jstring jtitle,
1200 jboolean is_folder, 1200 jboolean is_folder,
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after
1616 } 1616 }
1617 1617
1618 void ChromeBrowserProvider::OnURLVisited(HistoryService* history_service, 1618 void ChromeBrowserProvider::OnURLVisited(HistoryService* history_service,
1619 ui::PageTransition transition, 1619 ui::PageTransition transition,
1620 const history::URLRow& row, 1620 const history::URLRow& row,
1621 const history::RedirectList& redirects, 1621 const history::RedirectList& redirects,
1622 base::Time visit_time) { 1622 base::Time visit_time) {
1623 OnHistoryChanged(); 1623 OnHistoryChanged();
1624 } 1624 }
1625 1625
1626 void ChromeBrowserProvider::OnURLsDeleted(HistoryService* history_service,
1627 bool all_history,
1628 bool expired,
1629 const history::URLRows& deleted_rows,
1630 const std::set<GURL>& favicon_urls) {
1631 OnHistoryChanged();
1632 }
1633
1626 void ChromeBrowserProvider::Observe( 1634 void ChromeBrowserProvider::Observe(
1627 int type, 1635 int type,
1628 const content::NotificationSource& source, 1636 const content::NotificationSource& source,
1629 const content::NotificationDetails& details) { 1637 const content::NotificationDetails& details) {
1630 if (type == chrome::NOTIFICATION_HISTORY_URLS_DELETED) { 1638 DCHECK_EQ(type, chrome::NOTIFICATION_HISTORY_KEYWORD_SEARCH_TERM_UPDATED);
1631 OnHistoryChanged();
1632 } else if (type ==
1633 chrome::NOTIFICATION_HISTORY_KEYWORD_SEARCH_TERM_UPDATED) {
1634 JNIEnv* env = AttachCurrentThread(); 1639 JNIEnv* env = AttachCurrentThread();
1635 ScopedJavaLocalRef<jobject> obj = weak_java_provider_.get(env); 1640 ScopedJavaLocalRef<jobject> obj = weak_java_provider_.get(env);
1636 if (obj.is_null()) 1641 if (obj.is_null())
1637 return; 1642 return;
1638 Java_ChromeBrowserProvider_onSearchTermChanged(env, obj.obj()); 1643 Java_ChromeBrowserProvider_onSearchTermChanged(env, obj.obj());
1639 }
1640 } 1644 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698