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

Side by Side Diff: third_party/WebKit/Source/core/dom/Document.cpp

Issue 2160533002: Add use counters for Secure Context checks and sandboxed origins. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Wrong flag. Created 4 years, 5 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/frame/UseCounter.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org)
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r ights reserved. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r ights reserved.
7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) 7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/)
8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. 8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved.
9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) 9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved. 10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved.
(...skipping 5855 matching lines...) Expand 10 before | Expand all | Expand 10 after
5866 { 5866 {
5867 wrapper = V8DOMWrapper::associateObjectWithWrapper(isolate, this, wrapperTyp e, wrapper); 5867 wrapper = V8DOMWrapper::associateObjectWithWrapper(isolate, this, wrapperTyp e, wrapper);
5868 DOMWrapperWorld& world = DOMWrapperWorld::current(isolate); 5868 DOMWrapperWorld& world = DOMWrapperWorld::current(isolate);
5869 if (world.isMainWorld() && frame()) 5869 if (world.isMainWorld() && frame())
5870 frame()->script().windowProxy(world)->updateDocumentWrapper(wrapper); 5870 frame()->script().windowProxy(world)->updateDocumentWrapper(wrapper);
5871 return wrapper; 5871 return wrapper;
5872 } 5872 }
5873 5873
5874 bool Document::isSecureContext(String& errorMessage, const SecureContextCheck pr ivilegeContextCheck) const 5874 bool Document::isSecureContext(String& errorMessage, const SecureContextCheck pr ivilegeContextCheck) const
5875 { 5875 {
5876 if (isSecureContextImpl(privilegeContextCheck)) 5876 bool isSecure = isSecureContextImpl(privilegeContextCheck);
5877 if (getSandboxFlags() != SandboxNone) {
5878 UseCounter::count(*this, isSecure
5879 ? UseCounter::SecureContextCheckForSandboxedOriginPassed
5880 : UseCounter::SecureContextCheckForSandboxedOriginFailed);
5881 }
5882 UseCounter::count(*this, isSecure
5883 ? UseCounter::SecureContextCheckPassed
5884 : UseCounter::SecureContextCheckFailed);
5885
5886 if (isSecure)
5877 return true; 5887 return true;
5888
5878 errorMessage = SecurityOrigin::isPotentiallyTrustworthyErrorMessage(); 5889 errorMessage = SecurityOrigin::isPotentiallyTrustworthyErrorMessage();
5879 return false; 5890 return false;
5880 } 5891 }
5881 5892
5882 bool Document::isSecureContext(const SecureContextCheck privilegeContextCheck) c onst 5893 bool Document::isSecureContext(const SecureContextCheck privilegeContextCheck) c onst
5883 { 5894 {
5884 return isSecureContextImpl(privilegeContextCheck); 5895 bool isSecure = isSecureContextImpl(privilegeContextCheck);
5896 if (getSandboxFlags() != SandboxNone) {
5897 UseCounter::count(*this, isSecure
5898 ? UseCounter::SecureContextCheckForSandboxedOriginPassed
5899 : UseCounter::SecureContextCheckForSandboxedOriginFailed);
5900 }
5901 UseCounter::count(*this, isSecure
5902 ? UseCounter::SecureContextCheckPassed
5903 : UseCounter::SecureContextCheckFailed);
5904 return isSecure;
5885 } 5905 }
5886 5906
5887 void Document::enforceInsecureRequestPolicy(WebInsecureRequestPolicy policy) 5907 void Document::enforceInsecureRequestPolicy(WebInsecureRequestPolicy policy)
5888 { 5908 {
5889 // Combine the new policy with the existing policy, as a base policy may be 5909 // Combine the new policy with the existing policy, as a base policy may be
5890 // inherited from a remote parent before this page's policy is set. In other 5910 // inherited from a remote parent before this page's policy is set. In other
5891 // words, insecure requests should be upgraded or blocked if _either_ the 5911 // words, insecure requests should be upgraded or blocked if _either_ the
5892 // existing policy or the newly enforced policy triggers upgrades or 5912 // existing policy or the newly enforced policy triggers upgrades or
5893 // blockage. 5913 // blockage.
5894 setInsecureRequestPolicy(getInsecureRequestPolicy() | policy); 5914 setInsecureRequestPolicy(getInsecureRequestPolicy() | policy);
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
6019 } 6039 }
6020 6040
6021 void showLiveDocumentInstances() 6041 void showLiveDocumentInstances()
6022 { 6042 {
6023 WeakDocumentSet& set = liveDocumentSet(); 6043 WeakDocumentSet& set = liveDocumentSet();
6024 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); 6044 fprintf(stderr, "There are %u documents currently alive:\n", set.size());
6025 for (Document* document : set) 6045 for (Document* document : set)
6026 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().get String().utf8().data()); 6046 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().get String().utf8().data());
6027 } 6047 }
6028 #endif 6048 #endif
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/frame/UseCounter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698