~justinmcp/unity-chromium-extension/native-messaging-base

« back to all changes in this revision

Viewing changes to chromium-extension/content/unity-context-manager.js

  • Committer: Tarmac
  • Author(s): Alexandre Abreu
  • Date: 2013-09-16 21:39:13 UTC
  • mfrom: (228.1.1 revert)
  • Revision ID: tarmac-20130916213913-63a50kn45ddqom1j
Revert revision 228: deprecate tab integration.

Approved by Robert Bruce Park, PS Jenkins bot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
function UnityContextManager () {
 
2
    this.contexts = [];
 
3
}
 
4
 
 
5
UnityContextManager.prototype.addContext = function (context) {
 
6
    if (this.contexts.indexOf(context) >= 0) {
 
7
        return;
 
8
    }
 
9
    this.contexts.push (context);
 
10
}
 
11
 
 
12
UnityContextManager.prototype.removeContext = function (context) {
 
13
    var index = this.contexts.indexOf(context);
 
14
    
 
15
    if (index == -1)
 
16
        return false;
 
17
 
 
18
    delete this.contexts[this.contexts.indexOf(context)];
 
19
 
 
20
    return true;
 
21
}
 
22
 
 
23
UnityContextManager.prototype.findContextByWindow = function (window) {
 
24
    var i;
 
25
 
 
26
    for (i in this.contexts) {
 
27
           var context = this.contexts[i];
 
28
        
 
29
        if (context != undefined && 
 
30
               context != null && 
 
31
                context.window == window) {
 
32
               return context;
 
33
           }
 
34
    }
 
35
 
 
36
    return null;
 
37
}
 
38
 
 
39
UnityContextManager.prototype.findContextByParent = function (parent) {
 
40
    var i;
 
41
    
 
42
    for (i in this.contexts) {
 
43
        var context = this.contexts[i];
 
44
        
 
45
        if (context != undefined &&
 
46
            context != null &&
 
47
            context.parent == parent) {
 
48
            return context;
 
49
        }
 
50
    }
 
51
    return null;
 
52
}
 
53