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

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: Rebased. Created 6 years, 6 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
« no previous file with comments | « Source/core/fetch/ResourceFetcher.cpp ('k') | Source/core/loader/FrameLoaderClient.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 23 matching lines...) Expand all
34 #include "core/events/KeyboardEvent.h" 34 #include "core/events/KeyboardEvent.h"
35 #include "core/frame/LocalFrame.h" 35 #include "core/frame/LocalFrame.h"
36 #include "core/html/HTMLBodyElement.h" 36 #include "core/html/HTMLBodyElement.h"
37 #include "core/html/HTMLHeadElement.h" 37 #include "core/html/HTMLHeadElement.h"
38 #include "core/html/HTMLHtmlElement.h" 38 #include "core/html/HTMLHtmlElement.h"
39 #include "core/html/HTMLMetaElement.h" 39 #include "core/html/HTMLMetaElement.h"
40 #include "core/html/HTMLSourceElement.h" 40 #include "core/html/HTMLSourceElement.h"
41 #include "core/html/HTMLVideoElement.h" 41 #include "core/html/HTMLVideoElement.h"
42 #include "core/loader/DocumentLoader.h" 42 #include "core/loader/DocumentLoader.h"
43 #include "core/loader/FrameLoader.h" 43 #include "core/loader/FrameLoader.h"
44 #include "core/loader/FrameLoaderClient.h"
44 #include "platform/KeyboardCodes.h" 45 #include "platform/KeyboardCodes.h"
45 46
46 namespace WebCore { 47 namespace WebCore {
47 48
48 using namespace HTMLNames; 49 using namespace HTMLNames;
49 50
50 // FIXME: Share more code with PluginDocumentParser. 51 // FIXME: Share more code with PluginDocumentParser.
51 class MediaDocumentParser : public RawDataDocumentParser { 52 class MediaDocumentParser : public RawDataDocumentParser {
52 public: 53 public:
53 static PassRefPtrWillBeRawPtr<MediaDocumentParser> create(MediaDocument* doc ument) 54 static PassRefPtrWillBeRawPtr<MediaDocumentParser> create(MediaDocument* doc ument)
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 rootElement->appendChild(body.release()); 106 rootElement->appendChild(body.release());
106 107
107 m_didBuildDocumentStructure = true; 108 m_didBuildDocumentStructure = true;
108 } 109 }
109 110
110 void MediaDocumentParser::appendBytes(const char*, size_t) 111 void MediaDocumentParser::appendBytes(const char*, size_t)
111 { 112 {
112 if (m_didBuildDocumentStructure) 113 if (m_didBuildDocumentStructure)
113 return; 114 return;
114 115
116 LocalFrame* frame = document()->frame();
117 if (!frame->loader().client()->allowMedia(document()->url()))
118 return;
119
115 createDocumentStructure(); 120 createDocumentStructure();
116 finish(); 121 finish();
117 } 122 }
118 123
119 MediaDocument::MediaDocument(const DocumentInit& initializer) 124 MediaDocument::MediaDocument(const DocumentInit& initializer)
120 : HTMLDocument(initializer, MediaDocumentClass) 125 : HTMLDocument(initializer, MediaDocumentClass)
121 { 126 {
122 setCompatibilityMode(QuirksMode); 127 setCompatibilityMode(QuirksMode);
123 lockCompatibilityMode(); 128 lockCompatibilityMode();
124 } 129 }
(...skipping 17 matching lines...) Expand all
142 KeyboardEvent* keyboardEvent = toKeyboardEvent(event); 147 KeyboardEvent* keyboardEvent = toKeyboardEvent(event);
143 if (keyboardEvent->keyIdentifier() == "U+0020" || keyboardEvent->keyCode () == VKEY_MEDIA_PLAY_PAUSE) { 148 if (keyboardEvent->keyIdentifier() == "U+0020" || keyboardEvent->keyCode () == VKEY_MEDIA_PLAY_PAUSE) {
144 // space or media key (play/pause) 149 // space or media key (play/pause)
145 video->togglePlayState(); 150 video->togglePlayState();
146 event->setDefaultHandled(); 151 event->setDefaultHandled();
147 } 152 }
148 } 153 }
149 } 154 }
150 155
151 } 156 }
OLDNEW
« no previous file with comments | « Source/core/fetch/ResourceFetcher.cpp ('k') | Source/core/loader/FrameLoaderClient.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698