-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Blink: Move isolated world related calls out of WebLocalFrame.
Isolated worlds are per renderer. Hence the functions to set IsolatedWorldInfo and query information about an isolated world don't belong on a WebLocalFrame. This CL moves them out of the WebLocalFrame. In WebLocalFrameImpl::SetIsolatedWorldInfo, currently we use the corresponding dom window's agent cluster ID for the isolated world origin. This is probably incorrect since the isolated world security origin is per renderer. To accommodate agent cluster ID, DOMWrapperWorld::IsolatedWorldSecurityOrigin is modified to take in a cluster ID from the client. BUG=961448, 896041 Change-Id: Ice72c3f4f3f99372093422ea581ba0545375122c Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2255746 Auto-Submit: Karan Bhatia <karandeepb@chromium.org> Reviewed-by: Takashi Toyoshima <toyoshim@chromium.org> Reviewed-by: Mike West <mkwst@chromium.org> Reviewed-by: Chris Hamilton <chrisha@chromium.org> Reviewed-by: Devlin <rdevlin.cronin@chromium.org> Reviewed-by: danakj <danakj@chromium.org> Reviewed-by: Dave Tapuska <dtapuska@chromium.org> Commit-Queue: Karan Bhatia <karandeepb@chromium.org> Cr-Commit-Position: refs/heads/master@{#788942}
- Loading branch information
Karandeep Bhatia
authored and
Commit Bot
committed
Jul 16, 2020
1 parent
b4592b5
commit 4a8b435
Showing
21 changed files
with
174 additions
and
150 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
components/translate/content/renderer/isolated_world_util.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Copyright 2020 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "components/translate/content/renderer/isolated_world_util.h" | ||
|
||
#include "base/check_op.h" | ||
#include "base/optional.h" | ||
#include "components/translate/core/common/translate_util.h" | ||
#include "third_party/blink/public/platform/web_isolated_world_info.h" | ||
#include "third_party/blink/public/platform/web_url.h" | ||
|
||
namespace translate { | ||
|
||
void EnsureIsolatedWorldInitialized(int world_id) { | ||
static base::Optional<int> last_used_world_id; | ||
if (last_used_world_id) { | ||
// Early return since the isolated world info. is already initialized. | ||
DCHECK_EQ(*last_used_world_id, world_id) | ||
<< "EnsureIsolatedWorldInitialized should always be called with the " | ||
"same |world_id|"; | ||
return; | ||
} | ||
|
||
last_used_world_id = world_id; | ||
constexpr char kContentSecurityPolicy[] = "script-src 'self' 'unsafe-eval'"; | ||
|
||
blink::WebIsolatedWorldInfo info; | ||
info.security_origin = | ||
blink::WebSecurityOrigin::Create(GetTranslateSecurityOrigin()); | ||
info.content_security_policy = | ||
blink::WebString::FromUTF8(kContentSecurityPolicy); | ||
blink::SetIsolatedWorldInfo(world_id, info); | ||
} | ||
|
||
} // namespace translate |
15 changes: 15 additions & 0 deletions
15
components/translate/content/renderer/isolated_world_util.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Copyright 2020 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#ifndef COMPONENTS_TRANSLATE_CONTENT_RENDERER_ISOLATED_WORLD_UTIL_H_ | ||
#define COMPONENTS_TRANSLATE_CONTENT_RENDERER_ISOLATED_WORLD_UTIL_H_ | ||
|
||
namespace translate { | ||
|
||
// Ensures the isolated world information for |world_id| is initialized. | ||
void EnsureIsolatedWorldInitialized(int world_id); | ||
|
||
} // namespace translate | ||
|
||
#endif // COMPONENTS_TRANSLATE_CONTENT_RENDERER_ISOLATED_WORLD_UTIL_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.