| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009, 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2009, 2012 Google Inc. All rights reserved. |
| 3 * Copyright (C) 2011 Apple Inc. All rights reserved. | 3 * Copyright (C) 2011 Apple Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
| 7 * met: | 7 * met: |
| 8 * | 8 * |
| 9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 web_frame_->Client()->DidCreateDocumentElement(web_frame_); | 205 web_frame_->Client()->DidCreateDocumentElement(web_frame_); |
| 206 } | 206 } |
| 207 | 207 |
| 208 void LocalFrameClientImpl::RunScriptsAtDocumentElementAvailable() { | 208 void LocalFrameClientImpl::RunScriptsAtDocumentElementAvailable() { |
| 209 if (web_frame_->Client()) | 209 if (web_frame_->Client()) |
| 210 web_frame_->Client()->RunScriptsAtDocumentElementAvailable(web_frame_); | 210 web_frame_->Client()->RunScriptsAtDocumentElementAvailable(web_frame_); |
| 211 // The callback might have deleted the frame, do not use |this|! | 211 // The callback might have deleted the frame, do not use |this|! |
| 212 } | 212 } |
| 213 | 213 |
| 214 void LocalFrameClientImpl::RunScriptsAtDocumentReady(bool document_is_empty) { | 214 void LocalFrameClientImpl::RunScriptsAtDocumentReady(bool document_is_empty) { |
| 215 if (!document_is_empty && IsLoadedAsMHTMLArchive(web_frame_->GetFrame())) { |
| 216 // For MHTML pages, recreate the shadow DOM contents from the templates that |
| 217 // are captured from the shadow DOM trees at serialization. |
| 218 // Note that the MHTML page is loaded in sandboxing mode with script |
| 219 // execution disabled and thus only the following script will be executed. |
| 220 // Any other scripts and event handlers outside the scope of the following |
| 221 // script, including those that may be inserted in shadow DOM templates, |
| 222 // will NOT be run. |
| 223 String script = R"( |
| 224 function createShadowRootWithin(node) { |
| 225 var nodes = node.querySelectorAll('template[shadowmode]'); |
| 226 for (var i = 0; i < nodes.length; ++i) { |
| 227 var template = nodes[i]; |
| 228 var mode = template.getAttribute('shadowmode'); |
| 229 var parent = template.parentNode; |
| 230 if (!parent) |
| 231 continue; |
| 232 parent.removeChild(template); |
| 233 var shadowRoot; |
| 234 if (mode == 'v0') { |
| 235 shadowRoot = parent.createShadowRoot(); |
| 236 } else if (mode == 'open' || mode == 'closed') { |
| 237 var delegatesFocus = template.hasAttribute('shadowdelegatesfocus'); |
| 238 shadowRoot = parent.attachShadow({'mode': mode, |
| 239 'delegatesFocus': delegatesFocus}); |
| 240 } |
| 241 if (!shadowRoot) |
| 242 continue; |
| 243 var clone = document.importNode(template.content, true); |
| 244 shadowRoot.appendChild(clone); |
| 245 createShadowRootWithin(shadowRoot); |
| 246 } |
| 247 } |
| 248 createShadowRootWithin(document.body); |
| 249 )"; |
| 250 web_frame_->GetFrame()->GetScriptController().ExecuteScriptInMainWorld( |
| 251 script, ScriptController::kExecuteScriptWhenScriptsDisabled); |
| 252 } |
| 253 |
| 215 if (web_frame_->Client()) { | 254 if (web_frame_->Client()) { |
| 216 web_frame_->Client()->RunScriptsAtDocumentReady(document_is_empty); | 255 web_frame_->Client()->RunScriptsAtDocumentReady(document_is_empty); |
| 217 } | 256 } |
| 218 // The callback might have deleted the frame, do not use |this|! | 257 // The callback might have deleted the frame, do not use |this|! |
| 219 } | 258 } |
| 220 | 259 |
| 221 void LocalFrameClientImpl::RunScriptsAtDocumentIdle() { | 260 void LocalFrameClientImpl::RunScriptsAtDocumentIdle() { |
| 222 if (web_frame_->Client()) | 261 if (web_frame_->Client()) |
| 223 web_frame_->Client()->RunScriptsAtDocumentIdle(); | 262 web_frame_->Client()->RunScriptsAtDocumentIdle(); |
| 224 // The callback might have deleted the frame, do not use |this|! | 263 // The callback might have deleted the frame, do not use |this|! |
| (...skipping 838 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1063 service_manager::InterfaceProvider* | 1102 service_manager::InterfaceProvider* |
| 1064 LocalFrameClientImpl::GetInterfaceProvider() { | 1103 LocalFrameClientImpl::GetInterfaceProvider() { |
| 1065 return web_frame_->Client()->GetInterfaceProvider(); | 1104 return web_frame_->Client()->GetInterfaceProvider(); |
| 1066 } | 1105 } |
| 1067 | 1106 |
| 1068 void LocalFrameClientImpl::AnnotatedRegionsChanged() { | 1107 void LocalFrameClientImpl::AnnotatedRegionsChanged() { |
| 1069 web_frame_->Client()->DraggableRegionsChanged(); | 1108 web_frame_->Client()->DraggableRegionsChanged(); |
| 1070 } | 1109 } |
| 1071 | 1110 |
| 1072 } // namespace blink | 1111 } // namespace blink |
| OLD | NEW |