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

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

Issue 335833003: Rename "managed (mode|user)" to "supervised user" (part 2) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review comments (+ a few other cleanups) Created 6 years, 6 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 | Annotate | Revision Log
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/ui/webui/history_ui.h" 5 #include "chrome/browser/ui/webui/history_ui.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 #include "grit/generated_resources.h" 51 #include "grit/generated_resources.h"
52 #include "grit/theme_resources.h" 52 #include "grit/theme_resources.h"
53 #include "net/base/escape.h" 53 #include "net/base/escape.h"
54 #include "net/base/net_util.h" 54 #include "net/base/net_util.h"
55 #include "sync/protocol/history_delete_directive_specifics.pb.h" 55 #include "sync/protocol/history_delete_directive_specifics.pb.h"
56 #include "ui/base/l10n/l10n_util.h" 56 #include "ui/base/l10n/l10n_util.h"
57 #include "ui/base/l10n/time_format.h" 57 #include "ui/base/l10n/time_format.h"
58 #include "ui/base/resource/resource_bundle.h" 58 #include "ui/base/resource/resource_bundle.h"
59 59
60 #if defined(ENABLE_MANAGED_USERS) 60 #if defined(ENABLE_MANAGED_USERS)
61 #include "chrome/browser/managed_mode/managed_mode_navigation_observer.h" 61 #include "chrome/browser/supervised_user/supervised_user_navigation_observer.h"
62 #include "chrome/browser/managed_mode/managed_mode_url_filter.h" 62 #include "chrome/browser/supervised_user/supervised_user_service.h"
63 #include "chrome/browser/managed_mode/managed_user_service.h" 63 #include "chrome/browser/supervised_user/supervised_user_service_factory.h"
64 #include "chrome/browser/managed_mode/managed_user_service_factory.h" 64 #include "chrome/browser/supervised_user/supervised_user_url_filter.h"
65 #endif 65 #endif
66 66
67 #if defined(OS_ANDROID) 67 #if defined(OS_ANDROID)
68 #include "chrome/browser/android/chromium_application.h" 68 #include "chrome/browser/android/chromium_application.h"
69 #endif 69 #endif
70 70
71 #if !defined(OS_ANDROID) && !defined(OS_IOS) 71 #if !defined(OS_ANDROID) && !defined(OS_IOS)
72 #include "chrome/browser/ui/webui/ntp/foreign_session_handler.h" 72 #include "chrome/browser/ui/webui/ntp/foreign_session_handler.h"
73 #include "chrome/browser/ui/webui/ntp/ntp_login_handler.h" 73 #include "chrome/browser/ui/webui/ntp/ntp_login_handler.h"
74 #endif 74 #endif
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 if (using_url_as_the_title) 304 if (using_url_as_the_title)
305 base::i18n::WrapStringWithLTRFormatting(&title_to_set); 305 base::i18n::WrapStringWithLTRFormatting(&title_to_set);
306 else 306 else
307 base::i18n::AdjustStringForLocaleDirection(&title_to_set); 307 base::i18n::AdjustStringForLocaleDirection(&title_to_set);
308 } 308 }
309 result->SetString("title", title_to_set); 309 result->SetString("title", title_to_set);
310 } 310 }
311 311
312 scoped_ptr<base::DictionaryValue> BrowsingHistoryHandler::HistoryEntry::ToValue( 312 scoped_ptr<base::DictionaryValue> BrowsingHistoryHandler::HistoryEntry::ToValue(
313 BookmarkModel* bookmark_model, 313 BookmarkModel* bookmark_model,
314 ManagedUserService* managed_user_service, 314 SupervisedUserService* supervised_user_service,
315 const ProfileSyncService* sync_service) const { 315 const ProfileSyncService* sync_service) const {
316 scoped_ptr<base::DictionaryValue> result(new base::DictionaryValue()); 316 scoped_ptr<base::DictionaryValue> result(new base::DictionaryValue());
317 SetUrlAndTitle(result.get()); 317 SetUrlAndTitle(result.get());
318 318
319 base::string16 domain = net::IDNToUnicode(url.host(), accept_languages); 319 base::string16 domain = net::IDNToUnicode(url.host(), accept_languages);
320 // When the domain is empty, use the scheme instead. This allows for a 320 // When the domain is empty, use the scheme instead. This allows for a
321 // sensible treatment of e.g. file: URLs when group by domain is on. 321 // sensible treatment of e.g. file: URLs when group by domain is on.
322 if (domain.empty()) 322 if (domain.empty())
323 domain = base::UTF8ToUTF16(url.scheme() + ":"); 323 domain = base::UTF8ToUTF16(url.scheme() + ":");
324 324
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 result->SetBoolean("starred", bookmark_model->IsBookmarked(url)); 358 result->SetBoolean("starred", bookmark_model->IsBookmarked(url));
359 359
360 std::string device_name; 360 std::string device_name;
361 std::string device_type; 361 std::string device_type;
362 if (!client_id.empty()) 362 if (!client_id.empty())
363 GetDeviceNameAndType(sync_service, client_id, &device_name, &device_type); 363 GetDeviceNameAndType(sync_service, client_id, &device_name, &device_type);
364 result->SetString("deviceName", device_name); 364 result->SetString("deviceName", device_name);
365 result->SetString("deviceType", device_type); 365 result->SetString("deviceType", device_type);
366 366
367 #if defined(ENABLE_MANAGED_USERS) 367 #if defined(ENABLE_MANAGED_USERS)
368 if (managed_user_service) { 368 if (supervised_user_service) {
369 const ManagedModeURLFilter* url_filter = 369 const SupervisedUserURLFilter* url_filter =
370 managed_user_service->GetURLFilterForUIThread(); 370 supervised_user_service->GetURLFilterForUIThread();
371 int filtering_behavior = 371 int filtering_behavior =
372 url_filter->GetFilteringBehaviorForURL(url.GetWithEmptyPath()); 372 url_filter->GetFilteringBehaviorForURL(url.GetWithEmptyPath());
373 result->SetInteger("hostFilteringBehavior", filtering_behavior); 373 result->SetInteger("hostFilteringBehavior", filtering_behavior);
374 374
375 result->SetBoolean("blockedVisit", blocked_visit); 375 result->SetBoolean("blockedVisit", blocked_visit);
376 } 376 }
377 #endif 377 #endif
378 378
379 return result.Pass(); 379 return result.Pass();
380 } 380 }
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
702 BrowsingHistoryHandler::HistoryEntry::COMBINED_ENTRY; 702 BrowsingHistoryHandler::HistoryEntry::COMBINED_ENTRY;
703 } 703 }
704 } 704 }
705 } 705 }
706 results->swap(new_results); 706 results->swap(new_results);
707 } 707 }
708 708
709 void BrowsingHistoryHandler::ReturnResultsToFrontEnd() { 709 void BrowsingHistoryHandler::ReturnResultsToFrontEnd() {
710 Profile* profile = Profile::FromWebUI(web_ui()); 710 Profile* profile = Profile::FromWebUI(web_ui());
711 BookmarkModel* bookmark_model = BookmarkModelFactory::GetForProfile(profile); 711 BookmarkModel* bookmark_model = BookmarkModelFactory::GetForProfile(profile);
712 ManagedUserService* managed_user_service = NULL; 712 SupervisedUserService* supervised_user_service = NULL;
713 #if defined(ENABLE_MANAGED_USERS) 713 #if defined(ENABLE_MANAGED_USERS)
714 if (profile->IsSupervised()) 714 if (profile->IsSupervised())
715 managed_user_service = ManagedUserServiceFactory::GetForProfile(profile); 715 supervised_user_service =
716 SupervisedUserServiceFactory::GetForProfile(profile);
716 #endif 717 #endif
717 ProfileSyncService* sync_service = 718 ProfileSyncService* sync_service =
718 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile); 719 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile);
719 720
720 // Combine the local and remote results into |query_results_|, and remove 721 // Combine the local and remote results into |query_results_|, and remove
721 // any duplicates. 722 // any duplicates.
722 if (!web_history_query_results_.empty()) { 723 if (!web_history_query_results_.empty()) {
723 int local_result_count = query_results_.size(); 724 int local_result_count = query_results_.size();
724 query_results_.insert(query_results_.end(), 725 query_results_.insert(query_results_.end(),
725 web_history_query_results_.begin(), 726 web_history_query_results_.begin(),
726 web_history_query_results_.end()); 727 web_history_query_results_.end());
727 MergeDuplicateResults(&query_results_); 728 MergeDuplicateResults(&query_results_);
728 729
729 if (local_result_count) { 730 if (local_result_count) {
730 // In the best case, we expect that all local results are duplicated on 731 // In the best case, we expect that all local results are duplicated on
731 // the server. Keep track of how many are missing. 732 // the server. Keep track of how many are missing.
732 int missing_count = std::count_if( 733 int missing_count = std::count_if(
733 query_results_.begin(), query_results_.end(), IsLocalOnlyResult); 734 query_results_.begin(), query_results_.end(), IsLocalOnlyResult);
734 UMA_HISTOGRAM_PERCENTAGE("WebHistory.LocalResultMissingOnServer", 735 UMA_HISTOGRAM_PERCENTAGE("WebHistory.LocalResultMissingOnServer",
735 missing_count * 100.0 / local_result_count); 736 missing_count * 100.0 / local_result_count);
736 } 737 }
737 } 738 }
738 739
739 // Convert the result vector into a ListValue. 740 // Convert the result vector into a ListValue.
740 base::ListValue results_value; 741 base::ListValue results_value;
741 for (std::vector<BrowsingHistoryHandler::HistoryEntry>::iterator it = 742 for (std::vector<BrowsingHistoryHandler::HistoryEntry>::iterator it =
742 query_results_.begin(); it != query_results_.end(); ++it) { 743 query_results_.begin(); it != query_results_.end(); ++it) {
743 scoped_ptr<base::Value> value( 744 scoped_ptr<base::Value> value(
744 it->ToValue(bookmark_model, managed_user_service, sync_service)); 745 it->ToValue(bookmark_model, supervised_user_service, sync_service));
745 results_value.Append(value.release()); 746 results_value.Append(value.release());
746 } 747 }
747 748
748 web_ui()->CallJavascriptFunction( 749 web_ui()->CallJavascriptFunction(
749 "historyResult", results_info_value_, results_value); 750 "historyResult", results_info_value_, results_value);
750 results_info_value_.Clear(); 751 results_info_value_.Clear();
751 query_results_.clear(); 752 query_results_.clear();
752 web_history_query_results_.clear(); 753 web_history_query_results_.clear();
753 } 754 }
754 755
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
1001 Profile* profile = Profile::FromWebUI(web_ui); 1002 Profile* profile = Profile::FromWebUI(web_ui);
1002 content::WebUIDataSource::Add(profile, CreateHistoryUIHTMLSource(profile)); 1003 content::WebUIDataSource::Add(profile, CreateHistoryUIHTMLSource(profile));
1003 } 1004 }
1004 1005
1005 // static 1006 // static
1006 base::RefCountedMemory* HistoryUI::GetFaviconResourceBytes( 1007 base::RefCountedMemory* HistoryUI::GetFaviconResourceBytes(
1007 ui::ScaleFactor scale_factor) { 1008 ui::ScaleFactor scale_factor) {
1008 return ResourceBundle::GetSharedInstance(). 1009 return ResourceBundle::GetSharedInstance().
1009 LoadDataResourceBytesForScale(IDR_HISTORY_FAVICON, scale_factor); 1010 LoadDataResourceBytesForScale(IDR_HISTORY_FAVICON, scale_factor);
1010 } 1011 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/history_ui.h ('k') | chrome/browser/ui/webui/options/create_profile_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698