tizen beta release
[framework/web/webkit-efl.git] / debian / tmp / usr / share / ewebkit-0 / webinspector / NetworkItemView.js
1 /*
2  * Copyright (C) 2010 Google Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are
6  * met:
7  *
8  *     * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  *     * Redistributions in binary form must reproduce the above
11  * copyright notice, this list of conditions and the following disclaimer
12  * in the documentation and/or other materials provided with the
13  * distribution.
14  *     * Neither the name of Google Inc. nor the names of its
15  * contributors may be used to endorse or promote products derived from
16  * this software without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  */
30
31 /**
32  * @extends {WebInspector.TabbedPane}
33  * @constructor
34  */
35 WebInspector.NetworkItemView = function(resource)
36 {
37     WebInspector.TabbedPane.call(this);
38
39     this.element.addStyleClass("network-item-view");
40
41     var headersView = new WebInspector.ResourceHeadersView(resource);
42     this.appendTab("headers", WebInspector.UIString("Headers"), headersView);
43
44     var responseView = new WebInspector.ResourceResponseView(resource);
45     var previewView = new WebInspector.ResourcePreviewView(resource, responseView);
46
47     this.appendTab("preview", WebInspector.UIString("Preview"), previewView);
48     this.appendTab("response", WebInspector.UIString("Response"), responseView);
49
50     if (Capabilities.showCookiesTab) {
51         this._cookiesView = new WebInspector.ResourceCookiesView(resource);
52         this.appendTab("cookies", WebInspector.UIString("Cookies"), this._cookiesView);
53     }
54
55     if (Capabilities.showTimingTab) {
56         var timingView = new WebInspector.ResourceTimingView(resource);
57         this.appendTab("timing", WebInspector.UIString("Timing"), timingView);
58     }
59
60     this.addEventListener("tab-selected", this._tabSelected, this);
61 }
62
63 WebInspector.NetworkItemView.prototype = {
64     wasShown: function()
65     {
66         WebInspector.TabbedPane.prototype.wasShown.call();
67         this._selectTab();
68     },
69
70     /**
71      * @param {string=} tabId
72      */
73     _selectTab: function(tabId)
74     {
75         if (!tabId)
76             tabId = WebInspector.settings.resourceViewTab.get();
77
78         if (!this.selectTab(tabId)) {
79             this._isInFallbackSelection = true;
80             this.selectTab("headers");
81             delete this._isInFallbackSelection;
82         }
83     },
84
85     _tabSelected: function(event)
86     {
87         if (event.data.isUserGesture)
88             WebInspector.settings.resourceViewTab.set(event.data.tabId);
89     }
90 }
91
92 WebInspector.NetworkItemView.prototype.__proto__ = WebInspector.TabbedPane.prototype;
93
94 /**
95  * @extends {WebInspector.ResourceView}
96  * @constructor
97  */
98 WebInspector.ResourceContentView = function(resource)
99 {
100     WebInspector.ResourceView.call(this, resource);
101 }
102
103 WebInspector.ResourceContentView.prototype = {
104     hasContent: function()
105     {
106         return true;
107     },
108
109     get innerView()
110     {
111         return this._innerView;
112     },
113
114     set innerView(innerView)
115     {
116         this._innerView = innerView;
117     },
118
119     wasShown: function()
120     {
121         this._ensureInnerViewShown();
122     },
123
124     _ensureInnerViewShown: function()
125     {
126         if (this._innerViewShowRequested)
127             return;
128         this._innerViewShowRequested = true;
129
130         function callback()
131         {
132             this._innerViewShowRequested = false;
133             this.contentLoaded();
134         }
135
136         this.resource.requestContent(callback.bind(this));
137     },
138
139     contentLoaded: function()
140     {
141         // Should be implemented by subclasses.
142     },
143
144     canHighlightLine: function()
145     {
146         return this._innerView && this._innerView.canHighlightLine();
147     },
148
149     highlightLine: function(line)
150     {
151         if (this.canHighlightLine())
152             this._innerView.highlightLine(line);
153     }
154 }
155
156 WebInspector.ResourceContentView.prototype.__proto__ = WebInspector.ResourceView.prototype;