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

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

Issue 13119011: Enable WebContents elevation for managed users. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address review comment. Created 7 years, 9 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 10 matching lines...) Expand all
21 #include "base/utf_string_conversions.h" 21 #include "base/utf_string_conversions.h"
22 #include "base/values.h" 22 #include "base/values.h"
23 #include "chrome/browser/bookmarks/bookmark_model.h" 23 #include "chrome/browser/bookmarks/bookmark_model.h"
24 #include "chrome/browser/bookmarks/bookmark_model_factory.h" 24 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
25 #include "chrome/browser/bookmarks/bookmark_utils.h" 25 #include "chrome/browser/bookmarks/bookmark_utils.h"
26 #include "chrome/browser/history/history_notifications.h" 26 #include "chrome/browser/history/history_notifications.h"
27 #include "chrome/browser/history/history_service_factory.h" 27 #include "chrome/browser/history/history_service_factory.h"
28 #include "chrome/browser/history/history_types.h" 28 #include "chrome/browser/history/history_types.h"
29 #include "chrome/browser/history/web_history_service.h" 29 #include "chrome/browser/history/web_history_service.h"
30 #include "chrome/browser/history/web_history_service_factory.h" 30 #include "chrome/browser/history/web_history_service_factory.h"
31 #include "chrome/browser/managed_mode/managed_mode_navigation_observer.h"
31 #include "chrome/browser/managed_mode/managed_mode_url_filter.h" 32 #include "chrome/browser/managed_mode/managed_mode_url_filter.h"
32 #include "chrome/browser/managed_mode/managed_user_service.h" 33 #include "chrome/browser/managed_mode/managed_user_service.h"
33 #include "chrome/browser/managed_mode/managed_user_service_factory.h" 34 #include "chrome/browser/managed_mode/managed_user_service_factory.h"
34 #include "chrome/browser/profiles/profile.h" 35 #include "chrome/browser/profiles/profile.h"
35 #include "chrome/browser/search/search.h" 36 #include "chrome/browser/search/search.h"
36 #include "chrome/browser/ui/browser_finder.h" 37 #include "chrome/browser/ui/browser_finder.h"
37 #include "chrome/browser/ui/chrome_pages.h" 38 #include "chrome/browser/ui/chrome_pages.h"
38 #include "chrome/browser/ui/webui/favicon_source.h" 39 #include "chrome/browser/ui/webui/favicon_source.h"
39 #include "chrome/common/chrome_notification_types.h" 40 #include "chrome/common/chrome_notification_types.h"
40 #include "chrome/common/chrome_switches.h" 41 #include "chrome/common/chrome_switches.h"
(...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after
598 bool allow = false; 599 bool allow = false;
599 if (!args->GetBoolean(0, &allow)) { 600 if (!args->GetBoolean(0, &allow)) {
600 LOG(ERROR) << "Unable to extract boolean argument."; 601 LOG(ERROR) << "Unable to extract boolean argument.";
601 web_ui()->CallJavascriptFunction("processingManagedFailed"); 602 web_ui()->CallJavascriptFunction("processingManagedFailed");
602 return; 603 return;
603 } 604 }
604 605
605 // Check if the managed user is authenticated. 606 // Check if the managed user is authenticated.
606 ManagedUserService* service = ManagedUserServiceFactory::GetForProfile( 607 ManagedUserService* service = ManagedUserServiceFactory::GetForProfile(
607 Profile::FromWebUI(web_ui())); 608 Profile::FromWebUI(web_ui()));
608 if (!service->IsElevated()) 609 if (!service->IsElevatedForWebContents(web_ui()->GetWebContents()))
609 return; 610 return;
610 611
611 // Since editing a host can have side effects on other hosts, update all of 612 // Since editing a host can have side effects on other hosts, update all of
612 // them but change the behavior only of the checked ones. 613 // them but change the behavior only of the checked ones.
613 std::vector<std::string> hosts_to_be_changed; 614 std::vector<std::string> hosts_to_be_changed;
614 std::vector<GURL> hosts_to_update; 615 std::vector<GURL> hosts_to_update;
615 // Get the host information. Currently the layout of this data is as follows: 616 // Get the host information. Currently the layout of this data is as follows:
616 // [[<is the host checked (boolean)>, <host (string)>], ...] 617 // [[<is the host checked (boolean)>, <host (string)>], ...]
617 const ListValue* host_list; 618 const ListValue* host_list;
618 if (!args->GetList(1, &host_list)) { 619 if (!args->GetList(1, &host_list)) {
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
744 bool elevated; 745 bool elevated;
745 elevated_arg->GetBoolean(0, &elevated); 746 elevated_arg->GetBoolean(0, &elevated);
746 ManagedUserService* service = ManagedUserServiceFactory::GetForProfile( 747 ManagedUserService* service = ManagedUserServiceFactory::GetForProfile(
747 Profile::FromWebUI(web_ui())); 748 Profile::FromWebUI(web_ui()));
748 if (elevated) { 749 if (elevated) {
749 service->RequestAuthorization( 750 service->RequestAuthorization(
750 web_ui()->GetWebContents(), 751 web_ui()->GetWebContents(),
751 base::Bind(&BrowsingHistoryHandler::PassphraseDialogCallback, 752 base::Bind(&BrowsingHistoryHandler::PassphraseDialogCallback,
752 base::Unretained(this))); 753 base::Unretained(this)));
753 } else { 754 } else {
754 service->SetElevated(elevated); 755 ManagedModeNavigationObserver* observer =
756 ManagedModeNavigationObserver::FromWebContents(
757 web_ui()->GetWebContents());
758 observer->set_elevated(false);
755 ManagedUserSetElevated(); 759 ManagedUserSetElevated();
756 } 760 }
757 } 761 }
758 762
759 void BrowsingHistoryHandler::PassphraseDialogCallback(bool success) { 763 void BrowsingHistoryHandler::PassphraseDialogCallback(bool success) {
760 if (success) { 764 if (success) {
761 ManagedUserService* service = ManagedUserServiceFactory::GetForProfile( 765 ManagedModeNavigationObserver* observer =
762 Profile::FromWebUI(web_ui())); 766 ManagedModeNavigationObserver::FromWebContents(
763 service->SetElevated(true); 767 web_ui()->GetWebContents());
768 observer->set_elevated(true);
764 ManagedUserSetElevated(); 769 ManagedUserSetElevated();
765 } 770 }
766 } 771 }
767 772
768 void BrowsingHistoryHandler::ManagedUserSetElevated() { 773 void BrowsingHistoryHandler::ManagedUserSetElevated() {
769 ManagedUserService* service = ManagedUserServiceFactory::GetForProfile( 774 ManagedUserService* service = ManagedUserServiceFactory::GetForProfile(
770 Profile::FromWebUI(web_ui())); 775 Profile::FromWebUI(web_ui()));
771 base::FundamentalValue is_elevated(service->IsElevated()); 776 base::FundamentalValue is_elevated(service->IsElevatedForWebContents(
777 web_ui()->GetWebContents()));
772 web_ui()->CallJavascriptFunction("managedUserElevated", is_elevated); 778 web_ui()->CallJavascriptFunction("managedUserElevated", is_elevated);
773 } 779 }
774 780
775 void BrowsingHistoryHandler::HandleManagedUserGetElevated( 781 void BrowsingHistoryHandler::HandleManagedUserGetElevated(
776 const ListValue* args) { 782 const ListValue* args) {
777 ManagedUserSetElevated(); 783 ManagedUserSetElevated();
778 } 784 }
779 #endif 785 #endif
780 786
781 // static 787 // static
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
1123 return GURL(std::string(chrome::kChromeUIHistoryURL) + "#q=" + 1129 return GURL(std::string(chrome::kChromeUIHistoryURL) + "#q=" +
1124 net::EscapeQueryParamValue(UTF16ToUTF8(text), true)); 1130 net::EscapeQueryParamValue(UTF16ToUTF8(text), true));
1125 } 1131 }
1126 1132
1127 // static 1133 // static
1128 base::RefCountedMemory* HistoryUI::GetFaviconResourceBytes( 1134 base::RefCountedMemory* HistoryUI::GetFaviconResourceBytes(
1129 ui::ScaleFactor scale_factor) { 1135 ui::ScaleFactor scale_factor) {
1130 return ResourceBundle::GetSharedInstance(). 1136 return ResourceBundle::GetSharedInstance().
1131 LoadDataResourceBytesForScale(IDR_HISTORY_FAVICON, scale_factor); 1137 LoadDataResourceBytesForScale(IDR_HISTORY_FAVICON, scale_factor);
1132 } 1138 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698