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