diff options
author | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-06 19:43:03 +0000 |
---|---|---|
committer | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-06 19:43:03 +0000 |
commit | b1f031fee7f0c43ef56e1152b79e5e806e5262bf (patch) | |
tree | 0cb7f2d0976ee30b08095f32a36c23e8673b1fa9 | |
parent | 2269fd09eff09fd41c988aaacf0ea7cef07eca27 (diff) | |
download | chromium_src-b1f031fee7f0c43ef56e1152b79e5e806e5262bf.zip chromium_src-b1f031fee7f0c43ef56e1152b79e5e806e5262bf.tar.gz chromium_src-b1f031fee7f0c43ef56e1152b79e5e806e5262bf.tar.bz2 |
Reland r11118.
TBR=dglazkov
Review URL: http://codereview.chromium.org/40240
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@11137 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | DEPS | 2 | ||||
-rw-r--r-- | chrome/renderer/renderer_glue.cc | 14 | ||||
-rw-r--r-- | chrome/renderer/renderer_webkitclient_impl.cc | 13 | ||||
-rw-r--r-- | chrome/renderer/renderer_webkitclient_impl.h | 2 | ||||
-rw-r--r-- | chrome/worker/worker_webkitclient_impl.cc | 9 | ||||
-rw-r--r-- | chrome/worker/worker_webkitclient_impl.h | 2 | ||||
-rw-r--r-- | webkit/glue/chromium_bridge_impl.cc | 108 | ||||
-rw-r--r-- | webkit/glue/webkit_glue.h | 38 | ||||
-rw-r--r-- | webkit/glue/webkitclient_impl.cc | 28 | ||||
-rw-r--r-- | webkit/glue/webkitclient_impl.h | 11 | ||||
-rwxr-xr-x | webkit/tools/test_shell/test_shell.cc | 17 | ||||
-rw-r--r-- | webkit/tools/test_shell/test_shell_webkit_init.h | 29 |
12 files changed, 86 insertions, 187 deletions
@@ -19,7 +19,7 @@ deps = { "http://googletest.googlecode.com/svn/trunk@167", "src/third_party/WebKit": - "/trunk/deps/third_party/WebKit@11128", + "/trunk/deps/third_party/WebKit@11136", "src/third_party/icu38": "/trunk/deps/third_party/icu38@10692", diff --git a/chrome/renderer/renderer_glue.cc b/chrome/renderer/renderer_glue.cc index 9508c50..22b2775 100644 --- a/chrome/renderer/renderer_glue.cc +++ b/chrome/renderer/renderer_glue.cc @@ -22,7 +22,6 @@ #include "chrome/renderer/render_process.h" #include "chrome/renderer/render_thread.h" #include "chrome/renderer/render_view.h" -#include "chrome/renderer/visitedlink_slave.h" #include "googleurl/src/url_util.h" #include "webkit/glue/scoped_clipboard_writer_glue.h" #include "webkit/glue/webframe.h" @@ -178,10 +177,6 @@ std::string GetDataResource(int resource_id) { return ResourceBundle::GetSharedInstance().GetDataResource(resource_id); } -SkBitmap* GetBitmapResource(int resource_id) { - return ResourceBundle::GetSharedInstance().GetBitmapNamed(resource_id); -} - #if defined(OS_WIN) HCURSOR LoadCursor(int cursor_id) { return ResourceBundle::GetSharedInstance().LoadCursor(cursor_id); @@ -251,15 +246,6 @@ webkit_glue::ScreenInfo GetScreenInfo(gfx::NativeViewId window) { return results; } -uint64 VisitedLinkHash(const char* canonical_url, size_t length) { - return RenderThread::current()->visited_link_slave()->ComputeURLFingerprint( - canonical_url, length); -} - -bool IsLinkVisited(uint64 link_hash) { - return RenderThread::current()->visited_link_slave()->IsVisited(link_hash); -} - #ifndef USING_SIMPLE_RESOURCE_LOADER_BRIDGE // Each RenderView has a ResourceDispatcher. In unit tests, this function may diff --git a/chrome/renderer/renderer_webkitclient_impl.cc b/chrome/renderer/renderer_webkitclient_impl.cc index 7a065f9..286d227 100644 --- a/chrome/renderer/renderer_webkitclient_impl.cc +++ b/chrome/renderer/renderer_webkitclient_impl.cc @@ -13,6 +13,7 @@ #include "chrome/plugin/npobject_util.h" #include "chrome/renderer/net/render_dns_master.h" #include "chrome/renderer/render_thread.h" +#include "chrome/renderer/visitedlink_slave.h" #include "webkit/glue/glue_util.h" #include "webkit/glue/webkit_glue.h" @@ -21,6 +22,18 @@ using WebKit::WebURL; //------------------------------------------------------------------------------ +uint64_t RendererWebKitClientImpl::visitedLinkHash(const char* canonical_url, + size_t length) { + return RenderThread::current()->visited_link_slave()->ComputeURLFingerprint( + canonical_url, length); +} + +bool RendererWebKitClientImpl::isLinkVisited(uint64_t link_hash) { + return RenderThread::current()->visited_link_slave()->IsVisited(link_hash); +} + +//------------------------------------------------------------------------------ + void RendererWebKitClientImpl::setCookies( const WebURL& url, const WebURL& policy_url, const WebString& value) { std::string value_utf8; diff --git a/chrome/renderer/renderer_webkitclient_impl.h b/chrome/renderer/renderer_webkitclient_impl.h index 9a7fe1d..2ed397b 100644 --- a/chrome/renderer/renderer_webkitclient_impl.h +++ b/chrome/renderer/renderer_webkitclient_impl.h @@ -14,6 +14,8 @@ class RendererWebKitClientImpl : public webkit_glue::WebKitClientImpl { virtual WebKit::WebMimeRegistry* mimeRegistry() { return &mime_registry_; } + virtual uint64_t visitedLinkHash(const char* canonicalURL, size_t length); + virtual bool isLinkVisited(uint64_t linkHash); virtual void setCookies( const WebKit::WebURL& url, const WebKit::WebURL& policy_url, const WebKit::WebString&); diff --git a/chrome/worker/worker_webkitclient_impl.cc b/chrome/worker/worker_webkitclient_impl.cc index 8bd147c..5873d3f 100644 --- a/chrome/worker/worker_webkitclient_impl.cc +++ b/chrome/worker/worker_webkitclient_impl.cc @@ -11,6 +11,15 @@ WebKit::WebMimeRegistry* WorkerWebKitClientImpl::mimeRegistry() { return NULL; } +uint64_t WorkerWebKitClientImpl::visitedLinkHash(const char* canonical_url, + size_t length) { + return 0; +} + +bool WorkerWebKitClientImpl::isLinkVisited(uint64_t link_hash) { + return false; +} + void WorkerWebKitClientImpl::setCookies(const WebKit::WebURL& url, const WebKit::WebURL& policy_url, const WebKit::WebString& value) { diff --git a/chrome/worker/worker_webkitclient_impl.h b/chrome/worker/worker_webkitclient_impl.h index e8b9a73..7c623b9 100644 --- a/chrome/worker/worker_webkitclient_impl.h +++ b/chrome/worker/worker_webkitclient_impl.h @@ -11,6 +11,8 @@ class WorkerWebKitClientImpl : public webkit_glue::WebKitClientImpl { public: // WebKitClient methods: virtual WebKit::WebMimeRegistry* mimeRegistry(); + virtual uint64_t visitedLinkHash(const char* canonicalURL, size_t length); + virtual bool isLinkVisited(uint64_t linkHash); virtual void setCookies(const WebKit::WebURL& url, const WebKit::WebURL& policy_url, const WebKit::WebString& value); diff --git a/webkit/glue/chromium_bridge_impl.cc b/webkit/glue/chromium_bridge_impl.cc index f832150..e2ac370 100644 --- a/webkit/glue/chromium_bridge_impl.cc +++ b/webkit/glue/chromium_bridge_impl.cc @@ -189,63 +189,6 @@ String ChromiumBridge::uiResourceProtocol() { } -// Resources ------------------------------------------------------------------ - -PassRefPtr<Image> ChromiumBridge::loadPlatformImageResource(const char* name) { - - // The rest get converted to a resource ID that we can pass to the glue. - int resource_id = 0; - if (!strcmp(name, "textAreaResizeCorner")) { - resource_id = IDR_TEXTAREA_RESIZER; - } else if (!strcmp(name, "missingImage")) { - resource_id = IDR_BROKENIMAGE; - } else if (!strcmp(name, "tickmarkDash")) { - resource_id = IDR_TICKMARK_DASH; - } else if (!strcmp(name, "panIcon")) { - resource_id = IDR_PAN_SCROLL_ICON; - } else if (!strcmp(name, "linuxCheckboxOff")) { - resource_id = IDR_LINUX_CHECKBOX_OFF; - } else if (!strcmp(name, "linuxCheckboxOn")) { - resource_id = IDR_LINUX_CHECKBOX_ON; - } else if (!strcmp(name, "linuxRadioOff")) { - resource_id = IDR_LINUX_RADIO_OFF; - } else if (!strcmp(name, "linuxRadioOn")) { - resource_id = IDR_LINUX_RADIO_ON; - } else if (!strcmp(name, "deleteButton")) { - if (WebKit::layoutTestMode()) { - RefPtr<Image> image = BitmapImage::create(); - // Create a red 30x30 square used only in layout tests. - const char red_square[] = - "\x89\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52" - "\x00\x00\x00\x1e\x00\x00\x00\x1e\x04\x03\x00\x00\x00\xc9\x1e\xb3" - "\x91\x00\x00\x00\x30\x50\x4c\x54\x45\x00\x00\x00\x80\x00\x00\x00" - "\x80\x00\x80\x80\x00\x00\x00\x80\x80\x00\x80\x00\x80\x80\x80\x80" - "\x80\xc0\xc0\xc0\xff\x00\x00\x00\xff\x00\xff\xff\x00\x00\x00\xff" - "\xff\x00\xff\x00\xff\xff\xff\xff\xff\x7b\x1f\xb1\xc4\x00\x00\x00" - "\x09\x70\x48\x59\x73\x00\x00\x0b\x13\x00\x00\x0b\x13\x01\x00\x9a" - "\x9c\x18\x00\x00\x00\x17\x49\x44\x41\x54\x78\x01\x63\x98\x89\x0a" - "\x18\x50\xb9\x33\x47\xf9\xa8\x01\x32\xd4\xc2\x03\x00\x33\x84\x0d" - "\x02\x3a\x91\xeb\xa5\x00\x00\x00\x00\x49\x45\x4e\x44\xae\x42\x60" - "\x82"; - const int size = arraysize(red_square); - RefPtr<SharedBuffer> buffer = SharedBuffer::create(red_square, size); - image->setData(buffer, true); - return image; - } - } else { - NOTREACHED() << "Unknown image resource " << name; - return Image::nullImage(); - } - - std::string data = webkit_glue::GetDataResource(resource_id); - RefPtr<SharedBuffer> buffer( - SharedBuffer::create(data.empty() ? "" : data.data(), - data.length())); - RefPtr<Image> image = BitmapImage::create(); - image->setData(buffer, true); - return image; -} - // Screen --------------------------------------------------------------------- int ChromiumBridge::screenDepth(Widget* widget) { @@ -397,57 +340,6 @@ KURL ChromiumBridge::inspectorURL() { return webkit_glue::GURLToKURL(webkit_glue::GetInspectorURL()); } -// Visited links -------------------------------------------------------------- - -WebCore::LinkHash ChromiumBridge::visitedLinkHash(const UChar* url, - unsigned length) { - url_canon::RawCanonOutput<2048> buffer; - url_parse::Parsed parsed; - if (!url_util::Canonicalize(url, length, NULL, &buffer, &parsed)) - return false; // Invalid URLs are unvisited. - return webkit_glue::VisitedLinkHash(buffer.data(), buffer.length()); -} - -WebCore::LinkHash ChromiumBridge::visitedLinkHash( - const WebCore::KURL& base, - const WebCore::AtomicString& attributeURL) { - // Resolve the relative URL using googleurl and pass the absolute URL up to - // the embedder. We could create a GURL object from the base and resolve the - // relative URL that way, but calling the lower-level functions directly - // saves us the std::string allocation in most cases. - url_canon::RawCanonOutput<2048> buffer; - url_parse::Parsed parsed; - -#if USE(GOOGLEURL) - const WebCore::CString& cstr = base.utf8String(); - const char* data = cstr.data(); - int length = cstr.length(); - const url_parse::Parsed& src_parsed = base.parsed(); -#else - // When we're not using GoogleURL, first canonicalize it so we can resolve it - // below. - url_canon::RawCanonOutput<2048> src_canon; - url_parse::Parsed src_parsed; - WebCore::String str = base.string(); - if (!url_util::Canonicalize(str.characters(), str.length(), NULL, - &src_canon, &src_parsed)) - return false; - const char* data = src_canon.data(); - int length = src_canon.length(); -#endif - - if (!url_util::ResolveRelative(data, length, src_parsed, - attributeURL.characters(), - attributeURL.length(), NULL, - &buffer, &parsed)) - return false; // Invalid resolved URL. - return webkit_glue::VisitedLinkHash(buffer.data(), buffer.length()); -} - -bool ChromiumBridge::isLinkVisited(WebCore::LinkHash visitedLinkHash) { - return webkit_glue::IsLinkVisited(visitedLinkHash); -} - // Widget --------------------------------------------------------------------- void ChromiumBridge::widgetSetCursor(Widget* widget, const Cursor& cursor) { diff --git a/webkit/glue/webkit_glue.h b/webkit/glue/webkit_glue.h index 0ddee38..7b79ff9 100644 --- a/webkit/glue/webkit_glue.h +++ b/webkit/glue/webkit_glue.h @@ -29,27 +29,6 @@ namespace WebKit { class WebString; } -#if defined(OS_MACOSX) -// TODO(port): -// When the code (that got compiled) only used SkBitmap*, it was OK to -// make a GlueBitmap be a SkBitmap* or CGImageRef. However, lots of -// other chrome files that need to be brought in (such as -// chrome/viewas/tree_model.h) uses SkBitmap (as a non-pointer). -// Although *(GlueBitmap) makes sense as *(SkBitmap*), it does not -// make sense as *(CGImageRef). -typedef struct CGImage* CGImageRef; -class GlueBitmap { - public: - explicit GlueBitmap(CGImageRef ref) : ref_(ref) { } - GlueBitmap() : ref_(0) { } - operator CGImageRef() { return ref_; } - private: - CGImageRef ref_; -}; -#else -typedef SkBitmap GlueBitmap; -#endif - namespace webkit_glue { struct ScreenInfo; @@ -162,15 +141,6 @@ string16 GetLocalizedString(int message_id); // specified as BINDATA in the relevant .rc file. std::string GetDataResource(int resource_id); -// Returns a GlueBitmap for a resource. This resource must have been -// specified as BINDATA in the relevant .rc file. -#if defined(OS_MACOSX) -// TODO(port) -SkBitmap* GetBitmapResource(int resource_id); -#else -GlueBitmap* GetBitmapResource(int resource_id); -#endif - #if defined(OS_WIN) // Loads and returns a cursor. HCURSOR LoadCursor(int cursor_id); @@ -247,14 +217,6 @@ bool FindProxyForUrl(const GURL& url, std::string* proxy_list); // the form language-country (e.g., en-US or pt-BR). std::wstring GetWebKitLocale(); -// Returns the hash for the given canonicalized URL for use in visited link -// coloring. -uint64 VisitedLinkHash(const char* canonical_url, size_t length); - -// Returns whether the given link hash is in the user's history. The hash must -// have been generated by calling VisitedLinkHash(). -bool IsLinkVisited(uint64 link_hash); - // ---- END FUNCTIONS IMPLEMENTED BY EMBEDDER --------------------------------- diff --git a/webkit/glue/webkitclient_impl.cc b/webkit/glue/webkitclient_impl.cc index e726a6c..61efece 100644 --- a/webkit/glue/webkitclient_impl.cc +++ b/webkit/glue/webkitclient_impl.cc @@ -4,7 +4,11 @@ #include "webkit/glue/webkitclient_impl.h" +#include "WebCString.h" + #include "base/message_loop.h" +#include "grit/webkit_resources.h" +#include "webkit/glue/webkit_glue.h" namespace webkit_glue { @@ -17,6 +21,30 @@ WebKit::WebClipboard* WebKitClientImpl::clipboard() { return &clipboard_; } +WebKit::WebCString WebKitClientImpl::loadResource(const char* name) { + struct { + const char* name; + int id; + } resources[] = { + { "textAreaResizeCorner", IDR_TEXTAREA_RESIZER }, + { "missingImage", IDR_BROKENIMAGE }, + { "tickmarkDash", IDR_TICKMARK_DASH }, + { "panIcon", IDR_PAN_SCROLL_ICON }, +#if defined(OS_LINUX) + { "linuxCheckboxOff", IDR_LINUX_CHECKBOX_OFF }, + { "linuxCheckboxOn", IDR_LINUX_CHECKBOX_ON }, + { "linuxRadioOff", IDR_LINUX_RADIO_OFF }, + { "linuxRadioOn", IDR_LINUX_RADIO_ON }, +#endif + }; + for (size_t i = 0; i < ARRAYSIZE_UNSAFE(resources); ++i) { + if (!strcmp(name, resources[i].name)) + return webkit_glue::GetDataResource(resources[i].id); + } + NOTREACHED() << "Unknown image resource " << name; + return WebKit::WebCString(); +} + double WebKitClientImpl::currentTime() { return base::Time::Now().ToDoubleT(); } diff --git a/webkit/glue/webkitclient_impl.h b/webkit/glue/webkitclient_impl.h index 4980685..e3c5aef 100644 --- a/webkit/glue/webkitclient_impl.h +++ b/webkit/glue/webkitclient_impl.h @@ -19,16 +19,9 @@ class WebKitClientImpl : public WebKit::WebKitClient { public: WebKitClientImpl(); - // WebKitClient methods: + // WebKitClient methods (partial implementation): virtual WebKit::WebClipboard* clipboard(); - virtual WebKit::WebMimeRegistry* mimeRegistry() = 0; - virtual void setCookies( - const WebKit::WebURL& url, const WebKit::WebURL& policy_url, - const WebKit::WebString&) = 0; - virtual WebKit::WebString cookies( - const WebKit::WebURL& url, const WebKit::WebURL& policy_url) = 0; - virtual void prefetchHostName(const WebKit::WebString&) = 0; - virtual WebKit::WebString defaultLocale() = 0; + virtual WebKit::WebCString loadResource(const char* name); virtual double currentTime(); virtual void setSharedTimerFiredFunction(void (*func)()); virtual void setSharedTimerFireTime(double fireTime); diff --git a/webkit/tools/test_shell/test_shell.cc b/webkit/tools/test_shell/test_shell.cc index 4b82dab..3dc08bb 100755 --- a/webkit/tools/test_shell/test_shell.cc +++ b/webkit/tools/test_shell/test_shell.cc @@ -564,15 +564,6 @@ void AppendToLog(const char* file, int line, const char* msg) { logging::LogMessage(file, line).stream() << msg; } -#if defined(OS_MACOSX) -SkBitmap* -#else -GlueBitmap* -#endif -GetBitmapResource(int resource_id) { - return NULL; -} - bool GetApplicationDirectory(std::wstring *path) { return PathService::Get(base::DIR_EXE, path); } @@ -617,12 +608,4 @@ std::wstring GetWebKitLocale() { return L"en-US"; } -uint64 VisitedLinkHash(const char* canonical_url, size_t length) { - return 0; -} - -bool IsLinkVisited(uint64 link_hash) { - return false; -} - } // namespace webkit_glue diff --git a/webkit/tools/test_shell/test_shell_webkit_init.h b/webkit/tools/test_shell/test_shell_webkit_init.h index d3f5d0b..295d212 100644 --- a/webkit/tools/test_shell/test_shell_webkit_init.h +++ b/webkit/tools/test_shell/test_shell_webkit_init.h @@ -13,6 +13,7 @@ #include "webkit/extensions/v8/interval_extension.h" #include "webkit/tools/test_shell/simple_resource_loader_bridge.h" +#include "WebCString.h" #include "WebKit.h" #include "WebString.h" #include "WebURL.h" @@ -36,6 +37,14 @@ class TestShellWebKitInit : public webkit_glue::WebKitClientImpl { return &mime_registry_; } + virtual uint64_t visitedLinkHash(const char* canonicalURL, size_t length) { + return 0; + } + + virtual bool isLinkVisited(uint64_t linkHash) { + return false; + } + virtual void setCookies( const WebKit::WebURL& url, const WebKit::WebURL& policy_url, const WebKit::WebString& value) { @@ -50,6 +59,26 @@ class TestShellWebKitInit : public webkit_glue::WebKitClientImpl { virtual void prefetchHostName(const WebKit::WebString&) { } + virtual WebKit::WebCString loadResource(const char* name) { + if (!strcmp(name, "deleteButton")) { + // Create a red 30x30 square. + const char red_square[] = + "\x89\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52" + "\x00\x00\x00\x1e\x00\x00\x00\x1e\x04\x03\x00\x00\x00\xc9\x1e\xb3" + "\x91\x00\x00\x00\x30\x50\x4c\x54\x45\x00\x00\x00\x80\x00\x00\x00" + "\x80\x00\x80\x80\x00\x00\x00\x80\x80\x00\x80\x00\x80\x80\x80\x80" + "\x80\xc0\xc0\xc0\xff\x00\x00\x00\xff\x00\xff\xff\x00\x00\x00\xff" + "\xff\x00\xff\x00\xff\xff\xff\xff\xff\x7b\x1f\xb1\xc4\x00\x00\x00" + "\x09\x70\x48\x59\x73\x00\x00\x0b\x13\x00\x00\x0b\x13\x01\x00\x9a" + "\x9c\x18\x00\x00\x00\x17\x49\x44\x41\x54\x78\x01\x63\x98\x89\x0a" + "\x18\x50\xb9\x33\x47\xf9\xa8\x01\x32\xd4\xc2\x03\x00\x33\x84\x0d" + "\x02\x3a\x91\xeb\xa5\x00\x00\x00\x00\x49\x45\x4e\x44\xae\x42\x60" + "\x82"; + return WebKit::WebCString(red_square, arraysize(red_square)); + } + return webkit_glue::WebKitClientImpl::loadResource(name); + } + virtual WebKit::WebString defaultLocale() { return ASCIIToUTF16("en-US"); } |