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

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

Issue 350003: Flesh out more of ChromiumBridge.cpp eliminating all but two methods on... (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/FrameLoaderClientImpl.cpp » ('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 15 matching lines...) Expand all
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 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. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "config.h" 31 #include "config.h"
32 #include "ChromiumBridge.h" 32 #include "ChromiumBridge.h"
33 33
34 #include <googleurl/src/url_util.h> 34 #include <googleurl/src/url_util.h>
35 35
36 #include "ChromeClientImpl.h"
36 #include "WebClipboard.h" 37 #include "WebClipboard.h"
37 #include "WebCookie.h" 38 #include "WebCookie.h"
39 #include "WebCursorInfo.h"
38 #include "WebData.h" 40 #include "WebData.h"
41 #include "WebFrameClient.h"
42 #include "WebFrameImpl.h"
39 #include "WebImage.h" 43 #include "WebImage.h"
40 #include "WebKit.h" 44 #include "WebKit.h"
41 #include "WebKitClient.h" 45 #include "WebKitClient.h"
42 #include "WebMimeRegistry.h" 46 #include "WebMimeRegistry.h"
43 #include "WebPluginContainerImpl.h" 47 #include "WebPluginContainerImpl.h"
44 #include "WebPluginListBuilderImpl.h" 48 #include "WebPluginListBuilderImpl.h"
49 #include "WebScreenInfo.h"
45 #include "WebString.h" 50 #include "WebString.h"
46 #include "WebVector.h" 51 #include "WebVector.h"
47 #include "WebURL.h" 52 #include "WebURL.h"
48 #include "Worker.h" 53 #include "WebViewClient.h"
49 #include "WorkerContextProxy.h" 54 #include "WebViewImpl.h"
55 #include "WebWorkerClientImpl.h"
50 56
51 #if PLATFORM(WIN_OS) 57 #if PLATFORM(WIN_OS)
52 #include "WebRect.h" 58 #include "WebRect.h"
53 #include "WebSandboxSupport.h" 59 #include "WebSandboxSupport.h"
54 #include "WebThemeEngine.h" 60 #include "WebThemeEngine.h"
55 #endif 61 #endif
56 62
57 #if PLATFORM(LINUX) 63 #if PLATFORM(LINUX)
58 #include "WebSandboxSupport.h" 64 #include "WebSandboxSupport.h"
59 #include "WebFontInfo.h" 65 #include "WebFontInfo.h"
60 #endif 66 #endif
61 67
62 #if WEBKIT_USING_SKIA 68 #if WEBKIT_USING_SKIA
63 #include "NativeImageSkia.h" 69 #include "NativeImageSkia.h"
64 #endif 70 #endif
65 71
66 #include "BitmapImage.h" 72 #include "BitmapImage.h"
67 #include "Cookie.h" 73 #include "Cookie.h"
68 #include "GraphicsContext.h" 74 #include "GraphicsContext.h"
69 #include "KURL.h" 75 #include "KURL.h"
76 #include "FrameView.h"
70 #include "NotImplemented.h" 77 #include "NotImplemented.h"
71 #include "PlatformContextSkia.h" 78 #include "PlatformContextSkia.h"
72 #include "PluginData.h" 79 #include "PluginData.h"
80 #include "Worker.h"
81 #include "WorkerContextProxy.h"
73 #include <wtf/Assertions.h> 82 #include <wtf/Assertions.h>
74 83
75 // We are part of the WebKit implementation. 84 // We are part of the WebKit implementation.
76 using namespace WebKit; 85 using namespace WebKit;
77 86
78 namespace WebCore { 87 namespace WebCore {
79 88
89 static ChromeClientImpl* toChromeClientImpl(Widget* widget)
90 {
91 FrameView* view;
92 if (widget->isFrameView())
93 view = static_cast<FrameView*>(widget);
94 else if (widget->parent() && widget->parent()->isFrameView())
95 view = static_cast<FrameView*>(widget->parent());
96 else
97 return 0;
98
99 Page* page = view->frame() ? view->frame()->page() : 0;
100 if (!page)
101 return 0;
102
103 return static_cast<ChromeClientImpl*>(page->chrome()->client());
104 }
105
106 static WebWidgetClient* toWebWidgetClient(Widget* widget)
107 {
108 ChromeClientImpl* chromeClientImpl = toChromeClientImpl(widget);
109 if (!chromeClientImpl || !chromeClientImpl->webView())
110 return 0;
111 return chromeClientImpl->webView()->client();
112 }
113
80 // Clipboard ------------------------------------------------------------------ 114 // Clipboard ------------------------------------------------------------------
81 115
82 bool ChromiumBridge::clipboardIsFormatAvailable( 116 bool ChromiumBridge::clipboardIsFormatAvailable(
83 PasteboardPrivate::ClipboardFormat format, 117 PasteboardPrivate::ClipboardFormat format,
84 PasteboardPrivate::ClipboardBuffer buffer) 118 PasteboardPrivate::ClipboardBuffer buffer)
85 { 119 {
86 return webKitClient()->clipboard()->isFormatAvailable( 120 return webKitClient()->clipboard()->isFormatAvailable(
87 static_cast<WebClipboard::Format>(format), 121 static_cast<WebClipboard::Format>(format),
88 static_cast<WebClipboard::Buffer>(buffer)); 122 static_cast<WebClipboard::Buffer>(buffer));
89 } 123 }
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 bool ChromiumBridge::plugins(bool refresh, Vector<PluginInfo*>* results) 392 bool ChromiumBridge::plugins(bool refresh, Vector<PluginInfo*>* results)
359 { 393 {
360 WebPluginListBuilderImpl builder(results); 394 WebPluginListBuilderImpl builder(results);
361 webKitClient()->getPluginList(refresh, &builder); 395 webKitClient()->getPluginList(refresh, &builder);
362 return true; // FIXME: There is no need for this function to return a value. 396 return true; // FIXME: There is no need for this function to return a value.
363 } 397 }
364 398
365 NPObject* ChromiumBridge::pluginScriptableObject(Widget* widget) 399 NPObject* ChromiumBridge::pluginScriptableObject(Widget* widget)
366 { 400 {
367 if (!widget) 401 if (!widget)
368 return NULL; 402 return 0;
369 403
370 ASSERT(!widget->isFrameView()); 404 ASSERT(!widget->isFrameView());
371 405
372 // NOTE: We have to trust that the widget passed to us here is a 406 // NOTE: We have to trust that the widget passed to us here is a
373 // WebPluginContainerImpl. There isn't a way to dynamically verify it, 407 // WebPluginContainerImpl. There isn't a way to dynamically verify it,
374 // since the derived class (Widget) has no identifier. 408 // since the derived class (Widget) has no identifier.
375 return static_cast<WebPluginContainerImpl*>(widget)->scriptableObject(); 409 return static_cast<WebPluginContainerImpl*>(widget)->scriptableObject();
376 } 410 }
377 411
378 // Resources ------------------------------------------------------------------ 412 // Resources ------------------------------------------------------------------
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 webKitClient()->traceEventBegin(name, id, extra); 547 webKitClient()->traceEventBegin(name, id, extra);
514 } 548 }
515 549
516 void ChromiumBridge::traceEventEnd(const char* name, void* id, const char* extra) 550 void ChromiumBridge::traceEventEnd(const char* name, void* id, const char* extra)
517 { 551 {
518 webKitClient()->traceEventEnd(name, id, extra); 552 webKitClient()->traceEventEnd(name, id, extra);
519 } 553 }
520 554
521 // Visited Links -------------------------------------------------------------- 555 // Visited Links --------------------------------------------------------------
522 556
523 WebCore::LinkHash ChromiumBridge::visitedLinkHash(const UChar* url, 557 LinkHash ChromiumBridge::visitedLinkHash(const UChar* url, unsigned length)
524 unsigned length)
525 { 558 {
526 url_canon::RawCanonOutput<2048> buffer; 559 url_canon::RawCanonOutput<2048> buffer;
527 url_parse::Parsed parsed; 560 url_parse::Parsed parsed;
528 if (!url_util::Canonicalize(url, length, NULL, &buffer, &parsed)) 561 if (!url_util::Canonicalize(url, length, 0, &buffer, &parsed))
529 return 0; // Invalid URLs are unvisited. 562 return 0; // Invalid URLs are unvisited.
530 return webKitClient()->visitedLinkHash(buffer.data(), buffer.length()); 563 return webKitClient()->visitedLinkHash(buffer.data(), buffer.length());
531 } 564 }
532 565
533 WebCore::LinkHash ChromiumBridge::visitedLinkHash(const WebCore::KURL& base, 566 LinkHash ChromiumBridge::visitedLinkHash(const KURL& base,
534 const WebCore::AtomicString& attributeURL) 567 const AtomicString& attributeURL)
535 { 568 {
536 // Resolve the relative URL using googleurl and pass the absolute URL up to 569 // Resolve the relative URL using googleurl and pass the absolute URL up to
537 // the embedder. We could create a GURL object from the base and resolve 570 // the embedder. We could create a GURL object from the base and resolve
538 // the relative URL that way, but calling the lower-level functions 571 // the relative URL that way, but calling the lower-level functions
539 // directly saves us the string allocation in most cases. 572 // directly saves us the string allocation in most cases.
540 url_canon::RawCanonOutput<2048> buffer; 573 url_canon::RawCanonOutput<2048> buffer;
541 url_parse::Parsed parsed; 574 url_parse::Parsed parsed;
542 575
543 #if USE(GOOGLEURL) 576 #if USE(GOOGLEURL)
544 const WebCore::CString& cstr = base.utf8String(); 577 const CString& cstr = base.utf8String();
545 const char* data = cstr.data(); 578 const char* data = cstr.data();
546 int length = cstr.length(); 579 int length = cstr.length();
547 const url_parse::Parsed& srcParsed = base.parsed(); 580 const url_parse::Parsed& srcParsed = base.parsed();
548 #else 581 #else
549 // When we're not using GoogleURL, first canonicalize it so we can resolve it 582 // When we're not using GoogleURL, first canonicalize it so we can resolve it
550 // below. 583 // below.
551 url_canon::RawCanonOutput<2048> srcCanon; 584 url_canon::RawCanonOutput<2048> srcCanon;
552 url_parse::Parsed srcParsed; 585 url_parse::Parsed srcParsed;
553 WebCore::String str = base.string(); 586 String str = base.string();
554 if (!url_util::Canonicalize(str.characters(), str.length(), NULL, &srcCanon, &srcParsed)) 587 if (!url_util::Canonicalize(str.characters(), str.length(), 0, &srcCanon, &srcParsed))
555 return 0; 588 return 0;
556 const char* data = srcCanon.data(); 589 const char* data = srcCanon.data();
557 int length = srcCanon.length(); 590 int length = srcCanon.length();
558 #endif 591 #endif
559 592
560 if (!url_util::ResolveRelative(data, length, srcParsed, attributeURL.characters(), 593 if (!url_util::ResolveRelative(data, length, srcParsed, attributeURL.characters(),
561 attributeURL.length(), NULL, &buffer, &parsed)) 594 attributeURL.length(), 0, &buffer, &parsed))
562 return 0; // Invalid resolved URL. 595 return 0; // Invalid resolved URL.
563 596
564 return webKitClient()->visitedLinkHash(buffer.data(), buffer.length()); 597 return webKitClient()->visitedLinkHash(buffer.data(), buffer.length());
565 } 598 }
566 599
567 bool ChromiumBridge::isLinkVisited(WebCore::LinkHash visitedLinkHash) 600 bool ChromiumBridge::isLinkVisited(LinkHash visitedLinkHash)
568 { 601 {
569 return webKitClient()->isLinkVisited(visitedLinkHash); 602 return webKitClient()->isLinkVisited(visitedLinkHash);
570 } 603 }
571 604
572 // These are temporary methoeds that the WebKit layer can use to call to the 605 // These are temporary methoeds that the WebKit layer can use to call to the
573 // Glue layer. Once the Glue layer moves entirely into the WebKit layer, these 606 // Glue layer. Once the Glue layer moves entirely into the WebKit layer, these
574 // methods will be deleted. 607 // methods will be deleted.
575 608
576 String ChromiumBridge::uiResourceProtocol() 609 String ChromiumBridge::uiResourceProtocol()
577 { 610 {
578 return webKitClient()->uiResourceProtocol(); 611 return webKitClient()->uiResourceProtocol();
579 } 612 }
580 613
581 void ChromiumBridge::notifyJSOutOfMemory(WebCore::Frame* frame) 614 void ChromiumBridge::notifyJSOutOfMemory(Frame* frame)
582 { 615 {
583 return webKitClient()->notifyJSOutOfMemory(frame); 616 if (!frame)
617 return;
618
619 WebFrameImpl* webFrame = WebFrameImpl::fromFrame(frame);
620 if (!webFrame->client())
621 return;
622 webFrame->client()->didExhaustMemoryAvailableForScript(webFrame);
584 } 623 }
585 624
586 int ChromiumBridge::screenDepth(Widget* widget) 625 int ChromiumBridge::screenDepth(Widget* widget)
587 { 626 {
588 return webKitClient()->screenDepth(widget); 627 WebWidgetClient* client = toWebWidgetClient(widget);
628 if (!client)
629 return 0;
630 return client->screenInfo().depth;
589 } 631 }
590 632
591 int ChromiumBridge::screenDepthPerComponent(Widget* widget) 633 int ChromiumBridge::screenDepthPerComponent(Widget* widget)
592 { 634 {
593 return webKitClient()->screenDepthPerComponent(widget); 635 WebWidgetClient* client = toWebWidgetClient(widget);
636 if (!client)
637 return 0;
638 return client->screenInfo().depthPerComponent;
594 } 639 }
595 640
596 bool ChromiumBridge::screenIsMonochrome(Widget* widget) 641 bool ChromiumBridge::screenIsMonochrome(Widget* widget)
597 { 642 {
598 return webKitClient()->screenIsMonochrome(widget); 643 WebWidgetClient* client = toWebWidgetClient(widget);
644 if (!client)
645 return 0;
646 return client->screenInfo().isMonochrome;
599 } 647 }
600 648
601 IntRect ChromiumBridge::screenRect(Widget* widget) 649 IntRect ChromiumBridge::screenRect(Widget* widget)
602 { 650 {
603 return webKitClient()->screenRect(widget); 651 WebWidgetClient* client = toWebWidgetClient(widget);
652 if (!client)
653 return IntRect();
654 return client->screenInfo().rect;
604 } 655 }
605 656
606 IntRect ChromiumBridge::screenAvailableRect(Widget* widget) 657 IntRect ChromiumBridge::screenAvailableRect(Widget* widget)
607 { 658 {
608 return webKitClient()->screenAvailableRect(widget); 659 WebWidgetClient* client = toWebWidgetClient(widget);
660 if (!client)
661 return IntRect();
662 return client->screenInfo().availableRect;
609 } 663 }
610 664
611 bool ChromiumBridge::popupsAllowed(NPP npp) 665 bool ChromiumBridge::popupsAllowed(NPP npp)
612 { 666 {
613 return webKitClient()->popupsAllowed(npp); 667 return webKitClient()->popupsAllowed(npp);
614 } 668 }
615 669
616 void ChromiumBridge::widgetSetCursor(Widget* widget, const Cursor& cursor) 670 void ChromiumBridge::widgetSetCursor(Widget* widget, const Cursor& cursor)
617 { 671 {
618 return webKitClient()->widgetSetCursor(widget, cursor); 672 ChromeClientImpl* client = toChromeClientImpl(widget);
673 if (client)
674 client->setCursor(WebCursorInfo(cursor));
619 } 675 }
620 676
621 void ChromiumBridge::widgetSetFocus(Widget* widget) 677 void ChromiumBridge::widgetSetFocus(Widget* widget)
622 { 678 {
623 return webKitClient()->widgetSetFocus(widget); 679 ChromeClientImpl* client = toChromeClientImpl(widget);
680 if (client)
681 client->focus();
624 } 682 }
625 683
626 WorkerContextProxy* WorkerContextProxy::create(Worker* worker) 684 WorkerContextProxy* WorkerContextProxy::create(Worker* worker)
627 { 685 {
628 return webKitClient()->createWorkerContextProxy(worker); 686 return WebWorkerClientImpl::createWorkerContextProxy(worker);
629 } 687 }
630 688
631 } // namespace WebCore 689 } // namespace WebCore
OLDNEW
« no previous file with comments | « webkit/api/src/ChromeClientImpl.h ('k') | webkit/api/src/FrameLoaderClientImpl.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698