OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/chrome_content_renderer_client.h" | 5 #include "chrome/renderer/chrome_content_renderer_client.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/values.h" | 8 #include "base/values.h" |
9 #include "chrome/common/chrome_constants.h" | 9 #include "chrome/common/chrome_constants.h" |
10 #include "chrome/common/chrome_switches.h" | 10 #include "chrome/common/chrome_switches.h" |
11 #include "chrome/common/jstemplate_builder.h" | 11 #include "chrome/common/jstemplate_builder.h" |
12 #include "chrome/common/render_messages.h" | 12 #include "chrome/common/render_messages.h" |
13 #include "chrome/common/url_constants.h" | 13 #include "chrome/common/url_constants.h" |
14 #include "chrome/renderer/blocked_plugin.h" | 14 #include "chrome/renderer/blocked_plugin.h" |
| 15 #include "chrome/renderer/extensions/bindings_utils.h" |
| 16 #include "chrome/renderer/extensions/extension_dispatcher.h" |
15 #include "chrome/renderer/localized_error.h" | 17 #include "chrome/renderer/localized_error.h" |
16 #include "chrome/renderer/render_thread.h" | |
17 #include "content/common/view_messages.h" | 18 #include "content/common/view_messages.h" |
18 #include "content/renderer/render_view.h" | 19 #include "content/renderer/render_view.h" |
19 #include "grit/generated_resources.h" | 20 #include "grit/generated_resources.h" |
20 #include "grit/locale_settings.h" | 21 #include "grit/locale_settings.h" |
21 #include "grit/renderer_resources.h" | 22 #include "grit/renderer_resources.h" |
22 #include "net/base/net_errors.h" | 23 #include "net/base/net_errors.h" |
23 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" | 24 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
24 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginParams.h" | 25 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginParams.h" |
25 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURL.h" | 26 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURL.h" |
26 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLError.h" | 27 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLError.h" |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 const WebURLRequest& failed_request, | 163 const WebURLRequest& failed_request, |
163 const WebURLError& error) { | 164 const WebURLError& error) { |
164 GURL failed_url = error.unreachableURL; | 165 GURL failed_url = error.unreachableURL; |
165 std::string html; | 166 std::string html; |
166 const Extension* extension = NULL; | 167 const Extension* extension = NULL; |
167 | 168 |
168 // Use a local error page. | 169 // Use a local error page. |
169 int resource_id; | 170 int resource_id; |
170 DictionaryValue error_strings; | 171 DictionaryValue error_strings; |
171 if (failed_url.is_valid() && !failed_url.SchemeIs(chrome::kExtensionScheme)) | 172 if (failed_url.is_valid() && !failed_url.SchemeIs(chrome::kExtensionScheme)) |
172 extension = RenderThread::current()->GetExtensions()->GetByURL(failed_url); | 173 extension = ExtensionDispatcher::Get()->extensions()->GetByURL(failed_url); |
173 if (extension) { | 174 if (extension) { |
174 LocalizedError::GetAppErrorStrings(error, failed_url, extension, | 175 LocalizedError::GetAppErrorStrings(error, failed_url, extension, |
175 &error_strings); | 176 &error_strings); |
176 | 177 |
177 // TODO(erikkay): Should we use a different template for different | 178 // TODO(erikkay): Should we use a different template for different |
178 // error messages? | 179 // error messages? |
179 resource_id = IDR_ERROR_APP_HTML; | 180 resource_id = IDR_ERROR_APP_HTML; |
180 } else { | 181 } else { |
181 if (error.domain == WebString::fromUTF8(net::kErrorDomain) && | 182 if (error.domain == WebString::fromUTF8(net::kErrorDomain) && |
182 error.reason == net::ERR_CACHE_MISS && | 183 error.reason == net::ERR_CACHE_MISS && |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 // the languages CLD can detect. As a result, it'll return the invalid | 222 // the languages CLD can detect. As a result, it'll return the invalid |
222 // language code for tradtional Chinese among others. | 223 // language code for tradtional Chinese among others. |
223 // |LanguageCodeWithDialect| will go through ISO 639-1, ISO-639-2 and | 224 // |LanguageCodeWithDialect| will go through ISO 639-1, ISO-639-2 and |
224 // 'other' tables to do the 'right' thing. In addition, it'll return zh-CN | 225 // 'other' tables to do the 'right' thing. In addition, it'll return zh-CN |
225 // for Simplified Chinese. | 226 // for Simplified Chinese. |
226 language = LanguageCodeWithDialects(cld_language); | 227 language = LanguageCodeWithDialects(cld_language); |
227 } | 228 } |
228 return language; | 229 return language; |
229 } | 230 } |
230 | 231 |
| 232 bool ChromeContentRendererClient::RunIdleHandlerWhenWidgetsHidden() { |
| 233 return !ExtensionDispatcher::Get()->is_extension_process(); |
| 234 } |
| 235 |
| 236 bool ChromeContentRendererClient::AllowPopup(const GURL& creator) { |
| 237 // Extensions and apps always allowed to create unrequested popups. The second |
| 238 // check is necessary to include content scripts. |
| 239 return ExtensionDispatcher::Get()->extensions()->GetByURL(creator) || |
| 240 bindings_utils::GetInfoForCurrentContext(); |
| 241 } |
| 242 |
231 } // namespace chrome | 243 } // namespace chrome |
OLD | NEW |