|
1 /* |
|
2 * Copyright (C) 2010 Google Inc. All rights reserved. |
|
3 * |
|
4 * Redistribution and use in source and binary forms, with or without |
|
5 * modification, are permitted provided that the following conditions are |
|
6 * met: |
|
7 * |
|
8 * * Redistributions of source code must retain the above copyright |
|
9 * notice, this list of conditions and the following disclaimer. |
|
10 * * Redistributions in binary form must reproduce the above |
|
11 * copyright notice, this list of conditions and the following disclaimer |
|
12 * in the documentation and/or other materials provided with the |
|
13 * distribution. |
|
14 * * Neither the name of Google Inc. nor the names of its |
|
15 * contributors may be used to endorse or promote products derived from |
|
16 * this software without specific prior written permission. |
|
17 * |
|
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
|
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
|
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
|
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
|
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
|
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
|
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
|
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
|
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
|
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
|
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
29 */ |
|
30 |
|
31 #include "config.h" |
|
32 #include "InspectorFrontendClientImpl.h" |
|
33 |
|
34 #include "Document.h" |
|
35 #include "Frame.h" |
|
36 #include "InspectorFrontendHost.h" |
|
37 #include "Page.h" |
|
38 #include "PlatformString.h" |
|
39 #include "V8InspectorFrontendHost.h" |
|
40 #include "V8Proxy.h" |
|
41 #include "WebDevToolsFrontendClient.h" |
|
42 #include "WebDevToolsFrontendImpl.h" |
|
43 |
|
44 using namespace WebCore; |
|
45 |
|
46 namespace WebKit { |
|
47 |
|
48 InspectorFrontendClientImpl::InspectorFrontendClientImpl(Page* frontendPage, WebDevToolsFrontendClient* client, WebDevToolsFrontendImpl* frontend) |
|
49 : m_frontendPage(frontendPage) |
|
50 , m_client(client) |
|
51 , m_frontend(frontend) |
|
52 { |
|
53 } |
|
54 |
|
55 InspectorFrontendClientImpl::~InspectorFrontendClientImpl() |
|
56 { |
|
57 if (m_frontendHost) |
|
58 m_frontendHost->disconnectClient(); |
|
59 m_client = 0; |
|
60 } |
|
61 |
|
62 void InspectorFrontendClientImpl::windowObjectCleared() |
|
63 { |
|
64 v8::HandleScope handleScope; |
|
65 v8::Handle<v8::Context> frameContext = V8Proxy::context(m_frontendPage->mainFrame()); |
|
66 v8::Context::Scope contextScope(frameContext); |
|
67 |
|
68 ASSERT(!m_frontendHost); |
|
69 m_frontendHost = InspectorFrontendHost::create(this, m_frontendPage); |
|
70 v8::Handle<v8::Value> frontendHostObj = toV8(m_frontendHost.get()); |
|
71 v8::Handle<v8::Object> global = frameContext->Global(); |
|
72 |
|
73 global->Set(v8::String::New("InspectorFrontendHost"), frontendHostObj); |
|
74 } |
|
75 |
|
76 void InspectorFrontendClientImpl::frontendLoaded() |
|
77 { |
|
78 m_frontend->frontendLoaded(); |
|
79 } |
|
80 |
|
81 void InspectorFrontendClientImpl::moveWindowBy(float x, float y) |
|
82 { |
|
83 } |
|
84 |
|
85 String InspectorFrontendClientImpl::localizedStringsURL() |
|
86 { |
|
87 return ""; |
|
88 } |
|
89 |
|
90 String InspectorFrontendClientImpl::hiddenPanels() |
|
91 { |
|
92 if (m_client->shouldHideScriptsPanel()) |
|
93 return "scripts"; |
|
94 return ""; |
|
95 } |
|
96 |
|
97 void InspectorFrontendClientImpl::bringToFront() |
|
98 { |
|
99 m_client->activateWindow(); |
|
100 } |
|
101 |
|
102 void InspectorFrontendClientImpl::closeWindow() |
|
103 { |
|
104 m_client->closeWindow(); |
|
105 } |
|
106 |
|
107 void InspectorFrontendClientImpl::requestAttachWindow() |
|
108 { |
|
109 m_client->requestDockWindow(); |
|
110 } |
|
111 |
|
112 void InspectorFrontendClientImpl::requestDetachWindow() |
|
113 { |
|
114 m_client->requestUndockWindow(); |
|
115 } |
|
116 |
|
117 void InspectorFrontendClientImpl::changeAttachedWindowHeight(unsigned) |
|
118 { |
|
119 // Do nothing; |
|
120 } |
|
121 |
|
122 void InspectorFrontendClientImpl::inspectedURLChanged(const String& url) |
|
123 { |
|
124 m_frontendPage->mainFrame()->document()->setTitle("Developer Tools - " + url); |
|
125 } |
|
126 |
|
127 } // namespace WebKit |