blob: de44d45d412b135c294660437a09015b4587d33e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
|
// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "config.h"
#include "base/compiler_specific.h"
MSVC_PUSH_WARNING_LEVEL(0);
#include "DOMWindow.h"
#include "FloatRect.h"
#include "InspectorController.h"
#include "Page.h"
#include "Settings.h"
MSVC_POP_WARNING();
#undef LOG
#include "base/logging.h"
#include "base/gfx/rect.h"
#include "webkit/glue/inspector_client_impl.h"
#include "webkit/glue/webkit_glue.h"
#include "webkit/glue/weburlrequest.h"
#include "webkit/glue/webview_impl.h"
#include "googleurl/src/gurl.h"
#include "net/base/net_util.h"
using namespace WebCore;
static const float kDefaultInspectorXPos = 10;
static const float kDefaultInspectorYPos = 50;
static const float kDefaultInspectorHeight = 640;
static const float kDefaultInspectorWidth = 480;
WebInspectorClient::WebInspectorClient(WebViewImpl* webView)
: inspected_web_view_(webView)
, inspector_web_view_(0) {
ASSERT(inspected_web_view_);
}
WebInspectorClient::~WebInspectorClient() {
}
void WebInspectorClient::inspectorDestroyed() {
delete this;
}
Page* WebInspectorClient::createPage() {
WebCore::Page* page;
if (inspector_web_view_ != NULL) {
page = inspector_web_view_->page();
ASSERT(page != NULL);
if (page != NULL)
return page;
}
WebViewDelegate* delegate = inspected_web_view_->GetDelegate();
if (!delegate)
return NULL;
inspector_web_view_ = static_cast<WebViewImpl*>(
delegate->CreateWebView(inspected_web_view_, true));
if (!inspector_web_view_)
return NULL;
GURL inspector_url(webkit_glue::GetInspectorURL());
scoped_ptr<WebRequest> request(WebRequest::Create(inspector_url));
inspector_web_view_->main_frame()->LoadRequest(request.get());
page = inspector_web_view_->page();
page->chrome()->setToolbarsVisible(false);
page->chrome()->setStatusbarVisible(false);
page->chrome()->setScrollbarsVisible(false);
page->chrome()->setMenubarVisible(false);
page->chrome()->setResizable(true);
// Don't allow inspection of inspector.
page->settings()->setDeveloperExtrasEnabled(false);
page->settings()->setPrivateBrowsingEnabled(true);
page->settings()->setPluginsEnabled(false);
page->settings()->setJavaEnabled(false);
FloatRect windowRect = page->chrome()->windowRect();
FloatSize pageSize = page->chrome()->pageRect().size();
windowRect.setX(kDefaultInspectorXPos);
windowRect.setY(kDefaultInspectorYPos);
windowRect.setWidth(kDefaultInspectorHeight);
windowRect.setHeight(kDefaultInspectorWidth);
page->chrome()->setWindowRect(windowRect);
page->chrome()->show();
return page;
}
void WebInspectorClient::showWindow() {
InspectorController* inspector = inspected_web_view_->page()->inspectorController();
inspector->setWindowVisible(true);
// Notify the webview delegate of how many resources we're inspecting.
WebViewDelegate* d = inspected_web_view_->delegate();
DCHECK(d);
d->WebInspectorOpened(inspector->resources().size());
}
void WebInspectorClient::closeWindow() {
inspector_web_view_ = NULL;
hideHighlight();
if (inspected_web_view_->page())
inspected_web_view_->page()->inspectorController()->setWindowVisible(false);
}
bool WebInspectorClient::windowVisible() {
if (inspector_web_view_ != NULL) {
Page* page = inspector_web_view_->page();
ASSERT(page != NULL);
if (page != NULL)
return true;
}
return false;
}
void WebInspectorClient::attachWindow() {
// TODO(jackson): Implement this
}
void WebInspectorClient::detachWindow() {
// TODO(jackson): Implement this
}
void WebInspectorClient::setAttachedWindowHeight(unsigned int height) {
// TODO(dglazkov): Implement this
NOTIMPLEMENTED();
}
static void invalidateNodeBoundingRect(WebViewImpl* web_view) {
// TODO(ojan): http://b/1143996 Is it important to just invalidate the rect
// of the node region given that this is not on a critical codepath?
// In order to do so, we'd have to take scrolling into account.
gfx::Size size = web_view->size();
gfx::Rect damaged_rect(0, 0, size.width(), size.height());
web_view->GetDelegate()->DidInvalidateRect(web_view, damaged_rect);
}
void WebInspectorClient::highlight(Node* node) {
// InspectorController does the actually tracking of the highlighted node
// and the drawing of the highlight. Here we just make sure to invalidate
// the rects of the old and new nodes.
hideHighlight();
}
void WebInspectorClient::hideHighlight() {
// TODO: Should be able to invalidate a smaller rect.
invalidateNodeBoundingRect(inspected_web_view_);
}
void WebInspectorClient::inspectedURLChanged(const String& newURL) {
// TODO(jackson): Implement this
}
String WebInspectorClient::localizedStringsURL() {
NOTIMPLEMENTED();
return String();
}
String WebInspectorClient::hiddenPanels() {
NOTIMPLEMENTED();
return String();
}
void WebInspectorClient::populateSetting(
const String& key, InspectorController::Setting&) {
NOTIMPLEMENTED();
}
void WebInspectorClient::storeSetting(
const String& key, const InspectorController::Setting&) {
NOTIMPLEMENTED();
}
void WebInspectorClient::removeSetting(const String& key) {
NOTIMPLEMENTED();
}
|