Diff
Modified: trunk/Source/WebKit2/ChangeLog (163655 => 163656)
--- trunk/Source/WebKit2/ChangeLog 2014-02-07 23:07:29 UTC (rev 163655)
+++ trunk/Source/WebKit2/ChangeLog 2014-02-07 23:26:25 UTC (rev 163656)
@@ -1,3 +1,36 @@
+2014-02-07 Anders Carlsson <[email protected]>
+
+ Make it possible for each web page to have different preferences
+ https://bugs.webkit.org/show_bug.cgi?id=128403
+
+ Reviewed by Tim Horton.
+
+ * UIProcess/API/C/WKPreferences.cpp:
+ (WKPreferencesCreate):
+ * UIProcess/WebContext.cpp:
+ (WebKit::WebContext::ensureNetworkProcess):
+ (WebKit::WebContext::createNewWebProcess):
+ * UIProcess/WebIconDatabase.cpp:
+ (WebKit::WebIconDatabase::setDatabasePath):
+ * UIProcess/WebPageGroup.cpp:
+ (WebKit::WebPageGroup::WebPageGroup):
+ (WebKit::WebPageGroup::~WebPageGroup):
+ (WebKit::WebPageGroup::setPreferences):
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::WebPageProxy::WebPageProxy):
+ (WebKit::WebPageProxy::~WebPageProxy):
+ (WebKit::WebPageProxy::setPreferences):
+ (WebKit::WebPageProxy::preferencesDidChange):
+ * UIProcess/WebPageProxy.h:
+ * UIProcess/WebPreferences.cpp:
+ (WebKit::WebPreferences::~WebPreferences):
+ (WebKit::WebPreferences::addPage):
+ (WebKit::WebPreferences::removePage):
+ (WebKit::WebPreferences::update):
+ (WebKit::WebPreferences::updatePrivateBrowsingValue):
+ (WebKit::WebPreferences::anyPagesAreUsingPrivateBrowsing):
+ * UIProcess/WebPreferences.h:
+
2014-02-07 Benjamin Poulain <[email protected]>
[WK2] Add support for text document viewport configuration
Modified: trunk/Source/WebKit2/UIProcess/API/C/WKPreferences.cpp (163655 => 163656)
--- trunk/Source/WebKit2/UIProcess/API/C/WKPreferences.cpp 2014-02-07 23:07:29 UTC (rev 163655)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKPreferences.cpp 2014-02-07 23:26:25 UTC (rev 163656)
@@ -43,7 +43,7 @@
WKPreferencesRef WKPreferencesCreate()
{
- RefPtr<WebPreferences> preferences = WebPreferences::create();
+ RefPtr<WebPreferences> preferences = WebPreferences::create(String());
return toAPI(preferences.release().leakRef());
}
Modified: trunk/Source/WebKit2/UIProcess/WebContext.cpp (163655 => 163656)
--- trunk/Source/WebKit2/UIProcess/WebContext.cpp 2014-02-07 23:07:29 UTC (rev 163655)
+++ trunk/Source/WebKit2/UIProcess/WebContext.cpp 2014-02-07 23:26:25 UTC (rev 163656)
@@ -377,7 +377,7 @@
NetworkProcessCreationParameters parameters;
- parameters.privateBrowsingEnabled = WebPreferences::anyPageGroupsAreUsingPrivateBrowsing();
+ parameters.privateBrowsingEnabled = WebPreferences::anyPagesAreUsingPrivateBrowsing();
parameters.cacheModel = m_cacheModel;
@@ -619,7 +619,7 @@
process->send(Messages::WebProcess::SetQOS(webProcessLatencyQOS(), webProcessThroughputQOS()), 0);
#endif
- if (WebPreferences::anyPageGroupsAreUsingPrivateBrowsing())
+ if (WebPreferences::anyPagesAreUsingPrivateBrowsing())
process->send(Messages::WebProcess::EnsurePrivateBrowsingSession(SessionTracker::legacyPrivateSessionID), 0);
m_processes.append(process);
Modified: trunk/Source/WebKit2/UIProcess/WebIconDatabase.cpp (163655 => 163656)
--- trunk/Source/WebKit2/UIProcess/WebIconDatabase.cpp 2014-02-07 23:07:29 UTC (rev 163655)
+++ trunk/Source/WebKit2/UIProcess/WebIconDatabase.cpp 2014-02-07 23:26:25 UTC (rev 163656)
@@ -79,7 +79,7 @@
// FIXME: WebIconDatabases are per-WebContext but WebContext's don't have their own notion of the current private browsing setting.
// As we clean up private browsing throughout the stack we need to clean it up here.
- m_iconDatabaseImpl->setPrivateBrowsingEnabled(WebPreferences::anyPageGroupsAreUsingPrivateBrowsing());
+ m_iconDatabaseImpl->setPrivateBrowsingEnabled(WebPreferences::anyPagesAreUsingPrivateBrowsing());
if (!m_iconDatabaseImpl->open(directoryName(path), pathGetFileName(path))) {
LOG_ERROR("Unable to open WebKit2 icon database on disk");
Modified: trunk/Source/WebKit2/UIProcess/WebPageGroup.cpp (163655 => 163656)
--- trunk/Source/WebKit2/UIProcess/WebPageGroup.cpp 2014-02-07 23:07:29 UTC (rev 163655)
+++ trunk/Source/WebKit2/UIProcess/WebPageGroup.cpp 2014-02-07 23:26:25 UTC (rev 163656)
@@ -86,13 +86,11 @@
: m_data(pageGroupData(identifier, visibleToInjectedBundle, visibleToHistoryClient))
, m_preferences(WebPreferences::create(m_data.identifer))
{
- m_preferences->addPageGroup(this);
webPageGroupMap().set(m_data.pageGroupID, this);
}
WebPageGroup::~WebPageGroup()
{
- m_preferences->removePageGroup(this);
webPageGroupMap().remove(pageGroupID());
}
@@ -111,14 +109,10 @@
if (preferences == m_preferences)
return;
- m_preferences->removePageGroup(this);
m_preferences = preferences;
- m_preferences->addPageGroup(this);
for (auto& webPageProxy : m_pages)
webPageProxy->setPreferences(*m_preferences);
-
- preferencesDidChange();
}
WebPreferences& WebPageGroup::preferences() const
Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp (163655 => 163656)
--- trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp 2014-02-07 23:07:29 UTC (rev 163655)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp 2014-02-07 23:26:25 UTC (rev 163656)
@@ -349,6 +349,7 @@
WebContext::statistics().wkPageCount++;
+ m_preferences->addPage(*this);
m_pageGroup->addPage(this);
#if ENABLE(INSPECTOR)
@@ -381,6 +382,7 @@
if (m_hasSpellDocumentTag)
TextChecker::closeSpellDocumentWithTag(m_spellDocumentTag);
+ m_preferences->removePage(*this);
m_pageGroup->removePage(this);
#ifndef NDEBUG
@@ -405,6 +407,18 @@
return m_isValid;
}
+void WebPageProxy::setPreferences(WebPreferences& preferences)
+{
+ if (&preferences == &m_preferences.get())
+ return;
+
+ m_preferences->removePage(*this);
+ m_preferences = preferences;
+ m_preferences->addPage(*this);
+
+ preferencesDidChange();
+}
+
PassRefPtr<API::Array> WebPageProxy::relatedPages() const
{
// pages() returns a list of pages in WebProcess, so this page may or may not be among them - a client can use a reference to WebPageProxy after the page has closed.
@@ -2067,7 +2081,7 @@
return;
#if ENABLE(INSPECTOR_SERVER)
- if (m_pageGroup->preferences().developerExtrasEnabled())
+ if (m_preferences->developerExtrasEnabled())
inspector()->enableRemoteInspection();
#endif
Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.h (163655 => 163656)
--- trunk/Source/WebKit2/UIProcess/WebPageProxy.h 2014-02-07 23:07:29 UTC (rev 163655)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.h 2014-02-07 23:26:25 UTC (rev 163656)
@@ -729,7 +729,7 @@
PlatformProcessIdentifier processIdentifier() const;
WebPreferences& preferences() { return m_preferences.get(); }
- void setPreferences(WebPreferences& preferences) { m_preferences = preferences; }
+ void setPreferences(WebPreferences&);
WebPageGroup& pageGroup() { return m_pageGroup.get(); }
Modified: trunk/Source/WebKit2/UIProcess/WebPreferences.cpp (163655 => 163656)
--- trunk/Source/WebKit2/UIProcess/WebPreferences.cpp 2014-02-07 23:07:29 UTC (rev 163655)
+++ trunk/Source/WebKit2/UIProcess/WebPreferences.cpp 2014-02-07 23:26:25 UTC (rev 163656)
@@ -34,13 +34,8 @@
// FIXME: Manipulating this variable is not thread safe.
// Instead of tracking private browsing state as a boolean preference, we should let the client provide storage sessions explicitly.
-static unsigned privateBrowsingPageGroupCount;
+static unsigned privateBrowsingPageCount;
-WebPreferences::WebPreferences()
-{
- platformInitializeStore();
-}
-
WebPreferences::WebPreferences(const String& identifier)
: m_identifier(identifier)
{
@@ -55,7 +50,7 @@
WebPreferences::~WebPreferences()
{
- ASSERT(m_pageGroups.isEmpty());
+ ASSERT(m_pages.isEmpty());
}
PassRefPtr<WebPreferences> WebPreferences::copy() const
@@ -63,30 +58,35 @@
return adoptRef(new WebPreferences(*this));
}
-void WebPreferences::addPageGroup(WebPageGroup* pageGroup)
+void WebPreferences::addPage(WebPageProxy& webPageProxy)
{
- bool didAddPageGroup = m_pageGroups.add(pageGroup).isNewEntry;
- if (didAddPageGroup && privateBrowsingEnabled()) {
- if (!privateBrowsingPageGroupCount)
+ ASSERT(!m_pages.contains(&webPageProxy));
+ m_pages.add(&webPageProxy);
+
+ if (privateBrowsingEnabled()) {
+ if (!privateBrowsingPageCount)
WebContext::willStartUsingPrivateBrowsing();
- ++privateBrowsingPageGroupCount;
+
+ ++privateBrowsingPageCount;
}
}
-void WebPreferences::removePageGroup(WebPageGroup* pageGroup)
+void WebPreferences::removePage(WebPageProxy& webPageProxy)
{
- bool didRemovePageGroup = m_pageGroups.remove(pageGroup);
- if (didRemovePageGroup && privateBrowsingEnabled()) {
- --privateBrowsingPageGroupCount;
- if (!privateBrowsingPageGroupCount)
+ ASSERT(m_pages.contains(&webPageProxy));
+ m_pages.remove(&webPageProxy);
+
+ if (privateBrowsingEnabled()) {
+ --privateBrowsingPageCount;
+ if (!privateBrowsingPageCount)
WebContext::willStopUsingPrivateBrowsing();
}
}
void WebPreferences::update()
{
- for (HashSet<WebPageGroup*>::iterator it = m_pageGroups.begin(), end = m_pageGroups.end(); it != end; ++it)
- (*it)->preferencesDidChange();
+ for (auto& webPageProxy : m_pages)
+ webPageProxy->preferencesDidChange();
}
void WebPreferences::updateStringValueForKey(const String& key, const String& value)
@@ -128,22 +128,22 @@
{
platformUpdateBoolValueForKey(WebPreferencesKey::privateBrowsingEnabledKey(), value);
- unsigned pageGroupsChanged = m_pageGroups.size();
- if (!pageGroupsChanged)
+ unsigned pagesChanged = m_pages.size();
+ if (!pagesChanged)
return;
if (value) {
- if (!privateBrowsingPageGroupCount)
+ if (!privateBrowsingPageCount)
WebContext::willStartUsingPrivateBrowsing();
- privateBrowsingPageGroupCount += pageGroupsChanged;
+ privateBrowsingPageCount += pagesChanged;
}
update(); // FIXME: Only send over the changed key and value.
if (!value) {
- ASSERT(privateBrowsingPageGroupCount >= pageGroupsChanged);
- privateBrowsingPageGroupCount -= pageGroupsChanged;
- if (!privateBrowsingPageGroupCount)
+ ASSERT(privateBrowsingPageCount >= pagesChanged);
+ privateBrowsingPageCount -= pagesChanged;
+ if (!privateBrowsingPageCount)
WebContext::willStopUsingPrivateBrowsing();
}
}
@@ -166,9 +166,9 @@
#undef DEFINE_PREFERENCE_GETTER_AND_SETTERS
-bool WebPreferences::anyPageGroupsAreUsingPrivateBrowsing()
+bool WebPreferences::anyPagesAreUsingPrivateBrowsing()
{
- return privateBrowsingPageGroupCount;
+ return privateBrowsingPageCount;
}
} // namespace WebKit
Modified: trunk/Source/WebKit2/UIProcess/WebPreferences.h (163655 => 163656)
--- trunk/Source/WebKit2/UIProcess/WebPreferences.h 2014-02-07 23:07:29 UTC (rev 163655)
+++ trunk/Source/WebKit2/UIProcess/WebPreferences.h 2014-02-07 23:26:25 UTC (rev 163656)
@@ -39,14 +39,10 @@
namespace WebKit {
-class WebPageGroup;
+class WebPageProxy;
class WebPreferences : public API::ObjectImpl<API::Object::Type::Preferences> {
public:
- static PassRefPtr<WebPreferences> create()
- {
- return adoptRef(new WebPreferences);
- }
static PassRefPtr<WebPreferences> create(const String& identifier)
{
return adoptRef(new WebPreferences(identifier));
@@ -56,8 +52,8 @@
PassRefPtr<WebPreferences> copy() const;
- void addPageGroup(WebPageGroup*);
- void removePageGroup(WebPageGroup*);
+ void addPage(WebPageProxy&);
+ void removePage(WebPageProxy&);
const WebPreferencesStore& store() const { return m_store; }
@@ -72,10 +68,9 @@
// Exposed for WebKitTestRunner use only.
void forceUpdate() { update(); }
- static bool anyPageGroupsAreUsingPrivateBrowsing();
+ static bool anyPagesAreUsingPrivateBrowsing();
private:
- WebPreferences();
explicit WebPreferences(const String&);
WebPreferences(const WebPreferences&);
@@ -96,9 +91,10 @@
void updatePrivateBrowsingValue(bool value);
- HashSet<WebPageGroup*> m_pageGroups;
- WebPreferencesStore m_store;
String m_identifier;
+ WebPreferencesStore m_store;
+
+ HashSet<WebPageProxy*> m_pages;
};
} // namespace WebKit