OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Shim that simulates a <adview> tag via Mutation Observers. | 5 // Shim that simulates a <adview> tag via Mutation Observers. |
6 // | 6 // |
7 // The actual tag is implemented via the browser plugin. The internals of this | 7 // The actual tag is implemented via the browser plugin. The internals of this |
8 // are hidden via Shadow DOM. | 8 // are hidden via Shadow DOM. |
9 | 9 |
10 // TODO(rpaquay): This file is currently very similar to "web_view.js". Do we | 10 // TODO(rpaquay): This file is currently very similar to "web_view.js". Do we |
11 // want to refactor to extract common pieces? | 11 // want to refactor to extract common pieces? |
12 | 12 |
13 var adViewCustom = require('adViewCustom'); | 13 var process = requireNative('process'); |
14 var watchForTag = require('tagWatcher').watchForTag; | 14 var watchForTag = require('tagWatcher').watchForTag; |
15 | 15 |
16 /** | 16 /** |
17 * Define "allowCustomAdNetworks" function such that it returns "true" if the | 17 * Define "allowCustomAdNetworks" function such that the |
18 * "adViewCustom" module was injected. This is so that the | |
19 * "kEnableAdviewSrcAttribute" flag is respected. | 18 * "kEnableAdviewSrcAttribute" flag is respected. |
20 */ | 19 */ |
21 var allowCustomAdNetworks = (function(allow){ | 20 function allowCustomAdNetworks() { |
22 return function() { return Boolean(allow); } | 21 return process.HasSwitch('enable-adview-src-attribute'); |
23 })(adViewCustom ? adViewCustom.enabled : false); | 22 } |
24 | 23 |
25 /** | 24 /** |
26 * List of attribute names to "blindly" sync between <adview> tag and internal | 25 * List of attribute names to "blindly" sync between <adview> tag and internal |
27 * browser plugin. | 26 * browser plugin. |
28 */ | 27 */ |
29 var AD_VIEW_ATTRIBUTES = [ | 28 var AD_VIEW_ATTRIBUTES = [ |
30 'name', | 29 'name', |
31 ]; | 30 ]; |
32 | 31 |
33 /** | 32 /** |
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
465 // Dispatch event. | 464 // Dispatch event. |
466 this.adviewNode_.dispatchEvent(evt); | 465 this.adviewNode_.dispatchEvent(evt); |
467 } | 466 } |
468 | 467 |
469 // | 468 // |
470 // Hook up <adview> tag creation in DOM. | 469 // Hook up <adview> tag creation in DOM. |
471 // | 470 // |
472 window.addEventListener('DOMContentLoaded', function() { | 471 window.addEventListener('DOMContentLoaded', function() { |
473 watchForTag('ADVIEW', function(addedNode) { new AdView(addedNode); }); | 472 watchForTag('ADVIEW', function(addedNode) { new AdView(addedNode); }); |
474 }); | 473 }); |
OLD | NEW |