OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 "content/browser/webui/web_ui_impl.h" | 5 #include "content/browser/webui/web_ui_impl.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/debug/dump_without_crashing.h" | 9 #include "base/debug/dump_without_crashing.h" |
10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 class WebUIImpl::MainFrameNavigationObserver : public WebContentsObserver { | 32 class WebUIImpl::MainFrameNavigationObserver : public WebContentsObserver { |
33 public: | 33 public: |
34 MainFrameNavigationObserver(WebUIImpl* web_ui, WebContents* contents) | 34 MainFrameNavigationObserver(WebUIImpl* web_ui, WebContents* contents) |
35 : WebContentsObserver(contents), web_ui_(web_ui) {} | 35 : WebContentsObserver(contents), web_ui_(web_ui) {} |
36 ~MainFrameNavigationObserver() override {} | 36 ~MainFrameNavigationObserver() override {} |
37 | 37 |
38 private: | 38 private: |
39 void DidFinishNavigation(NavigationHandle* navigation_handle) override { | 39 void DidFinishNavigation(NavigationHandle* navigation_handle) override { |
40 // Only disallow JavaScript on cross-document navigations in the main frame. | 40 // Only disallow JavaScript on cross-document navigations in the main frame. |
41 if (!navigation_handle->IsInMainFrame() || | 41 if (!navigation_handle->IsInMainFrame() || |
42 !navigation_handle->HasCommitted() || navigation_handle->IsSamePage()) { | 42 !navigation_handle->HasCommitted() || |
| 43 navigation_handle->IsSameDocument()) { |
43 return; | 44 return; |
44 } | 45 } |
45 | 46 |
46 web_ui_->DisallowJavascriptOnAllHandlers(); | 47 web_ui_->DisallowJavascriptOnAllHandlers(); |
47 } | 48 } |
48 | 49 |
49 WebUIImpl* web_ui_; | 50 WebUIImpl* web_ui_; |
50 }; | 51 }; |
51 | 52 |
52 const WebUI::TypeID WebUI::kNoWebUI = NULL; | 53 const WebUI::TypeID WebUI::kNoWebUI = NULL; |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 if (host->GetFrameName() == frame_name_) | 299 if (host->GetFrameName() == frame_name_) |
299 frame_set->insert(host); | 300 frame_set->insert(host); |
300 } | 301 } |
301 | 302 |
302 void WebUIImpl::DisallowJavascriptOnAllHandlers() { | 303 void WebUIImpl::DisallowJavascriptOnAllHandlers() { |
303 for (const std::unique_ptr<WebUIMessageHandler>& handler : handlers_) | 304 for (const std::unique_ptr<WebUIMessageHandler>& handler : handlers_) |
304 handler->DisallowJavascript(); | 305 handler->DisallowJavascript(); |
305 } | 306 } |
306 | 307 |
307 } // namespace content | 308 } // namespace content |
OLD | NEW |