| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "extensions/renderer/console.h" | 5 #include "extensions/renderer/console.h" |
| 6 | 6 |
| 7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
| 8 #include "base/debug/alias.h" | 8 #include "base/debug/alias.h" |
| 9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 static content::RenderView* Find(v8::Handle<v8::Context> context) { | 30 static content::RenderView* Find(v8::Handle<v8::Context> context) { |
| 31 ByContextFinder finder(context); | 31 ByContextFinder finder(context); |
| 32 content::RenderView::ForEach(&finder); | 32 content::RenderView::ForEach(&finder); |
| 33 return finder.found_; | 33 return finder.found_; |
| 34 } | 34 } |
| 35 | 35 |
| 36 private: | 36 private: |
| 37 explicit ByContextFinder(v8::Handle<v8::Context> context) | 37 explicit ByContextFinder(v8::Handle<v8::Context> context) |
| 38 : context_(context), found_(NULL) {} | 38 : context_(context), found_(NULL) {} |
| 39 | 39 |
| 40 virtual bool Visit(content::RenderView* render_view) OVERRIDE { | 40 virtual bool Visit(content::RenderView* render_view) override { |
| 41 ExtensionHelper* helper = ExtensionHelper::Get(render_view); | 41 ExtensionHelper* helper = ExtensionHelper::Get(render_view); |
| 42 if (helper && | 42 if (helper && |
| 43 helper->dispatcher()->script_context_set().GetByV8Context(context_)) { | 43 helper->dispatcher()->script_context_set().GetByV8Context(context_)) { |
| 44 found_ = render_view; | 44 found_ = render_view; |
| 45 } | 45 } |
| 46 return !found_; | 46 return !found_; |
| 47 } | 47 } |
| 48 | 48 |
| 49 v8::Handle<v8::Context> context_; | 49 v8::Handle<v8::Context> context_; |
| 50 content::RenderView* found_; | 50 content::RenderView* found_; |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 v8::Local<v8::Object> console_object = v8::Object::New(isolate); | 179 v8::Local<v8::Object> console_object = v8::Object::New(isolate); |
| 180 BindLogMethod(isolate, console_object, "debug", &Debug); | 180 BindLogMethod(isolate, console_object, "debug", &Debug); |
| 181 BindLogMethod(isolate, console_object, "log", &Log); | 181 BindLogMethod(isolate, console_object, "log", &Log); |
| 182 BindLogMethod(isolate, console_object, "warn", &Warn); | 182 BindLogMethod(isolate, console_object, "warn", &Warn); |
| 183 BindLogMethod(isolate, console_object, "error", &Error); | 183 BindLogMethod(isolate, console_object, "error", &Error); |
| 184 return handle_scope.Escape(console_object); | 184 return handle_scope.Escape(console_object); |
| 185 } | 185 } |
| 186 | 186 |
| 187 } // namespace console | 187 } // namespace console |
| 188 } // namespace extensions | 188 } // namespace extensions |
| OLD | NEW |