Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: safari/background.js

Issue 6369485355220992: Fixed reload issue in Chrome (Closed)
Patch Set: Created Nov. 15, 2013, 1:08 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <http://adblockplus.org/>, 2 * This file is part of Adblock Plus <http://adblockplus.org/>,
3 * Copyright (C) 2006-2013 Eyeo GmbH 3 * Copyright (C) 2006-2013 Eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 17 matching lines...) Expand all
28 _wrapListener: function(listener) 28 _wrapListener: function(listener)
29 { 29 {
30 return function(event) 30 return function(event)
31 { 31 {
32 if (event.target instanceof SafariBrowserTab) 32 if (event.target instanceof SafariBrowserTab)
33 listener(new Tab(event.target)); 33 listener(new Tab(event.target));
34 }; 34 };
35 } 35 }
36 }; 36 };
37 37
38 var LoadingTabEventTarget = function(target)
39 {
40 WrappedEventTarget.call(this, target, "message", false);
41 };
42 LoadingTabEventTarget.prototype = {
43 __proto__: WrappedEventTarget.prototype,
44 _wrapListener: function(listener)
45 {
46 return function (event) {
47 if (event.name == "loading" && event.message == event.target.url)
Felix Dahlke 2013/11/15 13:28:38 Shouldn't we check if event.target is an instance
Sebastian Noack 2013/11/15 13:45:29 Shouldn't be required here. Only tabs can send mes
48 listener(new Tab(event.target));
49 };
50 }
51 };
52
38 Tab = function(tab) 53 Tab = function(tab)
39 { 54 {
40 this._tab = tab; 55 this._tab = tab;
41 56
42 this._eventTarget = tab; 57 this._eventTarget = tab;
43 this._messageDispatcher = tab.page; 58 this._messageDispatcher = tab.page;
44 59
45 this.onBeforeNavigate = new TabEventTarget(tab, "beforeNavigate", false); 60 this.onLoading = new LoadingTabEventTarget(tab);
46 this.onCompleted = new TabEventTarget(tab, "navigate", false); 61 this.onCompleted = new TabEventTarget(tab, "navigate", false);
47 this.onActivated = new TabEventTarget(tab, "activate", false); 62 this.onActivated = new TabEventTarget(tab, "activate", false);
48 this.onRemoved = new TabEventTarget(tab, "close", false); 63 this.onRemoved = new TabEventTarget(tab, "close", false);
49 }; 64 };
50 Tab.prototype = { 65 Tab.prototype = {
51 get url() 66 get url()
52 { 67 {
53 return this._tab.url; 68 return this._tab.url;
54 }, 69 },
55 close: function() 70 close: function()
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 return new Window(win); 498 return new Window(win);
484 })); 499 }));
485 }, 500 },
486 getLastFocused: function(callback) 501 getLastFocused: function(callback)
487 { 502 {
488 callback(new Window(safari.application.activeBrowserWindow)); 503 callback(new Window(safari.application.activeBrowserWindow));
489 } 504 }
490 }; 505 };
491 506
492 ext.tabs = { 507 ext.tabs = {
493 onBeforeNavigate: new TabEventTarget(safari.application, "beforeNavigate", t rue), 508 onLoading: new LoadingTabEventTarget(safari.application),
494 onCompleted: new TabEventTarget(safari.application, "navigate", true), 509 onCompleted: new TabEventTarget(safari.application, "navigate", true),
495 onActivated: new TabEventTarget(safari.application, "activate", true), 510 onActivated: new TabEventTarget(safari.application, "activate", true),
496 onRemoved: new TabEventTarget(safari.application, "close", true) 511 onRemoved: new TabEventTarget(safari.application, "close", true)
497 }; 512 };
498 513
499 ext.backgroundPage = { 514 ext.backgroundPage = {
500 getWindow: function() 515 getWindow: function()
501 { 516 {
502 return safari.extension.globalPage.contentWindow; 517 return safari.extension.globalPage.contentWindow;
503 } 518 }
504 }; 519 };
505 520
506 ext.onMessage = new MessageEventTarget(safari.application); 521 ext.onMessage = new MessageEventTarget(safari.application);
507 522
508 523
509 // Safari will load the bubble once, and then show it everytime the icon is 524 // Safari will load the bubble once, and then show it everytime the icon is
510 // clicked. While Chrome loads it everytime you click the icon. So in order to 525 // clicked. While Chrome loads it everytime you click the icon. So in order to
511 // force the same behavior in Safari, we are going to reload the page of the 526 // force the same behavior in Safari, we are going to reload the page of the
512 // bubble everytime it is shown. 527 // bubble everytime it is shown.
513 if (safari.extension.globalPage.contentWindow != window) 528 if (safari.extension.globalPage.contentWindow != window)
514 safari.application.addEventListener("popover", function() 529 safari.application.addEventListener("popover", function()
515 { 530 {
516 document.documentElement.style.display = "none"; 531 document.documentElement.style.display = "none";
517 document.location.reload(); 532 document.location.reload();
518 }, true); 533 }, true);
519 })(); 534 })();
OLDNEW
« no previous file with comments | « chrome/background.js ('k') | safari/content.js » ('j') | safari/content.js » ('J')

Powered by Google App Engine
This is Rietveld