|
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::GetWindowInfoL() |
|
288 // ----------------------------------------------------------------------------- |
|
289 // |
|
290 CArrayFixFlat<CWindowInfo*>* CBrowserWindowManager::GetWindowInfoL( |
|
291 MWindowInfoProvider* aWindowInfo ) |
|
292 { |
|
293 __ASSERT_DEBUG( (aWindowInfo != NULL), Util::Panic( Util::EUninitializedData )); |
|
294 |
|
295 RemoveDeletedWindowsL(); |
|
296 CBrowserWindowQue* window = iWindowQueue; |
|
297 CArrayFixFlat<CWindowInfo*>* windowInfoList = new (ELeave) |
|
298 CArrayFixFlat<CWindowInfo*>( 3 /* KGranularityMedium */ ); |
|
299 CleanupStack::PushL( windowInfoList ); |
|
300 for( ; window; window = window->Next() ) |
|
301 { |
|
302 // create window info text by client |
|
303 HBufC* buf = aWindowInfo->CreateWindowInfoLC( *( window->iWindow ) ); |
|
304 |
|
305 if (!buf) |
|
306 { |
|
307 CleanupStack::PopAndDestroy( buf ); |
|
308 buf = KNullDesC().AllocLC(); |
|
309 } |
|
310 |
|
311 // create window info( text, id, current ) |
|
312 CWindowInfo* windowInfo = new ( ELeave ) CWindowInfo( |
|
313 buf, window->iWindow->WindowId(), iCurrentWindow == window ); |
|
314 |
|
315 CleanupStack::Pop( buf ); |
|
316 |
|
317 // append to list |
|
318 windowInfoList->AppendL( windowInfo ); |
|
319 |
|
320 } |
|
321 |
|
322 CleanupStack::Pop( windowInfoList ); |
|
323 return windowInfoList; |
|
324 } |
|
325 |
|
326 // ----------------------------------------------------------------------------- |
|
327 // CBrowserWindowManager::AddObserver() |
|
328 // ----------------------------------------------------------------------------- |
|
329 // |
|
330 void CBrowserWindowManager::AddObserverL( MWindowObserver* aObserver ) |
|
331 { |
|
332 LOG_ENTERFN("CBrowserWindowManager::AddObserver"); |
|
333 if ( iObservers ) |
|
334 { |
|
335 iObservers->AppendL( aObserver ); |
|
336 } |
|
337 } |
|
338 |
|
339 // ----------------------------------------------------------------------------- |
|
340 // CBrowserWindowManager::RemoveObserver() |
|
341 // ----------------------------------------------------------------------------- |
|
342 // |
|
343 void CBrowserWindowManager::RemoveObserver( MWindowObserver* aObserver ) |
|
344 { |
|
345 LOG_ENTERFN("CBrowserWindowManager::RemoveObserver"); |
|
346 TInt i( 0 ); |
|
347 TInt count = iObservers->Count(); |
|
348 for ( i = 0; i < count; i++ ) |
|
349 { |
|
350 if ( iObservers->At( i ) == aObserver ) |
|
351 { |
|
352 iObservers->Delete( i ); |
|
353 break; |
|
354 } |
|
355 } |
|
356 } |
|
357 |
|
358 // ----------------------------------------------------------------------------- |
|
359 // CBrowserWindowManager::NotifyObservers() |
|
360 // ----------------------------------------------------------------------------- |
|
361 // |
|
362 void CBrowserWindowManager::NotifyObserversL( TWindowEvent aEvent, TInt aWindowId ) |
|
363 { |
|
364 LOG_ENTERFN("CBrowserWindowManager::NotifyObservers"); |
|
365 if ( iObservers ) |
|
366 { |
|
367 TInt i; |
|
368 TInt count = iObservers->Count(); |
|
369 |
|
370 if ( count ) |
|
371 { |
|
372 for ( i = 0; i < count; i++ ) |
|
373 { |
|
374 iObservers->At( i )->WindowEventHandlerL( aEvent, aWindowId ); |
|
375 } |
|
376 } |
|
377 } |
|
378 } |
|
379 |
|
380 // ----------------------------------------------------------------------------- |
|
381 // CBrowserWindowManager::CreateWindowL() |
|
382 // ----------------------------------------------------------------------------- |
|
383 // |
|
384 CBrowserWindow* CBrowserWindowManager::CreateWindowL( |
|
385 TInt aParentId, |
|
386 const TDesC* aTargetName ) |
|
387 { |
|
388 PERFLOG_LOCAL_INIT |
|
389 PERFLOG_STOPWATCH_START |
|
390 LOG_ENTERFN("WindowManager::CreateWindowL"); |
|
391 RemoveDeletedWindowsL(); |
|
392 if( WindowCount() >= iMaxWindowCount ) |
|
393 { |
|
394 HBufC* maxWinsReached = StringLoader::LoadLC(R_BROWSER_NOTE_MAX_WINDOWS); |
|
395 ApiProvider()->DialogsProvider().DialogNoteL( *maxWinsReached ); |
|
396 CleanupStack::PopAndDestroy( maxWinsReached ); |
|
397 return NULL; |
|
398 } |
|
399 CBrowserWindow* window = NULL; |
|
400 // search for already existing window |
|
401 Window( aParentId, aTargetName, window, iWindowQueue ); // error is ignored |
|
402 if( window ) |
|
403 { |
|
404 |
|
405 return window; |
|
406 } |
|
407 window = CBrowserWindow::NewLC( ++iWindowIdGenerator, aTargetName, this ); |
|
408 BROWSER_LOG( ( _L( "Window is created, ID: %d, windowCount: %d" ), |
|
409 window->WindowId(), WindowCount ) ); |
|
410 // create a WindowQue instance initiated by the new window |
|
411 CBrowserWindowQue *windowQue = new (ELeave) CBrowserWindowQue( window ); |
|
412 CleanupStack::PushL( windowQue ); |
|
413 // and set window's parent |
|
414 TInt error2( Window( aParentId, windowQue->iParent, iWindowQueue ) ); |
|
415 BROWSER_LOG( ( _L( "error2: %d" ), error2 ) ); |
|
416 // append window to the list |
|
417 if( iWindowQueue ) |
|
418 { |
|
419 BROWSER_LOG( ( _L( "window queue not empty" ) ) ); |
|
420 iWindowQueue->AppendL( windowQue ); |
|
421 } |
|
422 else |
|
423 { |
|
424 BROWSER_LOG( ( _L( "window queue empty" ) ) ); |
|
425 iWindowQueue = windowQue; |
|
426 } |
|
427 CleanupStack::Pop( windowQue ); |
|
428 |
|
429 // window is created and append to the list successfully |
|
430 ++iWindowCount; |
|
431 |
|
432 CleanupStack::Pop( window ); |
|
433 NotifyObserversL( EWindowOpen, window->WindowId() ); |
|
434 |
|
435 // window is activated by the client |
|
436 PERFLOG_STOP_WRITE("****CreateWindowL***") |
|
437 return window; |
|
438 } |
|
439 |
|
440 // ----------------------------------------------------------------------------- |
|
441 // CBrowserWindowManager::DeleteWindowL() |
|
442 // ----------------------------------------------------------------------------- |
|
443 // |
|
444 TInt CBrowserWindowManager::DeleteWindowL( |
|
445 TInt aWindowId, |
|
446 TBool aUserInitiated ) |
|
447 { |
|
448 LOG_ENTERFN("WindowManager::DeleteWindowL"); |
|
449 TInt windowToBeActivated( KErrNotFound ); |
|
450 // find the window |
|
451 CBrowserWindowQue* windowQue = NULL; |
|
452 Window( aWindowId, windowQue, iWindowQueue ); |
|
453 if( windowQue ) |
|
454 { |
|
455 // make the old window absolutely inactive |
|
456 windowQue->iWindow->BrCtlInterface().HandleCommandL( |
|
457 (TInt)TBrCtlDefs::ECommandClearHistory + (TInt)TBrCtlDefs::ECommandIdBase ); |
|
458 // Changes were made to ClearHistory that cause it to keep one (current) page |
|
459 // In order to reuse a window we need to clear the history again after the first new page |
|
460 // is loaded. |
|
461 windowQue->iWindow->SetFirstPage(ETrue); |
|
462 |
|
463 |
|
464 windowQue->iWindow->BrCtlInterface().HandleCommandL( |
|
465 (TInt)TBrCtlDefs::ECommandLoseFocus + (TInt)TBrCtlDefs::ECommandIdBase ); |
|
466 |
|
467 if(windowQue->iWindow->HasWMLContent(EFalse)) |
|
468 { |
|
469 windowQue->iWindow->BrCtlInterface().HandleCommandL( |
|
470 (TInt)TBrCtlDefs::ECommandUnloadWMLEngine + (TInt)TBrCtlDefs::ECommandIdBase ); |
|
471 } |
|
472 |
|
473 // On 3.1 CancelFetch activates the content view for some reason |
|
474 // this section is temporarily flagged out until further |
|
475 // investigation. |
|
476 windowQue->iWindow->BrCtlInterface().HandleCommandL( |
|
477 (TInt)TBrCtlDefs::ECommandCancelFetch + (TInt)TBrCtlDefs::ECommandIdBase ); |
|
478 |
|
479 // if the topmost window is deleted |
|
480 // try to find a new one to be activated |
|
481 if( iCurrentWindow == windowQue ) |
|
482 { |
|
483 CBrowserWindowQue* next = windowQue->Next(); |
|
484 CBrowserWindowQue* prev = windowQue->Prev(); |
|
485 if( next ) |
|
486 { |
|
487 windowToBeActivated = next->iWindow->WindowId(); |
|
488 iCurrentWindow = next; |
|
489 } |
|
490 else if( prev ) |
|
491 { |
|
492 windowToBeActivated = prev->iWindow->WindowId(); |
|
493 iCurrentWindow = prev; |
|
494 } |
|
495 else |
|
496 { |
|
497 windowToBeActivated = 0; |
|
498 } |
|
499 } |
|
500 // else a background window was deleted |
|
501 |
|
502 // last window handling |
|
503 if( WindowCount() == 1 ) |
|
504 { |
|
505 // here we already set the windowToBeActivated to 0 |
|
506 // means CloseContentView or Exit in AppUi |
|
507 |
|
508 // clear all content of Window (images, scripts) |
|
509 |
|
510 // windowQue->iWindow->BrCtlInterface().HandleCommandL( |
|
511 // (TInt)TBrCtlDefs::ECommand + (TInt)TBrCtlDefs::ECommandIdBase ); |
|
512 windowQue->iWindow->BrCtlInterface().HandleCommandL( |
|
513 (TInt)TBrCtlDefs::ECommandUnloadWMLEngine + (TInt)TBrCtlDefs::ECommandIdBase ); |
|
514 |
|
515 //Remove the plugins windows. This is a fix for plugins still plays in the background |
|
516 //while the page is closed. |
|
517 windowQue->iWindow->BrCtlInterface().HandleCommandL( |
|
518 (TInt)TBrCtlDefs::ECommandUnLoadPluginWindows + (TInt)TBrCtlDefs::ECommandIdBase ); |
|
519 |
|
520 iIsContentExist = EFalse; |
|
521 windowQue->iWindow->SetHasWMLContent(EFalse); |
|
522 windowQue->iWindow->SetCurrWinHasWMLContent(EFalse); |
|
523 |
|
524 |
|
525 } |
|
526 // Update MW Indicator |
|
527 else if ( WindowCount() == 2 ) |
|
528 { |
|
529 // sets the window status |
|
530 windowQue->iStatus |= CBrowserWindowQue::EWindowDeleted; |
|
531 windowQue->iWindow->DeactivateL(); |
|
532 // maintain deleted windows' count |
|
533 ++iDeletedWindowCount; |
|
534 |
|
535 if( aUserInitiated ) |
|
536 { |
|
537 DeleteOneWindowL( aWindowId ); |
|
538 } |
|
539 } |
|
540 else |
|
541 { |
|
542 // sets the window status |
|
543 windowQue->iStatus |= CBrowserWindowQue::EWindowDeleted; |
|
544 windowQue->iWindow->DeactivateL(); |
|
545 // maintain deleted windows' count |
|
546 ++iDeletedWindowCount; |
|
547 |
|
548 if( aUserInitiated ) |
|
549 { |
|
550 DeleteOneWindowL( aWindowId ); |
|
551 } |
|
552 } |
|
553 } |
|
554 NotifyObserversL( EWindowClose, aWindowId ); |
|
555 |
|
556 return windowToBeActivated; |
|
557 } |
|
558 |
|
559 // ----------------------------------------------------------------------------- |
|
560 // CBrowserWindowManager::SwitchWindowL() |
|
561 // ----------------------------------------------------------------------------- |
|
562 // |
|
563 TInt CBrowserWindowManager::SwitchWindowL( TInt aWindowId, TBool aDraw ) |
|
564 { |
|
565 LOG_ENTERFN("WindowManager::SwitchWindowL"); |
|
566 CBrowserWindowQue* windowQue = NULL; |
|
567 TBool wdnSwitching = EFalse; |
|
568 TInt error( Window( aWindowId, windowQue, iWindowQueue ) ); |
|
569 BROWSER_LOG( ( _L( "error: %d" ), error ) ); |
|
570 if( windowQue ) |
|
571 { |
|
572 BROWSER_LOG( ( _L( "Switching..." ) ) ); |
|
573 if( windowQue != iCurrentWindow ) |
|
574 { |
|
575 wdnSwitching = ETrue; |
|
576 iCurrentWindow->iWindow->DeactivateL(); |
|
577 iCurrentWindow = windowQue; |
|
578 } |
|
579 //If the history view is up, don't activate the content view unless it is switching the window. Otherwise, |
|
580 //it will overdraw the history view and it will cause serious problems when there |
|
581 //is a background redirection |
|
582 if(!iCurrentWindow->iWindow->IsWindowActive() && (!iContentView->IsHistoryViewUp() || wdnSwitching)) |
|
583 { |
|
584 iCurrentWindow->iWindow->ActivateL( aDraw ); |
|
585 iContentView->UpdateCbaL(); |
|
586 } |
|
587 } |
|
588 return error; |
|
589 } |
|
590 |
|
591 // ----------------------------------------------------------------------------- |
|
592 // CBrowserWindowManager::Window() |
|
593 // ----------------------------------------------------------------------------- |
|
594 // search for a window identified by its Id |
|
595 TInt CBrowserWindowManager::Window( |
|
596 TInt aWindowId, |
|
597 CBrowserWindowQue*& aWindowQue, |
|
598 CBrowserWindowQue* aStartingItem ) const |
|
599 { |
|
600 LOG_ENTERFN("WindowManager::Window( Id )"); |
|
601 TInt error( KErrNotFound ); |
|
602 CBrowserWindowQue *windowQue = aStartingItem; |
|
603 for( ; (error != KErrNone) && (windowQue); windowQue = windowQue->iNext ) |
|
604 { |
|
605 if( windowQue->iWindow->WindowId() == aWindowId ) |
|
606 { |
|
607 error = KErrNone; |
|
608 aWindowQue = windowQue; |
|
609 } |
|
610 } |
|
611 return error; |
|
612 } |
|
613 |
|
614 // ----------------------------------------------------------------------------- |
|
615 // CBrowserWindowManager::Window() |
|
616 // ----------------------------------------------------------------------------- |
|
617 // search for a window identified by TargetName and its Parent |
|
618 TInt CBrowserWindowManager::Window( |
|
619 TInt aParentId, |
|
620 const TDesC* aTargetName, |
|
621 CBrowserWindow*& aWindow, |
|
622 CBrowserWindowQue* aStartingItem ) const |
|
623 { |
|
624 LOG_ENTERFN("WindowManager::Window( Parent, Target )"); |
|
625 TInt error( KErrNotFound ); |
|
626 if( aTargetName && aTargetName->Length() ) // sanity check |
|
627 { |
|
628 CBrowserWindow* window = NULL; |
|
629 CBrowserWindowQue *windowQue = aStartingItem; |
|
630 CBrowserWindowQue* parent = NULL; |
|
631 for( ; (error != KErrNone) && (windowQue); windowQue = windowQue->iNext ) |
|
632 { |
|
633 window = windowQue->iWindow; |
|
634 parent = windowQue->iParent; |
|
635 if( parent && |
|
636 ( parent->iWindow->WindowId() == aParentId ) && |
|
637 ( window->TargetName()->Compare( *aTargetName ) == 0 ) ) |
|
638 { |
|
639 error = KErrNone; |
|
640 aWindow = window; |
|
641 } |
|
642 } |
|
643 } |
|
644 return error; |
|
645 } |
|
646 |
|
647 // ----------------------------------------------------------------------------- |
|
648 // CBrowserWindowManager::DeleteOneWindowL() |
|
649 // ----------------------------------------------------------------------------- |
|
650 // |
|
651 TInt CBrowserWindowManager::DeleteOneWindowL( TInt aWindowId ) |
|
652 { |
|
653 // Last window cannot be deleted, this is not called then. |
|
654 LOG_ENTERFN("WindowManager::DeleteOneWindowL"); |
|
655 CBrowserWindowQue* windowQue = NULL; |
|
656 // find window, error ignored |
|
657 Window( aWindowId, windowQue, iWindowQueue ); |
|
658 if( windowQue ) |
|
659 { |
|
660 // set WindowQueue's first item if required |
|
661 if( iWindowQueue == windowQue ) |
|
662 { |
|
663 iWindowQueue = windowQue->iNext; |
|
664 } |
|
665 |
|
666 // clear children's parent pointer |
|
667 CBrowserWindowQue* queue = iWindowQueue; |
|
668 for( ; queue; queue = queue->iNext ) |
|
669 { |
|
670 if( queue->iParent == windowQue ) |
|
671 { |
|
672 queue->iParent = NULL; |
|
673 } |
|
674 } |
|
675 |
|
676 // decrease WindowCount |
|
677 --iWindowCount; |
|
678 |
|
679 // maintain deleted status |
|
680 if ( windowQue->iStatus & CBrowserWindowQue::EWindowDeleted ) |
|
681 { |
|
682 __ASSERT_DEBUG( iDeletedWindowCount, |
|
683 Util::Panic( Util::EUnExpected )); |
|
684 --iDeletedWindowCount; |
|
685 } |
|
686 // delete window via its windowQue container |
|
687 delete windowQue; |
|
688 } |
|
689 return KErrNone; |
|
690 } |
|
691 |
|
692 // ---------------------------------------------------------------------------- |
|
693 // CBrowserWindowManager::RemoveDeletedWindowsL() |
|
694 // ---------------------------------------------------------------------------- |
|
695 // |
|
696 void CBrowserWindowManager::RemoveDeletedWindowsL() |
|
697 { |
|
698 CBrowserWindowQue *window = iWindowQueue; |
|
699 CBrowserWindowQue *temp = NULL; |
|
700 // walk through all the windows |
|
701 for( ; window; ) |
|
702 { |
|
703 temp = window; |
|
704 window = window->iNext; |
|
705 // if it is set as deleted |
|
706 if( temp->iStatus & CBrowserWindowQue::EWindowDeleted ) |
|
707 { |
|
708 DeleteOneWindowL( temp->iWindow->WindowId() ); |
|
709 } |
|
710 } |
|
711 } |
|
712 |
|
713 // ---------------------------------------------------------------------------- |
|
714 // CBrowserWindowManager::HandlePreferencesChangeL() |
|
715 // ---------------------------------------------------------------------------- |
|
716 // |
|
717 void CBrowserWindowManager::HandlePreferencesChangeL( |
|
718 const TPreferencesEvent aEvent, |
|
719 TPreferencesValues& aValues, |
|
720 TBrCtlDefs::TBrCtlSettings aSettingType ) |
|
721 { |
|
722 LOG_ENTERFN("WindowManager::HandlePreferencesChangeL"); |
|
723 BROWSER_LOG( ( _L( "Preferences event: %d" ), aEvent ) ); |
|
724 switch( aEvent ) |
|
725 { |
|
726 case EPreferencesActivate: |
|
727 { |
|
728 // Topmost Window ONLY |
|
729 if ( iCurrentWindow ) |
|
730 { |
|
731 iCurrentWindow->iWindow->HandlePreferencesChangeL( |
|
732 aEvent, aValues, aSettingType ); |
|
733 } |
|
734 break; |
|
735 } |
|
736 case EPreferencesDeactivate: |
|
737 case EPreferencesItemChange: |
|
738 { |
|
739 // All windows |
|
740 CBrowserWindowQue *windowQue = iWindowQueue; |
|
741 for( ; windowQue; windowQue = windowQue->Next() ) |
|
742 { |
|
743 windowQue->iWindow->HandlePreferencesChangeL( |
|
744 aEvent, aValues, aSettingType ); |
|
745 } |
|
746 break; |
|
747 } |
|
748 default: |
|
749 // don't do anything |
|
750 break; |
|
751 } |
|
752 } |
|
753 |
|
754 // ---------------------------------------------------------------------------- |
|
755 // CBrowserWindowManager::SendCommandToAllWindowsL() |
|
756 // ---------------------------------------------------------------------------- |
|
757 // |
|
758 void CBrowserWindowManager::SendCommandToAllWindowsL( |
|
759 TInt aCommand ) |
|
760 { |
|
761 LOG_ENTERFN("WindowManager::SendCommandToAllWindowsL"); |
|
762 BROWSER_LOG( ( _L( "Command: %d" ), aCommand ) ); |
|
763 |
|
764 CBrowserWindowQue *windowQue = iWindowQueue; |
|
765 for( ; windowQue; windowQue = windowQue->Next() ) |
|
766 { |
|
767 windowQue->iWindow->BrCtlInterface().HandleCommandL(aCommand); |
|
768 } |
|
769 } |
|
770 |
|
771 // ---------------------------------------------------------------------------- |
|
772 // CBrowserWindowManager::SetCurrentWindowViewState() |
|
773 // ---------------------------------------------------------------------------- |
|
774 // |
|
775 void CBrowserWindowManager::SetCurrentWindowViewState(TBrCtlDefs::TBrCtlState aViewState, TInt aValue) |
|
776 { |
|
777 LOG_ENTERFN("WindowManager::SetCurrentWindowViewState"); |
|
778 BROWSER_LOG( ( _L( "State: %d" ), aViewState ) ); |
|
779 |
|
780 TBool val(aValue > 0); |
|
781 if (aViewState == TBrCtlDefs::EStateWmlView) |
|
782 { |
|
783 CurrentWindow()->SetWMLMode(val); // set current page has wml (true or false) |
|
784 if (val) |
|
785 { |
|
786 CurrentWindow()->SetHasWMLContent(ETrue); // at least 1 page in window has/had wml |
|
787 CurrentWindow()->SetCurrWinHasWMLContent(ETrue); // current page has wml content |
|
788 |
|
789 } |
|
790 else |
|
791 { |
|
792 CurrentWindow()->SetCurrWinHasWMLContent(EFalse);// current page isn't wml |
|
793 } |
|
794 } |
|
795 } |
|
796 |
|
797 // ---------------------------------------------------------------------------- |
|
798 // CBrowserWindowManager::CloseAllWindowsExceptCurrent() |
|
799 // ---------------------------------------------------------------------------- |
|
800 // |
|
801 void CBrowserWindowManager::CloseAllWindowsExceptCurrent() |
|
802 { |
|
803 LOG_ENTERFN("WindowManager::CloseAllWindowsExceptCurrent"); |
|
804 CBrowserWindowQue* window = iWindowQueue; |
|
805 for( ; window; window = window->Next() ) |
|
806 { |
|
807 if(iCurrentWindow != window) |
|
808 { |
|
809 DeleteWindowL(window->iWindow->WindowId(), EFalse); |
|
810 } |
|
811 } |
|
812 } |
|
813 // End of file |