Chromium Code Reviews| 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 <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 716 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 727 void ChromeContentRendererClient::SetExtensionDispatcher( | 727 void ChromeContentRendererClient::SetExtensionDispatcher( |
| 728 ExtensionDispatcher* extension_dispatcher) { | 728 ExtensionDispatcher* extension_dispatcher) { |
| 729 extension_dispatcher_.reset(extension_dispatcher); | 729 extension_dispatcher_.reset(extension_dispatcher); |
| 730 } | 730 } |
| 731 | 731 |
| 732 bool ChromeContentRendererClient::CrossesExtensionExtents( | 732 bool ChromeContentRendererClient::CrossesExtensionExtents( |
| 733 WebFrame* frame, | 733 WebFrame* frame, |
| 734 const GURL& new_url, | 734 const GURL& new_url, |
| 735 bool is_initial_navigation) { | 735 bool is_initial_navigation) { |
| 736 const ExtensionSet* extensions = extension_dispatcher_->extensions(); | 736 const ExtensionSet* extensions = extension_dispatcher_->extensions(); |
| 737 bool is_extension_url = !!extensions->GetByURL(new_url); | 737 |
| 738 // Determine if the new URL is an extension. | |
| 739 // Exclude bookmark apps, which do not use the app process model. | |
| 738 GURL old_url(frame->top()->document().url()); | 740 GURL old_url(frame->top()->document().url()); |
| 741 const Extension* new_url_extension = extensions->GetByURL(new_url); | |
|
Aaron Boodman
2011/11/18 18:19:52
Pull this into a helper, so that you don't have to
Charlie Reis
2011/11/18 19:45:42
Done.
| |
| 742 if (new_url_extension && new_url_extension->from_bookmark()) | |
| 743 new_url_extension = NULL; | |
| 739 | 744 |
| 740 // If old_url is still empty and this is an initial navigation, then this is | 745 // If old_url is still empty and this is an initial navigation, then this is |
| 741 // a window.open operation. We should look at the opener URL. | 746 // a window.open operation. We should look at the opener URL. |
| 742 if (is_initial_navigation && old_url.is_empty() && frame->opener()) { | 747 if (is_initial_navigation && old_url.is_empty() && frame->opener()) { |
| 743 // If we're about to open a normal web page from a same-origin opener stuck | 748 // If we're about to open a normal web page from a same-origin opener stuck |
| 744 // in an extension process, we want to keep it in process to allow the | 749 // in an extension process, we want to keep it in process to allow the |
| 745 // opener to script it. | 750 // opener to script it. |
| 746 GURL opener_url = frame->opener()->document().url(); | 751 GURL opener_url = frame->opener()->document().url(); |
| 747 bool opener_is_extension_url = !!extensions->GetByURL(opener_url); | 752 bool opener_is_extension_url = !!extensions->GetByURL(opener_url); |
| 748 WebSecurityOrigin opener = frame->opener()->document().securityOrigin(); | 753 WebSecurityOrigin opener = frame->opener()->document().securityOrigin(); |
| 749 if (!is_extension_url && | 754 if (!new_url_extension && |
| 750 !opener_is_extension_url && | 755 !opener_is_extension_url && |
| 751 extension_dispatcher_->is_extension_process() && | 756 extension_dispatcher_->is_extension_process() && |
| 752 opener.canRequest(WebURL(new_url))) | 757 opener.canRequest(WebURL(new_url))) |
| 753 return false; | 758 return false; |
| 754 | 759 |
| 755 // In all other cases, we want to compare against the top frame's URL (as | 760 // In all other cases, we want to compare against the top frame's URL (as |
| 756 // opposed to the opener frame's), since that's what determines the type of | 761 // opposed to the opener frame's), since that's what determines the type of |
| 757 // process. This allows iframes outside an app to open a popup in the app. | 762 // process. This allows iframes outside an app to open a popup in the app. |
| 758 old_url = frame->top()->opener()->top()->document().url(); | 763 old_url = frame->top()->opener()->top()->document().url(); |
| 759 } | 764 } |
| 760 | 765 |
| 766 // Determine if the old URL is an extension (excluding bookmark apps). | |
| 767 const Extension* old_url_extension = extensions->GetByURL(old_url); | |
| 768 if (old_url_extension && old_url_extension->from_bookmark()) | |
| 769 old_url_extension = NULL; | |
| 770 | |
| 761 // TODO(creis): Temporary workaround for crbug.com/59285: Only return true if | 771 // TODO(creis): Temporary workaround for crbug.com/59285: Only return true if |
| 762 // we would enter an extension app's extent from a non-app, or if we leave an | 772 // we would enter an extension app's extent from a non-app, or if we leave an |
| 763 // extension with no web extent. We avoid swapping processes to exit a hosted | 773 // extension with no web extent. We avoid swapping processes to exit a hosted |
| 764 // app for now, since we do not yet support postMessage calls from outside the | 774 // app for now, since we do not yet support postMessage calls from outside the |
| 765 // app back into it (e.g., as in Facebook OAuth 2.0). | 775 // app back into it (e.g., as in Facebook OAuth 2.0). |
| 766 bool old_url_is_hosted_app = extensions->GetByURL(old_url) && | 776 bool old_url_is_hosted_app = old_url_extension && |
| 767 !extensions->GetByURL(old_url)->web_extent().is_empty(); | 777 !old_url_extension->web_extent().is_empty(); |
| 768 return !extensions->InSameExtent(old_url, new_url) && | 778 if (old_url_is_hosted_app) |
| 769 !old_url_is_hosted_app; | 779 return false; |
| 780 | |
| 781 return old_url_extension != new_url_extension; | |
| 770 } | 782 } |
| 771 | 783 |
| 772 void ChromeContentRendererClient::OnPurgeMemory() { | 784 void ChromeContentRendererClient::OnPurgeMemory() { |
| 773 DVLOG(1) << "Resetting spellcheck in renderer client"; | 785 DVLOG(1) << "Resetting spellcheck in renderer client"; |
| 774 RenderThread* thread = RenderThread::Get(); | 786 RenderThread* thread = RenderThread::Get(); |
| 775 if (spellcheck_.get()) | 787 if (spellcheck_.get()) |
| 776 thread->RemoveObserver(spellcheck_.get()); | 788 thread->RemoveObserver(spellcheck_.get()); |
| 777 SpellCheck* new_spellcheck = new SpellCheck(); | 789 SpellCheck* new_spellcheck = new SpellCheck(); |
| 778 if (spellcheck_provider_) | 790 if (spellcheck_provider_) |
| 779 spellcheck_provider_->SetSpellCheck(new_spellcheck); | 791 spellcheck_provider_->SetSpellCheck(new_spellcheck); |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 802 bool ChromeContentRendererClient::IsOtherExtensionWithWebRequestInstalled() { | 814 bool ChromeContentRendererClient::IsOtherExtensionWithWebRequestInstalled() { |
| 803 return extension_dispatcher_->IsOtherExtensionWithWebRequestInstalled(); | 815 return extension_dispatcher_->IsOtherExtensionWithWebRequestInstalled(); |
| 804 } | 816 } |
| 805 | 817 |
| 806 void ChromeContentRendererClient::RegisterPPAPIInterfaceFactories( | 818 void ChromeContentRendererClient::RegisterPPAPIInterfaceFactories( |
| 807 webkit::ppapi::PpapiInterfaceFactoryManager* factory_manager) { | 819 webkit::ppapi::PpapiInterfaceFactoryManager* factory_manager) { |
| 808 factory_manager->RegisterFactory(ChromePPAPIInterfaceFactory); | 820 factory_manager->RegisterFactory(ChromePPAPIInterfaceFactory); |
| 809 } | 821 } |
| 810 | 822 |
| 811 } // namespace chrome | 823 } // namespace chrome |
| OLD | NEW |