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

Side by Side 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: Add elevation state to the managed mode navigation observer. 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/managed_mode/managed_mode_navigation_observer.h" 5 #include "chrome/browser/managed_mode/managed_mode_navigation_observer.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/i18n/rtl.h" 8 #include "base/i18n/rtl.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 RemoveTemporaryException(); 256 RemoveTemporaryException();
257 } 257 }
258 258
259 ManagedModeNavigationObserver::ManagedModeNavigationObserver( 259 ManagedModeNavigationObserver::ManagedModeNavigationObserver(
260 content::WebContents* web_contents) 260 content::WebContents* web_contents)
261 : WebContentsObserver(web_contents), 261 : WebContentsObserver(web_contents),
262 warn_infobar_delegate_(NULL), 262 warn_infobar_delegate_(NULL),
263 preview_infobar_delegate_(NULL), 263 preview_infobar_delegate_(NULL),
264 got_user_gesture_(false), 264 got_user_gesture_(false),
265 state_(RECORDING_URLS_BEFORE_PREVIEW), 265 state_(RECORDING_URLS_BEFORE_PREVIEW),
266 is_elevated_(false),
266 last_allowed_page_(-1) { 267 last_allowed_page_(-1) {
267 Profile* profile = 268 Profile* profile =
268 Profile::FromBrowserContext(web_contents->GetBrowserContext()); 269 Profile::FromBrowserContext(web_contents->GetBrowserContext());
269 managed_user_service_ = ManagedUserServiceFactory::GetForProfile(profile); 270 managed_user_service_ = ManagedUserServiceFactory::GetForProfile(profile);
271 if (!managed_user_service_->ProfileIsManaged())
272 is_elevated_ = true;
270 url_filter_ = managed_user_service_->GetURLFilterForUIThread(); 273 url_filter_ = managed_user_service_->GetURLFilterForUIThread();
271 } 274 }
272 275
273 void ManagedModeNavigationObserver::AddTemporaryException() { 276 void ManagedModeNavigationObserver::AddTemporaryException() {
274 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 277 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
275 DCHECK(web_contents()); 278 DCHECK(web_contents());
276 279
277 BrowserThread::PostTask( 280 BrowserThread::PostTask(
278 BrowserThread::IO, 281 BrowserThread::IO,
279 FROM_HERE, 282 FROM_HERE,
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 urls, ManagedUserService::MANUAL_ALLOW); 337 urls, ManagedUserService::MANUAL_ALLOW);
335 if (last_url_.is_valid()) { 338 if (last_url_.is_valid()) {
336 std::vector<std::string> hosts; 339 std::vector<std::string> hosts;
337 hosts.push_back(last_url_.host()); 340 hosts.push_back(last_url_.host());
338 managed_user_service_->SetManualBehaviorForHosts( 341 managed_user_service_->SetManualBehaviorForHosts(
339 hosts, ManagedUserService::MANUAL_ALLOW); 342 hosts, ManagedUserService::MANUAL_ALLOW);
340 } 343 }
341 ClearObserverState(); 344 ClearObserverState();
342 } 345 }
343 346
347 bool ManagedModeNavigationObserver::is_elevated() const {
348 return is_elevated_;
349 }
350
351 void ManagedModeNavigationObserver::SetElevated(bool is_elevated) {
352 is_elevated_ = is_elevated;
353 }
354
344 void ManagedModeNavigationObserver::AddURLToPatternList(const GURL& url) { 355 void ManagedModeNavigationObserver::AddURLToPatternList(const GURL& url) {
345 navigated_urls_.insert(url); 356 navigated_urls_.insert(url);
346 last_url_ = url; 357 last_url_ = url;
347 } 358 }
348 359
349 void ManagedModeNavigationObserver::SetStateToRecordingAfterPreview() { 360 void ManagedModeNavigationObserver::SetStateToRecordingAfterPreview() {
350 state_ = RECORDING_URLS_AFTER_PREVIEW; 361 state_ = RECORDING_URLS_AFTER_PREVIEW;
351 } 362 }
352 363
353 bool ManagedModeNavigationObserver::CanTemporarilyNavigateHost( 364 bool ManagedModeNavigationObserver::CanTemporarilyNavigateHost(
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 if (behavior == ManagedModeURLFilter::ALLOW) 515 if (behavior == ManagedModeURLFilter::ALLOW)
505 last_allowed_page_ = web_contents()->GetController().GetCurrentEntryIndex(); 516 last_allowed_page_ = web_contents()->GetController().GetCurrentEntryIndex();
506 } 517 }
507 518
508 void ManagedModeNavigationObserver::DidGetUserGesture() { 519 void ManagedModeNavigationObserver::DidGetUserGesture() {
509 got_user_gesture_ = true; 520 got_user_gesture_ = true;
510 // Update the exception status so that the resource throttle knows that 521 // Update the exception status so that the resource throttle knows that
511 // there was a manual navigation. 522 // there was a manual navigation.
512 UpdateExceptionNavigationStatus(); 523 UpdateExceptionNavigationStatus();
513 } 524 }
525
Bernhard Bauer 2013/03/20 15:08:30 Is this newline necessary?
Adrian Kuegel 2013/03/20 15:51:16 No, that was a leftover from copying the new metho
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698