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 1159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1170 favicon_service_ = FaviconServiceFactory::GetForProfile( | 1170 favicon_service_ = FaviconServiceFactory::GetForProfile( |
1171 profile_, Profile::EXPLICIT_ACCESS), | 1171 profile_, Profile::EXPLICIT_ACCESS), |
1172 service_.reset(new AndroidHistoryProviderService(profile_)); | 1172 service_.reset(new AndroidHistoryProviderService(profile_)); |
1173 | 1173 |
1174 // Registers the notifications we are interested. | 1174 // Registers the notifications we are interested. |
1175 bookmark_model_->AddObserver(this); | 1175 bookmark_model_->AddObserver(this); |
1176 history_service_observer_.Add( | 1176 history_service_observer_.Add( |
1177 HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS)); | 1177 HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS)); |
1178 notification_registrar_.Add(this, chrome::NOTIFICATION_HISTORY_URLS_DELETED, | 1178 notification_registrar_.Add(this, chrome::NOTIFICATION_HISTORY_URLS_DELETED, |
1179 content::NotificationService::AllSources()); | 1179 content::NotificationService::AllSources()); |
1180 notification_registrar_.Add(this, | |
1181 chrome::NOTIFICATION_HISTORY_KEYWORD_SEARCH_TERM_UPDATED, | |
1182 content::NotificationService::AllSources()); | |
1183 TemplateURLService* template_service = | 1180 TemplateURLService* template_service = |
1184 TemplateURLServiceFactory::GetForProfile(profile_); | 1181 TemplateURLServiceFactory::GetForProfile(profile_); |
1185 if (!template_service->loaded()) | 1182 if (!template_service->loaded()) |
1186 template_service->Load(); | 1183 template_service->Load(); |
1187 } | 1184 } |
1188 | 1185 |
1189 ChromeBrowserProvider::~ChromeBrowserProvider() { | 1186 ChromeBrowserProvider::~ChromeBrowserProvider() { |
1190 bookmark_model_->RemoveObserver(this); | 1187 bookmark_model_->RemoveObserver(this); |
1191 } | 1188 } |
1192 | 1189 |
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1620 } | 1617 } |
1621 | 1618 |
1622 void ChromeBrowserProvider::OnURLVisited(HistoryService* history_service, | 1619 void ChromeBrowserProvider::OnURLVisited(HistoryService* history_service, |
1623 ui::PageTransition transition, | 1620 ui::PageTransition transition, |
1624 const history::URLRow& row, | 1621 const history::URLRow& row, |
1625 const history::RedirectList& redirects, | 1622 const history::RedirectList& redirects, |
1626 base::Time visit_time) { | 1623 base::Time visit_time) { |
1627 OnHistoryChanged(); | 1624 OnHistoryChanged(); |
1628 } | 1625 } |
1629 | 1626 |
| 1627 void ChromeBrowserProvider::OnKeywordSearchTermUpdated( |
| 1628 HistoryService* history_service, |
| 1629 const history::URLRow& row, |
| 1630 history::KeywordID keyword_id, |
| 1631 const base::string16& term) { |
| 1632 JNIEnv* env = AttachCurrentThread(); |
| 1633 ScopedJavaLocalRef<jobject> obj = weak_java_provider_.get(env); |
| 1634 if (obj.is_null()) |
| 1635 return; |
| 1636 Java_ChromeBrowserProvider_onSearchTermChanged(env, obj.obj()); |
| 1637 } |
| 1638 |
1630 void ChromeBrowserProvider::Observe( | 1639 void ChromeBrowserProvider::Observe( |
1631 int type, | 1640 int type, |
1632 const content::NotificationSource& source, | 1641 const content::NotificationSource& source, |
1633 const content::NotificationDetails& details) { | 1642 const content::NotificationDetails& details) { |
1634 if (type == chrome::NOTIFICATION_HISTORY_URLS_DELETED) { | 1643 DCHECK_EQ(type, chrome::NOTIFICATION_HISTORY_URLS_DELETED); |
1635 OnHistoryChanged(); | 1644 OnHistoryChanged(); |
1636 } else if (type == | |
1637 chrome::NOTIFICATION_HISTORY_KEYWORD_SEARCH_TERM_UPDATED) { | |
1638 JNIEnv* env = AttachCurrentThread(); | |
1639 ScopedJavaLocalRef<jobject> obj = weak_java_provider_.get(env); | |
1640 if (obj.is_null()) | |
1641 return; | |
1642 Java_ChromeBrowserProvider_onSearchTermChanged(env, obj.obj()); | |
1643 } | |
1644 } | 1645 } |
OLD | NEW |