Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(360)

Side by Side Diff: Source/core/inspector/InspectorOverlay.cpp

Issue 367863002: Add ScriptForbiddenScopes to style and layout. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Blanket allow inspector scripts. Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/frame/FrameView.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 18 matching lines...) Expand all
29 #include "config.h" 29 #include "config.h"
30 #include "core/inspector/InspectorOverlay.h" 30 #include "core/inspector/InspectorOverlay.h"
31 31
32 #include "bindings/core/v8/ScriptController.h" 32 #include "bindings/core/v8/ScriptController.h"
33 #include "bindings/core/v8/ScriptSourceCode.h" 33 #include "bindings/core/v8/ScriptSourceCode.h"
34 #include "bindings/core/v8/V8InspectorOverlayHost.h" 34 #include "bindings/core/v8/V8InspectorOverlayHost.h"
35 #include "core/InspectorOverlayPage.h" 35 #include "core/InspectorOverlayPage.h"
36 #include "core/dom/Element.h" 36 #include "core/dom/Element.h"
37 #include "core/dom/Node.h" 37 #include "core/dom/Node.h"
38 #include "core/dom/PseudoElement.h" 38 #include "core/dom/PseudoElement.h"
39 #include "core/dom/ScriptForbiddenScope.h"
39 #include "core/frame/FrameView.h" 40 #include "core/frame/FrameView.h"
40 #include "core/frame/LocalFrame.h" 41 #include "core/frame/LocalFrame.h"
42 #include "core/frame/Settings.h"
41 #include "core/inspector/InspectorClient.h" 43 #include "core/inspector/InspectorClient.h"
42 #include "core/inspector/InspectorOverlayHost.h" 44 #include "core/inspector/InspectorOverlayHost.h"
43 #include "core/loader/EmptyClients.h" 45 #include "core/loader/EmptyClients.h"
44 #include "core/loader/FrameLoadRequest.h" 46 #include "core/loader/FrameLoadRequest.h"
45 #include "core/page/Chrome.h" 47 #include "core/page/Chrome.h"
46 #include "core/page/EventHandler.h" 48 #include "core/page/EventHandler.h"
47 #include "core/page/Page.h" 49 #include "core/page/Page.h"
48 #include "core/frame/Settings.h"
49 #include "core/rendering/RenderBoxModelObject.h" 50 #include "core/rendering/RenderBoxModelObject.h"
50 #include "core/rendering/RenderInline.h" 51 #include "core/rendering/RenderInline.h"
51 #include "core/rendering/RenderObject.h" 52 #include "core/rendering/RenderObject.h"
52 #include "core/rendering/style/RenderStyleConstants.h" 53 #include "core/rendering/style/RenderStyleConstants.h"
53 #include "platform/JSONValues.h" 54 #include "platform/JSONValues.h"
54 #include "platform/PlatformMouseEvent.h" 55 #include "platform/PlatformMouseEvent.h"
55 #include "platform/graphics/GraphicsContextStateSaver.h" 56 #include "platform/graphics/GraphicsContextStateSaver.h"
56 #include "wtf/text/StringBuilder.h" 57 #include "wtf/text/StringBuilder.h"
57 #include <v8.h> 58 #include <v8.h>
58 59
(...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after
671 { 672 {
672 if (m_drawViewSize) 673 if (m_drawViewSize)
673 evaluateInOverlay("drawViewSize", m_drawViewSizeWithGrid ? "true" : "fal se"); 674 evaluateInOverlay("drawViewSize", m_drawViewSizeWithGrid ? "true" : "fal se");
674 } 675 }
675 676
676 Page* InspectorOverlay::overlayPage() 677 Page* InspectorOverlay::overlayPage()
677 { 678 {
678 if (m_overlayPage) 679 if (m_overlayPage)
679 return m_overlayPage.get(); 680 return m_overlayPage.get();
680 681
682 ScriptForbiddenScope::AllowUserAgentScript allowScript;
683
681 static FrameLoaderClient* dummyFrameLoaderClient = new EmptyFrameLoaderClie nt; 684 static FrameLoaderClient* dummyFrameLoaderClient = new EmptyFrameLoaderClie nt;
682 Page::PageClients pageClients; 685 Page::PageClients pageClients;
683 fillWithEmptyClients(pageClients); 686 fillWithEmptyClients(pageClients);
684 ASSERT(!m_overlayChromeClient); 687 ASSERT(!m_overlayChromeClient);
685 m_overlayChromeClient = adoptPtr(new InspectorOverlayChromeClient(m_page->ch rome().client(), this)); 688 m_overlayChromeClient = adoptPtr(new InspectorOverlayChromeClient(m_page->ch rome().client(), this));
686 pageClients.chromeClient = m_overlayChromeClient.get(); 689 pageClients.chromeClient = m_overlayChromeClient.get();
687 m_overlayPage = adoptPtrWillBeNoop(new Page(pageClients)); 690 m_overlayPage = adoptPtrWillBeNoop(new Page(pageClients));
688 691
689 Settings& settings = m_page->settings(); 692 Settings& settings = m_page->settings();
690 Settings& overlaySettings = m_overlayPage->settings(); 693 Settings& overlaySettings = m_overlayPage->settings();
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
740 resetData->setNumber("deviceScaleFactor", m_page->deviceScaleFactor()); 743 resetData->setNumber("deviceScaleFactor", m_page->deviceScaleFactor());
741 resetData->setObject("viewportSize", buildObjectForSize(viewportSize)); 744 resetData->setObject("viewportSize", buildObjectForSize(viewportSize));
742 resetData->setNumber("pageZoomFactor", m_page->deprecatedLocalMainFrame()->p ageZoomFactor()); 745 resetData->setNumber("pageZoomFactor", m_page->deprecatedLocalMainFrame()->p ageZoomFactor());
743 resetData->setNumber("scrollX", scrollX); 746 resetData->setNumber("scrollX", scrollX);
744 resetData->setNumber("scrollY", scrollY); 747 resetData->setNumber("scrollY", scrollY);
745 evaluateInOverlay("reset", resetData.release()); 748 evaluateInOverlay("reset", resetData.release());
746 } 749 }
747 750
748 void InspectorOverlay::evaluateInOverlay(const String& method, const String& arg ument) 751 void InspectorOverlay::evaluateInOverlay(const String& method, const String& arg ument)
749 { 752 {
753 ScriptForbiddenScope::AllowUserAgentScript allowScript;
750 RefPtr<JSONArray> command = JSONArray::create(); 754 RefPtr<JSONArray> command = JSONArray::create();
751 command->pushString(method); 755 command->pushString(method);
752 command->pushString(argument); 756 command->pushString(argument);
753 toLocalFrame(overlayPage()->mainFrame())->script().executeScriptInMainWorld( "dispatch(" + command->toJSONString() + ")", ScriptController::ExecuteScriptWhen ScriptsDisabled); 757 toLocalFrame(overlayPage()->mainFrame())->script().executeScriptInMainWorld( "dispatch(" + command->toJSONString() + ")", ScriptController::ExecuteScriptWhen ScriptsDisabled);
754 } 758 }
755 759
756 void InspectorOverlay::evaluateInOverlay(const String& method, PassRefPtr<JSONVa lue> argument) 760 void InspectorOverlay::evaluateInOverlay(const String& method, PassRefPtr<JSONVa lue> argument)
757 { 761 {
762 ScriptForbiddenScope::AllowUserAgentScript allowScript;
758 RefPtr<JSONArray> command = JSONArray::create(); 763 RefPtr<JSONArray> command = JSONArray::create();
759 command->pushString(method); 764 command->pushString(method);
760 command->pushValue(argument); 765 command->pushValue(argument);
761 toLocalFrame(overlayPage()->mainFrame())->script().executeScriptInMainWorld( "dispatch(" + command->toJSONString() + ")", ScriptController::ExecuteScriptWhen ScriptsDisabled); 766 toLocalFrame(overlayPage()->mainFrame())->script().executeScriptInMainWorld( "dispatch(" + command->toJSONString() + ")", ScriptController::ExecuteScriptWhen ScriptsDisabled);
762 } 767 }
763 768
764 void InspectorOverlay::onTimer(Timer<InspectorOverlay>*) 769 void InspectorOverlay::onTimer(Timer<InspectorOverlay>*)
765 { 770 {
766 m_drawViewSize = false; 771 m_drawViewSize = false;
767 update(); 772 update();
(...skipping 17 matching lines...) Expand all
785 hideHighlight(); 790 hideHighlight();
786 } 791 }
787 792
788 void InspectorOverlay::startedRecordingProfile() 793 void InspectorOverlay::startedRecordingProfile()
789 { 794 {
790 if (!m_activeProfilerCount++) 795 if (!m_activeProfilerCount++)
791 freePage(); 796 freePage();
792 } 797 }
793 798
794 } // namespace WebCore 799 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/frame/FrameView.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698