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

Side by Side Diff: Source/core/html/MediaDocument.cpp

Issue 27694002: Ability to block <audio> and <video> media. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rename "video" to "media". Created 7 years, 2 months 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. 2 * Copyright (C) 2008 Apple 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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 15 matching lines...) Expand all
26 #include "config.h" 26 #include "config.h"
27 27
28 #include "core/html/MediaDocument.h" 28 #include "core/html/MediaDocument.h"
29 29
30 #include "HTMLNames.h" 30 #include "HTMLNames.h"
31 #include "bindings/v8/ExceptionStatePlaceholder.h" 31 #include "bindings/v8/ExceptionStatePlaceholder.h"
32 #include "core/dom/NodeTraversal.h" 32 #include "core/dom/NodeTraversal.h"
33 #include "core/dom/RawDataDocumentParser.h" 33 #include "core/dom/RawDataDocumentParser.h"
34 #include "core/events/KeyboardEvent.h" 34 #include "core/events/KeyboardEvent.h"
35 #include "core/events/ThreadLocalEventNames.h" 35 #include "core/events/ThreadLocalEventNames.h"
36 #include "core/frame/Frame.h"
36 #include "core/html/HTMLBodyElement.h" 37 #include "core/html/HTMLBodyElement.h"
37 #include "core/html/HTMLHeadElement.h" 38 #include "core/html/HTMLHeadElement.h"
38 #include "core/html/HTMLHtmlElement.h" 39 #include "core/html/HTMLHtmlElement.h"
39 #include "core/html/HTMLMetaElement.h" 40 #include "core/html/HTMLMetaElement.h"
40 #include "core/html/HTMLSourceElement.h" 41 #include "core/html/HTMLSourceElement.h"
41 #include "core/html/HTMLVideoElement.h" 42 #include "core/html/HTMLVideoElement.h"
42 #include "core/loader/DocumentLoader.h" 43 #include "core/loader/DocumentLoader.h"
43 #include "core/loader/FrameLoader.h" 44 #include "core/loader/FrameLoader.h"
44 #include "core/frame/Frame.h" 45 #include "core/loader/FrameLoaderClient.h"
46 #include "core/page/Settings.h"
45 #include "platform/KeyboardCodes.h" 47 #include "platform/KeyboardCodes.h"
46 48
47 namespace WebCore { 49 namespace WebCore {
48 50
49 using namespace HTMLNames; 51 using namespace HTMLNames;
50 52
51 // FIXME: Share more code with PluginDocumentParser. 53 // FIXME: Share more code with PluginDocumentParser.
52 class MediaDocumentParser : public RawDataDocumentParser { 54 class MediaDocumentParser : public RawDataDocumentParser {
53 public: 55 public:
54 static PassRefPtr<MediaDocumentParser> create(MediaDocument* document) 56 static PassRefPtr<MediaDocumentParser> create(MediaDocument* document)
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 body->appendChild(media.release()); 105 body->appendChild(media.release());
104 106
105 rootElement->appendChild(head.release()); 107 rootElement->appendChild(head.release());
106 rootElement->appendChild(body.release()); 108 rootElement->appendChild(body.release());
107 109
108 m_didBuildDocumentStructure = true; 110 m_didBuildDocumentStructure = true;
109 } 111 }
110 112
111 size_t MediaDocumentParser::appendBytes(const char*, size_t) 113 size_t MediaDocumentParser::appendBytes(const char*, size_t)
112 { 114 {
115 Frame* frame = document()->frame();
116 Settings* settings = frame->settings();
117 if (!frame->loader()->client()->allowMedia(!settings || settings->isMediaLoa dingEnabled(), document()->url()))
118 return 0;
119
113 if (m_didBuildDocumentStructure) 120 if (m_didBuildDocumentStructure)
114 return 0; 121 return 0;
115 122
116 createDocumentStructure(); 123 createDocumentStructure();
117 finish(); 124 finish();
118 return 0; 125 return 0;
119 } 126 }
120 127
121 MediaDocument::MediaDocument(const DocumentInit& initializer) 128 MediaDocument::MediaDocument(const DocumentInit& initializer)
122 : HTMLDocument(initializer, MediaDocumentClass) 129 : HTMLDocument(initializer, MediaDocumentClass)
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 if (video->canPlay()) 167 if (video->canPlay())
161 video->play(); 168 video->play();
162 } else 169 } else
163 video->pause(); 170 video->pause();
164 event->setDefaultHandled(); 171 event->setDefaultHandled();
165 } 172 }
166 } 173 }
167 } 174 }
168 175
169 } 176 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698