| 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/renderer/extensions/bindings_utils.h" | 9 #include "chrome/renderer/extensions/bindings_utils.h" |
| 10 #include "chrome/renderer/extensions/extension_renderer_info.h" | 10 #include "chrome/renderer/extensions/extension_renderer_info.h" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 WebFrame* frame = WebFrame::frameForCurrentContext(); | 50 WebFrame* frame = WebFrame::frameForCurrentContext(); |
| 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 = (ExtensionRendererInfo::GetByURL(url) != NULL); | 60 bool has_web_extent = |
| 61 RenderThread::current()->GetExtensions()->GetByURL(url) != NULL; |
| 61 return v8::Boolean::New(has_web_extent); | 62 return v8::Boolean::New(has_web_extent); |
| 62 } | 63 } |
| 63 | 64 |
| 64 static v8::Handle<v8::Value> Install(const v8::Arguments& args) { | 65 static v8::Handle<v8::Value> Install(const v8::Arguments& args) { |
| 65 WebFrame* frame = WebFrame::frameForCurrentContext(); | 66 WebFrame* frame = WebFrame::frameForCurrentContext(); |
| 66 RenderView* render_view = bindings_utils::GetRenderViewForCurrentContext(); | 67 RenderView* render_view = bindings_utils::GetRenderViewForCurrentContext(); |
| 67 if (frame && render_view) { | 68 if (frame && render_view) { |
| 68 string16 error; | 69 string16 error; |
| 69 if (!render_view->InstallWebApplicationUsingDefinitionFile(frame, &error)) | 70 if (!render_view->InstallWebApplicationUsingDefinitionFile(frame, &error)) |
| 70 v8::ThrowException(v8::String::New(UTF16ToUTF8(error).c_str())); | 71 v8::ThrowException(v8::String::New(UTF16ToUTF8(error).c_str())); |
| 71 } | 72 } |
| 72 | 73 |
| 73 return v8::Undefined(); | 74 return v8::Undefined(); |
| 74 } | 75 } |
| 75 }; | 76 }; |
| 76 | 77 |
| 77 v8::Extension* ChromeAppExtension::Get() { | 78 v8::Extension* ChromeAppExtension::Get() { |
| 78 return new ChromeAppExtensionWrapper(); | 79 return new ChromeAppExtensionWrapper(); |
| 79 } | 80 } |
| 80 | 81 |
| 81 } // namespace extensions_v8 | 82 } // namespace extensions_v8 |
| OLD | NEW |