Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(17)

Side by Side Diff: chrome/renderer/chrome_content_renderer_client.cc

Issue 956313002: ChromeContentRendererClient should not rely on Dispatcher::is_extension_process (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 bool IsSingleProcess() {
Lei Zhang 2015/02/26 22:17:58 Given you want to do this check in every place in
not at google - send to devlin 2015/02/26 22:25:03 I don't know this code that well either, but note
Devlin 2015/02/27 16:54:32 Two things: - I tend to agree with Ben - if "lying
João Eiras 2015/03/02 17:02:48 I changed the dispatcher code then. Thanks for you
287 return !base::CommandLine::ForCurrentProcess()->HasSwitch(
288 switches::kSingleProcess);
289 }
290
286 } // namespace 291 } // namespace
287 292
288 ChromeContentRendererClient::ChromeContentRendererClient() { 293 ChromeContentRendererClient::ChromeContentRendererClient() {
289 g_current_client = this; 294 g_current_client = this;
290 295
291 #if defined(ENABLE_EXTENSIONS) 296 #if defined(ENABLE_EXTENSIONS)
292 extensions::ExtensionsClient::Set( 297 extensions::ExtensionsClient::Set(
293 extensions::ChromeExtensionsClient::GetInstance()); 298 extensions::ChromeExtensionsClient::GetInstance());
294 extensions::ExtensionsRendererClient::Set( 299 extensions::ExtensionsRendererClient::Set(
295 ChromeExtensionsRendererClient::GetInstance()); 300 ChromeExtensionsRendererClient::GetInstance());
(...skipping 857 matching lines...) Expand 10 before | Expand all | Expand 10 after
1153 } 1158 }
1154 1159
1155 if (error_description) { 1160 if (error_description) {
1156 if (!extension) 1161 if (!extension)
1157 *error_description = LocalizedError::GetErrorDetails(error, is_post); 1162 *error_description = LocalizedError::GetErrorDetails(error, is_post);
1158 } 1163 }
1159 } 1164 }
1160 1165
1161 bool ChromeContentRendererClient::RunIdleHandlerWhenWidgetsHidden() { 1166 bool ChromeContentRendererClient::RunIdleHandlerWhenWidgetsHidden() {
1162 #if defined(ENABLE_EXTENSIONS) 1167 #if defined(ENABLE_EXTENSIONS)
1163 return !extension_dispatcher_->is_extension_process(); 1168 return !extension_dispatcher_->is_extension_process() || IsSingleProcess();
1164 #else 1169 #else
1165 return true; 1170 return true;
1166 #endif 1171 #endif
1167 } 1172 }
1168 1173
1169 bool ChromeContentRendererClient::AllowPopup() { 1174 bool ChromeContentRendererClient::AllowPopup() {
1170 #if defined(ENABLE_EXTENSIONS) 1175 #if defined(ENABLE_EXTENSIONS)
1171 extensions::ScriptContext* current_context = 1176 extensions::ScriptContext* current_context =
1172 extension_dispatcher_->script_context_set().GetCurrent(); 1177 extension_dispatcher_->script_context_set().GetCurrent();
1173 if (!current_context || !current_context->extension()) 1178 if (!current_context || !current_context->extension())
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
1268 extension_misc::APP_LAUNCH_CONTENT_NAVIGATION, extension->GetType()); 1273 extension_misc::APP_LAUNCH_CONTENT_NAVIGATION, extension->GetType());
1269 } 1274 }
1270 return true; 1275 return true;
1271 } 1276 }
1272 1277
1273 // If this is a reload, check whether it has the wrong process type. We 1278 // 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) 1279 // 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 1280 // in a normal process, or if it's a process for an extension that has been
1276 // uninstalled. 1281 // uninstalled.
1277 if (frame->top()->document().url() == url) { 1282 if (frame->top()->document().url() == url) {
1278 if (is_extension_url != extension_dispatcher_->is_extension_process()) 1283 if (is_extension_url != extension_dispatcher_->is_extension_process() &&
1284 !IsSingleProcess())
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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 extension_dispatcher_->is_extension_process() &&
1409 !IsSingleProcess() &&
1403 opener.canRequest(WebURL(new_url))) 1410 opener.canRequest(WebURL(new_url)))
1404 return false; 1411 return false;
1405 1412
1406 // In all other cases, we want to compare against the top frame's URL (as 1413 // 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 1414 // 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. 1415 // process. This allows iframes outside an app to open a popup in the app.
1409 old_url = frame->top()->opener()->top()->document().url(); 1416 old_url = frame->top()->opener()->top()->document().url();
1410 } 1417 }
1411 1418
1412 // Only consider keeping non-app URLs in an app process if this window 1419 // 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
1580 if (mime_type == content::kBrowserPluginMimeType) { 1587 if (mime_type == content::kBrowserPluginMimeType) {
1581 return new extensions::ExtensionsGuestViewContainer(render_frame); 1588 return new extensions::ExtensionsGuestViewContainer(render_frame);
1582 } else { 1589 } else {
1583 return new extensions::MimeHandlerViewContainer( 1590 return new extensions::MimeHandlerViewContainer(
1584 render_frame, mime_type, original_url); 1591 render_frame, mime_type, original_url);
1585 } 1592 }
1586 #else 1593 #else
1587 return NULL; 1594 return NULL;
1588 #endif 1595 #endif
1589 } 1596 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698