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

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

Issue 5766003: Temporarily avoid process swaps for renderer navigations away from an app. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Only swap for non-app URLs Created 10 years 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/extensions/extension_browsertests_misc.cc ('k') | 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) 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/render_view.h" 5 #include "chrome/renderer/render_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 384
385 // If the URL is still empty, this is a window.open navigation. Check the 385 // If the URL is still empty, this is a window.open navigation. Check the
386 // opener's URL. 386 // opener's URL.
387 GURL old_url(frame->url()); 387 GURL old_url(frame->url());
388 if (old_url.is_empty() && frame->opener()) 388 if (old_url.is_empty() && frame->opener())
389 old_url = frame->opener()->url(); 389 old_url = frame->opener()->url();
390 390
391 return !ExtensionRendererInfo::InSameExtent(old_url, new_url); 391 return !ExtensionRendererInfo::InSameExtent(old_url, new_url);
392 } 392 }
393 393
394 // Returns true if the frame is in an extension app's extent.
395 static bool InExtensionExtent(WebFrame* frame) {
396 if (!RenderThread::current())
darin (slow to review) 2010/12/14 17:17:40 what is the purpose of this null check? i don't s
Charlie Reis 2010/12/14 18:52:29 We don't need this function anymore, but the same
397 return false;
398
399 // If the URL is still empty, this is a window.open navigation. Check the
400 // opener's URL.
401 GURL old_url(frame->url());
402 if (old_url.is_empty() && frame->opener())
darin (slow to review) 2010/12/14 17:17:40 Why do you bother checking frame->opener() here?
Charlie Reis 2010/12/14 18:52:29 No longer needed here, but still used in CrossesEx
403 old_url = frame->opener()->url();
404
405 return ExtensionRendererInfo::GetByURL(old_url) != NULL;
406 }
407
394 // Returns the ISO 639_1 language code of the specified |text|, or 'unknown' 408 // Returns the ISO 639_1 language code of the specified |text|, or 'unknown'
395 // if it failed. 409 // if it failed.
396 static std::string DetermineTextLanguage(const string16& text) { 410 static std::string DetermineTextLanguage(const string16& text) {
397 std::string language = chrome::kUnknownLanguageCode; 411 std::string language = chrome::kUnknownLanguageCode;
398 int num_languages = 0; 412 int num_languages = 0;
399 int text_bytes = 0; 413 int text_bytes = 0;
400 bool is_reliable = false; 414 bool is_reliable = false;
401 Language cld_language = 415 Language cld_language =
402 DetectLanguageOfUnicodeText(NULL, text.c_str(), true, &is_reliable, 416 DetectLanguageOfUnicodeText(NULL, text.c_str(), true, &is_reliable,
403 &num_languages, NULL, &text_bytes); 417 &num_languages, NULL, &text_bytes);
(...skipping 2590 matching lines...) Expand 10 before | Expand all | Expand 10 after
2994 // We don't send referrer from extensions. 3008 // We don't send referrer from extensions.
2995 OpenURL(url, GURL(), default_policy); 3009 OpenURL(url, GURL(), default_policy);
2996 return WebKit::WebNavigationPolicyIgnore; // Suppress the load here. 3010 return WebKit::WebNavigationPolicyIgnore; // Suppress the load here.
2997 } 3011 }
2998 3012
2999 // If the navigation would cross an app extent boundary, we also need 3013 // If the navigation would cross an app extent boundary, we also need
3000 // to defer to the browser to ensure process isolation. 3014 // to defer to the browser to ensure process isolation.
3001 // TODO(erikkay) This is happening inside of a check to is_content_initiated 3015 // TODO(erikkay) This is happening inside of a check to is_content_initiated
3002 // which means that things like the back button won't trigger it. Is that 3016 // which means that things like the back button won't trigger it. Is that
3003 // OK? 3017 // OK?
3004 if (CrossesExtensionExtents(frame, url)) { 3018 if (CrossesExtensionExtents(frame, url) &&
3019 // Temporary workaround for crbug.com/65953: Only swap processes if we
darin (slow to review) 2010/12/14 17:17:40 nit: Comments like this should have a TODO(creis)
Charlie Reis 2010/12/14 18:52:29 Done.
3020 // are not already in an app, and only if window.opener is null, since
3021 // we do not yet restore window.opener if the window navigates back to
3022 // this process later.
3023 !InExtensionExtent(frame) &&
3024 frame->opener() == NULL) {
darin (slow to review) 2010/12/14 17:17:40 style nit: prefer "!frame->opener()"
Charlie Reis 2010/12/14 18:52:29 Simplified by removing this part of the check and
3005 // Include the referrer in this case since we're going from a hosted web 3025 // Include the referrer in this case since we're going from a hosted web
3006 // page. (the packaged case is handled previously by the extension 3026 // page. (the packaged case is handled previously by the extension
3007 // navigation test) 3027 // navigation test)
3008 GURL referrer(request.httpHeaderField(WebString::fromUTF8("Referer"))); 3028 GURL referrer(request.httpHeaderField(WebString::fromUTF8("Referer")));
3009 OpenURL(url, referrer, default_policy); 3029 OpenURL(url, referrer, default_policy);
3010 return WebKit::WebNavigationPolicyIgnore; // Suppress the load here. 3030 return WebKit::WebNavigationPolicyIgnore; // Suppress the load here.
3011 } 3031 }
3012 } 3032 }
3013 3033
3014 // Detect when a page is "forking" a new tab that can be safely rendered in 3034 // Detect when a page is "forking" a new tab that can be safely rendered in
(...skipping 2713 matching lines...) Expand 10 before | Expand all | Expand 10 after
5728 external_popup_menu_.reset(); 5748 external_popup_menu_.reset();
5729 } 5749 }
5730 #endif 5750 #endif
5731 5751
5732 void RenderView::AddErrorToRootConsole(const string16& message) { 5752 void RenderView::AddErrorToRootConsole(const string16& message) {
5733 if (webview() && webview()->mainFrame()) { 5753 if (webview() && webview()->mainFrame()) {
5734 webview()->mainFrame()->addMessageToConsole( 5754 webview()->mainFrame()->addMessageToConsole(
5735 WebConsoleMessage(WebConsoleMessage::LevelError, message)); 5755 WebConsoleMessage(WebConsoleMessage::LevelError, message));
5736 } 5756 }
5737 } 5757 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_browsertests_misc.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698