Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "chrome/renderer/extensions/chrome_v8_context.h" | 5 #include "chrome/renderer/extensions/chrome_v8_context.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/string_split.h" | 8 #include "base/string_split.h" |
| 9 #include "base/values.h" | 9 #include "base/values.h" |
| 10 #include "chrome/common/extensions/extension_set.h" | 10 #include "chrome/common/extensions/extension_set.h" |
| 11 #include "chrome/renderer/extensions/chrome_v8_extension.h" | 11 #include "chrome/renderer/extensions/chrome_v8_extension.h" |
| 12 #include "content/public/renderer/render_view.h" | 12 #include "content/public/renderer/render_view.h" |
| 13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" | 13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
| 14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" | 14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" |
| 15 #include "v8/include/v8.h" | 15 #include "v8/include/v8.h" |
| 16 | 16 |
| 17 namespace { | 17 namespace { |
| 18 | 18 |
| 19 const char kChromeHidden[] = "chromeHidden"; | 19 const char kChromeHidden[] = "chromeHidden"; |
| 20 | 20 |
| 21 #ifndef NDEBUG | 21 #ifndef NDEBUG |
| 22 const char kValidateCallbacks[] = "validateCallbacks"; | 22 const char kValidateCallbacks[] = "validateCallbacks"; |
| 23 #endif | 23 #endif |
| 24 | 24 |
| 25 } // namespace | 25 } // namespace |
| 26 | 26 |
| 27 | 27 |
| 28 ChromeV8Context::ChromeV8Context(v8::Handle<v8::Context> v8_context, | 28 ChromeV8Context::ChromeV8Context(v8::Handle<v8::Context> v8_context, |
| 29 WebKit::WebFrame* web_frame, | 29 WebKit::WebFrame* web_frame, |
| 30 const std::string& extension_id) | 30 const std::string& extension_id, |
| 31 bool is_content_script) | |
| 31 : v8_context_(v8::Persistent<v8::Context>::New(v8_context)), | 32 : v8_context_(v8::Persistent<v8::Context>::New(v8_context)), |
| 32 web_frame_(web_frame), | 33 web_frame_(web_frame), |
| 33 extension_id_(extension_id) { | 34 extension_id_(extension_id), |
| 35 is_content_script_(is_content_script) { | |
| 34 VLOG(1) << "Created context for extension\n" | 36 VLOG(1) << "Created context for extension\n" |
| 35 << " id: " << extension_id << "\n" | 37 << " id: " << extension_id << "\n" |
| 36 << " frame: " << web_frame_; | 38 << " frame: " << web_frame_; |
|
Aaron Boodman
2012/02/16 00:17:13
Add the context_script bit to this log line?
not at google - send to devlin
2012/02/16 01:45:53
Done.
| |
| 37 } | 39 } |
| 38 | 40 |
| 39 ChromeV8Context::~ChromeV8Context() { | 41 ChromeV8Context::~ChromeV8Context() { |
| 40 VLOG(1) << "Destroyed context for extension\n" | 42 VLOG(1) << "Destroyed context for extension\n" |
| 41 << " id: " << extension_id_; | 43 << " id: " << extension_id_; |
| 42 v8_context_.Dispose(); | 44 v8_context_.Dispose(); |
| 43 } | 45 } |
| 44 | 46 |
| 45 // static | 47 // static |
| 46 v8::Handle<v8::Value> ChromeV8Context::GetOrCreateChromeHidden( | 48 v8::Handle<v8::Value> ChromeV8Context::GetOrCreateChromeHidden( |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 120 argv[1] = v8::Boolean::New(is_extension_process); | 122 argv[1] = v8::Boolean::New(is_extension_process); |
| 121 argv[2] = v8::Boolean::New(is_incognito_process); | 123 argv[2] = v8::Boolean::New(is_incognito_process); |
| 122 argv[3] = v8::Integer::New(manifest_version); | 124 argv[3] = v8::Integer::New(manifest_version); |
| 123 CallChromeHiddenMethod("dispatchOnLoad", arraysize(argv), argv, NULL); | 125 CallChromeHiddenMethod("dispatchOnLoad", arraysize(argv), argv, NULL); |
| 124 } | 126 } |
| 125 | 127 |
| 126 void ChromeV8Context::DispatchOnUnloadEvent() const { | 128 void ChromeV8Context::DispatchOnUnloadEvent() const { |
| 127 v8::HandleScope handle_scope; | 129 v8::HandleScope handle_scope; |
| 128 CallChromeHiddenMethod("dispatchOnUnload", 0, NULL, NULL); | 130 CallChromeHiddenMethod("dispatchOnUnload", 0, NULL, NULL); |
| 129 } | 131 } |
| OLD | NEW |