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/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/json/json_writer.h" | 8 #include "base/json/json_writer.h" |
9 #include "base/string16.h" | 9 #include "base/string16.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
11 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
12 #include "base/values.h" | 12 #include "base/values.h" |
13 #include "chrome/common/chrome_switches.h" | 13 #include "chrome/common/chrome_switches.h" |
14 #include "chrome/common/extensions/extension_set.h" | 14 #include "chrome/common/extensions/extension_set.h" |
15 #include "chrome/renderer/extensions/bindings_utils.h" | 15 #include "chrome/renderer/extensions/bindings_utils.h" |
16 #include "chrome/renderer/extensions/extension_dispatcher.h" | 16 #include "chrome/renderer/extensions/extension_dispatcher.h" |
| 17 #include "chrome/renderer/extensions/extension_helper.h" |
17 #include "content/renderer/render_view.h" | 18 #include "content/renderer/render_view.h" |
18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" | 19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
19 #include "v8/include/v8.h" | 20 #include "v8/include/v8.h" |
20 | 21 |
21 using WebKit::WebFrame; | 22 using WebKit::WebFrame; |
22 | 23 |
23 namespace { | 24 namespace { |
24 | 25 |
25 bool IsCheckoutURL(const std::string& url_spec) { | 26 bool IsCheckoutURL(const std::string& url_spec) { |
26 std::string checkout_url_prefix = | 27 std::string checkout_url_prefix = |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 bool has_web_extent = | 117 bool has_web_extent = |
117 extension_dispatcher_->extensions()->GetByURL(url) != NULL; | 118 extension_dispatcher_->extensions()->GetByURL(url) != NULL; |
118 return v8::Boolean::New(has_web_extent); | 119 return v8::Boolean::New(has_web_extent); |
119 } | 120 } |
120 | 121 |
121 static v8::Handle<v8::Value> Install(const v8::Arguments& args) { | 122 static v8::Handle<v8::Value> Install(const v8::Arguments& args) { |
122 WebFrame* frame = WebFrame::frameForCurrentContext(); | 123 WebFrame* frame = WebFrame::frameForCurrentContext(); |
123 RenderView* render_view = bindings_utils::GetRenderViewForCurrentContext(); | 124 RenderView* render_view = bindings_utils::GetRenderViewForCurrentContext(); |
124 if (frame && render_view) { | 125 if (frame && render_view) { |
125 string16 error; | 126 string16 error; |
126 if (!render_view->InstallWebApplicationUsingDefinitionFile(frame, &error)) | 127 |
| 128 ExtensionHelper* helper = ExtensionHelper::Get(render_view); |
| 129 if (!helper->InstallWebApplicationUsingDefinitionFile(frame, &error)) |
127 v8::ThrowException(v8::String::New(UTF16ToUTF8(error).c_str())); | 130 v8::ThrowException(v8::String::New(UTF16ToUTF8(error).c_str())); |
128 } | 131 } |
129 | 132 |
130 return v8::Undefined(); | 133 return v8::Undefined(); |
131 } | 134 } |
132 | 135 |
133 static v8::Handle<v8::Value> GetDetails(const v8::Arguments& args) { | 136 static v8::Handle<v8::Value> GetDetails(const v8::Arguments& args) { |
134 return GetDetailsForFrameImpl(WebFrame::frameForCurrentContext()); | 137 return GetDetailsForFrameImpl(WebFrame::frameForCurrentContext()); |
135 } | 138 } |
136 | 139 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 }; | 183 }; |
181 | 184 |
182 ExtensionDispatcher* ChromeAppExtensionWrapper::extension_dispatcher_; | 185 ExtensionDispatcher* ChromeAppExtensionWrapper::extension_dispatcher_; |
183 | 186 |
184 v8::Extension* ChromeAppExtension::Get( | 187 v8::Extension* ChromeAppExtension::Get( |
185 ExtensionDispatcher* extension_dispatcher) { | 188 ExtensionDispatcher* extension_dispatcher) { |
186 return new ChromeAppExtensionWrapper(extension_dispatcher); | 189 return new ChromeAppExtensionWrapper(extension_dispatcher); |
187 } | 190 } |
188 | 191 |
189 } // namespace extensions_v8 | 192 } // namespace extensions_v8 |
OLD | NEW |