OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/debug/crash_logging.h" | 8 #include "base/debug/crash_logging.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/metrics/field_trial.h" | 10 #include "base/metrics/field_trial.h" |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 for (size_t i = 0; i < params.attributeNames.size(); ++i) { | 276 for (size_t i = 0; i < params.attributeNames.size(); ++i) { |
277 if (params.attributeNames[i].utf8() == "poster" && | 277 if (params.attributeNames[i].utf8() == "poster" && |
278 !params.attributeValues[i].isEmpty()) { | 278 !params.attributeValues[i].isEmpty()) { |
279 return page_base_url.Resolve(params.attributeValues[i].utf8()); | 279 return page_base_url.Resolve(params.attributeValues[i].utf8()); |
280 } | 280 } |
281 } | 281 } |
282 return GURL(); | 282 return GURL(); |
283 } | 283 } |
284 #endif | 284 #endif |
285 | 285 |
| 286 #if defined(ENABLE_EXTENSIONS) |
| 287 bool IsStandaloneExtensionProcess() { |
| 288 return base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 289 extensions::switches::kExtensionProcess); |
| 290 } |
| 291 #endif |
286 } // namespace | 292 } // namespace |
287 | 293 |
288 ChromeContentRendererClient::ChromeContentRendererClient() { | 294 ChromeContentRendererClient::ChromeContentRendererClient() { |
289 g_current_client = this; | 295 g_current_client = this; |
290 | 296 |
291 #if defined(ENABLE_EXTENSIONS) | 297 #if defined(ENABLE_EXTENSIONS) |
292 extensions::ExtensionsClient::Set( | 298 extensions::ExtensionsClient::Set( |
293 extensions::ChromeExtensionsClient::GetInstance()); | 299 extensions::ChromeExtensionsClient::GetInstance()); |
294 extensions::ExtensionsRendererClient::Set( | 300 extensions::ExtensionsRendererClient::Set( |
295 ChromeExtensionsRendererClient::GetInstance()); | 301 ChromeExtensionsRendererClient::GetInstance()); |
(...skipping 857 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1153 } | 1159 } |
1154 | 1160 |
1155 if (error_description) { | 1161 if (error_description) { |
1156 if (!extension) | 1162 if (!extension) |
1157 *error_description = LocalizedError::GetErrorDetails(error, is_post); | 1163 *error_description = LocalizedError::GetErrorDetails(error, is_post); |
1158 } | 1164 } |
1159 } | 1165 } |
1160 | 1166 |
1161 bool ChromeContentRendererClient::RunIdleHandlerWhenWidgetsHidden() { | 1167 bool ChromeContentRendererClient::RunIdleHandlerWhenWidgetsHidden() { |
1162 #if defined(ENABLE_EXTENSIONS) | 1168 #if defined(ENABLE_EXTENSIONS) |
1163 return !extension_dispatcher_->is_extension_process(); | 1169 return !IsStandaloneExtensionProcess(); |
1164 #else | 1170 #else |
1165 return true; | 1171 return true; |
1166 #endif | 1172 #endif |
1167 } | 1173 } |
1168 | 1174 |
1169 bool ChromeContentRendererClient::AllowPopup() { | 1175 bool ChromeContentRendererClient::AllowPopup() { |
1170 #if defined(ENABLE_EXTENSIONS) | 1176 #if defined(ENABLE_EXTENSIONS) |
1171 extensions::ScriptContext* current_context = | 1177 extensions::ScriptContext* current_context = |
1172 extension_dispatcher_->script_context_set().GetCurrent(); | 1178 extension_dispatcher_->script_context_set().GetCurrent(); |
1173 if (!current_context || !current_context->extension()) | 1179 if (!current_context || !current_context->extension()) |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1268 extension_misc::APP_LAUNCH_CONTENT_NAVIGATION, extension->GetType()); | 1274 extension_misc::APP_LAUNCH_CONTENT_NAVIGATION, extension->GetType()); |
1269 } | 1275 } |
1270 return true; | 1276 return true; |
1271 } | 1277 } |
1272 | 1278 |
1273 // If this is a reload, check whether it has the wrong process type. We | 1279 // If this is a reload, check whether it has the wrong process type. We |
1274 // should send it to the browser if it's an extension URL (e.g., hosted app) | 1280 // should send it to the browser if it's an extension URL (e.g., hosted app) |
1275 // in a normal process, or if it's a process for an extension that has been | 1281 // in a normal process, or if it's a process for an extension that has been |
1276 // uninstalled. | 1282 // uninstalled. |
1277 if (frame->top()->document().url() == url) { | 1283 if (frame->top()->document().url() == url) { |
1278 if (is_extension_url != extension_dispatcher_->is_extension_process()) | 1284 if (is_extension_url != IsStandaloneExtensionProcess()) |
1279 return true; | 1285 return true; |
1280 } | 1286 } |
1281 #endif // defined(ENABLE_EXTENSIONS) | 1287 #endif // defined(ENABLE_EXTENSIONS) |
1282 | 1288 |
1283 return false; | 1289 return false; |
1284 } | 1290 } |
1285 | 1291 |
1286 #if defined(ENABLE_EXTENSIONS) | 1292 #if defined(ENABLE_EXTENSIONS) |
1287 bool ChromeContentRendererClient::ShouldForwardToGuestContainer( | 1293 bool ChromeContentRendererClient::ShouldForwardToGuestContainer( |
1288 const IPC::Message& msg) { | 1294 const IPC::Message& msg) { |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1392 // If we're about to open a normal web page from a same-origin opener stuck | 1398 // If we're about to open a normal web page from a same-origin opener stuck |
1393 // in an extension process, we want to keep it in process to allow the | 1399 // in an extension process, we want to keep it in process to allow the |
1394 // opener to script it. | 1400 // opener to script it. |
1395 WebDocument opener_document = frame->opener()->document(); | 1401 WebDocument opener_document = frame->opener()->document(); |
1396 WebSecurityOrigin opener = frame->opener()->document().securityOrigin(); | 1402 WebSecurityOrigin opener = frame->opener()->document().securityOrigin(); |
1397 bool opener_is_extension_url = | 1403 bool opener_is_extension_url = |
1398 !opener.isUnique() && extensions.GetExtensionOrAppByURL( | 1404 !opener.isUnique() && extensions.GetExtensionOrAppByURL( |
1399 opener_document.url()) != NULL; | 1405 opener_document.url()) != NULL; |
1400 if (!is_extension_url && | 1406 if (!is_extension_url && |
1401 !opener_is_extension_url && | 1407 !opener_is_extension_url && |
1402 extension_dispatcher_->is_extension_process() && | 1408 IsStandaloneExtensionProcess() && |
1403 opener.canRequest(WebURL(new_url))) | 1409 opener.canRequest(WebURL(new_url))) |
1404 return false; | 1410 return false; |
1405 | 1411 |
1406 // In all other cases, we want to compare against the top frame's URL (as | 1412 // In all other cases, we want to compare against the top frame's URL (as |
1407 // opposed to the opener frame's), since that's what determines the type of | 1413 // opposed to the opener frame's), since that's what determines the type of |
1408 // process. This allows iframes outside an app to open a popup in the app. | 1414 // process. This allows iframes outside an app to open a popup in the app. |
1409 old_url = frame->top()->opener()->top()->document().url(); | 1415 old_url = frame->top()->opener()->top()->document().url(); |
1410 } | 1416 } |
1411 | 1417 |
1412 // Only consider keeping non-app URLs in an app process if this window | 1418 // Only consider keeping non-app URLs in an app process if this window |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1580 if (mime_type == content::kBrowserPluginMimeType) { | 1586 if (mime_type == content::kBrowserPluginMimeType) { |
1581 return new extensions::ExtensionsGuestViewContainer(render_frame); | 1587 return new extensions::ExtensionsGuestViewContainer(render_frame); |
1582 } else { | 1588 } else { |
1583 return new extensions::MimeHandlerViewContainer( | 1589 return new extensions::MimeHandlerViewContainer( |
1584 render_frame, mime_type, original_url); | 1590 render_frame, mime_type, original_url); |
1585 } | 1591 } |
1586 #else | 1592 #else |
1587 return NULL; | 1593 return NULL; |
1588 #endif | 1594 #endif |
1589 } | 1595 } |
OLD | NEW |