| 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/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/string_split.h" | 9 #include "base/string_split.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| 11 #include "chrome/common/extensions/extension_set.h" | 11 #include "chrome/common/extensions/extension_set.h" |
| 12 #include "chrome/renderer/extensions/chrome_v8_extension.h" | 12 #include "chrome/renderer/extensions/chrome_v8_extension.h" |
| 13 #include "content/public/renderer/render_view.h" | 13 #include "content/public/renderer/render_view.h" |
| 14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" | 14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
| 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" | 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" |
| 16 #include "v8/include/v8.h" | 16 #include "v8/include/v8.h" |
| 17 | 17 |
| 18 namespace { | 18 namespace { |
| 19 | 19 |
| 20 const char kChromeHidden[] = "chromeHidden"; | 20 const char kChromeHidden[] = "chromeHidden"; |
| 21 | 21 |
| 22 #ifndef NDEBUG | 22 #ifndef NDEBUG |
| 23 const char kValidateCallbacks[] = "validateCallbacks"; | 23 const char kValidateCallbacks[] = "validateCallbacks"; |
| 24 #endif | 24 #endif |
| 25 | 25 |
| 26 std::string GetContextTypeDescription( | 26 std::string GetContextTypeDescription( |
| 27 ChromeV8Context::ContextType context_type) { | 27 ChromeV8Context::ContextType context_type) { |
| 28 switch (context_type) { | 28 switch (context_type) { |
| 29 case ChromeV8Context::OTHER: return "other"; | 29 case ChromeV8Context::BLESSED: return "blessed"; |
| 30 case ChromeV8Context::CONTENT_SCRIPT: return "content script"; | 30 case ChromeV8Context::CONTENT_SCRIPT: return "content script"; |
| 31 case ChromeV8Context::UNPRIVILEGED: return "unprivileged"; |
| 31 } | 32 } |
| 32 NOTREACHED(); | 33 NOTREACHED(); |
| 33 return ""; | 34 return ""; |
| 34 } | 35 } |
| 35 | 36 |
| 36 } // namespace | 37 } // namespace |
| 37 | 38 |
| 38 ChromeV8Context::ChromeV8Context(v8::Handle<v8::Context> v8_context, | 39 ChromeV8Context::ChromeV8Context(v8::Handle<v8::Context> v8_context, |
| 39 WebKit::WebFrame* web_frame, | 40 WebKit::WebFrame* web_frame, |
| 40 const std::string& extension_id, | 41 const std::string& extension_id, |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 argv[1] = v8::Boolean::New(is_extension_process); | 137 argv[1] = v8::Boolean::New(is_extension_process); |
| 137 argv[2] = v8::Boolean::New(is_incognito_process); | 138 argv[2] = v8::Boolean::New(is_incognito_process); |
| 138 argv[3] = v8::Integer::New(manifest_version); | 139 argv[3] = v8::Integer::New(manifest_version); |
| 139 CallChromeHiddenMethod("dispatchOnLoad", arraysize(argv), argv, NULL); | 140 CallChromeHiddenMethod("dispatchOnLoad", arraysize(argv), argv, NULL); |
| 140 } | 141 } |
| 141 | 142 |
| 142 void ChromeV8Context::DispatchOnUnloadEvent() const { | 143 void ChromeV8Context::DispatchOnUnloadEvent() const { |
| 143 v8::HandleScope handle_scope; | 144 v8::HandleScope handle_scope; |
| 144 CallChromeHiddenMethod("dispatchOnUnload", 0, NULL, NULL); | 145 CallChromeHiddenMethod("dispatchOnUnload", 0, NULL, NULL); |
| 145 } | 146 } |
| OLD | NEW |