OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_app_bindings.h" | 5 #include "chrome/renderer/extensions/chrome_app_bindings.h" |
6 | 6 |
7 #include "base/string16.h" | 7 #include "base/string16.h" |
8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
9 #include "chrome/common/extensions/extension_set.h" | 9 #include "chrome/common/extensions/extension_set.h" |
10 #include "chrome/renderer/extensions/bindings_utils.h" | 10 #include "chrome/renderer/extensions/bindings_utils.h" |
11 #include "chrome/renderer/render_thread.h" | 11 #include "chrome/renderer/extensions/extension_dispatcher.h" |
12 #include "content/renderer/render_view.h" | 12 #include "content/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 "v8/include/v8.h" | 14 #include "v8/include/v8.h" |
15 | 15 |
16 using WebKit::WebFrame; | 16 using WebKit::WebFrame; |
17 | 17 |
18 namespace extensions_v8 { | 18 namespace extensions_v8 { |
19 | 19 |
20 static const char* const kAppExtensionName = "v8/ChromeApp"; | 20 static const char* const kAppExtensionName = "v8/ChromeApp"; |
21 | 21 |
(...skipping 29 matching lines...) Expand all Loading... |
51 if (!frame) | 51 if (!frame) |
52 return v8::Boolean::New(false); | 52 return v8::Boolean::New(false); |
53 | 53 |
54 GURL url(frame->url()); | 54 GURL url(frame->url()); |
55 if (url.is_empty() || | 55 if (url.is_empty() || |
56 !url.is_valid() || | 56 !url.is_valid() || |
57 !(url.SchemeIs("http") || url.SchemeIs("https"))) | 57 !(url.SchemeIs("http") || url.SchemeIs("https"))) |
58 return v8::Boolean::New(false); | 58 return v8::Boolean::New(false); |
59 | 59 |
60 bool has_web_extent = | 60 bool has_web_extent = |
61 RenderThread::current()->GetExtensions()->GetByURL(url) != NULL; | 61 ExtensionDispatcher::Get()->extensions()->GetByURL(url) != NULL; |
62 return v8::Boolean::New(has_web_extent); | 62 return v8::Boolean::New(has_web_extent); |
63 } | 63 } |
64 | 64 |
65 static v8::Handle<v8::Value> Install(const v8::Arguments& args) { | 65 static v8::Handle<v8::Value> Install(const v8::Arguments& args) { |
66 WebFrame* frame = WebFrame::frameForCurrentContext(); | 66 WebFrame* frame = WebFrame::frameForCurrentContext(); |
67 RenderView* render_view = bindings_utils::GetRenderViewForCurrentContext(); | 67 RenderView* render_view = bindings_utils::GetRenderViewForCurrentContext(); |
68 if (frame && render_view) { | 68 if (frame && render_view) { |
69 string16 error; | 69 string16 error; |
70 if (!render_view->InstallWebApplicationUsingDefinitionFile(frame, &error)) | 70 if (!render_view->InstallWebApplicationUsingDefinitionFile(frame, &error)) |
71 v8::ThrowException(v8::String::New(UTF16ToUTF8(error).c_str())); | 71 v8::ThrowException(v8::String::New(UTF16ToUTF8(error).c_str())); |
72 } | 72 } |
73 | 73 |
74 return v8::Undefined(); | 74 return v8::Undefined(); |
75 } | 75 } |
76 }; | 76 }; |
77 | 77 |
78 v8::Extension* ChromeAppExtension::Get() { | 78 v8::Extension* ChromeAppExtension::Get() { |
79 return new ChromeAppExtensionWrapper(); | 79 return new ChromeAppExtensionWrapper(); |
80 } | 80 } |
81 | 81 |
82 } // namespace extensions_v8 | 82 } // namespace extensions_v8 |
OLD | NEW |