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

Side by Side Diff: third_party/WebKit/Source/modules/navigatorcontentutils/NavigatorContentUtils.cpp

Issue 2053343002: Add use counters for secure/insecure OpenSearch links and registerProtocolHandler (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011, Google Inc. All rights reserved. 2 * Copyright (C) 2011, Google Inc. All rights reserved.
3 * Copyright (C) 2014, Samsung Electronics. All rights reserved. 3 * Copyright (C) 2014, Samsung Electronics. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 13 matching lines...) Expand all
24 * DAMAGE. 24 * DAMAGE.
25 */ 25 */
26 26
27 #include "modules/navigatorcontentutils/NavigatorContentUtils.h" 27 #include "modules/navigatorcontentutils/NavigatorContentUtils.h"
28 28
29 #include "bindings/core/v8/ExceptionState.h" 29 #include "bindings/core/v8/ExceptionState.h"
30 #include "core/dom/Document.h" 30 #include "core/dom/Document.h"
31 #include "core/dom/ExceptionCode.h" 31 #include "core/dom/ExceptionCode.h"
32 #include "core/frame/LocalFrame.h" 32 #include "core/frame/LocalFrame.h"
33 #include "core/frame/Navigator.h" 33 #include "core/frame/Navigator.h"
34 #include "core/frame/UseCounter.h"
34 #include "wtf/HashSet.h" 35 #include "wtf/HashSet.h"
35 #include "wtf/text/StringBuilder.h" 36 #include "wtf/text/StringBuilder.h"
36 37
37 namespace blink { 38 namespace blink {
38 39
39 static HashSet<String>* schemeWhitelist; 40 static HashSet<String>* schemeWhitelist;
40 41
41 static void initCustomSchemeHandlerWhitelist() 42 static void initCustomSchemeHandlerWhitelist()
42 { 43 {
43 schemeWhitelist = new HashSet<String>; 44 schemeWhitelist = new HashSet<String>;
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 158
158 Document* document = navigator.frame()->document(); 159 Document* document = navigator.frame()->document();
159 ASSERT(document); 160 ASSERT(document);
160 161
161 if (!verifyCustomHandlerURL(*document, url, exceptionState)) 162 if (!verifyCustomHandlerURL(*document, url, exceptionState))
162 return; 163 return;
163 164
164 if (!verifyCustomHandlerScheme(scheme, exceptionState)) 165 if (!verifyCustomHandlerScheme(scheme, exceptionState))
165 return; 166 return;
166 167
168 // Count usage; perhaps we can lock this to secure contexts.
169 UseCounter::count(*document, document->isSecureContext() ? UseCounter::Regis terProtocolHandlerSecureOrigin : UseCounter::RegisterProtocolHandlerInsecureOrig in);
170
167 NavigatorContentUtils::from(*navigator.frame())->client()->registerProtocolH andler(scheme, document->completeURL(url), title); 171 NavigatorContentUtils::from(*navigator.frame())->client()->registerProtocolH andler(scheme, document->completeURL(url), title);
168 } 172 }
169 173
170 static String customHandlersStateString(const NavigatorContentUtilsClient::Custo mHandlersState state) 174 static String customHandlersStateString(const NavigatorContentUtilsClient::Custo mHandlersState state)
171 { 175 {
172 DEFINE_STATIC_LOCAL(const String, newHandler, ("new")); 176 DEFINE_STATIC_LOCAL(const String, newHandler, ("new"));
173 DEFINE_STATIC_LOCAL(const String, registeredHandler, ("registered")); 177 DEFINE_STATIC_LOCAL(const String, registeredHandler, ("registered"));
174 DEFINE_STATIC_LOCAL(const String, declinedHandler, ("declined")); 178 DEFINE_STATIC_LOCAL(const String, declinedHandler, ("declined"));
175 179
176 switch (state) { 180 switch (state) {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 { 232 {
229 return "NavigatorContentUtils"; 233 return "NavigatorContentUtils";
230 } 234 }
231 235
232 void provideNavigatorContentUtilsTo(LocalFrame& frame, NavigatorContentUtilsClie nt* client) 236 void provideNavigatorContentUtilsTo(LocalFrame& frame, NavigatorContentUtilsClie nt* client)
233 { 237 {
234 NavigatorContentUtils::provideTo(frame, NavigatorContentUtils::supplementNam e(), NavigatorContentUtils::create(client)); 238 NavigatorContentUtils::provideTo(frame, NavigatorContentUtils::supplementNam e(), NavigatorContentUtils::create(client));
235 } 239 }
236 240
237 } // namespace blink 241 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/frame/UseCounter.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698