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

Side by Side Diff: chrome/browser/ui/webui/browsing_history_handler.cc

Issue 2354613002: [Sync] Fix namespaces for the browser_sync component. (Closed)
Patch Set: Address comments. Created 4 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/ui/webui/browsing_history_handler.h" 5 #include "chrome/browser/ui/webui/browsing_history_handler.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <set> 9 #include <set>
10 #include <utility> 10 #include <utility>
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 } 129 }
130 130
131 // Returns true if |entry| represents a local visit that had no corresponding 131 // Returns true if |entry| represents a local visit that had no corresponding
132 // visit on the server. 132 // visit on the server.
133 bool IsLocalOnlyResult(const BrowsingHistoryHandler::HistoryEntry& entry) { 133 bool IsLocalOnlyResult(const BrowsingHistoryHandler::HistoryEntry& entry) {
134 return entry.entry_type == BrowsingHistoryHandler::HistoryEntry::LOCAL_ENTRY; 134 return entry.entry_type == BrowsingHistoryHandler::HistoryEntry::LOCAL_ENTRY;
135 } 135 }
136 136
137 // Gets the name and type of a device for the given sync client ID. 137 // Gets the name and type of a device for the given sync client ID.
138 // |name| and |type| are out parameters. 138 // |name| and |type| are out parameters.
139 void GetDeviceNameAndType(const ProfileSyncService* sync_service, 139 void GetDeviceNameAndType(const browser_sync::ProfileSyncService* sync_service,
140 const std::string& client_id, 140 const std::string& client_id,
141 std::string* name, 141 std::string* name,
142 std::string* type) { 142 std::string* type) {
143 // DeviceInfoTracker must be syncing in order for remote history entries to 143 // DeviceInfoTracker must be syncing in order for remote history entries to
144 // be available. 144 // be available.
145 DCHECK(sync_service); 145 DCHECK(sync_service);
146 DCHECK(sync_service->GetDeviceInfoTracker()); 146 DCHECK(sync_service->GetDeviceInfoTracker());
147 DCHECK(sync_service->GetDeviceInfoTracker()->IsSyncing()); 147 DCHECK(sync_service->GetDeviceInfoTracker()->IsSyncing());
148 148
149 std::unique_ptr<sync_driver::DeviceInfo> device_info = 149 std::unique_ptr<sync_driver::DeviceInfo> device_info =
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 226
227 result->SetString("title", 227 result->SetString("title",
228 limit_title_length ? title_to_set.substr(0, kShortTitleLength) 228 limit_title_length ? title_to_set.substr(0, kShortTitleLength)
229 : title_to_set); 229 : title_to_set);
230 } 230 }
231 231
232 std::unique_ptr<base::DictionaryValue> 232 std::unique_ptr<base::DictionaryValue>
233 BrowsingHistoryHandler::HistoryEntry::ToValue( 233 BrowsingHistoryHandler::HistoryEntry::ToValue(
234 BookmarkModel* bookmark_model, 234 BookmarkModel* bookmark_model,
235 SupervisedUserService* supervised_user_service, 235 SupervisedUserService* supervised_user_service,
236 const ProfileSyncService* sync_service, 236 const browser_sync::ProfileSyncService* sync_service,
237 bool limit_title_length) const { 237 bool limit_title_length) const {
238 std::unique_ptr<base::DictionaryValue> result(new base::DictionaryValue()); 238 std::unique_ptr<base::DictionaryValue> result(new base::DictionaryValue());
239 SetUrlAndTitle(result.get(), limit_title_length); 239 SetUrlAndTitle(result.get(), limit_title_length);
240 240
241 base::string16 domain = url_formatter::IDNToUnicode(url.host()); 241 base::string16 domain = url_formatter::IDNToUnicode(url.host());
242 // When the domain is empty, use the scheme instead. This allows for a 242 // When the domain is empty, use the scheme instead. This allows for a
243 // sensible treatment of e.g. file: URLs when group by domain is on. 243 // sensible treatment of e.g. file: URLs when group by domain is on.
244 if (domain.empty()) 244 if (domain.empty())
245 domain = base::UTF8ToUTF16(url.scheme() + ":"); 245 domain = base::UTF8ToUTF16(url.scheme() + ":");
246 246
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 365
366 // Get notifications when web history is deleted. 366 // Get notifications when web history is deleted.
367 history::WebHistoryService* web_history = 367 history::WebHistoryService* web_history =
368 WebHistoryServiceFactory::GetForProfile(profile); 368 WebHistoryServiceFactory::GetForProfile(profile);
369 if (web_history) { 369 if (web_history) {
370 web_history_service_observer_.Add(web_history); 370 web_history_service_observer_.Add(web_history);
371 } else { 371 } else {
372 // If |web_history| is not available, it means that the history sync is 372 // If |web_history| is not available, it means that the history sync is
373 // disabled. Observe |sync_service| so that we can attach the listener 373 // disabled. Observe |sync_service| so that we can attach the listener
374 // in case it gets enabled later. 374 // in case it gets enabled later.
375 ProfileSyncService* sync_service = 375 browser_sync::ProfileSyncService* sync_service =
376 ProfileSyncServiceFactory::GetForProfile(profile); 376 ProfileSyncServiceFactory::GetForProfile(profile);
377 if (sync_service) 377 if (sync_service)
378 sync_service_observer_.Add(sync_service); 378 sync_service_observer_.Add(sync_service);
379 } 379 }
380 380
381 web_ui()->RegisterMessageCallback("queryHistory", 381 web_ui()->RegisterMessageCallback("queryHistory",
382 base::Bind(&BrowsingHistoryHandler::HandleQueryHistory, 382 base::Bind(&BrowsingHistoryHandler::HandleQueryHistory,
383 base::Unretained(this))); 383 base::Unretained(this)));
384 web_ui()->RegisterMessageCallback("removeVisits", 384 web_ui()->RegisterMessageCallback("removeVisits",
385 base::Bind(&BrowsingHistoryHandler::HandleRemoveVisits, 385 base::Bind(&BrowsingHistoryHandler::HandleRemoveVisits,
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
759 void BrowsingHistoryHandler::ReturnResultsToFrontEnd() { 759 void BrowsingHistoryHandler::ReturnResultsToFrontEnd() {
760 Profile* profile = Profile::FromWebUI(web_ui()); 760 Profile* profile = Profile::FromWebUI(web_ui());
761 BookmarkModel* bookmark_model = 761 BookmarkModel* bookmark_model =
762 BookmarkModelFactory::GetForBrowserContext(profile); 762 BookmarkModelFactory::GetForBrowserContext(profile);
763 SupervisedUserService* supervised_user_service = NULL; 763 SupervisedUserService* supervised_user_service = NULL;
764 #if defined(ENABLE_SUPERVISED_USERS) 764 #if defined(ENABLE_SUPERVISED_USERS)
765 if (profile->IsSupervised()) 765 if (profile->IsSupervised())
766 supervised_user_service = 766 supervised_user_service =
767 SupervisedUserServiceFactory::GetForProfile(profile); 767 SupervisedUserServiceFactory::GetForProfile(profile);
768 #endif 768 #endif
769 ProfileSyncService* sync_service = 769 browser_sync::ProfileSyncService* sync_service =
770 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile); 770 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile);
771 771
772 // Combine the local and remote results into |query_results_|, and remove 772 // Combine the local and remote results into |query_results_|, and remove
773 // any duplicates. 773 // any duplicates.
774 if (!web_history_query_results_.empty()) { 774 if (!web_history_query_results_.empty()) {
775 int local_result_count = query_results_.size(); 775 int local_result_count = query_results_.size();
776 query_results_.insert(query_results_.end(), 776 query_results_.insert(query_results_.end(),
777 web_history_query_results_.begin(), 777 web_history_query_results_.begin(),
778 web_history_query_results_.end()); 778 web_history_query_results_.end());
779 MergeDuplicateResults(&query_results_); 779 MergeDuplicateResults(&query_results_);
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
1004 bool expired, 1004 bool expired,
1005 const history::URLRows& deleted_rows, 1005 const history::URLRows& deleted_rows,
1006 const std::set<GURL>& favicon_urls) { 1006 const std::set<GURL>& favicon_urls) {
1007 if (all_history || DeletionsDiffer(deleted_rows, urls_to_be_deleted_)) 1007 if (all_history || DeletionsDiffer(deleted_rows, urls_to_be_deleted_))
1008 web_ui()->CallJavascriptFunctionUnsafe("historyDeleted"); 1008 web_ui()->CallJavascriptFunctionUnsafe("historyDeleted");
1009 } 1009 }
1010 1010
1011 void BrowsingHistoryHandler::OnWebHistoryDeleted() { 1011 void BrowsingHistoryHandler::OnWebHistoryDeleted() {
1012 web_ui()->CallJavascriptFunctionUnsafe("historyDeleted"); 1012 web_ui()->CallJavascriptFunctionUnsafe("historyDeleted");
1013 } 1013 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/browsing_history_handler.h ('k') | chrome/browser/ui/webui/browsing_history_handler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698