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

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

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

Powered by Google App Engine
This is Rietveld 408576698