1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
3
* The contents of this file are subject to the Mozilla Public
4
* License Version 1.1 (the "License"); you may not use this file
5
* except in compliance with the License. You may obtain a copy of
6
* the License at http://www.mozilla.org/MPL/
8
* Software distributed under the License is distributed on an "AS
9
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
10
* implied. See the License for the specific language governing
11
* rights and limitations under the License.
13
* The Original Code is the Mozilla browser.
15
* The Initial Developer of the Original Code is Netscape
16
* Communications, Inc. Portions created by Netscape are
17
* Copyright (C) 1999, Mozilla. All Rights Reserved.
20
* Conrad Carlen <ccarlen@netscape.com>
23
#include "CBrowserApp.h"
25
#include <PP_Messages.h>
26
#include <PP_Resources.h>
27
#include <UDrawingState.h>
28
#include <UMemoryMgr.h>
29
#include <URegistrar.h>
30
#include <LPushButton.h>
31
#include <LStaticText.h>
32
#include <LIconControl.h>
34
#include <LTextTableView.h>
35
#include <UControlRegistry.h>
36
#include <UGraphicUtils.h>
37
#include <UEnvironment.h>
38
#include <Appearance.h>
39
#include <LCMAttachment.h>
40
#include <UCMMUtils.h>
41
#include <UNavServicesDialogs.h>
44
#include "CBrowserWindow.h"
45
#include "CBrowserShell.h"
46
#include "CBrowserChrome.h"
47
#include "CWindowCreator.h"
48
#include "CUrlField.h"
49
#include "CThrobber.h"
50
#include "CIconServicesIcon.h"
51
#include "CWebBrowserCMAttachment.h"
52
#include "UMacUnicode.h"
53
#include "CAppFileLocationProvider.h"
54
#include "EmbedEventHandling.h"
55
#include "AppComponents.h"
57
#include "nsEmbedAPI.h"
59
#include "nsIComponentRegistrar.h"
60
#include "nsIDirectoryService.h"
61
#include "nsDirectoryServiceDefs.h"
62
#include "nsAppDirectoryServiceDefs.h"
63
#include "nsIObserverService.h"
64
#include "nsObserverService.h"
66
#include "nsRepeater.h"
67
#include "nsILocalFile.h"
68
#include "nsILocalFileMac.h"
69
#include "nsIFileChannel.h"
70
#include "nsXPIDLString.h"
71
#include "nsReadableUtils.h"
72
#include "nsNetUtil.h"
73
#include "nsIWindowWatcher.h"
74
#include "nsIDOMWindow.h"
75
#include "nsIDownload.h"
78
#if defined(__MWERKS__) && !defined(__MACH__)
79
#include "macstdlibextras.h"
83
#include <TextServices.h>
86
#include "CProfileManager.h"
87
#include "nsIProfileChangeStatus.h"
89
#include "nsProfileDirServiceProvider.h"
93
#include "nsIProfileSharingSetup.h"
94
#define kAppDataFolderName NS_LITERAL_STRING("PPEmbed Suite")
96
#define kAppDataFolderName NS_LITERAL_STRING("PPEmbed")
99
// ===========================================================================
101
// ===========================================================================
106
SetDebugThrow_(PP_PowerPlant::debugAction_Alert); // Set Debugging options
107
SetDebugSignal_(PP_PowerPlant::debugAction_Alert);
109
#ifdef POWERPLANT_IS_FRAMEWORK
110
// A framework's Resource Mgr resources must be opened explicitly.
111
CFBundleRef powerplantBundle = ::CFBundleGetBundleWithIdentifier(
112
CFSTR("org.mozilla.PowerPlant"));
113
SInt16 powerPlantResRefNum = -1;
114
if (powerplantBundle) {
115
powerPlantResRefNum = ::CFBundleOpenBundleResourceMap(powerplantBundle);
116
::CFRelease(powerplantBundle);
120
PP_PowerPlant::InitializeHeap(3); // Initialize Memory Manager
121
// Parameter is number of Master Pointer
122
// blocks to allocate
124
PP_PowerPlant::UQDGlobals::InitializeToolbox();
126
#if defined(__MWERKS__) && !TARGET_CARBON
127
::InitializeSIOUX(false);
131
new PP_PowerPlant::LGrowZone(20000); // Install a GrowZone function to catch low memory situations.
132
::InitTSMAwareApplication();
136
CBrowserApp theApp; // create instance of your application
141
::CloseTSMAwareApplication();
148
// ===========================================================================
149
// class CStartupTask
151
// A one-shot repeater which calls the application method to handle startup.
152
// ===========================================================================
154
class CStartUpTask : public LPeriodical
157
CStartUpTask(CBrowserApp *aBrowserApp) :
158
mBrowserApp(aBrowserApp)
165
void SpendTime(const EventRecord& inMacEvent)
168
mBrowserApp->OnStartUp();
172
CBrowserApp *mBrowserApp;
175
// ---------------------------------------------------------------------------
177
// ---------------------------------------------------------------------------
180
CBrowserApp::CBrowserApp()
186
mProfDirServiceProvider = nsnull;
190
InstallCarbonEventHandlers();
193
if ( PP_PowerPlant::UEnvironment::HasFeature( PP_PowerPlant::env_HasAppearance ) ) {
194
::RegisterAppearanceClient();
197
RegisterClass_(PP_PowerPlant::LWindow); // You must register each kind of
198
RegisterClass_(PP_PowerPlant::LCaption); // PowerPlant classes that you use in your PPob resource.
199
RegisterClass_(PP_PowerPlant::LTabGroupView);
200
RegisterClass_(PP_PowerPlant::LIconControl);
201
RegisterClass_(PP_PowerPlant::LView);
202
RegisterClass_(PP_PowerPlant::LDialogBox);
204
// Register the Appearance Manager/GA classes
205
PP_PowerPlant::UControlRegistry::RegisterClasses();
207
// QuickTime is used by CThrobber
208
UQuickTime::Initialize();
210
// Register classes used by embedding
211
RegisterClass_(CBrowserShell);
212
RegisterClass_(CBrowserWindow);
213
RegisterClass_(CUrlField);
214
RegisterClass_(CThrobber);
215
RegisterClass_(CIconServicesIcon);
218
RegisterClass_(LScroller);
219
RegisterClass_(LTextTableView);
220
RegisterClass_(LColorEraseAttachment);
223
// Contexual Menu Support
224
UCMMUtils::Initialize();
225
RegisterClass_(LCMAttachment);
226
RegisterClass_(CWebBrowserCMAttachment);
227
AddAttachment(new LCMAttachment);
231
// Get the directory which contains the mozilla parts
232
// In this case it is the app directory but it could
233
// be anywhere (an existing install of mozilla)
236
ProcessSerialNumber psn;
237
ProcessInfoRec processInfo;
239
nsCOMPtr<nsILocalFileMac> macDir;
241
if (!::GetCurrentProcess(&psn)) {
242
processInfo.processInfoLength = sizeof(processInfo);
243
processInfo.processName = NULL;
244
processInfo.processAppSpec = &appSpec;
245
if (!::GetProcessInformation(&psn, &processInfo)) {
246
// Turn the FSSpec of the app into an FSSpec of the app's directory
247
OSErr err = ::FSMakeFSSpec(appSpec.vRefNum, appSpec.parID, "\p", &appSpec);
248
// Make an nsILocalFile out of it
250
(void)NS_NewLocalFileWithFSSpec(&appSpec, PR_TRUE, getter_AddRefs(macDir));
254
CAppFileLocationProvider *fileLocProvider = new CAppFileLocationProvider(kAppDataFolderName);
255
ThrowIfNil_(fileLocProvider);
257
rv = NS_InitEmbedding(macDir, fileLocProvider);
259
OverrideComponents();
260
CWindowCreator::Initialize();
261
InitializeEmbedEventHandling(this);
264
// ---------------------------------------------------------------------------
266
// ---------------------------------------------------------------------------
270
CBrowserApp::~CBrowserApp()
273
nsCOMPtr<nsIProfile> profileService =
274
do_GetService(NS_PROFILE_CONTRACTID, &rv);
276
profileService->ShutDownCurrentProfile(nsIProfile::SHUTDOWN_PERSIST);
278
if (mProfDirServiceProvider) {
279
mProfDirServiceProvider->Shutdown();
280
NS_RELEASE(mProfDirServiceProvider);
288
CBrowserApp::OverrideComponents()
292
nsCOMPtr<nsIComponentRegistrar> cr;
293
NS_GetComponentRegistrar(getter_AddRefs(cr));
295
return NS_ERROR_FAILURE;
298
const nsModuleComponentInfo* componentInfo = GetAppModuleComponentInfo(&numComponents);
299
for (int i = 0; i < numComponents; ++i) {
300
nsCOMPtr<nsIGenericFactory> componentFactory;
301
rv = NS_NewGenericFactory(getter_AddRefs(componentFactory), &(componentInfo[i]));
303
NS_ASSERTION(PR_FALSE, "Unable to create factory for component");
307
rv = cr->RegisterFactory(componentInfo[i].mCID,
308
componentInfo[i].mDescription,
309
componentInfo[i].mContractID,
311
NS_ASSERTION(NS_SUCCEEDED(rv), "Unable to register factory for component");
318
// ---------------------------------------------------------------------------
320
// ---------------------------------------------------------------------------
323
CBrowserApp::MakeMenuBar()
325
LApplication::MakeMenuBar();
327
// Insert a menu which is not in the menu bar but which contains
328
// items which appear only in contextual menus. We have to do this hack
329
// because LCMAttachment::AddCommand needs a command which is in
330
// some LMenu in order to get the text for a contextual menu item.
332
LMenuBar::GetCurrentMenuBar()->InstallMenu(new LMenu(menu_Buzzwords), hierMenu);
335
// ---------------------------------------------------------------------------
337
// ---------------------------------------------------------------------------
338
// Initializes profile manager or directory service provider. If the user has
339
// chosen to be prompted to choose a profile at startup so the profile dialog
340
// appears and they cancel from that dialog, startup will terminate.
343
CBrowserApp::Initialize()
347
#ifdef SHARED_PROFILE
348
CFBundleRef appBundle = CFBundleGetMainBundle();
349
ThrowIfNil_(appBundle);
351
nsAutoString suiteMemberStr;
352
// We don't get an owning reference here, so no CFRelease.
353
CFStringRef bundleStrRef = (CFStringRef)CFBundleGetValueForInfoDictionaryKey(
354
appBundle, CFSTR("ProfilesSuiteMemberName"));
356
if (bundleStrRef && (CFGetTypeID(bundleStrRef) == CFStringGetTypeID())) {
358
CFIndex strLen = CFStringGetLength(bundleStrRef);
359
ThrowIf_(strLen >= (sizeof(buffer) / sizeof(buffer[0])));
360
CFStringGetCharacters(bundleStrRef, CFRangeMake(0, strLen), buffer);
362
suiteMemberStr.Assign(static_cast<PRUnichar*>(buffer));
364
ThrowIf_(suiteMemberStr.IsEmpty());
366
nsCOMPtr<nsIProfileSharingSetup> sharingSetup =
367
do_GetService("@mozilla.org/embedcomp/profile-sharing-setup;1");
368
ThrowIfNil_(sharingSetup);
369
rv = sharingSetup->EnableSharing(suiteMemberStr);
375
// Register for profile changes
376
nsCOMPtr<nsIObserverService> observerService =
377
do_GetService(NS_OBSERVERSERVICE_CONTRACTID, &rv);
378
ThrowIfNil_(observerService);
379
observerService->AddObserver(this, "profile-approve-change", PR_FALSE);
380
observerService->AddObserver(this, "profile-change-teardown", PR_FALSE);
381
observerService->AddObserver(this, "profile-after-change", PR_FALSE);
383
CProfileManager *profileMgr = new CProfileManager;
384
profileMgr->StartUp();
385
AddAttachment(profileMgr);
389
// If we don't want different user profiles, all that's needed is
390
// to make an nsProfileDirServiceProvider. This will provide the same file
391
// locations as the profile service but always within the specified folder.
393
nsCOMPtr<nsIFile> appDataDir;
394
rv = NS_GetSpecialDirectory(NS_APP_APPLICATION_REGISTRY_DIR, getter_AddRefs(appDataDir));
395
ThrowIfNil_(appDataDir);
397
nsCOMPtr<nsProfileDirServiceProvider> profDirServiceProvider;
398
NS_NewProfileDirServiceProvider(PR_TRUE, getter_AddRefs(profDirServiceProvider));
399
ThrowIfNil_(profDirServiceProvider);
400
rv = profDirServiceProvider->Register();
403
nsCOMPtr<nsILocalFile> localAppDataDir(do_QueryInterface(appDataDir));
404
rv = profDirServiceProvider->SetProfileDir(localAppDataDir);
406
NS_ADDREF(mProfDirServiceProvider = profDirServiceProvider);
409
// Now that we know profile selection wasn't canceled and we're gonna run...
410
CStartUpTask *startupTask = new CStartUpTask(this);
413
// ---------------------------------------------------------------------------
414
// ļæ½ AdjustCursor [public]
415
// ---------------------------------------------------------------------------
417
void CBrowserApp::AdjustCursor(const EventRecord& inMacEvent)
419
// Needed in order to give an attachment to the application a
420
// msg_AdjustCursor. CEmbedEventAttachment needs this.
422
if (ExecuteAttachments(msg_AdjustCursor, (void*) &inMacEvent))
423
LEventDispatcher::AdjustCursor(inMacEvent);
427
// ---------------------------------------------------------------------------
428
// ļæ½ HandleAppleEvent [public]
429
// ---------------------------------------------------------------------------
431
void CBrowserApp::HandleAppleEvent(const AppleEvent& inAppleEvent,
432
AppleEvent& outAEReply,
436
switch (inAENumber) {
442
StAEDescriptor urlDesc;
443
err = ::AEGetParamDesc(&inAppleEvent, keyDirectObject, typeChar, urlDesc);
446
Size dataSize = ::AEGetDescDataSize(urlDesc);
447
StPointerBlock urlPtr(dataSize);
448
err = ::AEGetDescData(urlDesc, urlPtr.Get(), dataSize);
451
const nsACString& urlAsStr = Substring(urlPtr.Get(), urlPtr.Get() + dataSize);
453
// If the URL begins with "view-source:", go with less chrome
454
PRUint32 chromeFlags;
455
NS_NAMED_LITERAL_CSTRING(kViewSourceProto, "view-source:");
456
if (Substring(urlAsStr, 0, kViewSourceProto.Length()).Equals(kViewSourceProto))
457
chromeFlags = nsIWebBrowserChrome::CHROME_WINDOW_CLOSE +
458
nsIWebBrowserChrome::CHROME_WINDOW_RESIZE;
460
chromeFlags = nsIWebBrowserChrome::CHROME_DEFAULT;
462
// See if we have a referrer
463
nsCAutoString referrerAsStr;
464
StAEDescriptor referrerDesc;
465
err = ::AEGetParamDesc(&inAppleEvent, keyGetURLReferrer, typeChar, referrerDesc);
467
dataSize = ::AEGetDescDataSize(referrerDesc);
468
StPointerBlock referrerPtr(dataSize);
469
err = ::AEGetDescData(referrerDesc, referrerPtr.Get(), dataSize);
471
referrerAsStr = Substring(referrerPtr.Get(), referrerPtr.Get() + dataSize);
473
LWindow *theWindow = CWindowCreator::CreateWindowInternal(chromeFlags, PR_TRUE, -1, -1);
474
ThrowIfNil_(theWindow);
475
CBrowserShell *theBrowser = dynamic_cast<CBrowserShell*>(theWindow->FindPaneByID(CBrowserShell::paneID_MainBrowser));
476
ThrowIfNil_(theBrowser);
477
theBrowser->LoadURL(urlAsStr, referrerAsStr);
483
case ae_ApplicationDied: // We get these from opening downloaded files with Stuffit - ignore.
487
LApplication::HandleAppleEvent(inAppleEvent, outAEReply, outResult, inAENumber);
492
// ---------------------------------------------------------------------------
494
// ---------------------------------------------------------------------------
495
// This method lets the application respond to commands like Menu commands
498
CBrowserApp::ObeyCommand(
499
PP_PowerPlant::CommandT inCommand,
502
Boolean cmdHandled = true;
506
case PP_PowerPlant::cmd_About:
509
case PP_PowerPlant::cmd_New:
511
LWindow *theWindow = CWindowCreator::CreateWindowInternal(nsIWebBrowserChrome::CHROME_DEFAULT, PR_TRUE, -1, -1);
512
ThrowIfNil_(theWindow);
513
CBrowserShell *theBrowser = dynamic_cast<CBrowserShell*>(theWindow->FindPaneByID(CBrowserShell::paneID_MainBrowser));
514
ThrowIfNil_(theBrowser);
515
// Just for demo sake, load a URL
516
theBrowser->LoadURL(nsDependentCString("http://www.mozilla.org"));
521
case PP_PowerPlant::cmd_Open:
522
case cmd_OpenDirectory:
525
if (SelectFileObject(inCommand, fileSpec))
528
nsCOMPtr<nsILocalFileMac> macFile;
530
rv = NS_NewLocalFileWithFSSpec(&fileSpec, PR_TRUE, getter_AddRefs(macFile));
531
ThrowIfError_(NS_ERROR_GET_CODE(rv));
533
nsCAutoString urlSpec;
534
rv = NS_GetURLSpecFromFile(macFile, urlSpec);
535
ThrowIfError_(NS_ERROR_GET_CODE(rv));
537
LWindow *theWindow = CWindowCreator::CreateWindowInternal(nsIWebBrowserChrome::CHROME_DEFAULT, PR_TRUE, -1, -1);
538
ThrowIfNil_(theWindow);
539
CBrowserShell *theBrowser = dynamic_cast<CBrowserShell*>(theWindow->FindPaneByID(CBrowserShell::paneID_MainBrowser));
540
ThrowIfNil_(theBrowser);
541
theBrowser->LoadURL(urlSpec);
547
case PP_PowerPlant::cmd_Preferences:
549
nsCOMPtr<nsIWindowWatcher> wwatch(do_GetService("@mozilla.org/embedcomp/window-watcher;1"));
552
// Note: We're not making this window modal even though it looks like a modal
553
// dialog (has OK and Cancel buttons). Reason is, the help window which can
554
// be opened from the prefs dialog is non-modal. If the prefs dialog was modal,
555
// the help window would be stuck behind it in the non-modal layer.
557
// And, since its non-modal, we have to check for an already open prefs window
558
// and just select it rather than making a new one.
559
nsCOMPtr<nsIDOMWindow> extantPrefsWindow;
560
wwatch->GetWindowByName(NS_LITERAL_STRING("_prefs").get(), nsnull, getter_AddRefs(extantPrefsWindow));
561
if (extantPrefsWindow) {
562
// activate the window
563
LWindow *extantPrefsLWindow = CBrowserChrome::GetLWindowForDOMWindow(extantPrefsWindow);
564
ThrowIfNil_(extantPrefsLWindow);
565
extantPrefsLWindow->Select();
568
nsCOMPtr<nsIDOMWindow> domWindow;
569
wwatch->OpenWindow(nsnull,
570
"chrome://communicator/content/pref/pref.xul",
572
"centerscreen,chrome,dialog,titlebar",
574
getter_AddRefs(domWindow));
579
// Any that you don't handle, such as cmd_About and cmd_Quit,
580
// will be passed up to LApplication
582
cmdHandled = PP_PowerPlant::LApplication::ObeyCommand(inCommand, ioParam);
589
// ---------------------------------------------------------------------------
590
// ļæ½ FindCommandStatus
591
// ---------------------------------------------------------------------------
592
// This function enables menu commands.
596
CBrowserApp::FindCommandStatus(
597
PP_PowerPlant::CommandT inCommand,
599
Boolean &outUsesMark,
606
case PP_PowerPlant::cmd_About:
610
case PP_PowerPlant::cmd_New:
614
case PP_PowerPlant::cmd_Open:
615
case cmd_OpenDirectory:
619
case PP_PowerPlant::cmd_Preferences:
623
// Any that you don't handle, such as cmd_About and cmd_Quit,
624
// will be passed up to LApplication
626
PP_PowerPlant::LApplication::FindCommandStatus(inCommand, outEnabled,
627
outUsesMark, outMark, outName);
633
Boolean CBrowserApp::AttemptQuitSelf(SInt32 inSaveOption)
635
// IMPORTANT: This is one unfortunate thing about Powerplant - Windows don't
636
// get destroyed until the destructor of LCommander. We need to delete
637
// all of the CBrowserWindows though before we terminate embedding.
639
TArrayIterator<LCommander*> iterator(mSubCommanders, LArrayIterator::from_End);
641
while (iterator.Previous(theSub)) {
642
if (dynamic_cast<CBrowserWindow*>(theSub)) {
643
mSubCommanders.RemoveItemsAt(1, iterator.GetCurrentIndex());
653
void CBrowserApp::InstallCarbonEventHandlers()
655
EventTypeSpec appEventList[] = {{kEventClassCommand, kEventCommandProcess},
656
{kEventClassCommand, kEventCommandUpdateStatus}};
658
InstallApplicationEventHandler(NewEventHandlerUPP(AppEventHandler), 2, appEventList, this, NULL);
661
pascal OSStatus CBrowserApp::AppEventHandler(EventHandlerCallRef aHandlerChain,
666
OSStatus result = eventNotHandledErr; /* report failure by default */
668
if (::GetEventParameter(event, kEventParamDirectObject,
669
typeHICommand, NULL, sizeof(HICommand),
670
NULL, &command) != noErr)
673
switch (::GetEventKind(event))
675
case kEventCommandProcess:
677
switch (command.commandID)
679
case kHICommandPreferences:
681
CBrowserApp *theApp = reinterpret_cast<CBrowserApp*>(userData);
682
theApp->ObeyCommand(PP_PowerPlant::cmd_Preferences, nsnull);
692
case kEventCommandUpdateStatus:
694
switch (command.commandID)
696
case kHICommandPreferences:
697
::EnableMenuCommand(nsnull, kHICommandPreferences);
712
#endif // TARGET_CARBON
714
nsresult CBrowserApp::InitializePrefs()
717
nsCOMPtr<nsIPrefService> prefs(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
721
// We are using the default prefs from mozilla. If you were
722
// disributing your own, this would be done simply by editing
723
// the default pref files.
724
nsCOMPtr<nsIPrefBranch> branch;
725
rv = prefs->GetBranch(nsnull, getter_AddRefs(branch));
729
const char kVariableFontSizePref[] = "font.size.variable.x-western";
730
const char kFixedFontSizePref[] = "font.size.fixed.x-western";
733
rv = branch->GetIntPref(kVariableFontSizePref, &intValue);
735
branch->SetIntPref(kVariableFontSizePref, 14);
737
rv = branch->GetIntPref(kFixedFontSizePref, &intValue);
739
branch->SetIntPref(kFixedFontSizePref, 13);
744
// ---------------------------------------------------------------------------
745
// CBrowserApp::DoStartUp
747
// Called from CStartUpTask. We must use this INSTEAD of LApplication::StartUp.
748
// Reason is, LApplication::StartUp happens in response to the open application AE
749
// which is processed as soon as we process any events - as in while the profile
750
// manager dialog is up :-/
751
// ---------------------------------------------------------------------------
753
void CBrowserApp::OnStartUp()
755
ObeyCommand(PP_PowerPlant::cmd_New, nil);
758
Boolean CBrowserApp::SelectFileObject(PP_PowerPlant::CommandT inCommand,
761
UNavServicesDialogs::LFileChooser chooser;
763
NavDialogOptions *theDialogOptions = chooser.GetDialogOptions();
764
if (theDialogOptions) {
765
theDialogOptions->dialogOptionFlags |= kNavSelectAllReadableItem;
771
if (inCommand == cmd_OpenDirectory)
773
result = chooser.AskChooseFolder(outSpec, dirID);
777
result = chooser.AskOpenFile(LFileTypeList(fileTypes_All));
779
chooser.GetFileSpec(1, outSpec);
786
// ---------------------------------------------------------------------------
787
// CBrowserApp : nsISupports
788
// ---------------------------------------------------------------------------
790
NS_IMPL_ISUPPORTS2(CBrowserApp, nsIObserver, nsISupportsWeakReference)
792
// ---------------------------------------------------------------------------
793
// CBrowserApp : nsIObserver
794
// ---------------------------------------------------------------------------
796
NS_IMETHODIMP CBrowserApp::Observe(nsISupports *aSubject, const char *aTopic, const PRUnichar *someData)
798
#define CLOSE_WINDOWS_ON_SWITCH 1
802
if (!nsCRT::strcmp(aTopic, "profile-approve-change"))
804
// Ask the user if they want to
805
DialogItemIndex item = UModalAlerts::StopAlert(alrt_ConfirmProfileSwitch);
806
if (item != kStdOkItemIndex)
808
nsCOMPtr<nsIProfileChangeStatus> status = do_QueryInterface(aSubject);
809
NS_ENSURE_TRUE(status, NS_ERROR_FAILURE);
810
status->VetoChange();
813
else if (!nsCRT::strcmp(aTopic, "profile-change-teardown"))
815
// Close all open windows. Alternatively, we could just call CBrowserWindow::Stop()
816
// on each. Either way, we have to stop all network activity on this phase.
818
TArrayIterator<LCommander*> iterator(mSubCommanders, LArrayIterator::from_End);
820
while (iterator.Previous(theSub)) {
821
CBrowserWindow *browserWindow = dynamic_cast<CBrowserWindow*>(theSub);
823
//browserWindow->Stop();
824
mSubCommanders.RemoveItemsAt(1, iterator.GetCurrentIndex());
825
delete browserWindow;
829
else if (!nsCRT::strcmp(aTopic, "profile-after-change"))
833
if (!nsCRT::strcmp(someData, NS_LITERAL_STRING("switch").get())) {
834
// Make a new default window
835
ObeyCommand(PP_PowerPlant::cmd_New, nil);
841
#endif // USE_PROFILES