update
[webos-internals:skurriers-modifications.git] / browser / browser-behavior-and-options-tweaks.patch
1 diff --git a/usr/palm/applications/com.palm.app.browser/app/controllers/page-applicationmenu.js b/usr/palm/applications/com.palm.app.browser/app/controllers/page-applicationmenu.js
2 index 6bf5870..d1d1e7b 100644
3 --- a/usr/palm/applications/com.palm.app.browser/app/controllers/page-applicationmenu.js
4 +++ b/usr/palm/applications/com.palm.app.browser/app/controllers/page-applicationmenu.js
5 @@ -37,6 +37,11 @@ MenuData.ApplicationMenu = {
6                 checkEnabled: true
7         },
8         
9 +       TogglePrivate: {
10 +               label: $L('Enable Private Browsing'),
11 +               command: 'enable-private-cmd'
12 +       },
13 +       
14         ShowHistory: {
15                 label: $L('History'),
16                 command: 'show-history-cmd',
17 diff --git a/usr/palm/applications/com.palm.app.browser/app/controllers/page-assistant.js b/usr/palm/applications/com.palm.app.browser/app/controllers/page-assistant.js
18 index 388cffc..d15b6a7 100644
19 --- a/usr/palm/applications/com.palm.app.browser/app/controllers/page-assistant.js
20 +++ b/usr/palm/applications/com.palm.app.browser/app/controllers/page-assistant.js
21 @@ -93,8 +93,29 @@ PageAssistant.prototype.setup = function() {
22                 this._updateOrientation();
23  
24                 // Allow override of 'back' gesture in landscape mode.
25 -               this.controller.useLandscapePageUpDown(true);
26  
27 +               this.getTweaksOptions = new Mojo.Service.Request("palm://org.webosinternals.tweaks.prefs/", {
28 +                               method: 'get', parameters: {'owner': "browser-behavior-options-tweaks", 
29 +                               keys: ["gestureScroll", "goFullscreen"]},
30 +                               onSuccess: function(response) {
31 +                                       if(response) {
32 +                                               if(response.gestureScroll == false) {
33 +                                                       this.gestureScroll = false;
34 +                                               } else {
35 +                                                       this.gestureScroll = true;
36 +                                               }
37 +                                               if(response.goFullscreen == true) {
38 +                                                       this.goFullscreen = true;
39 +                                               } else {
40 +                                                       this.goFullscreen = false;
41 +                                               }
42 +                                       }
43 +               }.bind(this)});
44 +               
45 +               this.controller.useLandscapePageUpDown(this.gestureScroll);
46 +               
47 +
48 +               
49                 // Create the browser server status control.
50                 this._browserServerStatus = new BrowserServerStatus(this.controller);
51                 this._browserServerStatus.setup({
52 @@ -117,7 +138,10 @@ PageAssistant.prototype.setup = function() {
53                 this.savedFlickRatio = scroller.mojo.kFlickRatio;
54                 scroller.mojo.updatePhysicsParameters({flickSpeed: 0.12, flickRatio: 0.2});
55  
56 -
57 +               if (this.goFullscreen) {
58 +                       this.controller.enableFullScreenMode(true);
59 +               }
60 +               
61                 // Listen for drag events, and stop them when appropriate
62                 Mojo.Event.listen(this.controller.getSceneScroller(), Mojo.Event.dragStart, this._stopSceneScrolling, true);
63  
64 @@ -217,6 +241,10 @@ PageAssistant.prototype._updateOrientation = function() {
65                 this._orientation = Mojo.Controller.appController.getScreenOrientation();
66                 targetWindow.PalmSystem.setWindowOrientation(this._orientation);
67         }
68 +       
69 +       if (this.goFullscreen) {
70 +                       this.controller.enableFullScreenMode(true);
71 +       }
72  };
73  
74  PageAssistant.prototype.orientationChanged = function(event) {
75 @@ -245,6 +273,10 @@ PageAssistant.prototype.orientationChanged = function(event) {
76         }
77  
78         this._setOrientation(this._orientation);
79 +       
80 +       if (this.goFullscreen) {
81 +                       this.controller.enableFullScreenMode(true);
82 +       }
83  };
84  
85  /*
86 @@ -304,6 +336,11 @@ PageAssistant.prototype.activate = function(message) {
87                 
88                 this._updateOrientation();
89                 
90 +               if (this.goFullscreen) {
91 +                       this.controller.enableFullScreenMode(true);
92 +               }
93 +
94 +               
95                 // Update any pending web preferences changes
96                 AppAssistant.WebPreferences.activate(this._webView.mojo);
97  
98 @@ -804,6 +841,20 @@ PageAssistant.prototype._setupMenus = function() {
99                 };
100  
101                 this.controller.setupWidget(Mojo.Menu.appMenu, undefined, this.appMenuModel);
102 +               
103 +               this.getTweaksMainMenu = new Mojo.Service.Request("palm://org.webosinternals.tweaks.prefs/", {
104 +                       method: 'get', parameters: {'owner': "browser-behavior-options-tweaks", 
105 +                       keys: ["privateBrowsing", "viewSource"]},
106 +                       onSuccess: function(response) {
107 +                               if(response) {
108 +                                       if(response.privateBrowsing == true)
109 +                                               this.appMenuModel.items.push(this.togglePrivate = MenuData.ApplicationMenu.TogglePrivate);
110 +                                       if(response.viewSource == true)
111 +                                               this.appMenuModel.items.push({label:"View Source", command:"view-source-cmd"});
112 +                               }
113 +               }.bind(this)});
114 +               
115 +               this.controller.modelChanged(this.appMenuModel);
116  
117                 // Create the URL Bar
118                 this._addressBar = new AddressBar(this.controller);
119 @@ -1066,6 +1117,10 @@ PageAssistant.prototype._updateHistory = function() {
120         if (!this.currentUrl || (this.currentUrl.length === 0)) {
121                 return;
122         }
123 +       
124 +       if (this.togglePrivate.enabled) {
125 +               return;
126 +       }
127  
128         var title = this.currentTitle || null;
129         this.historyStore.addHistory(this.currentUrl, title, new Date(),
130 @@ -1946,6 +2001,10 @@ PageAssistant.prototype.moved = function(scrollState) {
131                         this._addressBar.hide();
132                         this.chrome.hide();
133  
134 +                       if(this.goFullscreen) {
135 +                               this.controller.enableFullScreenMode(true);
136 +                       }
137 +
138                         // Only focus this webview widget if this assistant has
139                         // focus. All page-assisants can receive 'moved' events
140                         // so we have to be careful when explicitly setting the
141 @@ -1969,6 +2028,10 @@ PageAssistant.prototype.moved = function(scrollState) {
142                 //Mojo.Log.info("-> TOP > 0 SO SHOWING");
143                 this._addressBar.show();
144                 this.chrome.show();
145 +               
146 +               if(this.goFullscreen) {
147 +                       this.controller.enableFullScreenMode(false);
148 +               }
149  
150         } else {
151                 //Mojo.Log.info("-> TOP == 0 Do Nothing.");
152 @@ -2180,6 +2243,41 @@ PageAssistant.prototype.handleCommand = function(event) {
153                                 case MenuData.NavigationMenu.Back.command:
154                                         this._goBack();
155                                         break;
156 +                               
157 +                               //PRIVATE BROWSING
158 +                                       
159 +                               case 'enable-private-cmd':
160 +                                       this.togglePrivate.command = 'disable-private-cmd';
161 +                                       this.togglePrivate.label = $L('Disable Private Browsing');
162 +                                       
163 +                                       this.togglePrivate.enabled = true;
164 +                                       
165 +                                       this.controller.modelChanged(this.appMenuModel);
166 +                                       Mojo.Controller.getAppController().showBanner("Private Browsing: Enabled!",  {source: 'notification'});
167 +                                       break;
168 +                                       
169 +                               case 'disable-private-cmd':
170 +                                       this.togglePrivate.command = 'enable-private-cmd';
171 +                                       this.togglePrivate.label = $L('Enable Private Browsing');
172 +                                       
173 +                                       this.togglePrivate.enabled = false;
174 +                                       
175 +                                       this.controller.modelChanged(this.appMenuModel);
176 +                                       Mojo.Controller.getAppController().showBanner("Private Browsing: Disabled!",  {source: 'notification'});
177 +                                       break;          
178 +
179 +                               //VIEW SOURCE
180 +                               case "view-source-cmd":
181 +                                       this.controller.serviceRequest("palm://com.palm.applicationManager", {
182 +                                               method: "open",
183 +                                               parameters: {
184 +                                                       id: "ca.canucksoftware.internalz",
185 +                                                       params: {
186 +                                                               target: "view-source://" + this.currentUrl
187 +                                                       }
188 +                                               }
189 +                                       });
190 +                                       break;
191  
192                                 case MenuData.NavigationMenu.Forward.command:
193                                         this._goForward();
194 diff --git a/usr/palm/applications/com.palm.app.browser/app/controllers/page-controls.js b/usr/palm/applications/com.palm.app.browser/app/controllers/page-controls.js
195 index 6ad7ebd..789559f 100644
196 --- a/usr/palm/applications/com.palm.app.browser/app/controllers/page-controls.js
197 +++ b/usr/palm/applications/com.palm.app.browser/app/controllers/page-controls.js
198 @@ -6,6 +6,17 @@
199  */
200  function PageControls (controller){
201         this._controller = controller;
202 +       
203 +               this.hideIcons = false;
204 +               this.getTweaksOptions = new Mojo.Service.Request("palm://org.webosinternals.tweaks.prefs/", {
205 +                       method: 'get', parameters: {'owner': "browser-behavior-options-tweaks", 
206 +                       keys: ["hideIcons"]},
207 +                       onSuccess: function(response) {
208 +                               if(response) {
209 +                                       if(response.hideIcons == true)
210 +                                               this.hideIcons = true;
211 +                               }
212 +               }.bind(this)});
213  
214                 // We can always go back.
215                 this._back = true;
216 @@ -112,7 +123,7 @@ PageControls.prototype={
217                 // The spacer... right aligns the following button.
218                 this._model.items.push(idleModel);
219                 this._controller.modelChanged(this._model);
220 -
221 +               if (this.hideIcons) { this._controller.setMenuVisible(Mojo.Menu.commandMenu, false);}
222                 this._currentPageModel = idleModel;
223         },
224  
225 @@ -142,7 +153,7 @@ PageControls.prototype={
226                         this._model.items.push(progressModel);
227                         this._controller.modelChanged(this._model);
228                         this._animation.start(0);
229 -
230 +                       if (this.hideIcons) {this._controller.setMenuVisible(Mojo.Menu.commandMenu, true);}
231                         this._currentPageModel = progressModel;
232  
233                 } catch (e) {
234 @@ -187,7 +198,7 @@ PageControls.prototype={
235                         this._model.items.push(searchModel);
236                         this._controller.modelChanged(this._model);
237                         this._animation.start();
238 -
239 +                       if (this.hideIcons) {this._controller.setMenuVisible(Mojo.Menu.commandMenu, true);}
240                         this._currentPageModel = searchModel;
241  
242                 } catch (e) {
243 @@ -204,6 +215,7 @@ PageControls.prototype={
244                                         this._model.items[i].type='flash';
245                                         this._model.items[i].icon= MenuData.NavigationMenu.Cancel.icon;
246                                         this._model.items[i].command=MenuData.NavigationMenu.Cancel.command;
247 +                                       if (this.hideIcons) {this._controller.setMenuVisible(Mojo.Menu.commandMenu, true);}
248                                         break;
249                                 }
250                                 
251 @@ -219,6 +231,7 @@ PageControls.prototype={
252                                         this._model.items[i].type='idle';
253                                         this._model.items[i].icon= MenuData.NavigationMenu.Reload.icon;
254                                         this._model.items[i].command=MenuData.NavigationMenu.Reload.command;
255 +                                       if (this.hideIcons) {this._controller.setMenuVisible(Mojo.Menu.commandMenu, false);}
256                                         break;
257                                 }
258                                 
259 diff --git a/usr/palm/applications/com.palm.app.browser/app/controllers/startpage-assistant.js b/usr/palm/applications/com.palm.app.browser/app/controllers/startpage-assistant.js
260 index 0fbc276..8d767c9 100644
261 --- a/usr/palm/applications/com.palm.app.browser/app/controllers/startpage-assistant.js
262 +++ b/usr/palm/applications/com.palm.app.browser/app/controllers/startpage-assistant.js
263 @@ -24,6 +24,16 @@ StartpageAssistant.prototype.setup = function() {
264  
265         // Allow override of 'back' gesture in landscape mode.
266         this.controller.useLandscapePageUpDown(true);
267 +       this.goFullscreen = false;
268 +       this.getTweaksOptions = new Mojo.Service.Request("palm://org.webosinternals.tweaks.prefs/", {
269 +                       method: 'get', parameters: {'owner': "browser-behavior-options-tweaks", 
270 +                       keys: ["gestureScroll"]},
271 +                       onSuccess: function(response) {
272 +                               if(response) {
273 +                                       if(response.gestureScroll == false)
274 +                                               this.controller.useLandscapePageUpDown(false);
275 +                               }
276 +               }.bind(this)});
277  
278         // Listen for scene scope keyboard events.
279         this.controller.listen(this.controller.sceneElement, Mojo.Event.keydown, this._onKeyDownEventHandler);
280 @@ -53,6 +63,16 @@ StartpageAssistant.prototype.setup = function() {
281                         MenuData.ApplicationMenu.ShowBookmarks,
282                         MenuData.ApplicationMenu.ShowHistory]
283         };
284 +       
285 +       this.getTweaksPrefs = new Mojo.Service.Request("palm://org.webosinternals.tweaks.prefs/", {
286 +                       method: 'get', parameters: {'owner': "browser-behavior-options-tweaks", 
287 +                       keys: ["privateBrowsing" ]},
288 +                       onSuccess: function(response) {
289 +                               if(response) {
290 +                                       if(response.privateBrowsing == true)
291 +                                               this.appMenuModel.items.splice(3,0,this.togglePrivate = MenuData.ApplicationMenu.TogglePrivate);
292 +                               }
293 +               }.bind(this)});
294  
295         this.controller.setupWidget(Mojo.Menu.appMenu, undefined, this.appMenuModel);
296  
297 @@ -367,7 +387,27 @@ StartpageAssistant.prototype.handleCommand = function(event) {
298                                 case MenuData.ApplicationMenu.ShowHistory.command:
299                                         this._openHistoryView();
300                                         break;
301 -
302 +                               
303 +                               case 'enable-private-cmd':
304 +                                       this.togglePrivate.command = 'disable-private-cmd';
305 +                                       this.togglePrivate.label = $L('Disable Private Browsing');
306 +                                       
307 +                                       this.togglePrivate.enabled = true;
308 +                                       
309 +                                       this.controller.modelChanged(this.appMenuModel);
310 +                                       Mojo.Controller.getAppController().showBanner("Private Browsing: Enabled!",  {source: 'notification'});
311 +                                       break;
312 +                                       
313 +                               case 'disable-private-cmd':
314 +                                       this.togglePrivate.command = 'enable-private-cmd';
315 +                                       this.togglePrivate.label = $L('Enable Private Browsing');
316 +                                       
317 +                                       this.togglePrivate.enabled = false;
318 +                                       
319 +                                       this.controller.modelChanged(this.appMenuModel);
320 +                                       Mojo.Controller.getAppController().showBanner("Private Browsing: Disabled!",  {source: 'notification'});
321 +                                       break;
322 +                               
323                                 case MenuData.ApplicationMenu.ShowBookmarks.command:
324                                         this._openBookmarkView();
325                                         break;