| OLD | NEW |
| 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 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 return frame_url.SchemeIs(kDirProtocols[i]) && | 371 return frame_url.SchemeIs(kDirProtocols[i]) && |
| 372 frame_url.ExtractFileName().empty(); | 372 frame_url.ExtractFileName().empty(); |
| 373 } | 373 } |
| 374 } | 374 } |
| 375 | 375 |
| 376 return false; | 376 return false; |
| 377 } | 377 } |
| 378 | 378 |
| 379 // Returns true if the frame is navigating to an URL either into or out of an | 379 // Returns true if the frame is navigating to an URL either into or out of an |
| 380 // extension app's extent. | 380 // extension app's extent. |
| 381 static bool CrossesExtensionExtents(WebFrame* frame, const GURL& new_url) { | 381 // TODO(creis): Temporary workaround for crbug.com/65953: Only return true if |
| 382 if (!RenderThread::current()) | 382 // we would enter an extension app's extent from a non-app. We avoid swapping |
| 383 return false; | 383 // processes to exit an app for now, since we do not yet restore context (such |
| 384 | 384 // as window.opener) if the window navigates back. |
| 385 static bool CrossesIntoExtensionExtent(WebFrame* frame, const GURL& new_url) { |
| 385 // If the URL is still empty, this is a window.open navigation. Check the | 386 // If the URL is still empty, this is a window.open navigation. Check the |
| 386 // opener's URL. | 387 // opener's URL. |
| 387 GURL old_url(frame->url()); | 388 GURL old_url(frame->url()); |
| 388 if (old_url.is_empty() && frame->opener()) | 389 if (old_url.is_empty() && frame->opener()) |
| 389 old_url = frame->opener()->url(); | 390 old_url = frame->opener()->url(); |
| 390 | 391 |
| 391 return !ExtensionRendererInfo::InSameExtent(old_url, new_url); | 392 return !ExtensionRendererInfo::InSameExtent(old_url, new_url) && |
| 393 !ExtensionRendererInfo::GetByURL(old_url); |
| 392 } | 394 } |
| 393 | 395 |
| 394 // Returns the ISO 639_1 language code of the specified |text|, or 'unknown' | 396 // Returns the ISO 639_1 language code of the specified |text|, or 'unknown' |
| 395 // if it failed. | 397 // if it failed. |
| 396 static std::string DetermineTextLanguage(const string16& text) { | 398 static std::string DetermineTextLanguage(const string16& text) { |
| 397 std::string language = chrome::kUnknownLanguageCode; | 399 std::string language = chrome::kUnknownLanguageCode; |
| 398 int num_languages = 0; | 400 int num_languages = 0; |
| 399 int text_bytes = 0; | 401 int text_bytes = 0; |
| 400 bool is_reliable = false; | 402 bool is_reliable = false; |
| 401 Language cld_language = | 403 Language cld_language = |
| (...skipping 2592 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2994 // We don't send referrer from extensions. | 2996 // We don't send referrer from extensions. |
| 2995 OpenURL(url, GURL(), default_policy); | 2997 OpenURL(url, GURL(), default_policy); |
| 2996 return WebKit::WebNavigationPolicyIgnore; // Suppress the load here. | 2998 return WebKit::WebNavigationPolicyIgnore; // Suppress the load here. |
| 2997 } | 2999 } |
| 2998 | 3000 |
| 2999 // If the navigation would cross an app extent boundary, we also need | 3001 // If the navigation would cross an app extent boundary, we also need |
| 3000 // to defer to the browser to ensure process isolation. | 3002 // to defer to the browser to ensure process isolation. |
| 3001 // TODO(erikkay) This is happening inside of a check to is_content_initiated | 3003 // 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 | 3004 // which means that things like the back button won't trigger it. Is that |
| 3003 // OK? | 3005 // OK? |
| 3004 if (CrossesExtensionExtents(frame, url)) { | 3006 // TODO(creis): For now, we only swap processes to enter an app and not |
| 3007 // exit it, since we currently lose context (e.g., window.opener) if the |
| 3008 // window navigates back. See crbug.com/65953. |
| 3009 if (CrossesIntoExtensionExtent(frame, url)) { |
| 3005 // Include the referrer in this case since we're going from a hosted web | 3010 // 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 | 3011 // page. (the packaged case is handled previously by the extension |
| 3007 // navigation test) | 3012 // navigation test) |
| 3008 GURL referrer(request.httpHeaderField(WebString::fromUTF8("Referer"))); | 3013 GURL referrer(request.httpHeaderField(WebString::fromUTF8("Referer"))); |
| 3009 OpenURL(url, referrer, default_policy); | 3014 OpenURL(url, referrer, default_policy); |
| 3010 return WebKit::WebNavigationPolicyIgnore; // Suppress the load here. | 3015 return WebKit::WebNavigationPolicyIgnore; // Suppress the load here. |
| 3011 } | 3016 } |
| 3012 } | 3017 } |
| 3013 | 3018 |
| 3014 // Detect when a page is "forking" a new tab that can be safely rendered in | 3019 // 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 Loading... |
| 5728 external_popup_menu_.reset(); | 5733 external_popup_menu_.reset(); |
| 5729 } | 5734 } |
| 5730 #endif | 5735 #endif |
| 5731 | 5736 |
| 5732 void RenderView::AddErrorToRootConsole(const string16& message) { | 5737 void RenderView::AddErrorToRootConsole(const string16& message) { |
| 5733 if (webview() && webview()->mainFrame()) { | 5738 if (webview() && webview()->mainFrame()) { |
| 5734 webview()->mainFrame()->addMessageToConsole( | 5739 webview()->mainFrame()->addMessageToConsole( |
| 5735 WebConsoleMessage(WebConsoleMessage::LevelError, message)); | 5740 WebConsoleMessage(WebConsoleMessage::LevelError, message)); |
| 5736 } | 5741 } |
| 5737 } | 5742 } |
| OLD | NEW |