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
3 // found in the LICENSE file.
5 #include "chrome/common/extensions/extension_process_policy.h"
7 #include "chrome/common/extensions/extension_constants.h"
8 #include "chrome/common/extensions/manifest_handlers/app_isolation_info.h"
9 #include "extensions/common/extension.h"
10 #include "extensions/common/extension_set.h"
12 namespace extensions
{
14 const extensions::Extension
* GetNonBookmarkAppExtension(
15 const ExtensionSet
& extensions
, const GURL
& url
) {
16 // Exclude bookmark apps, which do not use the app process model.
17 const extensions::Extension
* extension
=
18 extensions
.GetExtensionOrAppByURL(url
);
19 if (extension
&& extension
->from_bookmark())
24 bool CrossesExtensionProcessBoundary(
25 const ExtensionSet
& extensions
,
28 bool should_consider_workaround
) {
29 const extensions::Extension
* old_url_extension
= GetNonBookmarkAppExtension(
32 const extensions::Extension
* new_url_extension
= GetNonBookmarkAppExtension(
36 // TODO(creis): Temporary workaround for crbug.com/59285: Do not swap process
37 // to navigate from a hosted app to a normal page or another hosted app
38 // (unless either is the web store). This is because some OAuth providers
39 // use non-app popups that communicate with non-app iframes inside the app
40 // (e.g., Facebook). This would require out-of-process iframes to support.
41 // See http://crbug.com/99379.
42 // Note that we skip this exception for isolated apps, which require strict
43 // process separation from non-app pages.
44 if (should_consider_workaround
) {
45 bool old_url_is_hosted_app
= old_url_extension
&&
46 !old_url_extension
->web_extent().is_empty() &&
47 !AppIsolationInfo::HasIsolatedStorage(old_url_extension
);
48 bool new_url_is_normal_or_hosted
= !new_url_extension
||
49 (!new_url_extension
->web_extent().is_empty() &&
50 !AppIsolationInfo::HasIsolatedStorage(new_url_extension
));
51 bool either_is_web_store
=
53 old_url_extension
->id() == extension_misc::kWebStoreAppId
) ||
55 new_url_extension
->id() == extension_misc::kWebStoreAppId
);
56 if (old_url_is_hosted_app
&&
57 new_url_is_normal_or_hosted
&&
62 return old_url_extension
!= new_url_extension
;
65 } // namespace extensions