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

Unified Diff: chrome/browser/managed_mode/managed_mode_navigation_observer.cc

Issue 12413028: Add elevation to the managed mode navigation observer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase to ToT. 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/managed_mode/managed_mode_navigation_observer.cc
diff --git a/chrome/browser/managed_mode/managed_mode_navigation_observer.cc b/chrome/browser/managed_mode/managed_mode_navigation_observer.cc
index af66cf33aa5be0f03abd13c420302de2ee808fe3..2740d5fa5a0cea03ae196e436f0f77c315126949 100644
--- a/chrome/browser/managed_mode/managed_mode_navigation_observer.cc
+++ b/chrome/browser/managed_mode/managed_mode_navigation_observer.cc
@@ -8,6 +8,7 @@
#include "base/i18n/rtl.h"
#include "base/metrics/histogram.h"
#include "base/prefs/pref_service.h"
+#include "base/string_util.h"
#include "base/strings/string_number_conversions.h"
#include "chrome/browser/infobars/confirm_infobar_delegate.h"
#include "chrome/browser/infobars/infobar_service.h"
@@ -25,6 +26,7 @@
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/host_desktop.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
+#include "chrome/common/extensions/extension_constants.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h"
#include "content/public/browser/browser_thread.h"
@@ -263,10 +265,13 @@ ManagedModeNavigationObserver::ManagedModeNavigationObserver(
preview_infobar_delegate_(NULL),
got_user_gesture_(false),
state_(RECORDING_URLS_BEFORE_PREVIEW),
+ is_elevated_(false),
last_allowed_page_(-1) {
Profile* profile =
Profile::FromBrowserContext(web_contents->GetBrowserContext());
managed_user_service_ = ManagedUserServiceFactory::GetForProfile(profile);
+ if (!managed_user_service_->ProfileIsManaged())
+ is_elevated_ = true;
url_filter_ = managed_user_service_->GetURLFilterForUIThread();
}
@@ -341,6 +346,14 @@ void ManagedModeNavigationObserver::AddSavedURLsToWhitelistAndClearState() {
ClearObserverState();
}
+bool ManagedModeNavigationObserver::is_elevated() const {
+ return is_elevated_;
+}
+
+void ManagedModeNavigationObserver::set_elevated(bool is_elevated) {
+ is_elevated_ = is_elevated;
+}
+
void ManagedModeNavigationObserver::AddURLToPatternList(const GURL& url) {
navigated_urls_.insert(url);
last_url_ = url;
@@ -355,6 +368,23 @@ bool ManagedModeNavigationObserver::CanTemporarilyNavigateHost(
return last_url_.host() == url.host();
}
+bool ManagedModeNavigationObserver::ShouldStayElevatedForURL(
+ const GURL& navigation_url) {
+ std::string url = navigation_url.spec();
+ // Handle chrome:// URLs specially.
+ if (navigation_url.host() == "chrome") {
+ // The path contains the actual host name, but starts with a "/". Remove
+ // the "/".
+ url = navigation_url.path().substr(1);
+ }
+
+ // Check if any of the special URLs is a prefix of |url|.
+ return StartsWithASCII(url, chrome::kChromeUIHistoryHost, false) ||
+ StartsWithASCII(url, chrome::kChromeUIExtensionsHost, false) ||
+ StartsWithASCII(url, chrome::kChromeUISettingsHost, false) ||
+ StartsWithASCII(url, extension_urls::kGalleryBrowsePrefix, false);
+}
+
void ManagedModeNavigationObserver::ClearObserverState() {
if (preview_infobar_delegate_) {
InfoBarService* infobar_service =
@@ -387,6 +417,8 @@ void ManagedModeNavigationObserver::NavigateToPendingEntry(
void ManagedModeNavigationObserver::DidNavigateMainFrame(
const content::LoadCommittedDetails& details,
const content::FrameNavigateParams& params) {
+ if (!ShouldStayElevatedForURL(params.url))
+ is_elevated_ = false;
content::RecordAction(UserMetricsAction("ManagedMode_MainFrameNavigation"));
@@ -430,21 +462,12 @@ void ManagedModeNavigationObserver::DidNavigateMainFrame(
got_user_gesture_ = false;
}
-void ManagedModeNavigationObserver::DidStartProvisionalLoadForFrame(
- int64 frame_id,
- int64 parent_frame_id,
- bool is_main_frame,
- const GURL& validated_url,
- bool is_error_page,
- bool is_iframe_srcdoc,
- content::RenderViewHost* render_view_host) {
- if (!is_main_frame)
- return;
-}
-
void ManagedModeNavigationObserver::ProvisionalChangeToMainFrameUrl(
const GURL& url,
content::RenderViewHost* render_view_host) {
+ if (!ShouldStayElevatedForURL(url))
+ is_elevated_ = false;
+
// This function is the last one to be called before the resource throttle
// shows the interstitial if the URL must be blocked.
DVLOG(1) << "ProvisionalChangeToMainFrameURL " << url.spec();
« no previous file with comments | « chrome/browser/managed_mode/managed_mode_navigation_observer.h ('k') | chrome/browser/managed_mode/managed_user_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698