extensions/renderer/script_injection.cc
int GetIsolatedWorldIdForExtension(const Extension* extension,
                                   blink::WebFrame* frame) {
  static int g_next_isolated_world_id =
      ExtensionsRendererClient::Get()->GetLowestIsolatedWorldId();

  IsolatedWorldMap& isolated_worlds = g_isolated_worlds.Get();

  int id = 0;
  IsolatedWorldMap::iterator iter = isolated_worlds.find(extension->id());
  if (iter != isolated_worlds.end()) {
    id = iter->second;
  } else {
    id = g_next_isolated_world_id++;
    // This map will tend to pile up over time, but realistically, you're never
    // going to have enough extensions for it to matter.
    isolated_worlds[extension->id()] = id;
  }

  // We need to set the isolated world origin and CSP even if it's not a new
  // world since these are stored per frame, and we might not have used this
  // isolated world in this frame before.
  frame->setIsolatedWorldSecurityOrigin(
      id, blink::WebSecurityOrigin::create(extension->url()));
  frame->setIsolatedWorldContentSecurityPolicy(
      id,
      blink::WebString::fromUTF8(CSPInfo::GetContentSecurityPolicy(extension)));

  return id;
}
// Gets the isolated world ID to use for the given |extension| in the given
// |frame|. If no isolated world has been created for that extension,
// one will be created and initialized.
Gets the isolated world ID to use for the given |extension| in the given
|frame|. If no isolated world has been created for that extension,
one will be created and initialized.
Gets the isolated world ID to use for the given |extension| in the given |frame| . If no isolated world has been created for that extension one will be created and initialized .
int GetIsolatedWorldIdForExtension(const Extension* extension,
                                   blink::WebFrame* frame) {
  static int g_next_isolated_world_id =
      ExtensionsRendererClient::Get()->GetLowestIsolatedWorldId();
  IsolatedWorldMap& isolated_worlds = g_isolated_worlds.Get();
  int id = 0;
  IsolatedWorldMap::iterator iter = isolated_worlds.find(extension->id());
  if (iter != isolated_worlds.end()) {
    id = iter->second;
  } else {
    id = g_next_isolated_world_id++;
    isolated_worlds[extension->id()] = id;
  }
  frame->setIsolatedWorldSecurityOrigin(
      id, blink::WebSecurityOrigin::create(extension->url()));
  frame->setIsolatedWorldContentSecurityPolicy(
      id,
      blink::WebString::fromUTF8(CSPInfo::GetContentSecurityPolicy(extension)));
  return id;
}
int GetIsolatedWorldIdForExtension ( const Extension * extension , blink :: WebFrame * frame ) { static int g_next_isolated_world_id = ExtensionsRendererClient :: Get ( ) -> GetLowestIsolatedWorldId ( ) ; IsolatedWorldMap & isolated_worlds = g_isolated_worlds . Get ( ) ; int id = 0 ; IsolatedWorldMap :: iterator iter = isolated_worlds . find ( extension -> id ( ) ) ; if ( iter != isolated_worlds . end ( ) ) { id = iter -> second ; } else { id = g_next_isolated_world_id ++ ; isolated_worlds [ extension -> id ( ) ] = id ; } frame -> setIsolatedWorldSecurityOrigin ( id , blink :: WebSecurityOrigin :: create ( extension -> url ( ) ) ) ; frame -> setIsolatedWorldContentSecurityPolicy ( id , blink :: WebString :: fromUTF8 ( CSPInfo :: GetContentSecurityPolicy ( extension ) ) ) ; return id ; }
Gets the isolated world ID to use for the given |extension| in the given
|frame|.
Gets the isolated world ID to use for the given |extension| in the given |frame| .
// This map will tend to pile up over time, but realistically, you're never // going to have enough extensions for it to matter. // We need to set the isolated world origin and CSP even if it's not a new // world since these are stored per frame, and we might not have used this // isolated world in this frame before.