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

Side by Side Diff: content/renderer/do_not_track_bindings.cc

Issue 10960042: Add navigator.doNotTrack property (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 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
« no previous file with comments | « content/renderer/do_not_track_bindings.h ('k') | content/renderer/render_view_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "content/renderer/do_not_track_bindings.h"
6
7 #include "content/renderer/render_view_impl.h"
8 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
9 #include "v8/include/v8.h"
10
11 using WebKit::WebFrame;
12
13 namespace {
14
15 v8::Handle<v8::Value> GetDoNotTrack(v8::Local<v8::String> property,
16 const v8::AccessorInfo& info) {
17 WebFrame* frame = WebFrame::frameForCurrentContext();
18 if (!frame)
19 return v8::Null();
20 RenderViewImpl* view = RenderViewImpl::FromWebView(frame->view());
21 if (!view)
22 return v8::Null();
23 if (view->enable_do_not_track())
24 return v8::String::New("1");
25 return v8::Null();
26 }
27
28 } // namespace
29
30 namespace content {
31
32 void InjectDoNotTrackBindings(WebFrame* frame) {
33 v8::HandleScope handle_scope;
34
35 v8::Handle<v8::Context> v8_context = frame->mainWorldScriptContext();
36 if (v8_context.IsEmpty())
37 return;
38
39 v8::Context::Scope scope(v8_context);
40
41 v8::Handle<v8::Object> global = v8_context->Global();
42 v8::Handle<v8::Object> navigator =
43 global->Get(v8::String::New("navigator"))->ToObject();
44 if (navigator.IsEmpty())
45 return;
46 navigator->SetAccessor(v8::String::New("doNotTrack"), GetDoNotTrack);
47 }
48
49 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/do_not_track_bindings.h ('k') | content/renderer/render_view_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698