Source/WebCore/ChangeLog

 12011-02-25 Eric Carlson <eric.carlson@apple.com>
 2
 3 Reviewed by NOBODY (OOPS!).
 4
 5 <audio> and <video> should respect private browsing mode
 6 https://bugs.webkit.org/show_bug.cgi?id=55287
 7 <rdar://problem/9057699>
 8
 9 No new tests, this is just the plumbing.
 10
 11 * dom/Document.cpp:
 12 (WebCore::Document::privateBrowsingStateChanged): New.
 13 (WebCore::Document::registerForPrivateBrowsingStateChangedCallbacks): Ditto.
 14 (WebCore::Document::unregisterForPrivateBrowsingStateChangedCallbacks): Ditto.
 15 * dom/Document.h:
 16
 17 * dom/Element.h:
 18 (WebCore::Element::privateBrowsingStateChanged): New.
 19
 20 * html/HTMLMediaElement.cpp:
 21 (WebCore::HTMLMediaElement::HTMLMediaElement): Register for privacy mode changes.
 22 (WebCore::HTMLMediaElement::~HTMLMediaElement): Unregister for privacy mode changes.
 23 (WebCore::HTMLMediaElement::loadResource): Tell player current privacy mode.
 24 (WebCore::HTMLMediaElement::privateBrowsingStateChanged): New, call through to MediaPlayer.
 25 * html/HTMLMediaElement.h:
 26
 27 * page/Page.cpp:
 28 (WebCore::Page::privateBrowsingStateChanged): Call document()->privateBrowsingStateChanged.
 29
 30 * platform/graphics/MediaPlayer.cpp:
 31 (WebCore::MediaPlayer::setPrivateBrowsingMode): New, call through to media engine.
 32 * platform/graphics/MediaPlayer.h:
 33
 34 * platform/graphics/MediaPlayerPrivate.h:
 35 (WebCore::MediaPlayerPrivateInterface::setPrivateBrowsingMode): Declare new interface.
 36
1372011-02-25 Chris Fleizach <cfleizach@apple.com>
238
339 Reviewed by Anders Carlsson.
79757

Source/WebCore/dom/Document.cpp

33 * (C) 1999 Antti Koivisto (koivisto@kde.org)
44 * (C) 2001 Dirk Mueller (mueller@kde.org)
55 * (C) 2006 Alexey Proskuryakov (ap@webkit.org)
6  * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011 Apple Inc. All rights reserved.
77 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
88 * Copyright (C) 2008, 2009 Google Inc. All rights reserved.
99 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)

@@void Document::unregisterForMediaVolumeC
39663966 m_mediaVolumeCallbackElements.remove(e);
39673967}
39683968
 3969void Document::privateBrowsingStateChanged(bool privateBrowsingEnabled)
 3970{
 3971 HashSet<Element*>::iterator end = m_privateBrowsingStateChangedElements.end();
 3972 for (HashSet<Element*>::iterator i = m_privateBrowsingStateChangedElements.begin(); i != end; ++i)
 3973 (*i)->privateBrowsingStateChanged(privateBrowsingEnabled);
 3974}
 3975
 3976void Document::registerForPrivateBrowsingStateChangedCallbacks(Element* e)
 3977{
 3978 m_privateBrowsingStateChangedElements.add(e);
 3979}
 3980
 3981void Document::unregisterForPrivateBrowsingStateChangedCallbacks(Element* e)
 3982{
 3983 m_privateBrowsingStateChangedElements.remove(e);
 3984}
 3985
39693986void Document::setShouldCreateRenderers(bool f)
39703987{
39713988 m_createRenderers = f;
79328

Source/WebCore/dom/Document.h

@@public:
984984 void unregisterForMediaVolumeCallbacks(Element*);
985985 void mediaVolumeDidChange();
986986
 987 void registerForPrivateBrowsingStateChangedCallbacks(Element*);
 988 void unregisterForPrivateBrowsingStateChangedCallbacks(Element*);
 989 void privateBrowsingStateChanged(bool);
 990
987991 void setShouldCreateRenderers(bool);
988992 bool shouldCreateRenderers();
989993

@@private:
13631367
13641368 HashSet<Element*> m_documentActivationCallbackElements;
13651369 HashSet<Element*> m_mediaVolumeCallbackElements;
 1370 HashSet<Element*> m_privateBrowsingStateChangedElements;
13661371
13671372 bool m_useSecureKeyboardEntryWhenActive;
13681373
79328

Source/WebCore/dom/Element.h

33 * (C) 1999 Antti Koivisto (koivisto@kde.org)
44 * (C) 2001 Peter Kelly (pmk@post.com)
55 * (C) 2001 Dirk Mueller (mueller@kde.org)
6  * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
 6 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
77 *
88 * This library is free software; you can redistribute it and/or
99 * modify it under the terms of the GNU Library General Public

@@public:
274274 // Use Document::registerForMediaVolumeCallbacks() to subscribe to this
275275 virtual void mediaVolumeDidChange() { }
276276
 277 // Use Document::registerForPrivateBrowsingStateChangedCallbacks() to subscribe to this
 278 virtual void privateBrowsingStateChanged(bool) { }
 279
277280 bool isFinishedParsingChildren() const { return isParsingChildrenFinished(); }
278281 virtual void finishParsingChildren();
279282 virtual void beginParsingChildren();
79328

Source/WebCore/html/HTMLMediaElement.cpp

11/*
2  * Copyright (C) 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
 2 * Copyright (C) 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
33 *
44 * Redistribution and use in source and binary forms, with or without
55 * modification, are permitted provided that the following conditions

@@HTMLMediaElement::HTMLMediaElement(const
171171 LOG(Media, "HTMLMediaElement::HTMLMediaElement");
172172 document->registerForDocumentActivationCallbacks(this);
173173 document->registerForMediaVolumeCallbacks(this);
 174 document->registerForPrivateBrowsingStateChangedCallbacks(this);
174175}
175176
176177HTMLMediaElement::~HTMLMediaElement()

@@HTMLMediaElement::~HTMLMediaElement()
181182 setShouldDelayLoadEvent(false);
182183 document()->unregisterForDocumentActivationCallbacks(this);
183184 document()->unregisterForMediaVolumeCallbacks(this);
 185 document()->unregisterForPrivateBrowsingStateChangedCallbacks(this);
184186}
185187
186188void HTMLMediaElement::willMoveToNewOwnerDocument()

@@void HTMLMediaElement::loadResource(cons
696698 if (m_sendProgressEvents)
697699 startProgressEventTimer();
698700
 701 Settings* settings = document()->settings();
 702 bool privateMode = !settings || settings->privateBrowsingEnabled();
 703 m_player->setPrivateBrowsingMode(privateMode);
 704
699705 if (!autoplay())
700706 m_player->setPreload(m_preload);
701707 m_player->setPreservesPitch(m_webkitPreservesPitch);

@@void HTMLMediaElement::clearMediaCacheFo
25522558 m_player->clearMediaCacheForSite(site);
25532559}
25542560
 2561void HTMLMediaElement::privateBrowsingStateChanged(bool privateBrowsingMode)
 2562{
 2563 if (m_player)
 2564 m_player->setPrivateBrowsingMode(privateBrowsingMode);
 2565}
 2566
25552567}
25562568
25572569#endif
79744

Source/WebCore/html/HTMLMediaElement.h

@@public:
180180 void getSitesInMediaCache(Vector<String>&);
181181 void clearMediaCache();
182182 void clearMediaCacheForSite(const String&);
183 
 183
 184 void privateBrowsingStateChanged(bool);
 185
184186protected:
185187 HTMLMediaElement(const QualifiedName&, Document*);
186188 virtual ~HTMLMediaElement();
79744

Source/WebCore/page/Page.cpp

11/*
2  * Copyright (C) 2006, 2007, 2008, 2009, 2010 Apple Inc. All Rights Reserved.
 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All Rights Reserved.
33 * Copyright (C) 2008 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
44 *
55 * This library is free software; you can redistribute it and/or

@@void Page::privateBrowsingStateChanged()
853853{
854854 bool privateBrowsingEnabled = m_settings->privateBrowsingEnabled();
855855
 856 for (Frame* frame = mainFrame(); frame; frame = frame->tree()->traverseNext())
 857 frame->document()->privateBrowsingStateChanged(privateBrowsingEnabled);
 858
856859 // Collect the PluginViews in to a vector to ensure that action the plug-in takes
857860 // from below privateBrowsingStateChanged does not affect their lifetime.
858861 Vector<RefPtr<PluginViewBase>, 32> pluginViewBases;
79328

Source/WebCore/platform/graphics/MediaPlayer.cpp

11/*
2  * Copyright (C) 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
 2 * Copyright (C) 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
33 *
44 * Redistribution and use in source and binary forms, with or without
55 * modification, are permitted provided that the following conditions

@@void MediaPlayer::clearMediaCacheForSite
733733 m_private->clearMediaCacheForSite(site);
734734}
735735
 736void MediaPlayer::setPrivateBrowsingMode(bool privateBrowsingMode)
 737{
 738 m_private->setPrivateBrowsingMode(privateBrowsingMode);
 739}
 740
736741// Client callbacks.
737742void MediaPlayer::networkStateChanged()
738743{
79744

Source/WebCore/platform/graphics/MediaPlayer.h

11/*
2  * Copyright (C) 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
 2 * Copyright (C) 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
33 *
44 * Redistribution and use in source and binary forms, with or without
55 * modification, are permitted provided that the following conditions

@@public:
291291 void getSitesInMediaCache(Vector<String>&);
292292 void clearMediaCache();
293293 void clearMediaCacheForSite(const String&);
294 
 294
 295 void setPrivateBrowsingMode(bool);
 296
295297private:
296298 MediaPlayer(MediaPlayerClient*);
297299 void loadWithNextMediaEngine(MediaPlayerFactory*);
79744

Source/WebCore/platform/graphics/MediaPlayerPrivate.h

11/*
2  * Copyright (C) 2009, 2010 Apple Inc. All rights reserved.
 2 * Copyright (C) 2009, 2010, 2011 Apple Inc. All rights reserved.
33 *
44 * Redistribution and use in source and binary forms, with or without
55 * modification, are permitted provided that the following conditions

@@public:
144144 void getSitesInMediaCache(Vector<String>&) { }
145145 void clearMediaCache() { }
146146 void clearMediaCacheForSite(const String&) { }
 147
 148 void setPrivateBrowsingMode(bool) { }
147149};
148150
149151}
79744