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

Side by Side Diff: webkit/api/src/ChromeClientImpl.cpp

Issue 341030: Moves webview_impl.cc, webframe_impl.cc and webframeloaderclient_impl.cc into... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 1 month 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 | « webkit/api/src/ChromeClientImpl.h ('k') | webkit/api/src/ContextMenuClientImpl.h » ('j') | 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) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 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 are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * 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 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 #include "NotificationPresenterImpl.h" 49 #include "NotificationPresenterImpl.h"
50 #include "Page.h" 50 #include "Page.h"
51 #include "PopupMenuChromium.h" 51 #include "PopupMenuChromium.h"
52 #include "ScriptController.h" 52 #include "ScriptController.h"
53 #if USE(V8) 53 #if USE(V8)
54 #include "V8Proxy.h" 54 #include "V8Proxy.h"
55 #endif 55 #endif
56 #include "WebAccessibilityObject.h" 56 #include "WebAccessibilityObject.h"
57 #include "WebConsoleMessage.h" 57 #include "WebConsoleMessage.h"
58 #include "WebCursorInfo.h" 58 #include "WebCursorInfo.h"
59 #include "WebFileChooserCompletion.h" 59 #include "WebFileChooserCompletionImpl.h"
60 #include "WebFrameClient.h" 60 #include "WebFrameClient.h"
61 #include "WebFrameImpl.h"
61 #include "WebInputEvent.h" 62 #include "WebInputEvent.h"
62 #include "WebKit.h" 63 #include "WebKit.h"
64 #include "WebPopupMenuImpl.h"
63 #include "WebPopupMenuInfo.h" 65 #include "WebPopupMenuInfo.h"
64 #include "WebRect.h" 66 #include "WebRect.h"
65 #include "WebTextDirection.h" 67 #include "WebTextDirection.h"
66 #include "WebURLRequest.h" 68 #include "WebURLRequest.h"
67 #include "WebViewClient.h" 69 #include "WebViewClient.h"
68 #include "WebFileChooserCompletionImpl.h" 70 #include "WebViewImpl.h"
69 #include "WebPopupMenuImpl.h"
70 #include "WindowFeatures.h" 71 #include "WindowFeatures.h"
71 #include "WrappedResourceRequest.h" 72 #include "WrappedResourceRequest.h"
72 73
73 // FIXME: Remove these once they move out of glue/.
74 #include "webkit/glue/webframe_impl.h"
75 #include "webkit/glue/webview_impl.h"
76
77 using namespace WebCore; 74 using namespace WebCore;
78 75
79 namespace WebKit { 76 namespace WebKit {
80 77
81 ChromeClientImpl::ChromeClientImpl(WebViewImpl* webView) 78 ChromeClientImpl::ChromeClientImpl(WebViewImpl* webView)
82 : m_webView(webView) 79 : m_webView(webView)
83 , m_toolbarsVisible(true) 80 , m_toolbarsVisible(true)
84 , m_statusbarVisible(true) 81 , m_statusbarVisible(true)
85 , m_scrollbarsVisible(true) 82 , m_scrollbarsVisible(true)
86 , m_menubarVisible(true) 83 , m_menubarVisible(true)
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 138
142 void ChromeClientImpl::focus() 139 void ChromeClientImpl::focus()
143 { 140 {
144 if (!m_webView->client()) 141 if (!m_webView->client())
145 return; 142 return;
146 143
147 m_webView->client()->didFocus(); 144 m_webView->client()->didFocus();
148 145
149 // If accessibility is enabled, we should notify assistive technology that 146 // If accessibility is enabled, we should notify assistive technology that
150 // the active AccessibilityObject changed. 147 // the active AccessibilityObject changed.
151 const Frame* frame = m_webView->GetFocusedWebCoreFrame(); 148 const Frame* frame = m_webView->focusedWebCoreFrame();
152 if (!frame) 149 if (!frame)
153 return; 150 return;
154 151
155 Document* doc = frame->document(); 152 Document* doc = frame->document();
156 153
157 if (doc && doc->axObjectCache()->accessibilityEnabled()) { 154 if (doc && doc->axObjectCache()->accessibilityEnabled()) {
158 Node* focusedNode = m_webView->GetFocusedNode(); 155 Node* focusedNode = m_webView->focusedWebCoreNode();
159 156
160 if (!focusedNode) { 157 if (!focusedNode) {
161 // Could not retrieve focused Node. 158 // Could not retrieve focused Node.
162 return; 159 return;
163 } 160 }
164 161
165 // Retrieve the focused AccessibilityObject. 162 // Retrieve the focused AccessibilityObject.
166 AccessibilityObject* focusedAccObj = 163 AccessibilityObject* focusedAccObj =
167 doc->axObjectCache()->getOrCreate(focusedNode->renderer()); 164 doc->axObjectCache()->getOrCreate(focusedNode->renderer());
168 165
(...skipping 26 matching lines...) Expand all
195 m_webView->client()->focusNext(); 192 m_webView->client()->focusNext();
196 } 193 }
197 194
198 Page* ChromeClientImpl::createWindow( 195 Page* ChromeClientImpl::createWindow(
199 Frame* frame, const FrameLoadRequest& r, const WindowFeatures& features) 196 Frame* frame, const FrameLoadRequest& r, const WindowFeatures& features)
200 { 197 {
201 if (!m_webView->client()) 198 if (!m_webView->client())
202 return 0; 199 return 0;
203 200
204 WebViewImpl* newView = static_cast<WebViewImpl*>( 201 WebViewImpl* newView = static_cast<WebViewImpl*>(
205 m_webView->client()->createView(WebFrameImpl::FromFrame(frame))); 202 m_webView->client()->createView(WebFrameImpl::fromFrame(frame)));
206 if (!newView) 203 if (!newView)
207 return 0; 204 return 0;
208 205
209 // The request is empty when we are just being asked to open a blank window. 206 // The request is empty when we are just being asked to open a blank window.
210 // This corresponds to window.open(""), for example. 207 // This corresponds to window.open(""), for example.
211 if (!r.resourceRequest().isEmpty()) { 208 if (!r.resourceRequest().isEmpty()) {
212 WrappedResourceRequest request(r.resourceRequest()); 209 WrappedResourceRequest request(r.resourceRequest());
213 newView->main_frame()->loadRequest(request); 210 newView->mainFrame()->loadRequest(request);
214 } 211 }
215 212
216 return newView->page(); 213 return newView->page();
217 } 214 }
218 215
219 static inline bool CurrentEventShouldCauseBackgroundTab(const WebInputEvent* inputEvent) 216 static inline bool currentEventShouldCauseBackgroundTab(const WebInputEvent* inputEvent)
220 { 217 {
221 if (!inputEvent) 218 if (!inputEvent)
222 return false; 219 return false;
223 220
224 if (inputEvent->type != WebInputEvent::MouseUp) 221 if (inputEvent->type != WebInputEvent::MouseUp)
225 return false; 222 return false;
226 223
227 const WebMouseEvent* mouseEvent = static_cast<const WebMouseEvent*>(inputEvent); 224 const WebMouseEvent* mouseEvent = static_cast<const WebMouseEvent*>(inputEvent);
228 225
229 WebNavigationPolicy policy; 226 WebNavigationPolicy policy;
230 unsigned short buttonNumber; 227 unsigned short buttonNumber;
231 switch (mouseEvent->button) { 228 switch (mouseEvent->button) {
232 case WebMouseEvent::ButtonLeft: 229 case WebMouseEvent::ButtonLeft:
233 buttonNumber = 0; 230 buttonNumber = 0;
234 break; 231 break;
235 case WebMouseEvent::ButtonMiddle: 232 case WebMouseEvent::ButtonMiddle:
236 buttonNumber = 1; 233 buttonNumber = 1;
237 break; 234 break;
238 case WebMouseEvent::ButtonRight: 235 case WebMouseEvent::ButtonRight:
239 buttonNumber = 2; 236 buttonNumber = 2;
240 break; 237 break;
241 default: 238 default:
242 return false; 239 return false;
243 } 240 }
244 bool ctrl = mouseEvent->modifiers & WebMouseEvent::ControlKey; 241 bool ctrl = mouseEvent->modifiers & WebMouseEvent::ControlKey;
245 bool shift = mouseEvent->modifiers & WebMouseEvent::ShiftKey; 242 bool shift = mouseEvent->modifiers & WebMouseEvent::ShiftKey;
246 bool alt = mouseEvent->modifiers & WebMouseEvent::AltKey; 243 bool alt = mouseEvent->modifiers & WebMouseEvent::AltKey;
247 bool meta = mouseEvent->modifiers & WebMouseEvent::MetaKey; 244 bool meta = mouseEvent->modifiers & WebMouseEvent::MetaKey;
248 245
249 if (!WebViewImpl::NavigationPolicyFromMouseEvent(buttonNumber, ctrl, shift, alt, meta, &policy)) 246 if (!WebViewImpl::navigationPolicyFromMouseEvent(buttonNumber, ctrl, shift, alt, meta, &policy))
250 return false; 247 return false;
251 248
252 return policy == WebNavigationPolicyNewBackgroundTab; 249 return policy == WebNavigationPolicyNewBackgroundTab;
253 } 250 }
254 251
255 void ChromeClientImpl::show() 252 void ChromeClientImpl::show()
256 { 253 {
257 if (!m_webView->client()) 254 if (!m_webView->client())
258 return; 255 return;
259 256
260 // If our default configuration was modified by a script or wasn't 257 // If our default configuration was modified by a script or wasn't
261 // created by a user gesture, then show as a popup. Else, let this 258 // created by a user gesture, then show as a popup. Else, let this
262 // new window be opened as a toplevel window. 259 // new window be opened as a toplevel window.
263 bool asPopup = 260 bool asPopup =
264 !m_toolbarsVisible || 261 !m_toolbarsVisible ||
265 !m_statusbarVisible || 262 !m_statusbarVisible ||
266 !m_scrollbarsVisible || 263 !m_scrollbarsVisible ||
267 !m_menubarVisible || 264 !m_menubarVisible ||
268 !m_resizable; 265 !m_resizable;
269 266
270 WebNavigationPolicy policy = WebNavigationPolicyNewForegroundTab; 267 WebNavigationPolicy policy = WebNavigationPolicyNewForegroundTab;
271 if (asPopup) 268 if (asPopup)
272 policy = WebNavigationPolicyNewPopup; 269 policy = WebNavigationPolicyNewPopup;
273 if (CurrentEventShouldCauseBackgroundTab(WebViewImpl::current_input_event())) 270 if (currentEventShouldCauseBackgroundTab(WebViewImpl::currentInputEvent()))
274 policy = WebNavigationPolicyNewBackgroundTab; 271 policy = WebNavigationPolicyNewBackgroundTab;
275 272
276 m_webView->client()->show(policy); 273 m_webView->client()->show(policy);
277 } 274 }
278 275
279 bool ChromeClientImpl::canRunModal() 276 bool ChromeClientImpl::canRunModal()
280 { 277 {
281 return m_webView->client() != 0; 278 return m_webView->client() != 0;
282 } 279 }
283 280
(...skipping 21 matching lines...) Expand all
305 bool ChromeClientImpl::statusbarVisible() 302 bool ChromeClientImpl::statusbarVisible()
306 { 303 {
307 return m_statusbarVisible; 304 return m_statusbarVisible;
308 } 305 }
309 306
310 void ChromeClientImpl::setScrollbarsVisible(bool value) 307 void ChromeClientImpl::setScrollbarsVisible(bool value)
311 { 308 {
312 m_scrollbarsVisible = value; 309 m_scrollbarsVisible = value;
313 WebFrameImpl* web_frame = static_cast<WebFrameImpl*>(m_webView->mainFrame()); 310 WebFrameImpl* web_frame = static_cast<WebFrameImpl*>(m_webView->mainFrame());
314 if (web_frame) 311 if (web_frame)
315 web_frame->SetAllowsScrolling(value); 312 web_frame->setAllowsScrolling(value);
316 } 313 }
317 314
318 bool ChromeClientImpl::scrollbarsVisible() 315 bool ChromeClientImpl::scrollbarsVisible()
319 { 316 {
320 return m_scrollbarsVisible; 317 return m_scrollbarsVisible;
321 } 318 }
322 319
323 void ChromeClientImpl::setMenubarVisible(bool value) 320 void ChromeClientImpl::setMenubarVisible(bool value)
324 { 321 {
325 m_menubarVisible = value; 322 m_menubarVisible = value;
(...skipping 26 matching lines...) Expand all
352 349
353 bool ChromeClientImpl::canRunBeforeUnloadConfirmPanel() 350 bool ChromeClientImpl::canRunBeforeUnloadConfirmPanel()
354 { 351 {
355 return m_webView->client() != 0; 352 return m_webView->client() != 0;
356 } 353 }
357 354
358 bool ChromeClientImpl::runBeforeUnloadConfirmPanel(const String& message, Frame* frame) 355 bool ChromeClientImpl::runBeforeUnloadConfirmPanel(const String& message, Frame* frame)
359 { 356 {
360 if (m_webView->client()) { 357 if (m_webView->client()) {
361 return m_webView->client()->runModalBeforeUnloadDialog( 358 return m_webView->client()->runModalBeforeUnloadDialog(
362 WebFrameImpl::FromFrame(frame), message); 359 WebFrameImpl::fromFrame(frame), message);
363 } 360 }
364 return false; 361 return false;
365 } 362 }
366 363
367 void ChromeClientImpl::closeWindowSoon() 364 void ChromeClientImpl::closeWindowSoon()
368 { 365 {
369 // Make sure this Page can no longer be found by JS. 366 // Make sure this Page can no longer be found by JS.
370 m_webView->page()->setGroupName(String()); 367 m_webView->page()->setGroupName(String());
371 368
372 // Make sure that all loading is stopped. Ensures that JS stops executing! 369 // Make sure that all loading is stopped. Ensures that JS stops executing!
373 m_webView->mainFrame()->stopLoading(); 370 m_webView->mainFrame()->stopLoading();
374 371
375 if (m_webView->client()) 372 if (m_webView->client())
376 m_webView->client()->closeWidgetSoon(); 373 m_webView->client()->closeWidgetSoon();
377 } 374 }
378 375
379 // Although a Frame is passed in, we don't actually use it, since we 376 // Although a Frame is passed in, we don't actually use it, since we
380 // already know our own m_webView. 377 // already know our own m_webView.
381 void ChromeClientImpl::runJavaScriptAlert(Frame* frame, const String& message) 378 void ChromeClientImpl::runJavaScriptAlert(Frame* frame, const String& message)
382 { 379 {
383 if (m_webView->client()) { 380 if (m_webView->client()) {
384 #if USE(V8) 381 #if USE(V8)
385 // Before showing the JavaScript dialog, we give the proxy implementation 382 // Before showing the JavaScript dialog, we give the proxy implementation
386 // a chance to process any pending console messages. 383 // a chance to process any pending console messages.
387 V8Proxy::processConsoleMessages(); 384 V8Proxy::processConsoleMessages();
388 #endif 385 #endif
389 m_webView->client()->runModalAlertDialog( 386 m_webView->client()->runModalAlertDialog(
390 WebFrameImpl::FromFrame(frame), message); 387 WebFrameImpl::fromFrame(frame), message);
391 } 388 }
392 } 389 }
393 390
394 // See comments for runJavaScriptAlert(). 391 // See comments for runJavaScriptAlert().
395 bool ChromeClientImpl::runJavaScriptConfirm(Frame* frame, const String& message) 392 bool ChromeClientImpl::runJavaScriptConfirm(Frame* frame, const String& message)
396 { 393 {
397 if (m_webView->client()) { 394 if (m_webView->client()) {
398 return m_webView->client()->runModalConfirmDialog( 395 return m_webView->client()->runModalConfirmDialog(
399 WebFrameImpl::FromFrame(frame), message); 396 WebFrameImpl::fromFrame(frame), message);
400 } 397 }
401 return false; 398 return false;
402 } 399 }
403 400
404 // See comments for runJavaScriptAlert(). 401 // See comments for runJavaScriptAlert().
405 bool ChromeClientImpl::runJavaScriptPrompt(Frame* frame, 402 bool ChromeClientImpl::runJavaScriptPrompt(Frame* frame,
406 const String& message, 403 const String& message,
407 const String& defaultValue, 404 const String& defaultValue,
408 String& result) 405 String& result)
409 { 406 {
410 if (m_webView->client()) { 407 if (m_webView->client()) {
411 WebString actualValue; 408 WebString actualValue;
412 bool ok = m_webView->client()->runModalPromptDialog( 409 bool ok = m_webView->client()->runModalPromptDialog(
413 WebFrameImpl::FromFrame(frame), 410 WebFrameImpl::fromFrame(frame),
414 message, 411 message,
415 defaultValue, 412 defaultValue,
416 &actualValue); 413 &actualValue);
417 if (ok) 414 if (ok)
418 result = actualValue; 415 result = actualValue;
419 return ok; 416 return ok;
420 } 417 }
421 return false; 418 return false;
422 } 419 }
423 420
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 if (m_webView->client()) { 482 if (m_webView->client()) {
486 WebRect windowRect = m_webView->client()->windowRect(); 483 WebRect windowRect = m_webView->client()->windowRect();
487 screenRect.move(windowRect.x, windowRect.y); 484 screenRect.move(windowRect.x, windowRect.y);
488 } 485 }
489 486
490 return screenRect; 487 return screenRect;
491 } 488 }
492 489
493 void ChromeClientImpl::contentsSizeChanged(Frame* frame, const IntSize& size) const 490 void ChromeClientImpl::contentsSizeChanged(Frame* frame, const IntSize& size) const
494 { 491 {
495 WebFrameImpl* webframe = WebFrameImpl::FromFrame(frame); 492 WebFrameImpl* webframe = WebFrameImpl::fromFrame(frame);
496 if (webframe->client()) 493 if (webframe->client())
497 webframe->client()->didChangeContentsSize(webframe, size); 494 webframe->client()->didChangeContentsSize(webframe, size);
498 } 495 }
499 496
500 void ChromeClientImpl::scrollbarsModeDidChange() const 497 void ChromeClientImpl::scrollbarsModeDidChange() const
501 { 498 {
502 } 499 }
503 500
504 void ChromeClientImpl::mouseDidMoveOverElement( 501 void ChromeClientImpl::mouseDidMoveOverElement(
505 const HitTestResult& result, unsigned modifierFlags) 502 const HitTestResult& result, unsigned modifierFlags)
(...skipping 14 matching lines...) Expand all
520 WebTextDirection textDirection = (dir == RTL) ? 517 WebTextDirection textDirection = (dir == RTL) ?
521 WebTextDirectionRightToLeft : 518 WebTextDirectionRightToLeft :
522 WebTextDirectionLeftToRight; 519 WebTextDirectionLeftToRight;
523 m_webView->client()->setToolTipText( 520 m_webView->client()->setToolTipText(
524 tooltipText, textDirection); 521 tooltipText, textDirection);
525 } 522 }
526 523
527 void ChromeClientImpl::print(Frame* frame) 524 void ChromeClientImpl::print(Frame* frame)
528 { 525 {
529 if (m_webView->client()) 526 if (m_webView->client())
530 m_webView->client()->printPage(WebFrameImpl::FromFrame(frame)); 527 m_webView->client()->printPage(WebFrameImpl::fromFrame(frame));
531 } 528 }
532 529
533 void ChromeClientImpl::exceededDatabaseQuota(Frame* frame, const String& databaseName) 530 void ChromeClientImpl::exceededDatabaseQuota(Frame* frame, const String& databaseName)
534 { 531 {
535 // set a reasonable quota for now -- 5Mb should be enough for anybody 532 // set a reasonable quota for now -- 5Mb should be enough for anybody
536 // TODO(dglazkov): this should be configurable 533 // TODO(dglazkov): this should be configurable
537 SecurityOrigin* origin = frame->document()->securityOrigin(); 534 SecurityOrigin* origin = frame->document()->securityOrigin();
538 DatabaseTracker::tracker().setQuota(origin, 1024 * 1024 * 5); 535 DatabaseTracker::tracker().setQuota(origin, 1024 * 1024 * 5);
539 } 536 }
540 537
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
606 // Currently, Widget::setCursor is always called after this function in 603 // Currently, Widget::setCursor is always called after this function in
607 // EventHandler.cpp and since we don't want that we set a flag indicating 604 // EventHandler.cpp and since we don't want that we set a flag indicating
608 // that the next SetCursor call is to be ignored. 605 // that the next SetCursor call is to be ignored.
609 m_ignoreNextSetCursor = true; 606 m_ignoreNextSetCursor = true;
610 } 607 }
611 608
612 void ChromeClientImpl::formStateDidChange(const Node* node) 609 void ChromeClientImpl::formStateDidChange(const Node* node)
613 { 610 {
614 // The current history item is not updated yet. That happens lazily when 611 // The current history item is not updated yet. That happens lazily when
615 // WebFrame::currentHistoryItem is requested. 612 // WebFrame::currentHistoryItem is requested.
616 WebFrameImpl* webframe = WebFrameImpl::FromFrame(node->document()->frame()); 613 WebFrameImpl* webframe = WebFrameImpl::fromFrame(node->document()->frame());
617 if (webframe->client()) 614 if (webframe->client())
618 webframe->client()->didUpdateCurrentHistoryItem(webframe); 615 webframe->client()->didUpdateCurrentHistoryItem(webframe);
619 } 616 }
620 617
621 void ChromeClientImpl::getPopupMenuInfo(PopupContainer* popupContainer, 618 void ChromeClientImpl::getPopupMenuInfo(PopupContainer* popupContainer,
622 WebPopupMenuInfo* info) 619 WebPopupMenuInfo* info)
623 { 620 {
624 const Vector<PopupItem*>& inputItems = popupContainer->popupData(); 621 const Vector<PopupItem*>& inputItems = popupContainer->popupData();
625 622
626 WebVector<WebPopupMenuInfo::Item> outputItems(inputItems.size()); 623 WebVector<WebPopupMenuInfo::Item> outputItems(inputItems.size());
(...skipping 21 matching lines...) Expand all
648 } 645 }
649 646
650 info->itemHeight = popupContainer->menuItemHeight(); 647 info->itemHeight = popupContainer->menuItemHeight();
651 info->selectedIndex = popupContainer->selectedIndex(); 648 info->selectedIndex = popupContainer->selectedIndex();
652 info->items.swap(outputItems); 649 info->items.swap(outputItems);
653 } 650 }
654 651
655 #if ENABLE(NOTIFICATIONS) 652 #if ENABLE(NOTIFICATIONS)
656 NotificationPresenter* ChromeClientImpl::notificationPresenter() const 653 NotificationPresenter* ChromeClientImpl::notificationPresenter() const
657 { 654 {
658 return m_webView->GetNotificationPresenter(); 655 return m_webView->notificationPresenterImpl();
659 } 656 }
660 #endif 657 #endif
661 658
662 } // namespace WebKit 659 } // namespace WebKit
OLDNEW
« no previous file with comments | « webkit/api/src/ChromeClientImpl.h ('k') | webkit/api/src/ContextMenuClientImpl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698