| 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/common/extensions/extension_process_policy.h" | 5 #include "chrome/common/extensions/extension_process_policy.h" |
| 6 | 6 |
| 7 #include "chrome/common/extensions/extension_set.h" | 7 #include "chrome/common/extensions/extension_set.h" |
| 8 | 8 |
| 9 namespace extensions { | 9 namespace extensions { |
| 10 | 10 |
| 11 const Extension* GetNonBookmarkAppExtension( | 11 const Extension* GetNonBookmarkAppExtension( |
| 12 const ExtensionSet& extensions, const ExtensionURLInfo& url) { | 12 const ExtensionSet& extensions, const ExtensionURLInfo& url) { |
| 13 // Exclude bookmark apps, which do not use the app process model. | 13 // Exclude bookmark apps, which do not use the app process model. |
| 14 const Extension* extension = extensions.GetExtensionOrAppByURL(url); | 14 const Extension* extension = extensions.GetExtensionOrAppByURL(url); |
| 15 if (extension && extension->from_bookmark()) | 15 if (extension && extension->from_bookmark()) |
| 16 extension = NULL; | 16 extension = NULL; |
| 17 return extension; | 17 return extension; |
| 18 } | 18 } |
| 19 | 19 |
| 20 bool CrossesExtensionProcessBoundary( | 20 bool CrossesExtensionProcessBoundary( |
| 21 const ExtensionSet& extensions, | 21 const ExtensionSet& extensions, |
| 22 const ExtensionURLInfo& old_url, | 22 const ExtensionURLInfo& old_url, |
| 23 const ExtensionURLInfo& new_url) { | 23 const ExtensionURLInfo& new_url) { |
| 24 const Extension* old_url_extension = GetNonBookmarkAppExtension(extensions, | 24 const Extension* old_url_extension = GetNonBookmarkAppExtension(extensions, |
| 25 old_url); | 25 old_url); |
| 26 const Extension* new_url_extension = GetNonBookmarkAppExtension(extensions, | 26 const Extension* new_url_extension = GetNonBookmarkAppExtension(extensions, |
| 27 new_url); | 27 new_url); |
| 28 | 28 |
| 29 // TODO(creis): Temporary workaround for crbug.com/59285: Do not swap process | |
| 30 // to navigate from a hosted app to a normal page or another hosted app | |
| 31 // (unless either is the web store). This is because we do not yet support | |
| 32 // postMessage calls from outside the app back into it (e.g., as in Facebook | |
| 33 // OAuth 2.0). This will be removed when http://crbug.com/99202 is fixed. | |
| 34 bool old_url_is_hosted_app = old_url_extension && | |
| 35 !old_url_extension->web_extent().is_empty(); | |
| 36 bool new_url_is_normal_or_hosted = !new_url_extension || | |
| 37 !new_url_extension->web_extent().is_empty(); | |
| 38 bool either_is_web_store = | |
| 39 (old_url_extension && | |
| 40 old_url_extension->id() == extension_misc::kWebStoreAppId) || | |
| 41 (new_url_extension && | |
| 42 new_url_extension->id() == extension_misc::kWebStoreAppId); | |
| 43 if (old_url_is_hosted_app && | |
| 44 new_url_is_normal_or_hosted && | |
| 45 !either_is_web_store) | |
| 46 return false; | |
| 47 | |
| 48 return old_url_extension != new_url_extension; | 29 return old_url_extension != new_url_extension; |
| 49 } | 30 } |
| 50 | 31 |
| 51 } // namespace extensions | 32 } // namespace extensions |
| OLD | NEW |