|
1 /* |
|
2 * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the License "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * Multiple Windows' WindowManager. |
|
16 * |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 // INCLUDE FILES |
|
22 #include "BrowserWindowManager.h" |
|
23 #include "BrowserWindow.h" |
|
24 #include "BrowserWindowQueue.h" |
|
25 #include "BrowserContentView.h" |
|
26 #include "WindowInfoProvider.h" |
|
27 #include "Logger.h" |
|
28 #include "Preferences.h" |
|
29 #include "Display.h" |
|
30 #include "ApiProvider.h" |
|
31 #include <brctldefs.h> |
|
32 #include "BrowserUtil.h" |
|
33 #include <BrowserNG.rsg> |
|
34 #include <StringLoader.h> |
|
35 #include <AknQueryDialog.h> |
|
36 |
|
37 |
|
38 // ----------------------------------------------------------------------------- |
|
39 // CBrowserWindowQue::LastItem() |
|
40 // ----------------------------------------------------------------------------- |
|
41 // |
|
42 CBrowserWindowQue* CBrowserWindowQue::LastItem() const |
|
43 { |
|
44 // remove 'const' modifier from 'this' in a const member function |
|
45 CBrowserWindowQue* a = CONST_CAST( CBrowserWindowQue*, this ); |
|
46 for( ; a->iNext; a=a->iNext) |
|
47 ; |
|
48 return a; |
|
49 } |
|
50 |
|
51 // ----------------------------------------------------------------------------- |
|
52 // CBrowserWindowQue::~CBrowserWindowQue() |
|
53 // ----------------------------------------------------------------------------- |
|
54 // |
|
55 CBrowserWindowQue::~CBrowserWindowQue() |
|
56 { |
|
57 LOG_ENTERFN("WindowQue::~WindowQue"); |
|
58 if( this->iPrev ) |
|
59 { |
|
60 BROWSER_LOG( ( _L( "iPrev" ) ) ); |
|
61 this->iPrev->iNext = this->iNext; |
|
62 } |
|
63 if( this->iNext ) |
|
64 { |
|
65 BROWSER_LOG( ( _L( "iNext" ) ) ); |
|
66 this->iNext->iPrev = this->iPrev; |
|
67 } |
|
68 delete iWindow; |
|
69 iWindow = NULL; |
|
70 } |
|
71 |
|
72 // ----------------------------------------------------------------------------- |
|
73 // CBrowserWindowQue::AppendL() |
|
74 // ----------------------------------------------------------------------------- |
|
75 // |
|
76 void CBrowserWindowQue::AppendL( CBrowserWindowQue* aItem ) |
|
77 { |
|
78 __ASSERT_DEBUG( (aItem != NULL), Util::Panic( Util::EUninitializedData )); |
|
79 aItem->iPrev = LastItem(); |
|
80 aItem->iPrev->iNext = aItem; |
|
81 } |
|
82 |
|
83 // ----------------------------------------------------------------------------- |
|
84 // CBrowserWindowQue::Next() |
|
85 // ----------------------------------------------------------------------------- |
|
86 // |
|
87 CBrowserWindowQue* CBrowserWindowQue::Next() const |
|
88 { |
|
89 CBrowserWindowQue* b = this->iNext; |
|
90 while( b && (b->iStatus & CBrowserWindowQue::EWindowDeleted ) ) |
|
91 { |
|
92 b = b->iNext; |
|
93 } |
|
94 return b; |
|
95 } |
|
96 |
|
97 // ----------------------------------------------------------------------------- |
|
98 // CBrowserWindowQue::Prev() |
|
99 // ----------------------------------------------------------------------------- |
|
100 // |
|
101 CBrowserWindowQue* CBrowserWindowQue::Prev() const |
|
102 { |
|
103 CBrowserWindowQue* b = this->iPrev; |
|
104 while( b && (b->iStatus & CBrowserWindowQue::EWindowDeleted ) ) |
|
105 { |
|
106 b = b->iPrev; |
|
107 } |
|
108 return b; |
|
109 } |
|
110 |
|
111 // ----------------------------------------------------------------------------- |
|
112 // CBrowserWindowManager:: |
|
113 // ----------------------------------------------------------------------------- |
|
114 // initialization of static member variable |
|
115 TInt CBrowserWindowManager::iWindowIdGenerator( 0 ); |
|
116 |
|
117 // ----------------------------------------------------------------------------- |
|
118 // CBrowserWindowManager::NewLC() |
|
119 // ----------------------------------------------------------------------------- |
|
120 // |
|
121 CBrowserWindowManager* CBrowserWindowManager::NewLC( |
|
122 MApiProvider& aApiProvider, |
|
123 CBrowserContentView& aContentView, |
|
124 TInt aMaxWindowCount ) |
|
125 { |
|
126 CBrowserWindowManager* self = new (ELeave) |
|
127 CBrowserWindowManager( aApiProvider, aContentView, aMaxWindowCount ); |
|
128 CleanupStack::PushL( self ); |
|
129 self->ConstructL(); |
|
130 return self; |
|
131 } |
|
132 |
|
133 // ----------------------------------------------------------------------------- |
|
134 // CBrowserWindowManager::NewL() |
|
135 // ----------------------------------------------------------------------------- |
|
136 // |
|
137 CBrowserWindowManager* CBrowserWindowManager::NewL( |
|
138 MApiProvider& aApiProvider, |
|
139 CBrowserContentView& aContentView, |
|
140 TInt aMaxWindowCount ) |
|
141 { |
|
142 CBrowserWindowManager* self = CBrowserWindowManager::NewLC( |
|
143 aApiProvider, aContentView, aMaxWindowCount ); |
|
144 CleanupStack::Pop( self ); |
|
145 return self; |
|
146 } |
|
147 |
|
148 // ----------------------------------------------------------------------------- |
|
149 // CBrowserWindowManager::~CBrowserWindowManager() |
|
150 // ----------------------------------------------------------------------------- |
|
151 // |
|
152 CBrowserWindowManager::~CBrowserWindowManager( ) |
|
153 { |
|
154 LOG_ENTERFN("WindowManager::~WindowManager"); |
|
155 // Preferences must exist! |
|
156 if(iApiProvider!=NULL) |
|
157 { |
|
158 iApiProvider->Preferences().RemoveObserver( this ); |
|
159 } |
|
160 RemoveObserver(iContentView); |
|
161 CBrowserWindowQue *window = iWindowQueue; |
|
162 CBrowserWindowQue *temp = NULL; |
|
163 |
|
164 |
|
165 TBool isStandAlone( !iApiProvider->IsEmbeddedModeOn() ); |
|
166 if ( ( isStandAlone && !iUserExit ) || ( !isStandAlone ) ) |
|
167 { |
|
168 TRAP_IGNORE( window->iWindow->BrCtlInterface().HandleCommandL( |
|
169 (TInt)TBrCtlDefs::ECommandSaveLaunchParams + (TInt)TBrCtlDefs::ECommandIdBase ) ); |
|
170 } |
|
171 |
|
172 for(; window; ) |
|
173 { |
|
174 temp = window; |
|
175 window = window->iNext; |
|
176 DeleteOneWindowL( temp->iWindow->WindowId() ); |
|
177 /*delete temp; |
|
178 temp = NULL;*/ |
|
179 } |
|
180 RemoveDeletedWindowsL(); |
|
181 delete iObservers; |
|
182 iObservers = NULL; |
|
183 } |
|
184 |
|
185 // ----------------------------------------------------------------------------- |
|
186 // CBrowserWindowManager::WindowCount() |
|
187 // ----------------------------------------------------------------------------- |
|
188 // |
|
189 TInt CBrowserWindowManager::WindowCount() const |
|
190 { |
|
191 return iWindowCount - iDeletedWindowCount; |
|
192 } |
|
193 |
|
194 // ----------------------------------------------------------------------------- |
|
195 // CBrowserWindowManager::CBrowserWindowManager() |
|
196 // ----------------------------------------------------------------------------- |
|
197 // |
|
198 CBrowserWindowManager::CBrowserWindowManager( |
|
199 MApiProvider& aApiProvider, |
|
200 CBrowserContentView& aContentView, |
|
201 TInt aMaxWindowCount ) : |
|
202 iApiProvider( &aApiProvider ), |
|
203 iContentView( &aContentView), |
|
204 iMaxWindowCount( aMaxWindowCount ), |
|
205 iWindowCount( 0 ), |
|
206 iDeletedWindowCount( 0 ), |
|
207 iWindowQueue( NULL ), |
|
208 iCurrentWindow( NULL ), |
|
209 iUserExit( EFalse ), |
|
210 iIsContentExist( EFalse ) |
|
211 { |
|
212 } |
|
213 |
|
214 // ----------------------------------------------------------------------------- |
|
215 // CBrowserWindowManager::ConstructL() |
|
216 // ----------------------------------------------------------------------------- |
|
217 // |
|
218 void CBrowserWindowManager::ConstructL( ) |
|
219 { |
|
220 iApiProvider->Preferences().AddObserverL( this ); |
|
221 CreateWindowL( 0, &KNullDesC ); |
|
222 iCurrentWindow = iWindowQueue; |
|
223 // don't draw anything, just activate it |
|
224 iCurrentWindow->iWindow->ActivateL( EFalse ); |
|
225 iObservers = new ( ELeave ) CArrayPtrFlat< MWindowObserver >( 1 ); |
|
226 AddObserverL(iContentView); |
|
227 } |
|
228 |
|
229 // ----------------------------------------------------------------------------- |
|
230 // CBrowserWindowManager::Window() |
|
231 // ----------------------------------------------------------------------------- |
|
232 // |
|
233 TInt CBrowserWindowManager::Window( |
|
234 TInt aWindowId, |
|
235 CBrowserWindow*& aWindow ) |
|
236 { |
|
237 RemoveDeletedWindowsL(); |
|
238 CBrowserWindowQue *windowQue = NULL; |
|
239 TInt error( Window( aWindowId, windowQue, iWindowQueue ) ); |
|
240 if( windowQue ) |
|
241 { |
|
242 aWindow = windowQue->iWindow; |
|
243 } |
|
244 return error; |
|
245 } |
|
246 |
|
247 // ----------------------------------------------------------------------------- |
|
248 // CBrowserWindowManager::FindWindowL() |
|
249 // ----------------------------------------------------------------------------- |
|
250 // |
|
251 CBrowserWindow* CBrowserWindowManager::FindWindowL( |
|
252 const TDesC& aTargetName ) |
|
253 { |
|
254 LOG_ENTERFN("WindowManager::FindWindowL( Target )"); |
|
255 RemoveDeletedWindowsL(); |
|
256 CBrowserWindow* result = NULL; |
|
257 CBrowserWindow* window = NULL; |
|
258 CBrowserWindowQue *windowQue = iWindowQueue; |
|
259 for( ; windowQue; windowQue = windowQue->Next() ) |
|
260 { |
|
261 window = windowQue->iWindow; |
|
262 if( window->TargetName()->Compare( aTargetName ) == 0 ) |
|
263 { |
|
264 result = window; |
|
265 } |
|
266 } |
|
267 return result; |
|
268 } |
|
269 |
|
270 // ----------------------------------------------------------------------------- |
|
271 // CBrowserWindowManager::CurrentWindow() |
|
272 // ----------------------------------------------------------------------------- |
|
273 // |
|
274 CBrowserWindow* CBrowserWindowManager::CurrentWindow() const |
|
275 { |
|
276 if( iCurrentWindow ) |
|
277 { |
|
278 return iCurrentWindow->iWindow; |
|
279 } |
|
280 else |
|
281 { |
|
282 return NULL; |
|
283 } |
|
284 } |
|
285 |
|
286 // ----------------------------------------------------------------------------- |
|
287 // CBrowserWindowManager::CurrentWindowQue() |
|
288 // ----------------------------------------------------------------------------- |
|
289 // |
|
290 CBrowserWindowQue* CBrowserWindowManager::CurrentWindowQue() const |
|
291 { |
|
292 if( iCurrentWindow ) |
|
293 { |
|
294 return iCurrentWindow; |
|
295 } |
|
296 else |
|
297 { |
|
298 return NULL; |
|
299 } |
|
300 } |
|
301 |
|
302 // ----------------------------------------------------------------------------- |
|
303 // CBrowserWindowManager::GetWindowInfoL() |
|
304 // ----------------------------------------------------------------------------- |
|
305 // |
|
306 CArrayFixFlat<CWindowInfo*>* CBrowserWindowManager::GetWindowInfoL( |
|
307 MWindowInfoProvider* aWindowInfo ) |
|
308 { |
|
309 __ASSERT_DEBUG( (aWindowInfo != NULL), Util::Panic( Util::EUninitializedData )); |
|
310 |
|
311 RemoveDeletedWindowsL(); |
|
312 CBrowserWindowQue* window = iWindowQueue; |
|
313 CArrayFixFlat<CWindowInfo*>* windowInfoList = new (ELeave) |
|
314 CArrayFixFlat<CWindowInfo*>( 3 /* KGranularityMedium */ ); |
|
315 CleanupStack::PushL( windowInfoList ); |
|
316 for( ; window; window = window->Next() ) |
|
317 { |
|
318 // create window info text by client |
|
319 HBufC* buf = aWindowInfo->CreateWindowInfoLC( *( window->iWindow ) ); |
|
320 |
|
321 if (!buf) |
|
322 { |
|
323 CleanupStack::PopAndDestroy( buf ); |
|
324 buf = KNullDesC().AllocLC(); |
|
325 } |
|
326 |
|
327 // create window info( text, id, current ) |
|
328 CWindowInfo* windowInfo = new ( ELeave ) CWindowInfo( |
|
329 buf, window->iWindow->WindowId(), iCurrentWindow == window ); |
|
330 |
|
331 CleanupStack::Pop( buf ); |
|
332 |
|
333 // append to list |
|
334 windowInfoList->AppendL( windowInfo ); |
|
335 |
|
336 } |
|
337 |
|
338 CleanupStack::Pop( windowInfoList ); |
|
339 return windowInfoList; |
|
340 } |
|
341 |
|
342 // ----------------------------------------------------------------------------- |
|
343 // CBrowserWindowManager::AddObserver() |
|
344 // ----------------------------------------------------------------------------- |
|
345 // |
|
346 void CBrowserWindowManager::AddObserverL( MWindowObserver* aObserver ) |
|
347 { |
|
348 LOG_ENTERFN("CBrowserWindowManager::AddObserver"); |
|
349 if ( iObservers ) |
|
350 { |
|
351 iObservers->AppendL( aObserver ); |
|
352 } |
|
353 } |
|
354 |
|
355 // ----------------------------------------------------------------------------- |
|
356 // CBrowserWindowManager::RemoveObserver() |
|
357 // ----------------------------------------------------------------------------- |
|
358 // |
|
359 void CBrowserWindowManager::RemoveObserver( MWindowObserver* aObserver ) |
|
360 { |
|
361 LOG_ENTERFN("CBrowserWindowManager::RemoveObserver"); |
|
362 TInt i( 0 ); |
|
363 TInt count = iObservers->Count(); |
|
364 for ( i = 0; i < count; i++ ) |
|
365 { |
|
366 if ( iObservers->At( i ) == aObserver ) |
|
367 { |
|
368 iObservers->Delete( i ); |
|
369 break; |
|
370 } |
|
371 } |
|
372 } |
|
373 |
|
374 // ----------------------------------------------------------------------------- |
|
375 // CBrowserWindowManager::NotifyObservers() |
|
376 // ----------------------------------------------------------------------------- |
|
377 // |
|
378 void CBrowserWindowManager::NotifyObserversL( TWindowEvent aEvent, TInt aWindowId ) |
|
379 { |
|
380 LOG_ENTERFN("CBrowserWindowManager::NotifyObservers"); |
|
381 if ( iObservers ) |
|
382 { |
|
383 TInt i; |
|
384 TInt count = iObservers->Count(); |
|
385 |
|
386 if ( count ) |
|
387 { |
|
388 for ( i = 0; i < count; i++ ) |
|
389 { |
|
390 iObservers->At( i )->WindowEventHandlerL( aEvent, aWindowId ); |
|
391 } |
|
392 } |
|
393 } |
|
394 } |
|
395 |
|
396 // ----------------------------------------------------------------------------- |
|
397 // CBrowserWindowManager::CreateWindowL() |
|
398 // ----------------------------------------------------------------------------- |
|
399 // |
|
400 CBrowserWindow* CBrowserWindowManager::CreateWindowL( |
|
401 TInt aParentId, |
|
402 const TDesC* aTargetName ) |
|
403 { |
|
404 PERFLOG_LOCAL_INIT |
|
405 PERFLOG_STOPWATCH_START |
|
406 LOG_ENTERFN("WindowManager::CreateWindowL"); |
|
407 RemoveDeletedWindowsL(); |
|
408 if( WindowCount() >= iMaxWindowCount ) |
|
409 { |
|
410 HBufC* maxWinsReached = StringLoader::LoadLC(R_BROWSER_NOTE_MAX_WINDOWS); |
|
411 ApiProvider()->DialogsProvider().DialogNoteL( *maxWinsReached ); |
|
412 CleanupStack::PopAndDestroy( maxWinsReached ); |
|
413 return NULL; |
|
414 } |
|
415 CBrowserWindow* window = NULL; |
|
416 // search for already existing window |
|
417 Window( aParentId, aTargetName, window, iWindowQueue ); // error is ignored |
|
418 if( window ) |
|
419 { |
|
420 |
|
421 return window; |
|
422 } |
|
423 window = CBrowserWindow::NewLC( ++iWindowIdGenerator, aTargetName, this ); |
|
424 BROWSER_LOG( ( _L( "Window is created, ID: %d, windowCount: %d" ), |
|
425 window->WindowId(), WindowCount ) ); |
|
426 // create a WindowQue instance initiated by the new window |
|
427 CBrowserWindowQue *windowQue = new (ELeave) CBrowserWindowQue( window ); |
|
428 CleanupStack::PushL( windowQue ); |
|
429 // and set window's parent |
|
430 TInt error2( Window( aParentId, windowQue->iParent, iWindowQueue ) ); |
|
431 BROWSER_LOG( ( _L( "error2: %d" ), error2 ) ); |
|
432 // append window to the list |
|
433 if( iWindowQueue ) |
|
434 { |
|
435 BROWSER_LOG( ( _L( "window queue not empty" ) ) ); |
|
436 iWindowQueue->AppendL( windowQue ); |
|
437 } |
|
438 else |
|
439 { |
|
440 BROWSER_LOG( ( _L( "window queue empty" ) ) ); |
|
441 iWindowQueue = windowQue; |
|
442 } |
|
443 CleanupStack::Pop( windowQue ); |
|
444 |
|
445 // window is created and append to the list successfully |
|
446 ++iWindowCount; |
|
447 |
|
448 CleanupStack::Pop( window ); |
|
449 NotifyObserversL( EWindowOpen, window->WindowId() ); |
|
450 |
|
451 // window is activated by the client |
|
452 PERFLOG_STOP_WRITE("****CreateWindowL***") |
|
453 return window; |
|
454 } |
|
455 |
|
456 // ----------------------------------------------------------------------------- |
|
457 // CBrowserWindowManager::DeleteWindowL() |
|
458 // ----------------------------------------------------------------------------- |
|
459 // |
|
460 TInt CBrowserWindowManager::DeleteWindowL( |
|
461 TInt aWindowId, |
|
462 TBool aUserInitiated ) |
|
463 { |
|
464 LOG_ENTERFN("WindowManager::DeleteWindowL"); |
|
465 TInt windowToBeActivated( KErrNotFound ); |
|
466 // find the window |
|
467 CBrowserWindowQue* windowQue = NULL; |
|
468 Window( aWindowId, windowQue, iWindowQueue ); |
|
469 if( windowQue ) |
|
470 { |
|
471 // make the old window absolutely inactive |
|
472 windowQue->iWindow->BrCtlInterface().HandleCommandL( |
|
473 (TInt)TBrCtlDefs::ECommandClearHistory + (TInt)TBrCtlDefs::ECommandIdBase ); |
|
474 // Changes were made to ClearHistory that cause it to keep one (current) page |
|
475 // In order to reuse a window we need to clear the history again after the first new page |
|
476 // is loaded. |
|
477 windowQue->iWindow->SetFirstPage(ETrue); |
|
478 |
|
479 |
|
480 windowQue->iWindow->BrCtlInterface().HandleCommandL( |
|
481 (TInt)TBrCtlDefs::ECommandLoseFocus + (TInt)TBrCtlDefs::ECommandIdBase ); |
|
482 |
|
483 if(windowQue->iWindow->HasWMLContent(EFalse)) |
|
484 { |
|
485 windowQue->iWindow->BrCtlInterface().HandleCommandL( |
|
486 (TInt)TBrCtlDefs::ECommandUnloadWMLEngine + (TInt)TBrCtlDefs::ECommandIdBase ); |
|
487 } |
|
488 |
|
489 // On 3.1 CancelFetch activates the content view for some reason |
|
490 // this section is temporarily flagged out until further |
|
491 // investigation. |
|
492 windowQue->iWindow->BrCtlInterface().HandleCommandL( |
|
493 (TInt)TBrCtlDefs::ECommandCancelFetch + (TInt)TBrCtlDefs::ECommandIdBase ); |
|
494 |
|
495 // if the topmost window is deleted |
|
496 // try to find a new one to be activated |
|
497 if( iCurrentWindow == windowQue ) |
|
498 { |
|
499 CBrowserWindowQue* next = windowQue->Next(); |
|
500 CBrowserWindowQue* prev = windowQue->Prev(); |
|
501 if( next ) |
|
502 { |
|
503 windowToBeActivated = next->iWindow->WindowId(); |
|
504 iCurrentWindow = next; |
|
505 } |
|
506 else if( prev ) |
|
507 { |
|
508 windowToBeActivated = prev->iWindow->WindowId(); |
|
509 iCurrentWindow = prev; |
|
510 } |
|
511 else |
|
512 { |
|
513 windowToBeActivated = 0; |
|
514 } |
|
515 } |
|
516 // else a background window was deleted |
|
517 |
|
518 // last window handling |
|
519 if( WindowCount() == 1 ) |
|
520 { |
|
521 // here we already set the windowToBeActivated to 0 |
|
522 // means CloseContentView or Exit in AppUi |
|
523 |
|
524 // clear all content of Window (images, scripts) |
|
525 |
|
526 // windowQue->iWindow->BrCtlInterface().HandleCommandL( |
|
527 // (TInt)TBrCtlDefs::ECommand + (TInt)TBrCtlDefs::ECommandIdBase ); |
|
528 windowQue->iWindow->BrCtlInterface().HandleCommandL( |
|
529 (TInt)TBrCtlDefs::ECommandUnloadWMLEngine + (TInt)TBrCtlDefs::ECommandIdBase ); |
|
530 |
|
531 //Remove the plugins windows. This is a fix for plugins still plays in the background |
|
532 //while the page is closed. |
|
533 windowQue->iWindow->BrCtlInterface().HandleCommandL( |
|
534 (TInt)TBrCtlDefs::ECommandUnLoadPluginWindows + (TInt)TBrCtlDefs::ECommandIdBase ); |
|
535 |
|
536 iIsContentExist = EFalse; |
|
537 windowQue->iWindow->SetHasWMLContent(EFalse); |
|
538 windowQue->iWindow->SetCurrWinHasWMLContent(EFalse); |
|
539 |
|
540 |
|
541 } |
|
542 // Update MW Indicator |
|
543 else if ( WindowCount() == 2 ) |
|
544 { |
|
545 // sets the window status |
|
546 windowQue->iStatus |= CBrowserWindowQue::EWindowDeleted; |
|
547 windowQue->iWindow->BrCtlInterface().HandleCommandL((TInt)TBrCtlDefs::ECommandNotifyPluginFocusChangeEvent + (TInt)TBrCtlDefs::ECommandIdBase); |
|
548 windowQue->iWindow->DeactivateL(); |
|
549 // maintain deleted windows' count |
|
550 ++iDeletedWindowCount; |
|
551 |
|
552 if( aUserInitiated ) |
|
553 { |
|
554 DeleteOneWindowL( aWindowId ); |
|
555 } |
|
556 } |
|
557 else |
|
558 { |
|
559 // sets the window status |
|
560 windowQue->iStatus |= CBrowserWindowQue::EWindowDeleted; |
|
561 windowQue->iWindow->BrCtlInterface().HandleCommandL((TInt)TBrCtlDefs::ECommandNotifyPluginFocusChangeEvent + (TInt)TBrCtlDefs::ECommandIdBase); |
|
562 windowQue->iWindow->DeactivateL(); |
|
563 // maintain deleted windows' count |
|
564 ++iDeletedWindowCount; |
|
565 |
|
566 if( aUserInitiated ) |
|
567 { |
|
568 DeleteOneWindowL( aWindowId ); |
|
569 } |
|
570 } |
|
571 } |
|
572 NotifyObserversL( EWindowClose, aWindowId ); |
|
573 |
|
574 return windowToBeActivated; |
|
575 } |
|
576 |
|
577 // ----------------------------------------------------------------------------- |
|
578 // CBrowserWindowManager::SwitchWindowL() |
|
579 // ----------------------------------------------------------------------------- |
|
580 // |
|
581 TInt CBrowserWindowManager::SwitchWindowL( TInt aWindowId, TBool aDraw ) |
|
582 { |
|
583 LOG_ENTERFN("WindowManager::SwitchWindowL"); |
|
584 CBrowserWindowQue* windowQue = NULL; |
|
585 TBool wdnSwitching = EFalse; |
|
586 TInt error( Window( aWindowId, windowQue, iWindowQueue ) ); |
|
587 BROWSER_LOG( ( _L( "error: %d" ), error ) ); |
|
588 if( windowQue ) |
|
589 { |
|
590 BROWSER_LOG( ( _L( "Switching..." ) ) ); |
|
591 if( windowQue != iCurrentWindow ) |
|
592 { |
|
593 wdnSwitching = ETrue; |
|
594 iCurrentWindow->iWindow->BrCtlInterface().HandleCommandL((TInt)TBrCtlDefs::ECommandNotifyPluginFocusChangeEvent + (TInt)TBrCtlDefs::ECommandIdBase); |
|
595 iCurrentWindow->iWindow->DeactivateL(); |
|
596 iCurrentWindow = windowQue; |
|
597 } |
|
598 //If the history view is up, don't activate the content view unless it is switching the window. Otherwise, |
|
599 //it will overdraw the history view and it will cause serious problems when there |
|
600 //is a background redirection |
|
601 if(!iCurrentWindow->iWindow->IsWindowActive() && (!iContentView->IsHistoryViewUp() || wdnSwitching)) |
|
602 { |
|
603 iCurrentWindow->iWindow->BrCtlInterface().HandleCommandL((TInt)TBrCtlDefs::ECommandNotifyPluginFocusChangeEvent + (TInt)TBrCtlDefs::ECommandIdBase); |
|
604 iCurrentWindow->iWindow->ActivateL( aDraw ); |
|
605 iContentView->UpdateCbaL(); |
|
606 } |
|
607 } |
|
608 return error; |
|
609 } |
|
610 |
|
611 // ----------------------------------------------------------------------------- |
|
612 // CBrowserWindowManager::Window() |
|
613 // ----------------------------------------------------------------------------- |
|
614 // search for a window identified by its Id |
|
615 TInt CBrowserWindowManager::Window( |
|
616 TInt aWindowId, |
|
617 CBrowserWindowQue*& aWindowQue, |
|
618 CBrowserWindowQue* aStartingItem ) const |
|
619 { |
|
620 LOG_ENTERFN("WindowManager::Window( Id )"); |
|
621 TInt error( KErrNotFound ); |
|
622 CBrowserWindowQue *windowQue = aStartingItem; |
|
623 for( ; (error != KErrNone) && (windowQue); windowQue = windowQue->iNext ) |
|
624 { |
|
625 if( windowQue->iWindow->WindowId() == aWindowId ) |
|
626 { |
|
627 error = KErrNone; |
|
628 aWindowQue = windowQue; |
|
629 } |
|
630 } |
|
631 return error; |
|
632 } |
|
633 |
|
634 // ----------------------------------------------------------------------------- |
|
635 // CBrowserWindowManager::Window() |
|
636 // ----------------------------------------------------------------------------- |
|
637 // search for a window identified by TargetName and its Parent |
|
638 TInt CBrowserWindowManager::Window( |
|
639 TInt aParentId, |
|
640 const TDesC* aTargetName, |
|
641 CBrowserWindow*& aWindow, |
|
642 CBrowserWindowQue* aStartingItem ) const |
|
643 { |
|
644 LOG_ENTERFN("WindowManager::Window( Parent, Target )"); |
|
645 TInt error( KErrNotFound ); |
|
646 if( aTargetName && aTargetName->Length() ) // sanity check |
|
647 { |
|
648 CBrowserWindow* window = NULL; |
|
649 CBrowserWindowQue *windowQue = aStartingItem; |
|
650 CBrowserWindowQue* parent = NULL; |
|
651 for( ; (error != KErrNone) && (windowQue); windowQue = windowQue->iNext ) |
|
652 { |
|
653 window = windowQue->iWindow; |
|
654 parent = windowQue->iParent; |
|
655 if( parent && |
|
656 ( parent->iWindow->WindowId() == aParentId ) && |
|
657 ( window->TargetName()->Compare( *aTargetName ) == 0 ) ) |
|
658 { |
|
659 error = KErrNone; |
|
660 aWindow = window; |
|
661 } |
|
662 } |
|
663 } |
|
664 return error; |
|
665 } |
|
666 |
|
667 // ----------------------------------------------------------------------------- |
|
668 // CBrowserWindowManager::DeleteOneWindowL() |
|
669 // ----------------------------------------------------------------------------- |
|
670 // |
|
671 TInt CBrowserWindowManager::DeleteOneWindowL( TInt aWindowId ) |
|
672 { |
|
673 // Last window cannot be deleted, this is not called then. |
|
674 LOG_ENTERFN("WindowManager::DeleteOneWindowL"); |
|
675 CBrowserWindowQue* windowQue = NULL; |
|
676 // find window, error ignored |
|
677 Window( aWindowId, windowQue, iWindowQueue ); |
|
678 if( windowQue ) |
|
679 { |
|
680 // set WindowQueue's first item if required |
|
681 if( iWindowQueue == windowQue ) |
|
682 { |
|
683 iWindowQueue = windowQue->iNext; |
|
684 } |
|
685 |
|
686 // clear children's parent pointer |
|
687 CBrowserWindowQue* queue = iWindowQueue; |
|
688 for( ; queue; queue = queue->iNext ) |
|
689 { |
|
690 if( queue->iParent == windowQue ) |
|
691 { |
|
692 queue->iParent = NULL; |
|
693 } |
|
694 } |
|
695 |
|
696 // decrease WindowCount |
|
697 --iWindowCount; |
|
698 |
|
699 // maintain deleted status |
|
700 if ( windowQue->iStatus & CBrowserWindowQue::EWindowDeleted ) |
|
701 { |
|
702 __ASSERT_DEBUG( iDeletedWindowCount, |
|
703 Util::Panic( Util::EUnExpected )); |
|
704 --iDeletedWindowCount; |
|
705 } |
|
706 // delete window via its windowQue container |
|
707 delete windowQue; |
|
708 } |
|
709 return KErrNone; |
|
710 } |
|
711 |
|
712 // ---------------------------------------------------------------------------- |
|
713 // CBrowserWindowManager::RemoveDeletedWindowsL() |
|
714 // ---------------------------------------------------------------------------- |
|
715 // |
|
716 void CBrowserWindowManager::RemoveDeletedWindowsL() |
|
717 { |
|
718 CBrowserWindowQue *window = iWindowQueue; |
|
719 CBrowserWindowQue *temp = NULL; |
|
720 // walk through all the windows |
|
721 for( ; window; ) |
|
722 { |
|
723 temp = window; |
|
724 window = window->iNext; |
|
725 // if it is set as deleted |
|
726 if( temp->iStatus & CBrowserWindowQue::EWindowDeleted ) |
|
727 { |
|
728 DeleteOneWindowL( temp->iWindow->WindowId() ); |
|
729 } |
|
730 } |
|
731 } |
|
732 |
|
733 // ---------------------------------------------------------------------------- |
|
734 // CBrowserWindowManager::HandlePreferencesChangeL() |
|
735 // ---------------------------------------------------------------------------- |
|
736 // |
|
737 void CBrowserWindowManager::HandlePreferencesChangeL( |
|
738 const TPreferencesEvent aEvent, |
|
739 TPreferencesValues& aValues, |
|
740 TBrCtlDefs::TBrCtlSettings aSettingType ) |
|
741 { |
|
742 LOG_ENTERFN("WindowManager::HandlePreferencesChangeL"); |
|
743 BROWSER_LOG( ( _L( "Preferences event: %d" ), aEvent ) ); |
|
744 switch( aEvent ) |
|
745 { |
|
746 case EPreferencesActivate: |
|
747 { |
|
748 // Topmost Window ONLY |
|
749 if ( iCurrentWindow ) |
|
750 { |
|
751 iCurrentWindow->iWindow->HandlePreferencesChangeL( |
|
752 aEvent, aValues, aSettingType ); |
|
753 } |
|
754 break; |
|
755 } |
|
756 case EPreferencesDeactivate: |
|
757 case EPreferencesItemChange: |
|
758 { |
|
759 // All windows |
|
760 CBrowserWindowQue *windowQue = iWindowQueue; |
|
761 for( ; windowQue; windowQue = windowQue->Next() ) |
|
762 { |
|
763 windowQue->iWindow->HandlePreferencesChangeL( |
|
764 aEvent, aValues, aSettingType ); |
|
765 } |
|
766 break; |
|
767 } |
|
768 default: |
|
769 // don't do anything |
|
770 break; |
|
771 } |
|
772 } |
|
773 |
|
774 // ---------------------------------------------------------------------------- |
|
775 // CBrowserWindowManager::SendCommandToAllWindowsL() |
|
776 // ---------------------------------------------------------------------------- |
|
777 // |
|
778 void CBrowserWindowManager::SendCommandToAllWindowsL( |
|
779 TInt aCommand ) |
|
780 { |
|
781 LOG_ENTERFN("WindowManager::SendCommandToAllWindowsL"); |
|
782 BROWSER_LOG( ( _L( "Command: %d" ), aCommand ) ); |
|
783 |
|
784 CBrowserWindowQue *windowQue = iWindowQueue; |
|
785 for( ; windowQue; windowQue = windowQue->Next() ) |
|
786 { |
|
787 windowQue->iWindow->BrCtlInterface().HandleCommandL(aCommand); |
|
788 } |
|
789 } |
|
790 |
|
791 // ---------------------------------------------------------------------------- |
|
792 // CBrowserWindowManager::SetCurrentWindowViewState() |
|
793 // ---------------------------------------------------------------------------- |
|
794 // |
|
795 void CBrowserWindowManager::SetCurrentWindowViewState(TBrCtlDefs::TBrCtlState aViewState, TInt aValue) |
|
796 { |
|
797 LOG_ENTERFN("WindowManager::SetCurrentWindowViewState"); |
|
798 BROWSER_LOG( ( _L( "State: %d" ), aViewState ) ); |
|
799 |
|
800 TBool val(aValue > 0); |
|
801 if (aViewState == TBrCtlDefs::EStateWmlView) |
|
802 { |
|
803 CurrentWindow()->SetWMLMode(val); // set current page has wml (true or false) |
|
804 if (val) |
|
805 { |
|
806 CurrentWindow()->SetHasWMLContent(ETrue); // at least 1 page in window has/had wml |
|
807 CurrentWindow()->SetCurrWinHasWMLContent(ETrue); // current page has wml content |
|
808 |
|
809 } |
|
810 else |
|
811 { |
|
812 CurrentWindow()->SetCurrWinHasWMLContent(EFalse);// current page isn't wml |
|
813 } |
|
814 } |
|
815 } |
|
816 |
|
817 // ---------------------------------------------------------------------------- |
|
818 // CBrowserWindowManager::CloseAllWindowsExceptCurrent() |
|
819 // ---------------------------------------------------------------------------- |
|
820 // |
|
821 void CBrowserWindowManager::CloseAllWindowsExceptCurrent() |
|
822 { |
|
823 LOG_ENTERFN("WindowManager::CloseAllWindowsExceptCurrent"); |
|
824 CBrowserWindowQue* window = iWindowQueue; |
|
825 for( ; window; window = window->Next() ) |
|
826 { |
|
827 if(iCurrentWindow != window) |
|
828 { |
|
829 DeleteWindowL(window->iWindow->WindowId(), EFalse); |
|
830 } |
|
831 } |
|
832 } |
|
833 // End of file |