Commit 326237f6 authored by hyatt@apple.com's avatar hyatt@apple.com

WebCore: Add a method for removal of user scripts and stylesheets by URL from a specific world.

Reviewed by Adam Roben.

* page/PageGroup.cpp:
(WebCore::PageGroup::removeUserContentURLForWorld):
* page/PageGroup.h:

WebKit/mac: Add the ability to remove user stylesheets and scripts by URL.

Reviewed by Adam Roben.

* WebView/WebView.mm:
(+[WebView _removeUserContentFromGroup:url:worldID:]):
* WebView/WebViewPrivate.h:

WebKit/win: Add the ability to remove user stylesheets and scripts by URL.

Reviewed by Adam Roben.

* Interfaces/IWebViewPrivate.idl:
* WebView.cpp:
(WebView::removeUserContentWithURLFromGroup):
* WebView.h:



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@48941 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 3116d5d6
2009-09-30 Dave Hyatt <hyatt@apple.com>
Reviewed by Adam Roben.
Add a method for removal of user scripts and stylesheets by URL from a specific world.
* page/PageGroup.cpp:
(WebCore::PageGroup::removeUserContentURLForWorld):
* page/PageGroup.h:
2009-09-30 Chris Hawk <hawk@chromium.org>
Reviewed by Dimitri Glazkov.
......@@ -727,6 +727,7 @@ __ZN7WebCore9PageGroup17addUserStyleSheetERKNS_6StringERKNS_4KURLERKN3WTF6Vector
__ZN7WebCore9PageGroup17closeLocalStorageEv
__ZN7WebCore9PageGroup20removeAllUserContentEv
__ZN7WebCore9PageGroup21removeAllVisitedLinksEv
__ZN7WebCore9PageGroup32removeUserContentWithURLForWorldERKNS_4KURLEj
__ZN7WebCore9PageGroup25removeUserContentForWorldEj
__ZN7WebCore9PageGroup26setShouldTrackVisitedLinksEb
__ZN7WebCore9PageGroup9pageGroupERKNS_6StringE
......
......@@ -233,6 +233,41 @@ void PageGroup::addUserStyleSheet(const String& source, const KURL& url, const V
}
}
void PageGroup::removeUserContentWithURLForWorld(const KURL& url, unsigned worldID)
{
if (m_userScripts) {
UserScriptMap::iterator it = m_userScripts->find(worldID);
if (it != m_userScripts->end()) {
UserScriptVector* scripts = it->second;
for (int i = scripts->size() - 1; i >= 0; --i) {
if (scripts->at(i)->url() == url)
scripts->remove(i);
}
if (scripts->isEmpty()) {
m_userScripts->remove(it);
delete it->second;
}
}
}
if (m_userStyleSheets) {
UserStyleSheetMap::iterator it = m_userStyleSheets->find(worldID);
if (it != m_userStyleSheets->end()) {
UserStyleSheetVector* stylesheets = it->second;
for (int i = stylesheets->size() - 1; i >= 0; --i) {
if (stylesheets->at(i)->url() == url)
stylesheets->remove(i);
}
if (stylesheets->isEmpty()) {
m_userStyleSheets->remove(it);
delete it->second;
}
}
}
}
void PageGroup::removeUserContentForWorld(unsigned worldID)
{
if (m_userScripts) {
......
......@@ -78,6 +78,7 @@ namespace WebCore {
const UserStyleSheetMap* userStyleSheets() const { return m_userStyleSheets.get(); }
void removeUserContentForWorld(unsigned);
void removeUserContentWithURLForWorld(const KURL&, unsigned);
void removeAllUserContent();
private:
......
2009-09-30 Dave Hyatt <hyatt@apple.com>
Reviewed by Adam Roben.
Add the ability to remove user stylesheets and scripts by URL.
* WebView/WebView.mm:
(+[WebView _removeUserContentFromGroup:url:worldID:]):
* WebView/WebViewPrivate.h:
2009-09-29 Brady Eidson <beidson@apple.com>
Rubberstamped by Dan Bernstein.
......
......@@ -2175,6 +2175,19 @@ static inline IMP getMethod(id o, SEL s)
pageGroup->addUserStyleSheet(source, url, patternsVector, worldID);
}
+ (void)_removeUserContentFromGroup:(NSString *)groupName url:(NSURL *)url worldID:(unsigned)worldID
{
String group(groupName);
if (group.isEmpty())
return;
PageGroup* pageGroup = PageGroup::pageGroup(group);
if (!pageGroup)
return;
pageGroup->removeUserContentWithURLForWorld(url, worldID);
}
+ (void)_removeUserContentFromGroup:(NSString *)groupName worldID:(unsigned)worldID
{
String group(groupName);
......
......@@ -473,6 +473,7 @@ Could be worth adding to the API.
+ (void)_addUserScriptToGroup:(NSString *)groupName source:(NSString *)source url:(NSURL *)url worldID:(unsigned)worldID patterns:(NSArray *)patterns injectionTime:(WebUserScriptInjectionTime)injectionTime;
+ (void)_addUserStyleSheetToGroup:(NSString *)groupName source:(NSString *)source url:(NSURL *)url worldID:(unsigned)worldID patterns:(NSArray *)patterns;
+ (void)_removeUserContentFromGroup:(NSString *)groupName url:(NSURL *)url worldID:(unsigned)worldID;
+ (void)_removeUserContentFromGroup:(NSString *)groupName worldID:(unsigned)worldID;
+ (void)_removeAllUserContentFromGroup:(NSString *)groupName;
......
2009-09-30 Dave Hyatt <hyatt@apple.com>
Reviewed by Adam Roben.
Add the ability to remove user stylesheets and scripts by URL.
* Interfaces/IWebViewPrivate.idl:
* WebView.cpp:
(WebView::removeUserContentWithURLFromGroup):
* WebView.h:
2009-09-29 Kenneth Russell <kbr@google.com>
Reviewed by Dimitri Glazkov.
......
......@@ -183,6 +183,7 @@ interface IWebViewPrivate : IUnknown
// For the following functions, 0 < worldID < UINT_MAX.
HRESULT addUserScriptToGroup([in] BSTR groupName, [in] unsigned worldID, [in] BSTR source, [in] BSTR url, [in] unsigned patternsCount, [in, size_is(patternsCount)] BSTR* patterns, [in] WebUserScriptInjectionTime injectionTime);
HRESULT addUserStyleSheetToGroup([in] BSTR groupName, [in] unsigned worldID, [in] BSTR source, [in] BSTR url, [in] unsigned patternsCount, [in, size_is(patternsCount)] BSTR* patterns);
HRESULT removeUserContentWithURLFromGroup([in] BSTR groupName, [in] unsigned worldID, [in] BSTR url);
HRESULT removeUserContentFromGroup([in] BSTR groupName, [in] unsigned worldID);
HRESULT removeAllUserContentFromGroup([in] BSTR groupName);
......
......@@ -5476,6 +5476,22 @@ HRESULT WebView::addUserStyleSheetToGroup(BSTR groupName, unsigned worldID, BSTR
return S_OK;
}
HRESULT WebView::removeUserContentWithURLFromGroup(BSTR groupName, unsigned worldID, BSTR url)
{
String group(groupName, SysStringLen(groupName));
if (group.isEmpty() || !worldID || worldID == numeric_limits<unsigned>::max())
return E_INVALIDARG;
PageGroup* pageGroup = PageGroup::pageGroup(group);
ASSERT(pageGroup);
if (!pageGroup)
return E_FAIL;
pageGroup->removeUserContentWithURLForWorld(KURL(KURL(), String(url, SysStringLen(url))), worldID);
return S_OK;
}
HRESULT WebView::removeUserContentFromGroup(BSTR groupName, unsigned worldID)
{
String group(groupName, SysStringLen(groupName));
......
......@@ -742,6 +742,7 @@ public:
virtual HRESULT STDMETHODCALLTYPE addUserScriptToGroup(BSTR groupName, unsigned worldID, BSTR source, BSTR url, unsigned patternsCount, BSTR* patterns, WebUserScriptInjectionTime);
virtual HRESULT STDMETHODCALLTYPE addUserStyleSheetToGroup(BSTR groupName, unsigned worldID, BSTR source, BSTR url, unsigned patternsCount, BSTR* patterns);
virtual HRESULT STDMETHODCALLTYPE removeUserContentWithURLFromGroup(BSTR groupName, unsigned worldID, BSTR url);
virtual HRESULT STDMETHODCALLTYPE removeUserContentFromGroup(BSTR groupName, unsigned worldID);
virtual HRESULT STDMETHODCALLTYPE removeAllUserContentFromGroup(BSTR groupName);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment