| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "config.h" | 5 #include "config.h" |
| 6 | 6 |
| 7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
| 8 | 8 |
| 9 MSVC_PUSH_WARNING_LEVEL(0); | 9 MSVC_PUSH_WARNING_LEVEL(0); |
| 10 #include "Cursor.h" | 10 #include "Cursor.h" |
| 11 #include "FloatRect.h" | 11 #include "FloatRect.h" |
| 12 #include "FileChooser.h" | 12 #include "FileChooser.h" |
| 13 #include "FrameLoadRequest.h" | 13 #include "FrameLoadRequest.h" |
| 14 #include "FrameView.h" | 14 #include "FrameView.h" |
| 15 #include "HitTestResult.h" | 15 #include "HitTestResult.h" |
| 16 #include "IntRect.h" | 16 #include "IntRect.h" |
| 17 #include "Page.h" | 17 #include "Page.h" |
| 18 #include "PopupMenuChromium.h" |
| 18 #include "ScriptController.h" | 19 #include "ScriptController.h" |
| 19 #include "WindowFeatures.h" | 20 #include "WindowFeatures.h" |
| 20 #if USE(V8) | 21 #if USE(V8) |
| 21 #include "v8_proxy.h" | 22 #include "v8_proxy.h" |
| 22 #endif | 23 #endif |
| 23 MSVC_POP_WARNING(); | 24 MSVC_POP_WARNING(); |
| 24 | 25 |
| 25 #undef LOG | 26 #undef LOG |
| 26 | 27 |
| 27 #include "webkit/glue/chrome_client_impl.h" | 28 #include "webkit/glue/chrome_client_impl.h" |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 } | 80 } |
| 80 | 81 |
| 81 ChromeClientImpl::~ChromeClientImpl() { | 82 ChromeClientImpl::~ChromeClientImpl() { |
| 82 } | 83 } |
| 83 | 84 |
| 84 void ChromeClientImpl::chromeDestroyed() { | 85 void ChromeClientImpl::chromeDestroyed() { |
| 85 delete this; | 86 delete this; |
| 86 } | 87 } |
| 87 | 88 |
| 88 void ChromeClientImpl::setWindowRect(const WebCore::FloatRect& r) { | 89 void ChromeClientImpl::setWindowRect(const WebCore::FloatRect& r) { |
| 89 WebViewDelegate* d = webview_->delegate(); | 90 WebViewDelegate* delegate = webview_->delegate(); |
| 90 if (d) { | 91 if (delegate) { |
| 91 WebCore::IntRect ir(r); | 92 WebCore::IntRect ir(r); |
| 92 d->SetWindowRect(webview_, | 93 delegate->SetWindowRect(webview_, |
| 93 gfx::Rect(ir.x(), ir.y(), ir.width(), ir.height())); | 94 gfx::Rect(ir.x(), ir.y(), ir.width(), ir.height())); |
| 94 } | 95 } |
| 95 } | 96 } |
| 96 | 97 |
| 97 WebCore::FloatRect ChromeClientImpl::windowRect() { | 98 WebCore::FloatRect ChromeClientImpl::windowRect() { |
| 98 if (webview_->delegate()) { | 99 if (webview_->delegate()) { |
| 99 gfx::Rect rect; | 100 gfx::Rect rect; |
| 100 webview_->delegate()->GetRootWindowRect(webview_, &rect); | 101 webview_->delegate()->GetRootWindowRect(webview_, &rect); |
| 101 return WebCore::FloatRect( | 102 return WebCore::FloatRect( |
| 102 static_cast<float>(rect.x()), | 103 static_cast<float>(rect.x()), |
| 103 static_cast<float>(rect.y()), | 104 static_cast<float>(rect.y()), |
| (...skipping 25 matching lines...) Expand all Loading... |
| 129 // the implementor of the graphics layer is responsible for doing most of the | 130 // the implementor of the graphics layer is responsible for doing most of the |
| 130 // operations associated with scaling. However, this value is used ins some | 131 // operations associated with scaling. However, this value is used ins some |
| 131 // cases by WebCore. For example, this is used as a scaling factor in canvas | 132 // cases by WebCore. For example, this is used as a scaling factor in canvas |
| 132 // so that things drawn in it are scaled just like the web page is. | 133 // so that things drawn in it are scaled just like the web page is. |
| 133 // | 134 // |
| 134 // We don't currently implement scaling, so just return 1.0 (no scaling). | 135 // We don't currently implement scaling, so just return 1.0 (no scaling). |
| 135 return 1.0; | 136 return 1.0; |
| 136 } | 137 } |
| 137 | 138 |
| 138 void ChromeClientImpl::focus() { | 139 void ChromeClientImpl::focus() { |
| 139 WebViewDelegate* d = webview_->delegate(); | 140 WebViewDelegate* delegate = webview_->delegate(); |
| 140 if (d) | 141 if (delegate) |
| 141 d->Focus(webview_); | 142 delegate->Focus(webview_); |
| 142 } | 143 } |
| 143 | 144 |
| 144 void ChromeClientImpl::unfocus() { | 145 void ChromeClientImpl::unfocus() { |
| 145 WebViewDelegate* d = webview_->delegate(); | 146 WebViewDelegate* delegate = webview_->delegate(); |
| 146 if (d) | 147 if (delegate) |
| 147 d->Blur(webview_); | 148 delegate->Blur(webview_); |
| 148 } | 149 } |
| 149 | 150 |
| 150 bool ChromeClientImpl::canTakeFocus(WebCore::FocusDirection) { | 151 bool ChromeClientImpl::canTakeFocus(WebCore::FocusDirection) { |
| 151 // For now the browser can always take focus if we're not running layout | 152 // For now the browser can always take focus if we're not running layout |
| 152 // tests. | 153 // tests. |
| 153 return !WebKit::layoutTestMode(); | 154 return !WebKit::layoutTestMode(); |
| 154 } | 155 } |
| 155 | 156 |
| 156 void ChromeClientImpl::takeFocus(WebCore::FocusDirection direction) { | 157 void ChromeClientImpl::takeFocus(WebCore::FocusDirection direction) { |
| 157 WebViewDelegate* d = webview_->delegate(); | 158 WebViewDelegate* delegate = webview_->delegate(); |
| 158 if (d) { | 159 if (delegate) { |
| 159 d->TakeFocus(webview_, | 160 delegate->TakeFocus(webview_, |
| 160 direction == WebCore::FocusDirectionBackward); | 161 direction == WebCore::FocusDirectionBackward); |
| 161 } | 162 } |
| 162 } | 163 } |
| 163 | 164 |
| 164 WebCore::Page* ChromeClientImpl::createWindow( | 165 WebCore::Page* ChromeClientImpl::createWindow( |
| 165 WebCore::Frame* frame, const WebCore::FrameLoadRequest& r, | 166 WebCore::Frame* frame, const WebCore::FrameLoadRequest& r, |
| 166 const WebCore::WindowFeatures& features) { | 167 const WebCore::WindowFeatures& features) { |
| 167 WebViewDelegate* d = webview_->delegate(); | 168 WebViewDelegate* delegate = webview_->delegate(); |
| 168 if (!d) | 169 if (!delegate) |
| 169 return NULL; | 170 return NULL; |
| 170 | 171 |
| 171 bool userGesture = frame->script()->processingUserGesture(); | 172 bool userGesture = frame->script()->processingUserGesture(); |
| 172 WebViewImpl* new_view = static_cast<WebViewImpl*>( | 173 WebViewImpl* new_view = static_cast<WebViewImpl*>( |
| 173 d->CreateWebView(webview_, userGesture)); | 174 delegate->CreateWebView(webview_, userGesture)); |
| 174 if (!new_view) | 175 if (!new_view) |
| 175 return NULL; | 176 return NULL; |
| 176 | 177 |
| 177 // The request is empty when we are just being asked to open a blank window. | 178 // The request is empty when we are just being asked to open a blank window. |
| 178 // This corresponds to window.open(""), for example. | 179 // This corresponds to window.open(""), for example. |
| 179 if (!r.resourceRequest().isEmpty()) { | 180 if (!r.resourceRequest().isEmpty()) { |
| 180 WebRequestImpl request(r); | 181 WebRequestImpl request(r); |
| 181 new_view->main_frame()->LoadRequest(&request); | 182 new_view->main_frame()->LoadRequest(&request); |
| 182 } | 183 } |
| 183 | 184 |
| 184 WebViewImpl* new_view_impl = static_cast<WebViewImpl*>(new_view); | 185 WebViewImpl* new_view_impl = static_cast<WebViewImpl*>(new_view); |
| 185 return new_view_impl->page(); | 186 return new_view_impl->page(); |
| 186 } | 187 } |
| 187 | 188 |
| 188 static inline bool CurrentEventShouldCauseBackgroundTab( | 189 static inline bool CurrentEventShouldCauseBackgroundTab( |
| 189 const WebInputEvent* input_event) { | 190 const WebInputEvent* input_event) { |
| 190 if (!input_event) | 191 if (!input_event) |
| 191 return false; | 192 return false; |
| 192 | 193 |
| 193 if (input_event->type != WebInputEvent::MOUSE_UP) | 194 if (input_event->type != WebInputEvent::MOUSE_UP) |
| 194 return false; | 195 return false; |
| 195 | 196 |
| 196 const WebMouseEvent* mouse_event = static_cast<const WebMouseEvent*>(input_eve
nt); | 197 const WebMouseEvent* mouse_event = static_cast<const WebMouseEvent*>(input_eve
nt); |
| 197 return (mouse_event->button == WebMouseEvent::BUTTON_MIDDLE); | 198 return (mouse_event->button == WebMouseEvent::BUTTON_MIDDLE); |
| 198 } | 199 } |
| 199 | 200 |
| 200 void ChromeClientImpl::show() { | 201 void ChromeClientImpl::show() { |
| 201 WebViewDelegate* d = webview_->delegate(); | 202 WebViewDelegate* delegate = webview_->delegate(); |
| 202 if (d) { | 203 if (delegate) { |
| 203 // If our default configuration was modified by a script or wasn't | 204 // If our default configuration was modified by a script or wasn't |
| 204 // created by a user gesture, then show as a popup. Else, let this | 205 // created by a user gesture, then show as a popup. Else, let this |
| 205 // new window be opened as a toplevel window. | 206 // new window be opened as a toplevel window. |
| 206 // | 207 // |
| 207 bool as_popup = | 208 bool as_popup = |
| 208 !toolbars_visible_ || | 209 !toolbars_visible_ || |
| 209 !statusbar_visible_ || | 210 !statusbar_visible_ || |
| 210 !scrollbars_visible_ || | 211 !scrollbars_visible_ || |
| 211 !menubar_visible_ || | 212 !menubar_visible_ || |
| 212 !resizable_ || | 213 !resizable_ || |
| 213 !d->WasOpenedByUserGesture(webview_); | 214 !delegate->WasOpenedByUserGesture(webview_); |
| 214 | 215 |
| 215 WindowOpenDisposition disposition = NEW_FOREGROUND_TAB; | 216 WindowOpenDisposition disposition = NEW_FOREGROUND_TAB; |
| 216 if (as_popup) | 217 if (as_popup) |
| 217 disposition = NEW_POPUP; | 218 disposition = NEW_POPUP; |
| 218 if (CurrentEventShouldCauseBackgroundTab(WebViewImpl::current_input_event())
) | 219 if (CurrentEventShouldCauseBackgroundTab(WebViewImpl::current_input_event())
) |
| 219 disposition = NEW_BACKGROUND_TAB; | 220 disposition = NEW_BACKGROUND_TAB; |
| 220 | 221 |
| 221 d->Show(webview_, disposition); | 222 delegate->Show(webview_, disposition); |
| 222 } | 223 } |
| 223 } | 224 } |
| 224 | 225 |
| 225 bool ChromeClientImpl::canRunModal() { | 226 bool ChromeClientImpl::canRunModal() { |
| 226 return webview_->delegate() != NULL; | 227 return webview_->delegate() != NULL; |
| 227 } | 228 } |
| 228 | 229 |
| 229 void ChromeClientImpl::runModal() { | 230 void ChromeClientImpl::runModal() { |
| 230 WebViewDelegate* d = webview_->delegate(); | 231 WebViewDelegate* delegate = webview_->delegate(); |
| 231 if (d) | 232 if (delegate) |
| 232 d->RunModal(webview_); | 233 delegate->RunModal(webview_); |
| 233 } | 234 } |
| 234 | 235 |
| 235 void ChromeClientImpl::setToolbarsVisible(bool value) { | 236 void ChromeClientImpl::setToolbarsVisible(bool value) { |
| 236 toolbars_visible_ = value; | 237 toolbars_visible_ = value; |
| 237 } | 238 } |
| 238 | 239 |
| 239 bool ChromeClientImpl::toolbarsVisible() { | 240 bool ChromeClientImpl::toolbarsVisible() { |
| 240 return toolbars_visible_; | 241 return toolbars_visible_; |
| 241 } | 242 } |
| 242 | 243 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 268 return menubar_visible_; | 269 return menubar_visible_; |
| 269 } | 270 } |
| 270 | 271 |
| 271 void ChromeClientImpl::setResizable(bool value) { | 272 void ChromeClientImpl::setResizable(bool value) { |
| 272 resizable_ = value; | 273 resizable_ = value; |
| 273 } | 274 } |
| 274 | 275 |
| 275 void ChromeClientImpl::addMessageToConsole(const WebCore::String& message, | 276 void ChromeClientImpl::addMessageToConsole(const WebCore::String& message, |
| 276 unsigned int line_no, | 277 unsigned int line_no, |
| 277 const WebCore::String& source_id) { | 278 const WebCore::String& source_id) { |
| 278 WebViewDelegate* d = webview_->delegate(); | 279 WebViewDelegate* delegate = webview_->delegate(); |
| 279 if (d) { | 280 if (delegate) { |
| 280 std::wstring wstr_message = webkit_glue::StringToStdWString(message); | 281 std::wstring wstr_message = webkit_glue::StringToStdWString(message); |
| 281 std::wstring wstr_source_id = webkit_glue::StringToStdWString(source_id); | 282 std::wstring wstr_source_id = webkit_glue::StringToStdWString(source_id); |
| 282 d->AddMessageToConsole(webview_, wstr_message, line_no, wstr_source_id); | 283 delegate->AddMessageToConsole(webview_, wstr_message, |
| 284 line_no, wstr_source_id); |
| 283 } | 285 } |
| 284 } | 286 } |
| 285 | 287 |
| 286 bool ChromeClientImpl::canRunBeforeUnloadConfirmPanel() { | 288 bool ChromeClientImpl::canRunBeforeUnloadConfirmPanel() { |
| 287 return webview_->delegate() != NULL; | 289 return webview_->delegate() != NULL; |
| 288 } | 290 } |
| 289 | 291 |
| 290 bool ChromeClientImpl::runBeforeUnloadConfirmPanel( | 292 bool ChromeClientImpl::runBeforeUnloadConfirmPanel( |
| 291 const WebCore::String& message, | 293 const WebCore::String& message, |
| 292 WebCore::Frame* frame) { | 294 WebCore::Frame* frame) { |
| 293 WebViewDelegate* d = webview_->delegate(); | 295 WebViewDelegate* delegate = webview_->delegate(); |
| 294 if (d) { | 296 if (delegate) { |
| 295 std::wstring wstr = webkit_glue::StringToStdWString(message); | 297 std::wstring wstr = webkit_glue::StringToStdWString(message); |
| 296 return d->RunBeforeUnloadConfirm(WebFrameImpl::FromFrame(frame), wstr); | 298 return delegate->RunBeforeUnloadConfirm(WebFrameImpl::FromFrame(frame), |
| 299 wstr); |
| 297 } | 300 } |
| 298 return false; | 301 return false; |
| 299 } | 302 } |
| 300 | 303 |
| 301 void ChromeClientImpl::closeWindowSoon() { | 304 void ChromeClientImpl::closeWindowSoon() { |
| 302 // Make sure this Page can no longer be found by JS. | 305 // Make sure this Page can no longer be found by JS. |
| 303 webview_->page()->setGroupName(WebCore::String()); | 306 webview_->page()->setGroupName(WebCore::String()); |
| 304 | 307 |
| 305 // Make sure that all loading is stopped. Ensures that JS stops executing! | 308 // Make sure that all loading is stopped. Ensures that JS stops executing! |
| 306 webview_->StopLoading(); | 309 webview_->StopLoading(); |
| 307 | 310 |
| 308 WebViewDelegate* d = webview_->delegate(); | 311 WebViewDelegate* delegate = webview_->delegate(); |
| 309 if (d) | 312 if (delegate) |
| 310 d->CloseWidgetSoon(webview_); | 313 delegate->CloseWidgetSoon(webview_); |
| 311 } | 314 } |
| 312 | 315 |
| 313 // Although a WebCore::Frame is passed in, we don't actually use it, since we | 316 // Although a WebCore::Frame is passed in, we don't actually use it, since we |
| 314 // already know our own webview_. | 317 // already know our own webview_. |
| 315 void ChromeClientImpl::runJavaScriptAlert(WebCore::Frame* frame, | 318 void ChromeClientImpl::runJavaScriptAlert(WebCore::Frame* frame, |
| 316 const WebCore::String& message) { | 319 const WebCore::String& message) { |
| 317 // Pass the request on to the WebView delegate, for more control. | 320 // Pass the request on to the WebView delegate, for more control. |
| 318 WebViewDelegate* d = webview_->delegate(); | 321 WebViewDelegate* delegate = webview_->delegate(); |
| 319 if (d) { | 322 if (delegate) { |
| 320 #if USE(V8) | 323 #if USE(V8) |
| 321 // Before showing the JavaScript dialog, we give the proxy implementation | 324 // Before showing the JavaScript dialog, we give the proxy implementation |
| 322 // a chance to process any pending console messages. | 325 // a chance to process any pending console messages. |
| 323 WebCore::V8Proxy::ProcessConsoleMessages(); | 326 WebCore::V8Proxy::ProcessConsoleMessages(); |
| 324 #endif | 327 #endif |
| 325 | 328 |
| 326 std::wstring wstr = webkit_glue::StringToStdWString(message); | 329 std::wstring wstr = webkit_glue::StringToStdWString(message); |
| 327 d->RunJavaScriptAlert(WebFrameImpl::FromFrame(frame), wstr); | 330 delegate->RunJavaScriptAlert(WebFrameImpl::FromFrame(frame), wstr); |
| 328 } | 331 } |
| 329 } | 332 } |
| 330 | 333 |
| 331 // See comments for runJavaScriptAlert(). | 334 // See comments for runJavaScriptAlert(). |
| 332 bool ChromeClientImpl::runJavaScriptConfirm(WebCore::Frame* frame, | 335 bool ChromeClientImpl::runJavaScriptConfirm(WebCore::Frame* frame, |
| 333 const WebCore::String& message) { | 336 const WebCore::String& message) { |
| 334 WebViewDelegate* d = webview_->delegate(); | 337 WebViewDelegate* delegate = webview_->delegate(); |
| 335 if (d) { | 338 if (delegate) { |
| 336 std::wstring wstr = webkit_glue::StringToStdWString(message); | 339 std::wstring wstr = webkit_glue::StringToStdWString(message); |
| 337 return d->RunJavaScriptConfirm(WebFrameImpl::FromFrame(frame), wstr); | 340 return delegate->RunJavaScriptConfirm(WebFrameImpl::FromFrame(frame), wstr); |
| 338 } | 341 } |
| 339 return false; | 342 return false; |
| 340 } | 343 } |
| 341 | 344 |
| 342 // See comments for runJavaScriptAlert(). | 345 // See comments for runJavaScriptAlert(). |
| 343 bool ChromeClientImpl::runJavaScriptPrompt(WebCore::Frame* frame, | 346 bool ChromeClientImpl::runJavaScriptPrompt(WebCore::Frame* frame, |
| 344 const WebCore::String& message, | 347 const WebCore::String& message, |
| 345 const WebCore::String& defaultValue, | 348 const WebCore::String& defaultValue, |
| 346 WebCore::String& result) { | 349 WebCore::String& result) { |
| 347 WebViewDelegate* d = webview_->delegate(); | 350 WebViewDelegate* delegate = webview_->delegate(); |
| 348 if (d) { | 351 if (delegate) { |
| 349 std::wstring wstr_message = webkit_glue::StringToStdWString(message); | 352 std::wstring wstr_message = webkit_glue::StringToStdWString(message); |
| 350 std::wstring wstr_default = webkit_glue::StringToStdWString(defaultValue); | 353 std::wstring wstr_default = webkit_glue::StringToStdWString(defaultValue); |
| 351 std::wstring wstr_result; | 354 std::wstring wstr_result; |
| 352 bool ok = d->RunJavaScriptPrompt(WebFrameImpl::FromFrame(frame), | 355 bool ok = delegate->RunJavaScriptPrompt(WebFrameImpl::FromFrame(frame), |
| 353 wstr_message, | 356 wstr_message, |
| 354 wstr_default, | 357 wstr_default, |
| 355 &wstr_result); | 358 &wstr_result); |
| 356 if (ok) | 359 if (ok) |
| 357 result = webkit_glue::StdWStringToString(wstr_result); | 360 result = webkit_glue::StdWStringToString(wstr_result); |
| 358 return ok; | 361 return ok; |
| 359 } | 362 } |
| 360 return false; | 363 return false; |
| 361 } | 364 } |
| 362 | 365 |
| 363 void ChromeClientImpl::setStatusbarText(const WebCore::String& message) { | 366 void ChromeClientImpl::setStatusbarText(const WebCore::String& message) { |
| 364 WebViewDelegate* d = webview_->delegate(); | 367 WebViewDelegate* delegate = webview_->delegate(); |
| 365 if (d) { | 368 if (delegate) { |
| 366 std::wstring wstr = webkit_glue::StringToStdWString(message); | 369 std::wstring wstr = webkit_glue::StringToStdWString(message); |
| 367 d->SetStatusbarText(webview_, wstr); | 370 delegate->SetStatusbarText(webview_, wstr); |
| 368 } | 371 } |
| 369 } | 372 } |
| 370 | 373 |
| 371 bool ChromeClientImpl::shouldInterruptJavaScript() { | 374 bool ChromeClientImpl::shouldInterruptJavaScript() { |
| 372 // TODO(mbelshe): implement me | 375 // TODO(mbelshe): implement me |
| 373 return false; | 376 return false; |
| 374 } | 377 } |
| 375 | 378 |
| 376 bool ChromeClientImpl::tabsToLinks() const { | 379 bool ChromeClientImpl::tabsToLinks() const { |
| 377 // TODO(pamg): Consider controlling this with a user preference, when we have | 380 // TODO(pamg): Consider controlling this with a user preference, when we have |
| (...skipping 15 matching lines...) Expand all Loading... |
| 393 } | 396 } |
| 394 return rv; | 397 return rv; |
| 395 } | 398 } |
| 396 | 399 |
| 397 void ChromeClientImpl::repaint( | 400 void ChromeClientImpl::repaint( |
| 398 const WebCore::IntRect& paint_rect, bool content_changed, bool immediate, | 401 const WebCore::IntRect& paint_rect, bool content_changed, bool immediate, |
| 399 bool repaint_content_only) { | 402 bool repaint_content_only) { |
| 400 // Ignore spurious calls. | 403 // Ignore spurious calls. |
| 401 if (!content_changed || paint_rect.isEmpty()) | 404 if (!content_changed || paint_rect.isEmpty()) |
| 402 return; | 405 return; |
| 403 WebViewDelegate* d = webview_->delegate(); | 406 WebViewDelegate* delegate = webview_->delegate(); |
| 404 if (d) | 407 if (delegate) |
| 405 d->DidInvalidateRect(webview_, webkit_glue::FromIntRect(paint_rect)); | 408 delegate->DidInvalidateRect(webview_, webkit_glue::FromIntRect(paint_rect)); |
| 406 } | 409 } |
| 407 | 410 |
| 408 void ChromeClientImpl::scroll( | 411 void ChromeClientImpl::scroll( |
| 409 const WebCore::IntSize& scroll_delta, const WebCore::IntRect& scroll_rect, | 412 const WebCore::IntSize& scroll_delta, const WebCore::IntRect& scroll_rect, |
| 410 const WebCore::IntRect& clip_rect) { | 413 const WebCore::IntRect& clip_rect) { |
| 411 WebViewDelegate* d = webview_->delegate(); | 414 WebViewDelegate* delegate = webview_->delegate(); |
| 412 if (d) { | 415 if (delegate) { |
| 413 int dx = scroll_delta.width(); | 416 int dx = scroll_delta.width(); |
| 414 int dy = scroll_delta.height(); | 417 int dy = scroll_delta.height(); |
| 415 d->DidScrollRect(webview_, dx, dy, webkit_glue::FromIntRect(clip_rect)); | 418 delegate->DidScrollRect(webview_, dx, dy, |
| 419 webkit_glue::FromIntRect(clip_rect)); |
| 416 } | 420 } |
| 417 } | 421 } |
| 418 | 422 |
| 419 WebCore::IntPoint ChromeClientImpl::screenToWindow( | 423 WebCore::IntPoint ChromeClientImpl::screenToWindow( |
| 420 const WebCore::IntPoint&) const { | 424 const WebCore::IntPoint&) const { |
| 421 NOTIMPLEMENTED(); | 425 NOTIMPLEMENTED(); |
| 422 return WebCore::IntPoint(); | 426 return WebCore::IntPoint(); |
| 423 } | 427 } |
| 424 | 428 |
| 425 WebCore::IntRect ChromeClientImpl::windowToScreen( | 429 WebCore::IntRect ChromeClientImpl::windowToScreen( |
| 426 const WebCore::IntRect& rect) const { | 430 const WebCore::IntRect& rect) const { |
| 427 WebCore::IntRect screen_rect(rect); | 431 WebCore::IntRect screen_rect(rect); |
| 428 | 432 |
| 429 WebViewDelegate* d = webview_->delegate(); | 433 WebViewDelegate* delegate = webview_->delegate(); |
| 430 if (d) { | 434 if (delegate) { |
| 431 gfx::Rect window_rect; | 435 gfx::Rect window_rect; |
| 432 d->GetWindowRect(webview_, &window_rect); | 436 delegate->GetWindowRect(webview_, &window_rect); |
| 433 screen_rect.move(window_rect.x(), window_rect.y()); | 437 screen_rect.move(window_rect.x(), window_rect.y()); |
| 434 } | 438 } |
| 435 | 439 |
| 436 return screen_rect; | 440 return screen_rect; |
| 437 } | 441 } |
| 438 | 442 |
| 439 PlatformWidget ChromeClientImpl::platformWindow() const { | 443 PlatformWidget ChromeClientImpl::platformWindow() const { |
| 440 WebViewDelegate* d = webview_->delegate(); | 444 WebViewDelegate* delegate = webview_->delegate(); |
| 441 return d ? d->GetContainingView(webview_) : NULL; | 445 return delegate ? delegate->GetContainingView(webview_) : NULL; |
| 442 } | 446 } |
| 443 | 447 |
| 444 void ChromeClientImpl::mouseDidMoveOverElement( | 448 void ChromeClientImpl::mouseDidMoveOverElement( |
| 445 const WebCore::HitTestResult& result, unsigned modifierFlags) { | 449 const WebCore::HitTestResult& result, unsigned modifierFlags) { |
| 446 // Find out if the mouse is over a link, and if so, let our UI know... somehow | 450 // Find out if the mouse is over a link, and if so, let our UI know... somehow |
| 447 WebViewDelegate* d = webview_->delegate(); | 451 WebViewDelegate* delegate = webview_->delegate(); |
| 448 if (d) { | 452 if (delegate) { |
| 449 if (result.isLiveLink() && !result.absoluteLinkURL().string().isEmpty()) { | 453 if (result.isLiveLink() && !result.absoluteLinkURL().string().isEmpty()) { |
| 450 d->UpdateTargetURL(webview_, webkit_glue::KURLToGURL(result.absoluteLinkUR
L())); | 454 delegate->UpdateTargetURL( |
| 455 webview_, webkit_glue::KURLToGURL(result.absoluteLinkURL())); |
| 451 } else { | 456 } else { |
| 452 d->UpdateTargetURL(webview_, GURL()); | 457 delegate->UpdateTargetURL(webview_, GURL()); |
| 453 } | 458 } |
| 454 } | 459 } |
| 455 } | 460 } |
| 456 | 461 |
| 457 void ChromeClientImpl::setToolTip(const WebCore::String& tooltip_text) { | 462 void ChromeClientImpl::setToolTip(const WebCore::String& tooltip_text) { |
| 458 if (webview_->delegate()) { | 463 if (webview_->delegate()) { |
| 459 std::wstring tooltip_text_as_wstring = | 464 std::wstring tooltip_text_as_wstring = |
| 460 webkit_glue::StringToStdWString(tooltip_text); | 465 webkit_glue::StringToStdWString(tooltip_text); |
| 461 webview_->delegate()->SetTooltipText(webview_, tooltip_text_as_wstring); | 466 webview_->delegate()->SetTooltipText(webview_, tooltip_text_as_wstring); |
| 462 } | 467 } |
| 463 } | 468 } |
| 464 | 469 |
| 465 void ChromeClientImpl::print(WebCore::Frame* frame) { | 470 void ChromeClientImpl::print(WebCore::Frame* frame) { |
| 466 WebViewDelegate* d = webview_->delegate(); | 471 WebViewDelegate* delegate = webview_->delegate(); |
| 467 if (d) { | 472 if (delegate) { |
| 468 d->ScriptedPrint(WebFrameImpl::FromFrame(frame)); | 473 delegate->ScriptedPrint(WebFrameImpl::FromFrame(frame)); |
| 469 } | 474 } |
| 470 } | 475 } |
| 471 | 476 |
| 472 void ChromeClientImpl::exceededDatabaseQuota(WebCore::Frame* frame, | 477 void ChromeClientImpl::exceededDatabaseQuota(WebCore::Frame* frame, |
| 473 const WebCore::String& databaseName) { | 478 const WebCore::String& databaseName) { |
| 474 // TODO(tc): If we enable the storage API, we need to implement this function. | 479 // TODO(tc): If we enable the storage API, we need to implement this function. |
| 475 } | 480 } |
| 476 | 481 |
| 477 void ChromeClientImpl::runOpenPanel(WebCore::Frame* frame, | 482 void ChromeClientImpl::runOpenPanel(WebCore::Frame* frame, |
| 478 PassRefPtr<WebCore::FileChooser> fileChooser) { | 483 PassRefPtr<WebCore::FileChooser> fileChooser) { |
| 479 WebViewDelegate* delegate = webview_->delegate(); | 484 WebViewDelegate* delegate = webview_->delegate(); |
| 480 if (!delegate) | 485 if (!delegate) |
| 481 return; | 486 return; |
| 482 | 487 |
| 483 bool multiple_files = fileChooser->allowsMultipleFiles(); | 488 bool multiple_files = fileChooser->allowsMultipleFiles(); |
| 484 | 489 |
| 485 std::wstring suggestion; | 490 std::wstring suggestion; |
| 486 if (fileChooser->filenames().size() > 0) | 491 if (fileChooser->filenames().size() > 0) |
| 487 suggestion = webkit_glue::StringToStdWString(fileChooser->filenames()[0]); | 492 suggestion = webkit_glue::StringToStdWString(fileChooser->filenames()[0]); |
| 488 | 493 |
| 489 WebFileChooserCallbackImpl* chooser = new WebFileChooserCallbackImpl(fileChoos
er); | 494 WebFileChooserCallbackImpl* chooser = new WebFileChooserCallbackImpl(fileChoos
er); |
| 490 delegate->RunFileChooser(multiple_files, std::wstring(), suggestion, | 495 delegate->RunFileChooser(multiple_files, std::wstring(), suggestion, |
| 491 std::wstring(), chooser); | 496 std::wstring(), chooser); |
| 492 } | 497 } |
| 493 | 498 |
| 494 void ChromeClientImpl::popupOpened(WebCore::FramelessScrollView* popup_view, | 499 void ChromeClientImpl::popupOpened(WebCore::FramelessScrollView* popup_view, |
| 495 const WebCore::IntRect& bounds, | 500 const WebCore::IntRect& bounds, |
| 496 bool activatable) { | 501 bool activatable) { |
| 497 WebViewDelegate* d = webview_->delegate(); | 502 WebViewDelegate* delegate = webview_->delegate(); |
| 498 if (d) { | 503 if (delegate) { |
| 499 WebWidgetImpl* webwidget = | 504 WebWidgetImpl* webwidget = |
| 500 static_cast<WebWidgetImpl*>(d->CreatePopupWidget(webview_, | 505 static_cast<WebWidgetImpl*>(delegate->CreatePopupWidget(webview_, |
| 501 activatable)); | 506 activatable)); |
| 502 webwidget->Init(popup_view, webkit_glue::FromIntRect(bounds)); | 507 webwidget->Init(popup_view, webkit_glue::FromIntRect(bounds)); |
| 503 } | 508 } |
| 504 } | 509 } |
| 505 | 510 |
| 511 void ChromeClientImpl::popupOpenedWithItems( |
| 512 WebCore::FramelessScrollView* popup_view, |
| 513 const WebCore::IntRect& bounds, |
| 514 bool activatable, |
| 515 int item_height, |
| 516 int selected_index, |
| 517 const WTF::Vector<WebCore::PopupListData*>& items) { |
| 518 /* |
| 519 Uncomment this section once the changes to |
| 520 WebKit/WebCore/platform/chromium/PopupMenuChromium* have landed in our tree. |
| 521 |
| 522 WebViewDelegate* delegate = webview_->delegate(); |
| 523 if (!delegate) |
| 524 return; |
| 525 |
| 526 WebWidgetImpl* webwidget = |
| 527 static_cast<WebWidgetImpl*>(delegate->CreatePopupWidget(webview_, |
| 528 activatable)); |
| 529 // Convert WebKit types for Chromium. |
| 530 std::vector<MenuItem> popup_items; |
| 531 for (int i = 0; i < items.size(); ++i) { |
| 532 MenuItem menu_item; |
| 533 menu_item.label = webkit_glue::StringToString16(items[i]->label); |
| 534 menu_item.enabled = items[i]->enabled; |
| 535 switch (items[i]->type) { |
| 536 case WebCore::PopupListData::TypeOption: |
| 537 menu_item.type = MenuItem::OPTION; |
| 538 break; |
| 539 case WebCore::PopupListData::TypeGroup: |
| 540 menu_item.type = MenuItem::GROUP; |
| 541 break; |
| 542 case WebCore::PopupListData::TypeSeparator: |
| 543 menu_item.type = MenuItem::SEPARATOR; |
| 544 break; |
| 545 default: |
| 546 NOTIMPLEMENTED(); |
| 547 } |
| 548 popup_items.push_back(menu_item); |
| 549 } |
| 550 |
| 551 webwidget->InitWithItems(popup_view, |
| 552 webkit_glue::FromIntRect(bounds), |
| 553 item_height, |
| 554 selected_index, |
| 555 popup_items); |
| 556 */ |
| 557 } |
| 558 |
| 506 void ChromeClientImpl::SetCursor(const WebCursor& cursor) { | 559 void ChromeClientImpl::SetCursor(const WebCursor& cursor) { |
| 507 if (ignore_next_set_cursor_) { | 560 if (ignore_next_set_cursor_) { |
| 508 ignore_next_set_cursor_ = false; | 561 ignore_next_set_cursor_ = false; |
| 509 return; | 562 return; |
| 510 } | 563 } |
| 511 | 564 |
| 512 WebViewDelegate* d = webview_->delegate(); | 565 WebViewDelegate* delegate = webview_->delegate(); |
| 513 if (d) | 566 if (delegate) |
| 514 d->SetCursor(webview_, cursor); | 567 delegate->SetCursor(webview_, cursor); |
| 515 } | 568 } |
| 516 | 569 |
| 517 void ChromeClientImpl::SetCursorForPlugin(const WebCursor& cursor) { | 570 void ChromeClientImpl::SetCursorForPlugin(const WebCursor& cursor) { |
| 518 SetCursor(cursor); | 571 SetCursor(cursor); |
| 519 // Currently, Widget::setCursor is always called after this function in | 572 // Currently, Widget::setCursor is always called after this function in |
| 520 // EventHandler.cpp and since we don't want that we set a flag indicating | 573 // EventHandler.cpp and since we don't want that we set a flag indicating |
| 521 // that the next SetCursor call is to be ignored. | 574 // that the next SetCursor call is to be ignored. |
| 522 ignore_next_set_cursor_ = true; | 575 ignore_next_set_cursor_ = true; |
| 523 } | 576 } |
| 524 | 577 |
| 525 void ChromeClientImpl::enableSuddenTermination() { | 578 void ChromeClientImpl::enableSuddenTermination() { |
| 526 WebViewDelegate* d = webview_->delegate(); | 579 WebViewDelegate* delegate = webview_->delegate(); |
| 527 if (d) | 580 if (delegate) |
| 528 d->EnableSuddenTermination(); | 581 delegate->EnableSuddenTermination(); |
| 529 } | 582 } |
| 530 | 583 |
| 531 void ChromeClientImpl::disableSuddenTermination() { | 584 void ChromeClientImpl::disableSuddenTermination() { |
| 532 WebViewDelegate* d = webview_->delegate(); | 585 WebViewDelegate* delegate = webview_->delegate(); |
| 533 if (d) | 586 if (delegate) |
| 534 d->DisableSuddenTermination(); | 587 delegate->DisableSuddenTermination(); |
| 535 } | 588 } |
| 536 | 589 |
| 537 void ChromeClientImpl::formStateDidChange(const WebCore::Node*) { | 590 void ChromeClientImpl::formStateDidChange(const WebCore::Node*) { |
| 538 WebViewDelegate* d = webview_->delegate(); | 591 WebViewDelegate* delegate = webview_->delegate(); |
| 539 if (d) | 592 if (delegate) |
| 540 d->OnNavStateChanged(webview_); | 593 delegate->OnNavStateChanged(webview_); |
| 541 } | 594 } |
| OLD | NEW |