| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/external_extension.h" | 5 #include "chrome/renderer/external_extension.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "chrome/common/chrome_switches.h" | 8 #include "chrome/common/chrome_switches.h" |
| 9 #include "chrome/common/render_messages.h" | 9 #include "chrome/common/render_messages.h" |
| 10 #include "chrome/common/search_provider.h" | 10 #include "chrome/common/search_provider.h" |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 } | 136 } |
| 137 } | 137 } |
| 138 | 138 |
| 139 return v8::Undefined(); | 139 return v8::Undefined(); |
| 140 } | 140 } |
| 141 | 141 |
| 142 // static | 142 // static |
| 143 v8::Handle<v8::Value> ExternalExtensionWrapper::IsSearchProviderInstalled( | 143 v8::Handle<v8::Value> ExternalExtensionWrapper::IsSearchProviderInstalled( |
| 144 const v8::Arguments& args) { | 144 const v8::Arguments& args) { |
| 145 if (!args.Length()) return v8::Undefined(); | 145 if (!args.Length()) return v8::Undefined(); |
| 146 v8::String::Utf8Value utf8name(args[0]); |
| 147 if (!utf8name.length()) return v8::Undefined(); |
| 146 | 148 |
| 147 std::string name = std::string(*v8::String::Utf8Value(args[0])); | 149 std::string name = std::string(*utf8name); |
| 148 if (!name.length()) return v8::Undefined(); | |
| 149 | |
| 150 RenderView* render_view = GetRenderView(); | 150 RenderView* render_view = GetRenderView(); |
| 151 if (!render_view) return v8::Undefined(); | 151 if (!render_view) return v8::Undefined(); |
| 152 | 152 |
| 153 WebFrame* webframe = WebFrame::frameForEnteredContext(); | 153 WebFrame* webframe = WebFrame::frameForEnteredContext(); |
| 154 if (!webframe) return v8::Undefined(); | 154 if (!webframe) return v8::Undefined(); |
| 155 | 155 |
| 156 search_provider::InstallState install = search_provider::DENIED; | 156 search_provider::InstallState install = search_provider::DENIED; |
| 157 GURL inquiry_url = GURL(name); | 157 GURL inquiry_url = GURL(name); |
| 158 if (!inquiry_url.is_empty()) { | 158 if (!inquiry_url.is_empty()) { |
| 159 render_view->Send(new ViewHostMsg_GetSearchProviderInstallState( | 159 render_view->Send(new ViewHostMsg_GetSearchProviderInstallState( |
| 160 render_view->routing_id(), webframe->url(), inquiry_url, &install)); | 160 render_view->routing_id(), webframe->url(), inquiry_url, &install)); |
| 161 } | 161 } |
| 162 | 162 |
| 163 if (install == search_provider::DENIED) { | 163 if (install == search_provider::DENIED) { |
| 164 // FIXME: throw access denied exception. | 164 // FIXME: throw access denied exception. |
| 165 return v8::ThrowException(v8::Exception::Error(v8::String::Empty())); | 165 return v8::ThrowException(v8::Exception::Error(v8::String::Empty())); |
| 166 } | 166 } |
| 167 return v8::Integer::New(install); | 167 return v8::Integer::New(install); |
| 168 } | 168 } |
| 169 | 169 |
| 170 v8::Extension* ExternalExtension::Get() { | 170 v8::Extension* ExternalExtension::Get() { |
| 171 return new ExternalExtensionWrapper(); | 171 return new ExternalExtensionWrapper(); |
| 172 } | 172 } |
| 173 | 173 |
| 174 } // namespace extensions_v8 | 174 } // namespace extensions_v8 |
| OLD | NEW |