Teach url dispatch about the referrer field so opening links in a new

tab/window works correctly in all cases (bug 156732)
This commit is contained in:
pinkerton%netscape.com 2002-07-10 21:53:29 +00:00
Родитель a2208d3364
Коммит 6345420667
56 изменённых файлов: 340 добавлений и 346 удалений

Просмотреть файл

@ -396,7 +396,7 @@
content->GetAttr(kNameSpaceID_None, BookmarksService::gHrefAtom, href);
if (!href.IsEmpty()) {
NSString* url = [NSString stringWithCharacters: href.get() length: href.Length()];
[[[mBrowserWindowController getBrowserWrapper] getBrowserView] loadURI: url flags: NSLoadFlagsNone];
[[[mBrowserWindowController getBrowserWrapper] getBrowserView] loadURI: url referrer:nil flags: NSLoadFlagsNone];
// Focus and activate our content area.
[[[mBrowserWindowController getBrowserWrapper] getBrowserView] setActive: YES];
}
@ -682,7 +682,7 @@
PRBool loadInBackground;
pref->GetBoolPref("browser.tabs.loadInBackground", &loadInBackground);
[mBrowserWindowController openNewTabWithURL: hrefStr loadInBackground: loadInBackground];
[mBrowserWindowController openNewTabWithURL: hrefStr referrer:nil loadInBackground: loadInBackground];
}
}
@ -702,7 +702,7 @@
nsAutoString group;
[item contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gGroupAtom, group);
if (group.IsEmpty())
[mBrowserWindowController openNewWindowWithURL: hrefStr loadInBackground: NO];
[mBrowserWindowController openNewWindowWithURL: hrefStr referrer: nil loadInBackground: NO];
else {
nsCOMPtr<nsIDOMElement> elt(do_QueryInterface([item contentNode]));
[mBrowserWindowController openNewWindowWithGroup: elt loadInBackground: NO];

Просмотреть файл

@ -786,7 +786,7 @@ BookmarksService::OpenMenuBookmark(BrowserWindowController* aController, id aMen
NSString* url = [NSString stringWithCharacters: href.get() length: href.Length()];
// Now load the URL in the window.
[aController loadURL:url];
[aController loadURL:url referrer:nil];
// Focus and activate our content area.
[[[aController getBrowserWrapper] getBrowserView] setActive: YES];
@ -1013,7 +1013,7 @@ BookmarksService::OpenBookmarkGroup(id aTabView, nsIDOMElement* aFolder)
else
tabViewItem = [aTabView tabViewItemAtIndex: currentIndex];
[[[tabViewItem view] getBrowserView] loadURI: url
[[[tabViewItem view] getBrowserView] loadURI: url referrer:nil
flags: NSLoadFlagsNone];
}
}

Просмотреть файл

@ -120,7 +120,8 @@ class nsIDOMNode;
NSToolbarItem* mSidebarToolbarItem;
BOOL mInitialized;
NSString* mURL;
NSString* mPendingURL;
NSString* mPendingReferrer;
CHBrowserWrapper* mBrowserView;
@ -155,7 +156,7 @@ class nsIDOMNode;
-(id)getTabBrowser;
-(CHBrowserWrapper*)getBrowserWrapper;
- (void)loadURL:(NSString*)aURLSpec;
- (void)loadURL:(NSString*)aURLSpec referrer:(NSString*)aReferrer;
- (void)updateLocationFields:(NSString *)locationString;
- (void)updateToolbarItems;
- (void)focusURLBar;
@ -209,9 +210,9 @@ class nsIDOMNode;
-(void)enterModalSession;
-(void)openNewWindowWithURL: (NSString*)aURLSpec loadInBackground: (BOOL)aLoadInBG;
-(void)openNewWindowWithURL: (NSString*)aURLSpec referrer:(NSString*)aReferrer loadInBackground: (BOOL)aLoadInBG;
-(void)openNewWindowWithGroup: (nsIDOMElement*)aFolderElement loadInBackground: (BOOL)aLoadInBG;
-(void)openNewTabWithURL: (NSString*)aURLSpec loadInBackground: (BOOL)aLoadInBG;
-(void)openNewTabWithURL: (NSString*)aURLSpec referrer: (NSString*)aReferrer loadInBackground: (BOOL)aLoadInBG;
-(void)autosaveWindowFrame;
-(void)disableAutosave;

Просмотреть файл

@ -273,12 +273,20 @@ static NSArray* sToolbarDefaults = nil;
// We now remove the IB tab, then add one of our own.
[mTabBrowser removeTabViewItem:[mTabBrowser tabViewItemAtIndex:0]];
[self newTab:mShouldLoadHomePage];
if (mURL) {
// create ourselves a new tab and fill it with the appropriate content. If we
// have a URL pending to be opened here, don't load anything in it, otherwise,
// load the homepage if that's what the user wants (or about:blank).
[self newTab:(!mPendingURL && mShouldLoadHomePage)];
// we have a url "pending" from the "open new window with link" command. Deal
// with it now that everything is loaded.
if (mPendingURL) {
if (mShouldLoadHomePage)
[self loadURL: mURL];
[mURL release];
[self loadURL: mPendingURL referrer:mPendingReferrer];
[mPendingURL release];
[mPendingReferrer release];
mPendingURL = mPendingReferrer = nil;
}
[mSidebarDrawer setDelegate: self];
@ -332,7 +340,7 @@ static NSArray* sToolbarDefaults = nil;
- (void)drawerDidOpen:(NSNotification *)aNotification
{
// XXXdwh This is temporary.
// [[mSidebarBrowserView getBrowserView] loadURI: @"http://tinderbox.mozilla.org/SeaMonkey/panel.html" flags:NSLoadFlagsNone];
// [[mSidebarBrowserView getBrowserView] loadURI: @"http://tinderbox.mozilla.org/SeaMonkey/panel.html" referrer: nil flags:NSLoadFlagsNone];
// Toggle the sidebar icon.
if(mSidebarToolbarItem)
@ -346,7 +354,7 @@ static NSArray* sToolbarDefaults = nil;
[mSidebarToolbarItem setImage:[NSImage imageNamed:@"sidebarClosed"]];
// XXXdwh ignore for now.
// [[mSidebarBrowserView getBrowserView] loadURI: @"about:blank" flags:NSLoadFlagsNone];
// [[mSidebarBrowserView getBrowserView] loadURI: @"about:blank" referrer:nil flags:NSLoadFlagsNone];
if (mDrawerCachedFrame) {
mDrawerCachedFrame = NO;
@ -619,7 +627,7 @@ static NSArray* sToolbarDefaults = nil;
{
[mLocationSheetWindow orderOut:self];
[NSApp endSheet:mLocationSheetWindow returnCode:1];
[self loadURL:[mLocationSheetURLField stringValue]];
[self loadURL:[mLocationSheetURLField stringValue] referrer:nil];
// Focus and activate our content area.
[[mBrowserView getBrowserView] setActive: YES];
@ -668,7 +676,7 @@ static NSArray* sToolbarDefaults = nil;
[newView setFrame: NSZeroRect];
[newView setIsBookmarksImport: YES];
[[[self window] contentView] addSubview: newView];
[[newView getBrowserView] loadURI:aURLSpec flags:NSLoadFlagsNone];
[[newView getBrowserView] loadURI:aURLSpec referrer: nil flags:NSLoadFlagsNone];
}
- (IBAction)goToLocationFromToolbarURLField:(id)sender
@ -676,7 +684,7 @@ static NSArray* sToolbarDefaults = nil;
// trim off any whitespace around url
NSMutableString *theURL = [[NSMutableString alloc] initWithString:[sender stringValue]];
CFStringTrimWhitespace((CFMutableStringRef)theURL);
[self loadURL:theURL];
[self loadURL:theURL referrer:nil];
[theURL release];
// Focus and activate our content area.
@ -703,7 +711,7 @@ static NSArray* sToolbarDefaults = nil;
PRBool loadInBackground;
nsCOMPtr<nsIPrefBranch> pref(do_GetService("@mozilla.org/preferences-service;1"));
pref->GetBoolPref("browser.tabs.loadInBackground", &loadInBackground);
[self openNewTabWithURL: viewSource loadInBackground: loadInBackground];
[self openNewTabWithURL: viewSource referrer:nil loadInBackground: loadInBackground];
}
- (void)printDocument
@ -729,7 +737,7 @@ static NSArray* sToolbarDefaults = nil;
searchEngine = @"http://dmoz.org/";
}
[[mBrowserView getBrowserView] loadURI:searchEngine flags:NSLoadFlagsNone];
[[mBrowserView getBrowserView] loadURI:searchEngine referrer: nil flags:NSLoadFlagsNone];
}
@ -771,7 +779,7 @@ static NSArray* sToolbarDefaults = nil;
{
NSString *pageToLoad = NSLocalizedStringFromTable(@"ThrobberPageDefault", @"WebsiteDefaults", nil);
if (![pageToLoad isEqualToString:@"ThrobberPageDefault"])
[self loadURL:pageToLoad];
[self loadURL:pageToLoad referrer:nil];
}
- (void)startThrobber
@ -859,7 +867,7 @@ static NSArray* sToolbarDefaults = nil;
- (IBAction)home:(id)aSender
{
[[mBrowserView getBrowserView] loadURI:[[CHPreferenceManager sharedInstance] homePage:NO] flags:NSLoadFlagsNone];
[[mBrowserView getBrowserView] loadURI:[[CHPreferenceManager sharedInstance] homePage:NO] referrer: nil flags:NSLoadFlagsNone];
}
- (IBAction)toggleSidebar:(id)aSender
@ -877,14 +885,18 @@ static NSArray* sToolbarDefaults = nil;
[[self window] makeFirstResponder: resp];
}
-(void)loadURL:(NSString*)aURLSpec
-(void)loadURL:(NSString*)aURLSpec referrer:(NSString*)aReferrer
{
if (mInitialized) {
[[mBrowserView getBrowserView] loadURI:aURLSpec flags:NSLoadFlagsNone];
[[mBrowserView getBrowserView] loadURI:aURLSpec referrer:aReferrer flags:NSLoadFlagsNone];
}
else {
mURL = aURLSpec;
[mURL retain];
// we haven't yet initialized all the browser machinery, stash the url and referrer
// until we're ready in windowDidLoad:
mPendingURL = aURLSpec;
[mPendingURL retain];
mPendingReferrer = aReferrer;
[mPendingReferrer retain];
}
}
@ -923,7 +935,7 @@ static NSArray* sToolbarDefaults = nil;
[mTabBrowser addTabViewItem: newTab];
if (allowHomepage)
[[newView getBrowserView] loadURI: ((newTabPage == 1) ? [[CHPreferenceManager sharedInstance] homePage: NO] : @"about:blank") flags:NSLoadFlagsNone];
[[newView getBrowserView] loadURI: ((newTabPage == 1) ? [[CHPreferenceManager sharedInstance] homePage: NO] : @"about:blank") referrer:nil flags:NSLoadFlagsNone];
[mTabBrowser selectLastTabViewItem: self];
@ -990,13 +1002,13 @@ static NSArray* sToolbarDefaults = nil;
return mBrowserView;
}
-(void)openNewWindowWithURL: (NSString*)aURLSpec loadInBackground: (BOOL)aLoadInBG
-(void)openNewWindowWithURL: (NSString*)aURLSpec referrer: (NSString*)aReferrer loadInBackground: (BOOL)aLoadInBG
{
// Autosave our dimensions before we open a new window. That ensures the size ends up matching.
[self autosaveWindowFrame];
BrowserWindowController* browser = [[BrowserWindowController alloc] initWithWindowNibName: @"BrowserWindow"];
[browser loadURL: aURLSpec];
[browser loadURL: aURLSpec referrer:aReferrer];
if (aLoadInBG)
[[browser window] orderWindow: NSWindowBelow relativeTo: [[self window] windowNumber]];
else {
@ -1025,7 +1037,7 @@ static NSArray* sToolbarDefaults = nil;
[mSidebarBookmarksDataSource openBookmarkGroup: tabBrowser groupElement: aFolderElement];
}
-(void)openNewTabWithURL: (NSString*)aURLSpec loadInBackground: (BOOL)aLoadInBG
-(void)openNewTabWithURL: (NSString*)aURLSpec referrer:(NSString*)aReferrer loadInBackground: (BOOL)aLoadInBG
{
NSTabViewItem* newTab = [[[NSTabViewItem alloc] initWithIdentifier: nil] autorelease];
@ -1039,7 +1051,7 @@ static NSArray* sToolbarDefaults = nil;
[newTab setLabel: NSLocalizedString(@"TabLoading", @"")];
[newTab setView: newView];
[[newView getBrowserView] loadURI:aURLSpec flags:NSLoadFlagsNone];
[[newView getBrowserView] loadURI:aURLSpec referrer:aReferrer flags:NSLoadFlagsNone];
if (!aLoadInBG) {
[mTabBrowser selectTabViewItem: newTab];
@ -1257,10 +1269,12 @@ static NSArray* sToolbarDefaults = nil;
PRBool loadInBackground;
pref->GetBoolPref("browser.tabs.loadInBackground", &loadInBackground);
NSString* referrer = [[mBrowserView getBrowserView] getFocusedURLString];
if (aUseWindow)
[self openNewWindowWithURL: hrefStr loadInBackground: loadInBackground];
[self openNewWindowWithURL: hrefStr referrer:referrer loadInBackground: loadInBackground];
else
[self openNewTabWithURL: hrefStr loadInBackground: loadInBackground];
[self openNewTabWithURL: hrefStr referrer:referrer loadInBackground: loadInBackground];
}
- (IBAction)savePageAs:(id)aSender
@ -1330,8 +1344,9 @@ static NSArray* sToolbarDefaults = nil;
imgElement->GetSrc(url);
NSString* urlStr = [NSString stringWithCharacters: url.get() length:nsCRT::strlen(url.get())];
[self loadURL: urlStr];
NSString* referrer = [[mBrowserView getBrowserView] getFocusedURLString];
[self loadURL: urlStr referrer:referrer];
// Focus and activate our content area.
[[mBrowserView getBrowserView] setActive: YES];

Просмотреть файл

@ -63,7 +63,7 @@
NSString* url = [NSString stringWithCString: cref.get()];
// Now load the URL in the window.
[[[self window] windowController] loadURL: url];
[[[self window] windowController] loadURL: url referrer:nil];
// Focus and activate our content area.
[[[[[self window] windowController] getBrowserWrapper] getBrowserView] setActive: YES];

Просмотреть файл

@ -126,7 +126,7 @@ enum {
- (nsIDOMWindow*)getContentWindow;
// nsIWebNavigation methods
- (void)loadURI:(NSString *)urlSpec flags:(unsigned int)flags;
- (void)loadURI:(NSString *)urlSpec referrer:(NSString*)referrer flags:(unsigned int)flags;
- (void)reload:(unsigned int)flags;
- (BOOL)canGoBack;
- (BOOL)canGoForward;

Просмотреть файл

@ -1042,7 +1042,7 @@ nsHeaderSniffer::OnSecurityChange(nsIWebProgress *aWebProgress, nsIRequest *aReq
return window;
}
- (void)loadURI:(NSString *)urlSpec flags:(unsigned int)flags
- (void)loadURI:(NSString *)urlSpec referrer:(NSString*)referrer flags:(unsigned int)flags
{
nsCOMPtr<nsIWebNavigation> nav = do_QueryInterface(_webBrowser);
@ -1051,6 +1051,9 @@ nsHeaderSniffer::OnSecurityChange(nsIWebProgress *aWebProgress, nsIRequest *aReq
[urlSpec getCharacters:specStr];
specStr[length] = PRUnichar(0);
nsCOMPtr<nsIURI> referrerURI;
if ( referrer )
NS_NewURI(getter_AddRefs(referrerURI), [referrer cString]);
PRUint32 navFlags = nsIWebNavigation::LOAD_FLAGS_NONE;
if (flags & NSLoadFlagsDontPutInHistory) {
@ -1064,7 +1067,7 @@ nsHeaderSniffer::OnSecurityChange(nsIWebProgress *aWebProgress, nsIRequest *aReq
nsIWebNavigation::LOAD_FLAGS_BYPASS_PROXY;
}
nsresult rv = nav->LoadURI(specStr, navFlags, nsnull, nsnull, nsnull);
nsresult rv = nav->LoadURI(specStr, navFlags, referrerURI, nsnull, nsnull);
if (NS_FAILED(rv)) {
// XXX need to throw
}

Просмотреть файл

@ -85,7 +85,7 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
- (IBAction)load:(id)sender
{
[mBrowserView loadURI:[urlbar stringValue] flags:NSLoadFlagsNone];
[mBrowserView loadURI:[urlbar stringValue] referrer:nil flags:NSLoadFlagsNone];
}
-(void)disconnectView

Просмотреть файл

@ -30,6 +30,6 @@
- (BOOL)autoHides;
- (void)setAutoHides:(BOOL)newSetting;
-(void)addTabForURL:(NSString*)aURL;
-(void)addTabForURL:(NSString*)aURL referrer:(NSString*)aReferrer;
@end

Просмотреть файл

@ -135,11 +135,11 @@
- (void)handleDropOnTab:(NSTabViewItem*)overTabViewItem overContent:(BOOL)overContentArea withURL:(NSString*)url
{
if (overTabViewItem) {
[[[overTabViewItem view] getBrowserView] loadURI: url flags: NSLoadFlagsNone];
[[[overTabViewItem view] getBrowserView] loadURI: url referrer:nil flags: NSLoadFlagsNone];
} else if (overContentArea) {
[[[[self selectedTabViewItem] view] getBrowserView] loadURI: url flags: NSLoadFlagsNone];
[[[[self selectedTabViewItem] view] getBrowserView] loadURI: url referrer:nil flags: NSLoadFlagsNone];
} else
[self addTabForURL:url];
[self addTabForURL:url referrer:nil];
}
// NSDraggingDestination ///////////
@ -222,7 +222,7 @@
return YES;
}
-(void)addTabForURL:(NSString*)aURL
-(void)addTabForURL:(NSString*)aURL referrer:(NSString*)aReferrer
{
NSTabViewItem* tabViewItem;
CHBrowserWrapper* newView;
@ -234,7 +234,7 @@
[tabViewItem setView: newView];
[self addTabViewItem: tabViewItem];
[[[tabViewItem view] getBrowserView] loadURI: aURL
[[[tabViewItem view] getBrowserView] loadURI: aURL referrer:aReferrer
flags: NSLoadFlagsNone];
}

Просмотреть файл

@ -1,41 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is the Mozilla browser.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1999 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* David Hyatt <hyatt@netscape.com> (Original Author)
*/
#import "CHGetURLCommand.h"
#import <AppKit/AppKit.h>
#import "BrowserWindowController.h"
#include "nsIPref.h"
#include "nsCOMPtr.h"
#include "nsIServiceManagerUtils.h"
@implementation CHGetURLCommand
- (id)performDefaultImplementation
{
[[NSApp delegate] openNewWindowOrTabWithURL:[self directParameter]];
return nil;
}
@end

Просмотреть файл

@ -148,7 +148,7 @@
valueLiteral->GetValue(getter_Copies(literalValue));
NSString* url = [NSString stringWithCharacters: literalValue.get() length: literalValue.Length()];
[[[mBrowserWindowController getBrowserWrapper] getBrowserView] loadURI: url flags: NSLoadFlagsNone];
[[[mBrowserWindowController getBrowserWrapper] getBrowserView] loadURI: url referrer: nil flags: NSLoadFlagsNone];
// Focus and activate our content area.
[[[mBrowserWindowController getBrowserWrapper] getBrowserView] setActive: YES];
}

Просмотреть файл

@ -300,12 +300,14 @@ ContentClickListener::MouseClick(nsIDOMEvent* aEvent)
pref->GetBoolPref("browser.tabs.opentabfor.middleclick", &useTab);
PRBool loadInBackground;
pref->GetBoolPref("browser.tabs.loadInBackground", &loadInBackground);
NSString* referrer = [[[mBrowserController getBrowserWrapper] getBrowserView] getFocusedURLString];
if (shiftKey)
loadInBackground = !loadInBackground;
if (useTab)
[mBrowserController openNewTabWithURL: hrefStr loadInBackground: loadInBackground];
[mBrowserController openNewTabWithURL: hrefStr referrer:referrer loadInBackground: loadInBackground];
else
[mBrowserController openNewWindowWithURL: hrefStr loadInBackground: loadInBackground];
[mBrowserController openNewWindowWithURL: hrefStr referrer:referrer loadInBackground: loadInBackground];
}
else if (altKey) {
// The user wants to save this link.

Просмотреть файл

@ -124,8 +124,8 @@ class BookmarksService;
//Help menu actions
-(IBAction) feedbackLink:(id)aSender;
-(BrowserWindowController*)openBrowserWindowWithURL: (NSString*)aURL;
- (void)openNewWindowOrTabWithURL:(NSString*)inURLString;
-(BrowserWindowController*)openBrowserWindowWithURL: (NSString*)aURL andReferrer: (NSString*)aReferrer;
- (void)openNewWindowOrTabWithURL:(NSString*)inURLString andReferrer:(NSString*)aReferrer;
- (void)adjustCloseWindowMenuItemKeyEquivalent:(BOOL)inHaveTabs;
- (void)adjustCloseTabMenuItemKeyEquivalent:(BOOL)inHaveTabs;

Просмотреть файл

@ -160,7 +160,7 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
// Now open the new window.
NSString* homePage = mStartURL ? mStartURL : [mPreferenceManager homePage:YES];
BrowserWindowController* controller = [self openBrowserWindowWithURL:homePage];
BrowserWindowController* controller = [self openBrowserWindowWithURL:homePage andReferrer:nil];
if ([homePage isEqualToString: @"about:blank"])
[controller focusURLBar];
@ -215,11 +215,11 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
// ----------------------
NSWindow* mainWindow = [mApplication mainWindow];
if (mainWindow) {
[[mainWindow windowController] loadURL:[url absoluteString]];
[[mainWindow windowController] loadURL:[url absoluteString] referrer:nil];
[[[[mainWindow windowController] getBrowserWrapper] getBrowserView] setActive: YES];
}
else
[self openBrowserWindowWithURL:[url absoluteString]];
[self openBrowserWindowWithURL:[url absoluteString] andReferrer:nil];
}
}
@ -227,7 +227,7 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
{
NSWindow* mainWindow = [mApplication mainWindow];
if (!mainWindow) {
[self openBrowserWindowWithURL: @"about:blank"];
[self openBrowserWindowWithURL: @"about:blank" andReferrer:nil];
mainWindow = [mApplication mainWindow];
}
@ -357,16 +357,16 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
}
// open a new URL. This method always makes a new browser window
-(BrowserWindowController*)openBrowserWindowWithURL: (NSString*)aURL
-(BrowserWindowController*)openBrowserWindowWithURL: (NSString*)aURL andReferrer: (NSString*)aReferrer
{
BrowserWindowController* browser = [[BrowserWindowController alloc] initWithWindowNibName: @"BrowserWindow"];
[browser loadURL: aURL];
[browser loadURL: aURL referrer:aReferrer];
[browser showWindow: self];
return browser;
}
// open a new URL, observing the prefs on how to behave
- (void)openNewWindowOrTabWithURL:(NSString*)inURLString
- (void)openNewWindowOrTabWithURL:(NSString*)inURLString andReferrer: (NSString*)aReferrer
{
// make sure we're initted
[self preferenceManager];
@ -388,12 +388,12 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
NSWindow* browserWindow = [self getFrontmostBrowserWindow];
if (reuseWindow && browserWindow) {
controller = [browserWindow windowController];
[controller openNewTabWithURL:inURLString loadInBackground:loadInBackground];
[controller openNewTabWithURL:inURLString referrer:aReferrer loadInBackground:loadInBackground];
}
else {
// should use BrowserWindowController openNewWindowWithURL, but that method
// really needs to be on the MainController
controller = [self openBrowserWindowWithURL: inURLString];
controller = [self openBrowserWindowWithURL: inURLString andReferrer:aReferrer];
}
[[[controller getBrowserWrapper] getBrowserView] setActive: YES];
@ -472,7 +472,7 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
{
NSWindow* mainWind = [mApplication mainWindow];
if (!mainWind) {
[self openBrowserWindowWithURL: @"about:blank"];
[self openBrowserWindowWithURL: @"about:blank" andReferrer:nil];
mainWind = [mApplication mainWindow];
}
@ -483,7 +483,7 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
{
NSWindow* mainWindow = [mApplication mainWindow];
if (!mainWindow) {
[self openBrowserWindowWithURL: @"about:blank"];
[self openBrowserWindowWithURL: @"about:blank" andReferrer:nil];
mainWindow = [mApplication mainWindow];
}
@ -531,7 +531,7 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
[self openBrowserWindowWithURL:[[NSURL fileURLWithPath:filename] absoluteString]];
}
*/
[self openNewWindowOrTabWithURL:[[NSURL fileURLWithPath:filename] absoluteString]];
[self openNewWindowOrTabWithURL:[[NSURL fileURLWithPath:filename] absoluteString] andReferrer:nil];
return YES;
}
@ -677,7 +677,7 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
{
NSWindow* mainWindow = [mApplication mainWindow];
if (!mainWindow) {
[self openBrowserWindowWithURL: @"about:blank"];
[self openBrowserWindowWithURL: @"about:blank" andReferrer:nil];
mainWindow = [mApplication mainWindow];
}
@ -695,7 +695,7 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
{
NSString *pageToLoad = NSLocalizedStringFromTable(@"FeedbackPageDefault", @"WebsiteDefaults", nil);
if (![pageToLoad isEqualToString:@"FeedbackPageDefault"])
[self openNewWindowOrTabWithURL:pageToLoad];
[self openNewWindowOrTabWithURL:pageToLoad andReferrer:nil];
}
+ (NSImage*)createImageForDragging:(NSImage*)aIcon title:(NSString*)aTitle
@ -809,7 +809,7 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
[urlString appendString:tmpString];
}
[self openBrowserWindowWithURL:urlString];
[self openBrowserWindowWithURL:urlString andReferrer:nil];
}
@end

Просмотреть файл

@ -24,17 +24,13 @@
#import "CHGetURLCommand.h"
#import <AppKit/AppKit.h>
#import "BrowserWindowController.h"
#include "nsIPref.h"
#include "nsCOMPtr.h"
#include "nsIServiceManagerUtils.h"
#import "MainController.h"
@implementation CHGetURLCommand
- (id)performDefaultImplementation
{
[[NSApp delegate] openNewWindowOrTabWithURL:[self directParameter]];
[(MainController*)[NSApp delegate] openNewWindowOrTabWithURL:[self directParameter] andReferrer:nil];
return nil;
}

Просмотреть файл

@ -124,8 +124,8 @@ class BookmarksService;
//Help menu actions
-(IBAction) feedbackLink:(id)aSender;
-(BrowserWindowController*)openBrowserWindowWithURL: (NSString*)aURL;
- (void)openNewWindowOrTabWithURL:(NSString*)inURLString;
-(BrowserWindowController*)openBrowserWindowWithURL: (NSString*)aURL andReferrer: (NSString*)aReferrer;
- (void)openNewWindowOrTabWithURL:(NSString*)inURLString andReferrer:(NSString*)aReferrer;
- (void)adjustCloseWindowMenuItemKeyEquivalent:(BOOL)inHaveTabs;
- (void)adjustCloseTabMenuItemKeyEquivalent:(BOOL)inHaveTabs;

Просмотреть файл

@ -160,7 +160,7 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
// Now open the new window.
NSString* homePage = mStartURL ? mStartURL : [mPreferenceManager homePage:YES];
BrowserWindowController* controller = [self openBrowserWindowWithURL:homePage];
BrowserWindowController* controller = [self openBrowserWindowWithURL:homePage andReferrer:nil];
if ([homePage isEqualToString: @"about:blank"])
[controller focusURLBar];
@ -215,11 +215,11 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
// ----------------------
NSWindow* mainWindow = [mApplication mainWindow];
if (mainWindow) {
[[mainWindow windowController] loadURL:[url absoluteString]];
[[mainWindow windowController] loadURL:[url absoluteString] referrer:nil];
[[[[mainWindow windowController] getBrowserWrapper] getBrowserView] setActive: YES];
}
else
[self openBrowserWindowWithURL:[url absoluteString]];
[self openBrowserWindowWithURL:[url absoluteString] andReferrer:nil];
}
}
@ -227,7 +227,7 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
{
NSWindow* mainWindow = [mApplication mainWindow];
if (!mainWindow) {
[self openBrowserWindowWithURL: @"about:blank"];
[self openBrowserWindowWithURL: @"about:blank" andReferrer:nil];
mainWindow = [mApplication mainWindow];
}
@ -357,16 +357,16 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
}
// open a new URL. This method always makes a new browser window
-(BrowserWindowController*)openBrowserWindowWithURL: (NSString*)aURL
-(BrowserWindowController*)openBrowserWindowWithURL: (NSString*)aURL andReferrer: (NSString*)aReferrer
{
BrowserWindowController* browser = [[BrowserWindowController alloc] initWithWindowNibName: @"BrowserWindow"];
[browser loadURL: aURL];
[browser loadURL: aURL referrer:aReferrer];
[browser showWindow: self];
return browser;
}
// open a new URL, observing the prefs on how to behave
- (void)openNewWindowOrTabWithURL:(NSString*)inURLString
- (void)openNewWindowOrTabWithURL:(NSString*)inURLString andReferrer: (NSString*)aReferrer
{
// make sure we're initted
[self preferenceManager];
@ -388,12 +388,12 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
NSWindow* browserWindow = [self getFrontmostBrowserWindow];
if (reuseWindow && browserWindow) {
controller = [browserWindow windowController];
[controller openNewTabWithURL:inURLString loadInBackground:loadInBackground];
[controller openNewTabWithURL:inURLString referrer:aReferrer loadInBackground:loadInBackground];
}
else {
// should use BrowserWindowController openNewWindowWithURL, but that method
// really needs to be on the MainController
controller = [self openBrowserWindowWithURL: inURLString];
controller = [self openBrowserWindowWithURL: inURLString andReferrer:aReferrer];
}
[[[controller getBrowserWrapper] getBrowserView] setActive: YES];
@ -472,7 +472,7 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
{
NSWindow* mainWind = [mApplication mainWindow];
if (!mainWind) {
[self openBrowserWindowWithURL: @"about:blank"];
[self openBrowserWindowWithURL: @"about:blank" andReferrer:nil];
mainWind = [mApplication mainWindow];
}
@ -483,7 +483,7 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
{
NSWindow* mainWindow = [mApplication mainWindow];
if (!mainWindow) {
[self openBrowserWindowWithURL: @"about:blank"];
[self openBrowserWindowWithURL: @"about:blank" andReferrer:nil];
mainWindow = [mApplication mainWindow];
}
@ -531,7 +531,7 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
[self openBrowserWindowWithURL:[[NSURL fileURLWithPath:filename] absoluteString]];
}
*/
[self openNewWindowOrTabWithURL:[[NSURL fileURLWithPath:filename] absoluteString]];
[self openNewWindowOrTabWithURL:[[NSURL fileURLWithPath:filename] absoluteString] andReferrer:nil];
return YES;
}
@ -677,7 +677,7 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
{
NSWindow* mainWindow = [mApplication mainWindow];
if (!mainWindow) {
[self openBrowserWindowWithURL: @"about:blank"];
[self openBrowserWindowWithURL: @"about:blank" andReferrer:nil];
mainWindow = [mApplication mainWindow];
}
@ -695,7 +695,7 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
{
NSString *pageToLoad = NSLocalizedStringFromTable(@"FeedbackPageDefault", @"WebsiteDefaults", nil);
if (![pageToLoad isEqualToString:@"FeedbackPageDefault"])
[self openNewWindowOrTabWithURL:pageToLoad];
[self openNewWindowOrTabWithURL:pageToLoad andReferrer:nil];
}
+ (NSImage*)createImageForDragging:(NSImage*)aIcon title:(NSString*)aTitle
@ -809,7 +809,7 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
[urlString appendString:tmpString];
}
[self openBrowserWindowWithURL:urlString];
[self openBrowserWindowWithURL:urlString andReferrer:nil];
}
@end

Просмотреть файл

@ -63,7 +63,7 @@
NSString* url = [NSString stringWithCString: cref.get()];
// Now load the URL in the window.
[[[self window] windowController] loadURL: url];
[[[self window] windowController] loadURL: url referrer:nil];
// Focus and activate our content area.
[[[[[self window] windowController] getBrowserWrapper] getBrowserView] setActive: YES];

Просмотреть файл

@ -396,7 +396,7 @@
content->GetAttr(kNameSpaceID_None, BookmarksService::gHrefAtom, href);
if (!href.IsEmpty()) {
NSString* url = [NSString stringWithCharacters: href.get() length: href.Length()];
[[[mBrowserWindowController getBrowserWrapper] getBrowserView] loadURI: url flags: NSLoadFlagsNone];
[[[mBrowserWindowController getBrowserWrapper] getBrowserView] loadURI: url referrer:nil flags: NSLoadFlagsNone];
// Focus and activate our content area.
[[[mBrowserWindowController getBrowserWrapper] getBrowserView] setActive: YES];
}
@ -682,7 +682,7 @@
PRBool loadInBackground;
pref->GetBoolPref("browser.tabs.loadInBackground", &loadInBackground);
[mBrowserWindowController openNewTabWithURL: hrefStr loadInBackground: loadInBackground];
[mBrowserWindowController openNewTabWithURL: hrefStr referrer:nil loadInBackground: loadInBackground];
}
}
@ -702,7 +702,7 @@
nsAutoString group;
[item contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gGroupAtom, group);
if (group.IsEmpty())
[mBrowserWindowController openNewWindowWithURL: hrefStr loadInBackground: NO];
[mBrowserWindowController openNewWindowWithURL: hrefStr referrer: nil loadInBackground: NO];
else {
nsCOMPtr<nsIDOMElement> elt(do_QueryInterface([item contentNode]));
[mBrowserWindowController openNewWindowWithGroup: elt loadInBackground: NO];

Просмотреть файл

@ -786,7 +786,7 @@ BookmarksService::OpenMenuBookmark(BrowserWindowController* aController, id aMen
NSString* url = [NSString stringWithCharacters: href.get() length: href.Length()];
// Now load the URL in the window.
[aController loadURL:url];
[aController loadURL:url referrer:nil];
// Focus and activate our content area.
[[[aController getBrowserWrapper] getBrowserView] setActive: YES];
@ -1013,7 +1013,7 @@ BookmarksService::OpenBookmarkGroup(id aTabView, nsIDOMElement* aFolder)
else
tabViewItem = [aTabView tabViewItemAtIndex: currentIndex];
[[[tabViewItem view] getBrowserView] loadURI: url
[[[tabViewItem view] getBrowserView] loadURI: url referrer:nil
flags: NSLoadFlagsNone];
}
}

Просмотреть файл

@ -120,7 +120,8 @@ class nsIDOMNode;
NSToolbarItem* mSidebarToolbarItem;
BOOL mInitialized;
NSString* mURL;
NSString* mPendingURL;
NSString* mPendingReferrer;
CHBrowserWrapper* mBrowserView;
@ -155,7 +156,7 @@ class nsIDOMNode;
-(id)getTabBrowser;
-(CHBrowserWrapper*)getBrowserWrapper;
- (void)loadURL:(NSString*)aURLSpec;
- (void)loadURL:(NSString*)aURLSpec referrer:(NSString*)aReferrer;
- (void)updateLocationFields:(NSString *)locationString;
- (void)updateToolbarItems;
- (void)focusURLBar;
@ -209,9 +210,9 @@ class nsIDOMNode;
-(void)enterModalSession;
-(void)openNewWindowWithURL: (NSString*)aURLSpec loadInBackground: (BOOL)aLoadInBG;
-(void)openNewWindowWithURL: (NSString*)aURLSpec referrer:(NSString*)aReferrer loadInBackground: (BOOL)aLoadInBG;
-(void)openNewWindowWithGroup: (nsIDOMElement*)aFolderElement loadInBackground: (BOOL)aLoadInBG;
-(void)openNewTabWithURL: (NSString*)aURLSpec loadInBackground: (BOOL)aLoadInBG;
-(void)openNewTabWithURL: (NSString*)aURLSpec referrer: (NSString*)aReferrer loadInBackground: (BOOL)aLoadInBG;
-(void)autosaveWindowFrame;
-(void)disableAutosave;

Просмотреть файл

@ -273,12 +273,20 @@ static NSArray* sToolbarDefaults = nil;
// We now remove the IB tab, then add one of our own.
[mTabBrowser removeTabViewItem:[mTabBrowser tabViewItemAtIndex:0]];
[self newTab:mShouldLoadHomePage];
if (mURL) {
// create ourselves a new tab and fill it with the appropriate content. If we
// have a URL pending to be opened here, don't load anything in it, otherwise,
// load the homepage if that's what the user wants (or about:blank).
[self newTab:(!mPendingURL && mShouldLoadHomePage)];
// we have a url "pending" from the "open new window with link" command. Deal
// with it now that everything is loaded.
if (mPendingURL) {
if (mShouldLoadHomePage)
[self loadURL: mURL];
[mURL release];
[self loadURL: mPendingURL referrer:mPendingReferrer];
[mPendingURL release];
[mPendingReferrer release];
mPendingURL = mPendingReferrer = nil;
}
[mSidebarDrawer setDelegate: self];
@ -332,7 +340,7 @@ static NSArray* sToolbarDefaults = nil;
- (void)drawerDidOpen:(NSNotification *)aNotification
{
// XXXdwh This is temporary.
// [[mSidebarBrowserView getBrowserView] loadURI: @"http://tinderbox.mozilla.org/SeaMonkey/panel.html" flags:NSLoadFlagsNone];
// [[mSidebarBrowserView getBrowserView] loadURI: @"http://tinderbox.mozilla.org/SeaMonkey/panel.html" referrer: nil flags:NSLoadFlagsNone];
// Toggle the sidebar icon.
if(mSidebarToolbarItem)
@ -346,7 +354,7 @@ static NSArray* sToolbarDefaults = nil;
[mSidebarToolbarItem setImage:[NSImage imageNamed:@"sidebarClosed"]];
// XXXdwh ignore for now.
// [[mSidebarBrowserView getBrowserView] loadURI: @"about:blank" flags:NSLoadFlagsNone];
// [[mSidebarBrowserView getBrowserView] loadURI: @"about:blank" referrer:nil flags:NSLoadFlagsNone];
if (mDrawerCachedFrame) {
mDrawerCachedFrame = NO;
@ -619,7 +627,7 @@ static NSArray* sToolbarDefaults = nil;
{
[mLocationSheetWindow orderOut:self];
[NSApp endSheet:mLocationSheetWindow returnCode:1];
[self loadURL:[mLocationSheetURLField stringValue]];
[self loadURL:[mLocationSheetURLField stringValue] referrer:nil];
// Focus and activate our content area.
[[mBrowserView getBrowserView] setActive: YES];
@ -668,7 +676,7 @@ static NSArray* sToolbarDefaults = nil;
[newView setFrame: NSZeroRect];
[newView setIsBookmarksImport: YES];
[[[self window] contentView] addSubview: newView];
[[newView getBrowserView] loadURI:aURLSpec flags:NSLoadFlagsNone];
[[newView getBrowserView] loadURI:aURLSpec referrer: nil flags:NSLoadFlagsNone];
}
- (IBAction)goToLocationFromToolbarURLField:(id)sender
@ -676,7 +684,7 @@ static NSArray* sToolbarDefaults = nil;
// trim off any whitespace around url
NSMutableString *theURL = [[NSMutableString alloc] initWithString:[sender stringValue]];
CFStringTrimWhitespace((CFMutableStringRef)theURL);
[self loadURL:theURL];
[self loadURL:theURL referrer:nil];
[theURL release];
// Focus and activate our content area.
@ -703,7 +711,7 @@ static NSArray* sToolbarDefaults = nil;
PRBool loadInBackground;
nsCOMPtr<nsIPrefBranch> pref(do_GetService("@mozilla.org/preferences-service;1"));
pref->GetBoolPref("browser.tabs.loadInBackground", &loadInBackground);
[self openNewTabWithURL: viewSource loadInBackground: loadInBackground];
[self openNewTabWithURL: viewSource referrer:nil loadInBackground: loadInBackground];
}
- (void)printDocument
@ -729,7 +737,7 @@ static NSArray* sToolbarDefaults = nil;
searchEngine = @"http://dmoz.org/";
}
[[mBrowserView getBrowserView] loadURI:searchEngine flags:NSLoadFlagsNone];
[[mBrowserView getBrowserView] loadURI:searchEngine referrer: nil flags:NSLoadFlagsNone];
}
@ -771,7 +779,7 @@ static NSArray* sToolbarDefaults = nil;
{
NSString *pageToLoad = NSLocalizedStringFromTable(@"ThrobberPageDefault", @"WebsiteDefaults", nil);
if (![pageToLoad isEqualToString:@"ThrobberPageDefault"])
[self loadURL:pageToLoad];
[self loadURL:pageToLoad referrer:nil];
}
- (void)startThrobber
@ -859,7 +867,7 @@ static NSArray* sToolbarDefaults = nil;
- (IBAction)home:(id)aSender
{
[[mBrowserView getBrowserView] loadURI:[[CHPreferenceManager sharedInstance] homePage:NO] flags:NSLoadFlagsNone];
[[mBrowserView getBrowserView] loadURI:[[CHPreferenceManager sharedInstance] homePage:NO] referrer: nil flags:NSLoadFlagsNone];
}
- (IBAction)toggleSidebar:(id)aSender
@ -877,14 +885,18 @@ static NSArray* sToolbarDefaults = nil;
[[self window] makeFirstResponder: resp];
}
-(void)loadURL:(NSString*)aURLSpec
-(void)loadURL:(NSString*)aURLSpec referrer:(NSString*)aReferrer
{
if (mInitialized) {
[[mBrowserView getBrowserView] loadURI:aURLSpec flags:NSLoadFlagsNone];
[[mBrowserView getBrowserView] loadURI:aURLSpec referrer:aReferrer flags:NSLoadFlagsNone];
}
else {
mURL = aURLSpec;
[mURL retain];
// we haven't yet initialized all the browser machinery, stash the url and referrer
// until we're ready in windowDidLoad:
mPendingURL = aURLSpec;
[mPendingURL retain];
mPendingReferrer = aReferrer;
[mPendingReferrer retain];
}
}
@ -923,7 +935,7 @@ static NSArray* sToolbarDefaults = nil;
[mTabBrowser addTabViewItem: newTab];
if (allowHomepage)
[[newView getBrowserView] loadURI: ((newTabPage == 1) ? [[CHPreferenceManager sharedInstance] homePage: NO] : @"about:blank") flags:NSLoadFlagsNone];
[[newView getBrowserView] loadURI: ((newTabPage == 1) ? [[CHPreferenceManager sharedInstance] homePage: NO] : @"about:blank") referrer:nil flags:NSLoadFlagsNone];
[mTabBrowser selectLastTabViewItem: self];
@ -990,13 +1002,13 @@ static NSArray* sToolbarDefaults = nil;
return mBrowserView;
}
-(void)openNewWindowWithURL: (NSString*)aURLSpec loadInBackground: (BOOL)aLoadInBG
-(void)openNewWindowWithURL: (NSString*)aURLSpec referrer: (NSString*)aReferrer loadInBackground: (BOOL)aLoadInBG
{
// Autosave our dimensions before we open a new window. That ensures the size ends up matching.
[self autosaveWindowFrame];
BrowserWindowController* browser = [[BrowserWindowController alloc] initWithWindowNibName: @"BrowserWindow"];
[browser loadURL: aURLSpec];
[browser loadURL: aURLSpec referrer:aReferrer];
if (aLoadInBG)
[[browser window] orderWindow: NSWindowBelow relativeTo: [[self window] windowNumber]];
else {
@ -1025,7 +1037,7 @@ static NSArray* sToolbarDefaults = nil;
[mSidebarBookmarksDataSource openBookmarkGroup: tabBrowser groupElement: aFolderElement];
}
-(void)openNewTabWithURL: (NSString*)aURLSpec loadInBackground: (BOOL)aLoadInBG
-(void)openNewTabWithURL: (NSString*)aURLSpec referrer:(NSString*)aReferrer loadInBackground: (BOOL)aLoadInBG
{
NSTabViewItem* newTab = [[[NSTabViewItem alloc] initWithIdentifier: nil] autorelease];
@ -1039,7 +1051,7 @@ static NSArray* sToolbarDefaults = nil;
[newTab setLabel: NSLocalizedString(@"TabLoading", @"")];
[newTab setView: newView];
[[newView getBrowserView] loadURI:aURLSpec flags:NSLoadFlagsNone];
[[newView getBrowserView] loadURI:aURLSpec referrer:aReferrer flags:NSLoadFlagsNone];
if (!aLoadInBG) {
[mTabBrowser selectTabViewItem: newTab];
@ -1257,10 +1269,12 @@ static NSArray* sToolbarDefaults = nil;
PRBool loadInBackground;
pref->GetBoolPref("browser.tabs.loadInBackground", &loadInBackground);
NSString* referrer = [[mBrowserView getBrowserView] getFocusedURLString];
if (aUseWindow)
[self openNewWindowWithURL: hrefStr loadInBackground: loadInBackground];
[self openNewWindowWithURL: hrefStr referrer:referrer loadInBackground: loadInBackground];
else
[self openNewTabWithURL: hrefStr loadInBackground: loadInBackground];
[self openNewTabWithURL: hrefStr referrer:referrer loadInBackground: loadInBackground];
}
- (IBAction)savePageAs:(id)aSender
@ -1330,8 +1344,9 @@ static NSArray* sToolbarDefaults = nil;
imgElement->GetSrc(url);
NSString* urlStr = [NSString stringWithCharacters: url.get() length:nsCRT::strlen(url.get())];
[self loadURL: urlStr];
NSString* referrer = [[mBrowserView getBrowserView] getFocusedURLString];
[self loadURL: urlStr referrer:referrer];
// Focus and activate our content area.
[[mBrowserView getBrowserView] setActive: YES];

Просмотреть файл

@ -85,7 +85,7 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
- (IBAction)load:(id)sender
{
[mBrowserView loadURI:[urlbar stringValue] flags:NSLoadFlagsNone];
[mBrowserView loadURI:[urlbar stringValue] referrer:nil flags:NSLoadFlagsNone];
}
-(void)disconnectView

Просмотреть файл

@ -300,12 +300,14 @@ ContentClickListener::MouseClick(nsIDOMEvent* aEvent)
pref->GetBoolPref("browser.tabs.opentabfor.middleclick", &useTab);
PRBool loadInBackground;
pref->GetBoolPref("browser.tabs.loadInBackground", &loadInBackground);
NSString* referrer = [[[mBrowserController getBrowserWrapper] getBrowserView] getFocusedURLString];
if (shiftKey)
loadInBackground = !loadInBackground;
if (useTab)
[mBrowserController openNewTabWithURL: hrefStr loadInBackground: loadInBackground];
[mBrowserController openNewTabWithURL: hrefStr referrer:referrer loadInBackground: loadInBackground];
else
[mBrowserController openNewWindowWithURL: hrefStr loadInBackground: loadInBackground];
[mBrowserController openNewWindowWithURL: hrefStr referrer:referrer loadInBackground: loadInBackground];
}
else if (altKey) {
// The user wants to save this link.

Просмотреть файл

@ -126,7 +126,7 @@ enum {
- (nsIDOMWindow*)getContentWindow;
// nsIWebNavigation methods
- (void)loadURI:(NSString *)urlSpec flags:(unsigned int)flags;
- (void)loadURI:(NSString *)urlSpec referrer:(NSString*)referrer flags:(unsigned int)flags;
- (void)reload:(unsigned int)flags;
- (BOOL)canGoBack;
- (BOOL)canGoForward;

Просмотреть файл

@ -1042,7 +1042,7 @@ nsHeaderSniffer::OnSecurityChange(nsIWebProgress *aWebProgress, nsIRequest *aReq
return window;
}
- (void)loadURI:(NSString *)urlSpec flags:(unsigned int)flags
- (void)loadURI:(NSString *)urlSpec referrer:(NSString*)referrer flags:(unsigned int)flags
{
nsCOMPtr<nsIWebNavigation> nav = do_QueryInterface(_webBrowser);
@ -1051,6 +1051,9 @@ nsHeaderSniffer::OnSecurityChange(nsIWebProgress *aWebProgress, nsIRequest *aReq
[urlSpec getCharacters:specStr];
specStr[length] = PRUnichar(0);
nsCOMPtr<nsIURI> referrerURI;
if ( referrer )
NS_NewURI(getter_AddRefs(referrerURI), [referrer cString]);
PRUint32 navFlags = nsIWebNavigation::LOAD_FLAGS_NONE;
if (flags & NSLoadFlagsDontPutInHistory) {
@ -1064,7 +1067,7 @@ nsHeaderSniffer::OnSecurityChange(nsIWebProgress *aWebProgress, nsIRequest *aReq
nsIWebNavigation::LOAD_FLAGS_BYPASS_PROXY;
}
nsresult rv = nav->LoadURI(specStr, navFlags, nsnull, nsnull, nsnull);
nsresult rv = nav->LoadURI(specStr, navFlags, referrerURI, nsnull, nsnull);
if (NS_FAILED(rv)) {
// XXX need to throw
}

Просмотреть файл

@ -148,7 +148,7 @@
valueLiteral->GetValue(getter_Copies(literalValue));
NSString* url = [NSString stringWithCharacters: literalValue.get() length: literalValue.Length()];
[[[mBrowserWindowController getBrowserWrapper] getBrowserView] loadURI: url flags: NSLoadFlagsNone];
[[[mBrowserWindowController getBrowserWrapper] getBrowserView] loadURI: url referrer: nil flags: NSLoadFlagsNone];
// Focus and activate our content area.
[[[mBrowserWindowController getBrowserWrapper] getBrowserView] setActive: YES];
}

Просмотреть файл

@ -396,7 +396,7 @@
content->GetAttr(kNameSpaceID_None, BookmarksService::gHrefAtom, href);
if (!href.IsEmpty()) {
NSString* url = [NSString stringWithCharacters: href.get() length: href.Length()];
[[[mBrowserWindowController getBrowserWrapper] getBrowserView] loadURI: url flags: NSLoadFlagsNone];
[[[mBrowserWindowController getBrowserWrapper] getBrowserView] loadURI: url referrer:nil flags: NSLoadFlagsNone];
// Focus and activate our content area.
[[[mBrowserWindowController getBrowserWrapper] getBrowserView] setActive: YES];
}
@ -682,7 +682,7 @@
PRBool loadInBackground;
pref->GetBoolPref("browser.tabs.loadInBackground", &loadInBackground);
[mBrowserWindowController openNewTabWithURL: hrefStr loadInBackground: loadInBackground];
[mBrowserWindowController openNewTabWithURL: hrefStr referrer:nil loadInBackground: loadInBackground];
}
}
@ -702,7 +702,7 @@
nsAutoString group;
[item contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gGroupAtom, group);
if (group.IsEmpty())
[mBrowserWindowController openNewWindowWithURL: hrefStr loadInBackground: NO];
[mBrowserWindowController openNewWindowWithURL: hrefStr referrer: nil loadInBackground: NO];
else {
nsCOMPtr<nsIDOMElement> elt(do_QueryInterface([item contentNode]));
[mBrowserWindowController openNewWindowWithGroup: elt loadInBackground: NO];

Просмотреть файл

@ -786,7 +786,7 @@ BookmarksService::OpenMenuBookmark(BrowserWindowController* aController, id aMen
NSString* url = [NSString stringWithCharacters: href.get() length: href.Length()];
// Now load the URL in the window.
[aController loadURL:url];
[aController loadURL:url referrer:nil];
// Focus and activate our content area.
[[[aController getBrowserWrapper] getBrowserView] setActive: YES];
@ -1013,7 +1013,7 @@ BookmarksService::OpenBookmarkGroup(id aTabView, nsIDOMElement* aFolder)
else
tabViewItem = [aTabView tabViewItemAtIndex: currentIndex];
[[[tabViewItem view] getBrowserView] loadURI: url
[[[tabViewItem view] getBrowserView] loadURI: url referrer:nil
flags: NSLoadFlagsNone];
}
}

Просмотреть файл

@ -120,7 +120,8 @@ class nsIDOMNode;
NSToolbarItem* mSidebarToolbarItem;
BOOL mInitialized;
NSString* mURL;
NSString* mPendingURL;
NSString* mPendingReferrer;
CHBrowserWrapper* mBrowserView;
@ -155,7 +156,7 @@ class nsIDOMNode;
-(id)getTabBrowser;
-(CHBrowserWrapper*)getBrowserWrapper;
- (void)loadURL:(NSString*)aURLSpec;
- (void)loadURL:(NSString*)aURLSpec referrer:(NSString*)aReferrer;
- (void)updateLocationFields:(NSString *)locationString;
- (void)updateToolbarItems;
- (void)focusURLBar;
@ -209,9 +210,9 @@ class nsIDOMNode;
-(void)enterModalSession;
-(void)openNewWindowWithURL: (NSString*)aURLSpec loadInBackground: (BOOL)aLoadInBG;
-(void)openNewWindowWithURL: (NSString*)aURLSpec referrer:(NSString*)aReferrer loadInBackground: (BOOL)aLoadInBG;
-(void)openNewWindowWithGroup: (nsIDOMElement*)aFolderElement loadInBackground: (BOOL)aLoadInBG;
-(void)openNewTabWithURL: (NSString*)aURLSpec loadInBackground: (BOOL)aLoadInBG;
-(void)openNewTabWithURL: (NSString*)aURLSpec referrer: (NSString*)aReferrer loadInBackground: (BOOL)aLoadInBG;
-(void)autosaveWindowFrame;
-(void)disableAutosave;

Просмотреть файл

@ -273,12 +273,20 @@ static NSArray* sToolbarDefaults = nil;
// We now remove the IB tab, then add one of our own.
[mTabBrowser removeTabViewItem:[mTabBrowser tabViewItemAtIndex:0]];
[self newTab:mShouldLoadHomePage];
if (mURL) {
// create ourselves a new tab and fill it with the appropriate content. If we
// have a URL pending to be opened here, don't load anything in it, otherwise,
// load the homepage if that's what the user wants (or about:blank).
[self newTab:(!mPendingURL && mShouldLoadHomePage)];
// we have a url "pending" from the "open new window with link" command. Deal
// with it now that everything is loaded.
if (mPendingURL) {
if (mShouldLoadHomePage)
[self loadURL: mURL];
[mURL release];
[self loadURL: mPendingURL referrer:mPendingReferrer];
[mPendingURL release];
[mPendingReferrer release];
mPendingURL = mPendingReferrer = nil;
}
[mSidebarDrawer setDelegate: self];
@ -332,7 +340,7 @@ static NSArray* sToolbarDefaults = nil;
- (void)drawerDidOpen:(NSNotification *)aNotification
{
// XXXdwh This is temporary.
// [[mSidebarBrowserView getBrowserView] loadURI: @"http://tinderbox.mozilla.org/SeaMonkey/panel.html" flags:NSLoadFlagsNone];
// [[mSidebarBrowserView getBrowserView] loadURI: @"http://tinderbox.mozilla.org/SeaMonkey/panel.html" referrer: nil flags:NSLoadFlagsNone];
// Toggle the sidebar icon.
if(mSidebarToolbarItem)
@ -346,7 +354,7 @@ static NSArray* sToolbarDefaults = nil;
[mSidebarToolbarItem setImage:[NSImage imageNamed:@"sidebarClosed"]];
// XXXdwh ignore for now.
// [[mSidebarBrowserView getBrowserView] loadURI: @"about:blank" flags:NSLoadFlagsNone];
// [[mSidebarBrowserView getBrowserView] loadURI: @"about:blank" referrer:nil flags:NSLoadFlagsNone];
if (mDrawerCachedFrame) {
mDrawerCachedFrame = NO;
@ -619,7 +627,7 @@ static NSArray* sToolbarDefaults = nil;
{
[mLocationSheetWindow orderOut:self];
[NSApp endSheet:mLocationSheetWindow returnCode:1];
[self loadURL:[mLocationSheetURLField stringValue]];
[self loadURL:[mLocationSheetURLField stringValue] referrer:nil];
// Focus and activate our content area.
[[mBrowserView getBrowserView] setActive: YES];
@ -668,7 +676,7 @@ static NSArray* sToolbarDefaults = nil;
[newView setFrame: NSZeroRect];
[newView setIsBookmarksImport: YES];
[[[self window] contentView] addSubview: newView];
[[newView getBrowserView] loadURI:aURLSpec flags:NSLoadFlagsNone];
[[newView getBrowserView] loadURI:aURLSpec referrer: nil flags:NSLoadFlagsNone];
}
- (IBAction)goToLocationFromToolbarURLField:(id)sender
@ -676,7 +684,7 @@ static NSArray* sToolbarDefaults = nil;
// trim off any whitespace around url
NSMutableString *theURL = [[NSMutableString alloc] initWithString:[sender stringValue]];
CFStringTrimWhitespace((CFMutableStringRef)theURL);
[self loadURL:theURL];
[self loadURL:theURL referrer:nil];
[theURL release];
// Focus and activate our content area.
@ -703,7 +711,7 @@ static NSArray* sToolbarDefaults = nil;
PRBool loadInBackground;
nsCOMPtr<nsIPrefBranch> pref(do_GetService("@mozilla.org/preferences-service;1"));
pref->GetBoolPref("browser.tabs.loadInBackground", &loadInBackground);
[self openNewTabWithURL: viewSource loadInBackground: loadInBackground];
[self openNewTabWithURL: viewSource referrer:nil loadInBackground: loadInBackground];
}
- (void)printDocument
@ -729,7 +737,7 @@ static NSArray* sToolbarDefaults = nil;
searchEngine = @"http://dmoz.org/";
}
[[mBrowserView getBrowserView] loadURI:searchEngine flags:NSLoadFlagsNone];
[[mBrowserView getBrowserView] loadURI:searchEngine referrer: nil flags:NSLoadFlagsNone];
}
@ -771,7 +779,7 @@ static NSArray* sToolbarDefaults = nil;
{
NSString *pageToLoad = NSLocalizedStringFromTable(@"ThrobberPageDefault", @"WebsiteDefaults", nil);
if (![pageToLoad isEqualToString:@"ThrobberPageDefault"])
[self loadURL:pageToLoad];
[self loadURL:pageToLoad referrer:nil];
}
- (void)startThrobber
@ -859,7 +867,7 @@ static NSArray* sToolbarDefaults = nil;
- (IBAction)home:(id)aSender
{
[[mBrowserView getBrowserView] loadURI:[[CHPreferenceManager sharedInstance] homePage:NO] flags:NSLoadFlagsNone];
[[mBrowserView getBrowserView] loadURI:[[CHPreferenceManager sharedInstance] homePage:NO] referrer: nil flags:NSLoadFlagsNone];
}
- (IBAction)toggleSidebar:(id)aSender
@ -877,14 +885,18 @@ static NSArray* sToolbarDefaults = nil;
[[self window] makeFirstResponder: resp];
}
-(void)loadURL:(NSString*)aURLSpec
-(void)loadURL:(NSString*)aURLSpec referrer:(NSString*)aReferrer
{
if (mInitialized) {
[[mBrowserView getBrowserView] loadURI:aURLSpec flags:NSLoadFlagsNone];
[[mBrowserView getBrowserView] loadURI:aURLSpec referrer:aReferrer flags:NSLoadFlagsNone];
}
else {
mURL = aURLSpec;
[mURL retain];
// we haven't yet initialized all the browser machinery, stash the url and referrer
// until we're ready in windowDidLoad:
mPendingURL = aURLSpec;
[mPendingURL retain];
mPendingReferrer = aReferrer;
[mPendingReferrer retain];
}
}
@ -923,7 +935,7 @@ static NSArray* sToolbarDefaults = nil;
[mTabBrowser addTabViewItem: newTab];
if (allowHomepage)
[[newView getBrowserView] loadURI: ((newTabPage == 1) ? [[CHPreferenceManager sharedInstance] homePage: NO] : @"about:blank") flags:NSLoadFlagsNone];
[[newView getBrowserView] loadURI: ((newTabPage == 1) ? [[CHPreferenceManager sharedInstance] homePage: NO] : @"about:blank") referrer:nil flags:NSLoadFlagsNone];
[mTabBrowser selectLastTabViewItem: self];
@ -990,13 +1002,13 @@ static NSArray* sToolbarDefaults = nil;
return mBrowserView;
}
-(void)openNewWindowWithURL: (NSString*)aURLSpec loadInBackground: (BOOL)aLoadInBG
-(void)openNewWindowWithURL: (NSString*)aURLSpec referrer: (NSString*)aReferrer loadInBackground: (BOOL)aLoadInBG
{
// Autosave our dimensions before we open a new window. That ensures the size ends up matching.
[self autosaveWindowFrame];
BrowserWindowController* browser = [[BrowserWindowController alloc] initWithWindowNibName: @"BrowserWindow"];
[browser loadURL: aURLSpec];
[browser loadURL: aURLSpec referrer:aReferrer];
if (aLoadInBG)
[[browser window] orderWindow: NSWindowBelow relativeTo: [[self window] windowNumber]];
else {
@ -1025,7 +1037,7 @@ static NSArray* sToolbarDefaults = nil;
[mSidebarBookmarksDataSource openBookmarkGroup: tabBrowser groupElement: aFolderElement];
}
-(void)openNewTabWithURL: (NSString*)aURLSpec loadInBackground: (BOOL)aLoadInBG
-(void)openNewTabWithURL: (NSString*)aURLSpec referrer:(NSString*)aReferrer loadInBackground: (BOOL)aLoadInBG
{
NSTabViewItem* newTab = [[[NSTabViewItem alloc] initWithIdentifier: nil] autorelease];
@ -1039,7 +1051,7 @@ static NSArray* sToolbarDefaults = nil;
[newTab setLabel: NSLocalizedString(@"TabLoading", @"")];
[newTab setView: newView];
[[newView getBrowserView] loadURI:aURLSpec flags:NSLoadFlagsNone];
[[newView getBrowserView] loadURI:aURLSpec referrer:aReferrer flags:NSLoadFlagsNone];
if (!aLoadInBG) {
[mTabBrowser selectTabViewItem: newTab];
@ -1257,10 +1269,12 @@ static NSArray* sToolbarDefaults = nil;
PRBool loadInBackground;
pref->GetBoolPref("browser.tabs.loadInBackground", &loadInBackground);
NSString* referrer = [[mBrowserView getBrowserView] getFocusedURLString];
if (aUseWindow)
[self openNewWindowWithURL: hrefStr loadInBackground: loadInBackground];
[self openNewWindowWithURL: hrefStr referrer:referrer loadInBackground: loadInBackground];
else
[self openNewTabWithURL: hrefStr loadInBackground: loadInBackground];
[self openNewTabWithURL: hrefStr referrer:referrer loadInBackground: loadInBackground];
}
- (IBAction)savePageAs:(id)aSender
@ -1330,8 +1344,9 @@ static NSArray* sToolbarDefaults = nil;
imgElement->GetSrc(url);
NSString* urlStr = [NSString stringWithCharacters: url.get() length:nsCRT::strlen(url.get())];
[self loadURL: urlStr];
NSString* referrer = [[mBrowserView getBrowserView] getFocusedURLString];
[self loadURL: urlStr referrer:referrer];
// Focus and activate our content area.
[[mBrowserView getBrowserView] setActive: YES];

Просмотреть файл

@ -63,7 +63,7 @@
NSString* url = [NSString stringWithCString: cref.get()];
// Now load the URL in the window.
[[[self window] windowController] loadURL: url];
[[[self window] windowController] loadURL: url referrer:nil];
// Focus and activate our content area.
[[[[[self window] windowController] getBrowserWrapper] getBrowserView] setActive: YES];

Просмотреть файл

@ -126,7 +126,7 @@ enum {
- (nsIDOMWindow*)getContentWindow;
// nsIWebNavigation methods
- (void)loadURI:(NSString *)urlSpec flags:(unsigned int)flags;
- (void)loadURI:(NSString *)urlSpec referrer:(NSString*)referrer flags:(unsigned int)flags;
- (void)reload:(unsigned int)flags;
- (BOOL)canGoBack;
- (BOOL)canGoForward;

Просмотреть файл

@ -1042,7 +1042,7 @@ nsHeaderSniffer::OnSecurityChange(nsIWebProgress *aWebProgress, nsIRequest *aReq
return window;
}
- (void)loadURI:(NSString *)urlSpec flags:(unsigned int)flags
- (void)loadURI:(NSString *)urlSpec referrer:(NSString*)referrer flags:(unsigned int)flags
{
nsCOMPtr<nsIWebNavigation> nav = do_QueryInterface(_webBrowser);
@ -1051,6 +1051,9 @@ nsHeaderSniffer::OnSecurityChange(nsIWebProgress *aWebProgress, nsIRequest *aReq
[urlSpec getCharacters:specStr];
specStr[length] = PRUnichar(0);
nsCOMPtr<nsIURI> referrerURI;
if ( referrer )
NS_NewURI(getter_AddRefs(referrerURI), [referrer cString]);
PRUint32 navFlags = nsIWebNavigation::LOAD_FLAGS_NONE;
if (flags & NSLoadFlagsDontPutInHistory) {
@ -1064,7 +1067,7 @@ nsHeaderSniffer::OnSecurityChange(nsIWebProgress *aWebProgress, nsIRequest *aReq
nsIWebNavigation::LOAD_FLAGS_BYPASS_PROXY;
}
nsresult rv = nav->LoadURI(specStr, navFlags, nsnull, nsnull, nsnull);
nsresult rv = nav->LoadURI(specStr, navFlags, referrerURI, nsnull, nsnull);
if (NS_FAILED(rv)) {
// XXX need to throw
}

Просмотреть файл

@ -85,7 +85,7 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
- (IBAction)load:(id)sender
{
[mBrowserView loadURI:[urlbar stringValue] flags:NSLoadFlagsNone];
[mBrowserView loadURI:[urlbar stringValue] referrer:nil flags:NSLoadFlagsNone];
}
-(void)disconnectView

Просмотреть файл

@ -30,6 +30,6 @@
- (BOOL)autoHides;
- (void)setAutoHides:(BOOL)newSetting;
-(void)addTabForURL:(NSString*)aURL;
-(void)addTabForURL:(NSString*)aURL referrer:(NSString*)aReferrer;
@end

Просмотреть файл

@ -135,11 +135,11 @@
- (void)handleDropOnTab:(NSTabViewItem*)overTabViewItem overContent:(BOOL)overContentArea withURL:(NSString*)url
{
if (overTabViewItem) {
[[[overTabViewItem view] getBrowserView] loadURI: url flags: NSLoadFlagsNone];
[[[overTabViewItem view] getBrowserView] loadURI: url referrer:nil flags: NSLoadFlagsNone];
} else if (overContentArea) {
[[[[self selectedTabViewItem] view] getBrowserView] loadURI: url flags: NSLoadFlagsNone];
[[[[self selectedTabViewItem] view] getBrowserView] loadURI: url referrer:nil flags: NSLoadFlagsNone];
} else
[self addTabForURL:url];
[self addTabForURL:url referrer:nil];
}
// NSDraggingDestination ///////////
@ -222,7 +222,7 @@
return YES;
}
-(void)addTabForURL:(NSString*)aURL
-(void)addTabForURL:(NSString*)aURL referrer:(NSString*)aReferrer
{
NSTabViewItem* tabViewItem;
CHBrowserWrapper* newView;
@ -234,7 +234,7 @@
[tabViewItem setView: newView];
[self addTabViewItem: tabViewItem];
[[[tabViewItem view] getBrowserView] loadURI: aURL
[[[tabViewItem view] getBrowserView] loadURI: aURL referrer:aReferrer
flags: NSLoadFlagsNone];
}

Просмотреть файл

@ -1,41 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is the Mozilla browser.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1999 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* David Hyatt <hyatt@netscape.com> (Original Author)
*/
#import "CHGetURLCommand.h"
#import <AppKit/AppKit.h>
#import "BrowserWindowController.h"
#include "nsIPref.h"
#include "nsCOMPtr.h"
#include "nsIServiceManagerUtils.h"
@implementation CHGetURLCommand
- (id)performDefaultImplementation
{
[[NSApp delegate] openNewWindowOrTabWithURL:[self directParameter]];
return nil;
}
@end

Просмотреть файл

@ -148,7 +148,7 @@
valueLiteral->GetValue(getter_Copies(literalValue));
NSString* url = [NSString stringWithCharacters: literalValue.get() length: literalValue.Length()];
[[[mBrowserWindowController getBrowserWrapper] getBrowserView] loadURI: url flags: NSLoadFlagsNone];
[[[mBrowserWindowController getBrowserWrapper] getBrowserView] loadURI: url referrer: nil flags: NSLoadFlagsNone];
// Focus and activate our content area.
[[[mBrowserWindowController getBrowserWrapper] getBrowserView] setActive: YES];
}

Просмотреть файл

@ -300,12 +300,14 @@ ContentClickListener::MouseClick(nsIDOMEvent* aEvent)
pref->GetBoolPref("browser.tabs.opentabfor.middleclick", &useTab);
PRBool loadInBackground;
pref->GetBoolPref("browser.tabs.loadInBackground", &loadInBackground);
NSString* referrer = [[[mBrowserController getBrowserWrapper] getBrowserView] getFocusedURLString];
if (shiftKey)
loadInBackground = !loadInBackground;
if (useTab)
[mBrowserController openNewTabWithURL: hrefStr loadInBackground: loadInBackground];
[mBrowserController openNewTabWithURL: hrefStr referrer:referrer loadInBackground: loadInBackground];
else
[mBrowserController openNewWindowWithURL: hrefStr loadInBackground: loadInBackground];
[mBrowserController openNewWindowWithURL: hrefStr referrer:referrer loadInBackground: loadInBackground];
}
else if (altKey) {
// The user wants to save this link.

Просмотреть файл

@ -124,8 +124,8 @@ class BookmarksService;
//Help menu actions
-(IBAction) feedbackLink:(id)aSender;
-(BrowserWindowController*)openBrowserWindowWithURL: (NSString*)aURL;
- (void)openNewWindowOrTabWithURL:(NSString*)inURLString;
-(BrowserWindowController*)openBrowserWindowWithURL: (NSString*)aURL andReferrer: (NSString*)aReferrer;
- (void)openNewWindowOrTabWithURL:(NSString*)inURLString andReferrer:(NSString*)aReferrer;
- (void)adjustCloseWindowMenuItemKeyEquivalent:(BOOL)inHaveTabs;
- (void)adjustCloseTabMenuItemKeyEquivalent:(BOOL)inHaveTabs;

Просмотреть файл

@ -160,7 +160,7 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
// Now open the new window.
NSString* homePage = mStartURL ? mStartURL : [mPreferenceManager homePage:YES];
BrowserWindowController* controller = [self openBrowserWindowWithURL:homePage];
BrowserWindowController* controller = [self openBrowserWindowWithURL:homePage andReferrer:nil];
if ([homePage isEqualToString: @"about:blank"])
[controller focusURLBar];
@ -215,11 +215,11 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
// ----------------------
NSWindow* mainWindow = [mApplication mainWindow];
if (mainWindow) {
[[mainWindow windowController] loadURL:[url absoluteString]];
[[mainWindow windowController] loadURL:[url absoluteString] referrer:nil];
[[[[mainWindow windowController] getBrowserWrapper] getBrowserView] setActive: YES];
}
else
[self openBrowserWindowWithURL:[url absoluteString]];
[self openBrowserWindowWithURL:[url absoluteString] andReferrer:nil];
}
}
@ -227,7 +227,7 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
{
NSWindow* mainWindow = [mApplication mainWindow];
if (!mainWindow) {
[self openBrowserWindowWithURL: @"about:blank"];
[self openBrowserWindowWithURL: @"about:blank" andReferrer:nil];
mainWindow = [mApplication mainWindow];
}
@ -357,16 +357,16 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
}
// open a new URL. This method always makes a new browser window
-(BrowserWindowController*)openBrowserWindowWithURL: (NSString*)aURL
-(BrowserWindowController*)openBrowserWindowWithURL: (NSString*)aURL andReferrer: (NSString*)aReferrer
{
BrowserWindowController* browser = [[BrowserWindowController alloc] initWithWindowNibName: @"BrowserWindow"];
[browser loadURL: aURL];
[browser loadURL: aURL referrer:aReferrer];
[browser showWindow: self];
return browser;
}
// open a new URL, observing the prefs on how to behave
- (void)openNewWindowOrTabWithURL:(NSString*)inURLString
- (void)openNewWindowOrTabWithURL:(NSString*)inURLString andReferrer: (NSString*)aReferrer
{
// make sure we're initted
[self preferenceManager];
@ -388,12 +388,12 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
NSWindow* browserWindow = [self getFrontmostBrowserWindow];
if (reuseWindow && browserWindow) {
controller = [browserWindow windowController];
[controller openNewTabWithURL:inURLString loadInBackground:loadInBackground];
[controller openNewTabWithURL:inURLString referrer:aReferrer loadInBackground:loadInBackground];
}
else {
// should use BrowserWindowController openNewWindowWithURL, but that method
// really needs to be on the MainController
controller = [self openBrowserWindowWithURL: inURLString];
controller = [self openBrowserWindowWithURL: inURLString andReferrer:aReferrer];
}
[[[controller getBrowserWrapper] getBrowserView] setActive: YES];
@ -472,7 +472,7 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
{
NSWindow* mainWind = [mApplication mainWindow];
if (!mainWind) {
[self openBrowserWindowWithURL: @"about:blank"];
[self openBrowserWindowWithURL: @"about:blank" andReferrer:nil];
mainWind = [mApplication mainWindow];
}
@ -483,7 +483,7 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
{
NSWindow* mainWindow = [mApplication mainWindow];
if (!mainWindow) {
[self openBrowserWindowWithURL: @"about:blank"];
[self openBrowserWindowWithURL: @"about:blank" andReferrer:nil];
mainWindow = [mApplication mainWindow];
}
@ -531,7 +531,7 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
[self openBrowserWindowWithURL:[[NSURL fileURLWithPath:filename] absoluteString]];
}
*/
[self openNewWindowOrTabWithURL:[[NSURL fileURLWithPath:filename] absoluteString]];
[self openNewWindowOrTabWithURL:[[NSURL fileURLWithPath:filename] absoluteString] andReferrer:nil];
return YES;
}
@ -677,7 +677,7 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
{
NSWindow* mainWindow = [mApplication mainWindow];
if (!mainWindow) {
[self openBrowserWindowWithURL: @"about:blank"];
[self openBrowserWindowWithURL: @"about:blank" andReferrer:nil];
mainWindow = [mApplication mainWindow];
}
@ -695,7 +695,7 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
{
NSString *pageToLoad = NSLocalizedStringFromTable(@"FeedbackPageDefault", @"WebsiteDefaults", nil);
if (![pageToLoad isEqualToString:@"FeedbackPageDefault"])
[self openNewWindowOrTabWithURL:pageToLoad];
[self openNewWindowOrTabWithURL:pageToLoad andReferrer:nil];
}
+ (NSImage*)createImageForDragging:(NSImage*)aIcon title:(NSString*)aTitle
@ -809,7 +809,7 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
[urlString appendString:tmpString];
}
[self openBrowserWindowWithURL:urlString];
[self openBrowserWindowWithURL:urlString andReferrer:nil];
}
@end

Просмотреть файл

@ -24,17 +24,13 @@
#import "CHGetURLCommand.h"
#import <AppKit/AppKit.h>
#import "BrowserWindowController.h"
#include "nsIPref.h"
#include "nsCOMPtr.h"
#include "nsIServiceManagerUtils.h"
#import "MainController.h"
@implementation CHGetURLCommand
- (id)performDefaultImplementation
{
[[NSApp delegate] openNewWindowOrTabWithURL:[self directParameter]];
[(MainController*)[NSApp delegate] openNewWindowOrTabWithURL:[self directParameter] andReferrer:nil];
return nil;
}

Просмотреть файл

@ -124,8 +124,8 @@ class BookmarksService;
//Help menu actions
-(IBAction) feedbackLink:(id)aSender;
-(BrowserWindowController*)openBrowserWindowWithURL: (NSString*)aURL;
- (void)openNewWindowOrTabWithURL:(NSString*)inURLString;
-(BrowserWindowController*)openBrowserWindowWithURL: (NSString*)aURL andReferrer: (NSString*)aReferrer;
- (void)openNewWindowOrTabWithURL:(NSString*)inURLString andReferrer:(NSString*)aReferrer;
- (void)adjustCloseWindowMenuItemKeyEquivalent:(BOOL)inHaveTabs;
- (void)adjustCloseTabMenuItemKeyEquivalent:(BOOL)inHaveTabs;

Просмотреть файл

@ -160,7 +160,7 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
// Now open the new window.
NSString* homePage = mStartURL ? mStartURL : [mPreferenceManager homePage:YES];
BrowserWindowController* controller = [self openBrowserWindowWithURL:homePage];
BrowserWindowController* controller = [self openBrowserWindowWithURL:homePage andReferrer:nil];
if ([homePage isEqualToString: @"about:blank"])
[controller focusURLBar];
@ -215,11 +215,11 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
// ----------------------
NSWindow* mainWindow = [mApplication mainWindow];
if (mainWindow) {
[[mainWindow windowController] loadURL:[url absoluteString]];
[[mainWindow windowController] loadURL:[url absoluteString] referrer:nil];
[[[[mainWindow windowController] getBrowserWrapper] getBrowserView] setActive: YES];
}
else
[self openBrowserWindowWithURL:[url absoluteString]];
[self openBrowserWindowWithURL:[url absoluteString] andReferrer:nil];
}
}
@ -227,7 +227,7 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
{
NSWindow* mainWindow = [mApplication mainWindow];
if (!mainWindow) {
[self openBrowserWindowWithURL: @"about:blank"];
[self openBrowserWindowWithURL: @"about:blank" andReferrer:nil];
mainWindow = [mApplication mainWindow];
}
@ -357,16 +357,16 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
}
// open a new URL. This method always makes a new browser window
-(BrowserWindowController*)openBrowserWindowWithURL: (NSString*)aURL
-(BrowserWindowController*)openBrowserWindowWithURL: (NSString*)aURL andReferrer: (NSString*)aReferrer
{
BrowserWindowController* browser = [[BrowserWindowController alloc] initWithWindowNibName: @"BrowserWindow"];
[browser loadURL: aURL];
[browser loadURL: aURL referrer:aReferrer];
[browser showWindow: self];
return browser;
}
// open a new URL, observing the prefs on how to behave
- (void)openNewWindowOrTabWithURL:(NSString*)inURLString
- (void)openNewWindowOrTabWithURL:(NSString*)inURLString andReferrer: (NSString*)aReferrer
{
// make sure we're initted
[self preferenceManager];
@ -388,12 +388,12 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
NSWindow* browserWindow = [self getFrontmostBrowserWindow];
if (reuseWindow && browserWindow) {
controller = [browserWindow windowController];
[controller openNewTabWithURL:inURLString loadInBackground:loadInBackground];
[controller openNewTabWithURL:inURLString referrer:aReferrer loadInBackground:loadInBackground];
}
else {
// should use BrowserWindowController openNewWindowWithURL, but that method
// really needs to be on the MainController
controller = [self openBrowserWindowWithURL: inURLString];
controller = [self openBrowserWindowWithURL: inURLString andReferrer:aReferrer];
}
[[[controller getBrowserWrapper] getBrowserView] setActive: YES];
@ -472,7 +472,7 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
{
NSWindow* mainWind = [mApplication mainWindow];
if (!mainWind) {
[self openBrowserWindowWithURL: @"about:blank"];
[self openBrowserWindowWithURL: @"about:blank" andReferrer:nil];
mainWind = [mApplication mainWindow];
}
@ -483,7 +483,7 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
{
NSWindow* mainWindow = [mApplication mainWindow];
if (!mainWindow) {
[self openBrowserWindowWithURL: @"about:blank"];
[self openBrowserWindowWithURL: @"about:blank" andReferrer:nil];
mainWindow = [mApplication mainWindow];
}
@ -531,7 +531,7 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
[self openBrowserWindowWithURL:[[NSURL fileURLWithPath:filename] absoluteString]];
}
*/
[self openNewWindowOrTabWithURL:[[NSURL fileURLWithPath:filename] absoluteString]];
[self openNewWindowOrTabWithURL:[[NSURL fileURLWithPath:filename] absoluteString] andReferrer:nil];
return YES;
}
@ -677,7 +677,7 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
{
NSWindow* mainWindow = [mApplication mainWindow];
if (!mainWindow) {
[self openBrowserWindowWithURL: @"about:blank"];
[self openBrowserWindowWithURL: @"about:blank" andReferrer:nil];
mainWindow = [mApplication mainWindow];
}
@ -695,7 +695,7 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
{
NSString *pageToLoad = NSLocalizedStringFromTable(@"FeedbackPageDefault", @"WebsiteDefaults", nil);
if (![pageToLoad isEqualToString:@"FeedbackPageDefault"])
[self openNewWindowOrTabWithURL:pageToLoad];
[self openNewWindowOrTabWithURL:pageToLoad andReferrer:nil];
}
+ (NSImage*)createImageForDragging:(NSImage*)aIcon title:(NSString*)aTitle
@ -809,7 +809,7 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
[urlString appendString:tmpString];
}
[self openBrowserWindowWithURL:urlString];
[self openBrowserWindowWithURL:urlString andReferrer:nil];
}
@end

Просмотреть файл

@ -63,7 +63,7 @@
NSString* url = [NSString stringWithCString: cref.get()];
// Now load the URL in the window.
[[[self window] windowController] loadURL: url];
[[[self window] windowController] loadURL: url referrer:nil];
// Focus and activate our content area.
[[[[[self window] windowController] getBrowserWrapper] getBrowserView] setActive: YES];

Просмотреть файл

@ -396,7 +396,7 @@
content->GetAttr(kNameSpaceID_None, BookmarksService::gHrefAtom, href);
if (!href.IsEmpty()) {
NSString* url = [NSString stringWithCharacters: href.get() length: href.Length()];
[[[mBrowserWindowController getBrowserWrapper] getBrowserView] loadURI: url flags: NSLoadFlagsNone];
[[[mBrowserWindowController getBrowserWrapper] getBrowserView] loadURI: url referrer:nil flags: NSLoadFlagsNone];
// Focus and activate our content area.
[[[mBrowserWindowController getBrowserWrapper] getBrowserView] setActive: YES];
}
@ -682,7 +682,7 @@
PRBool loadInBackground;
pref->GetBoolPref("browser.tabs.loadInBackground", &loadInBackground);
[mBrowserWindowController openNewTabWithURL: hrefStr loadInBackground: loadInBackground];
[mBrowserWindowController openNewTabWithURL: hrefStr referrer:nil loadInBackground: loadInBackground];
}
}
@ -702,7 +702,7 @@
nsAutoString group;
[item contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gGroupAtom, group);
if (group.IsEmpty())
[mBrowserWindowController openNewWindowWithURL: hrefStr loadInBackground: NO];
[mBrowserWindowController openNewWindowWithURL: hrefStr referrer: nil loadInBackground: NO];
else {
nsCOMPtr<nsIDOMElement> elt(do_QueryInterface([item contentNode]));
[mBrowserWindowController openNewWindowWithGroup: elt loadInBackground: NO];

Просмотреть файл

@ -786,7 +786,7 @@ BookmarksService::OpenMenuBookmark(BrowserWindowController* aController, id aMen
NSString* url = [NSString stringWithCharacters: href.get() length: href.Length()];
// Now load the URL in the window.
[aController loadURL:url];
[aController loadURL:url referrer:nil];
// Focus and activate our content area.
[[[aController getBrowserWrapper] getBrowserView] setActive: YES];
@ -1013,7 +1013,7 @@ BookmarksService::OpenBookmarkGroup(id aTabView, nsIDOMElement* aFolder)
else
tabViewItem = [aTabView tabViewItemAtIndex: currentIndex];
[[[tabViewItem view] getBrowserView] loadURI: url
[[[tabViewItem view] getBrowserView] loadURI: url referrer:nil
flags: NSLoadFlagsNone];
}
}

Просмотреть файл

@ -120,7 +120,8 @@ class nsIDOMNode;
NSToolbarItem* mSidebarToolbarItem;
BOOL mInitialized;
NSString* mURL;
NSString* mPendingURL;
NSString* mPendingReferrer;
CHBrowserWrapper* mBrowserView;
@ -155,7 +156,7 @@ class nsIDOMNode;
-(id)getTabBrowser;
-(CHBrowserWrapper*)getBrowserWrapper;
- (void)loadURL:(NSString*)aURLSpec;
- (void)loadURL:(NSString*)aURLSpec referrer:(NSString*)aReferrer;
- (void)updateLocationFields:(NSString *)locationString;
- (void)updateToolbarItems;
- (void)focusURLBar;
@ -209,9 +210,9 @@ class nsIDOMNode;
-(void)enterModalSession;
-(void)openNewWindowWithURL: (NSString*)aURLSpec loadInBackground: (BOOL)aLoadInBG;
-(void)openNewWindowWithURL: (NSString*)aURLSpec referrer:(NSString*)aReferrer loadInBackground: (BOOL)aLoadInBG;
-(void)openNewWindowWithGroup: (nsIDOMElement*)aFolderElement loadInBackground: (BOOL)aLoadInBG;
-(void)openNewTabWithURL: (NSString*)aURLSpec loadInBackground: (BOOL)aLoadInBG;
-(void)openNewTabWithURL: (NSString*)aURLSpec referrer: (NSString*)aReferrer loadInBackground: (BOOL)aLoadInBG;
-(void)autosaveWindowFrame;
-(void)disableAutosave;

Просмотреть файл

@ -273,12 +273,20 @@ static NSArray* sToolbarDefaults = nil;
// We now remove the IB tab, then add one of our own.
[mTabBrowser removeTabViewItem:[mTabBrowser tabViewItemAtIndex:0]];
[self newTab:mShouldLoadHomePage];
if (mURL) {
// create ourselves a new tab and fill it with the appropriate content. If we
// have a URL pending to be opened here, don't load anything in it, otherwise,
// load the homepage if that's what the user wants (or about:blank).
[self newTab:(!mPendingURL && mShouldLoadHomePage)];
// we have a url "pending" from the "open new window with link" command. Deal
// with it now that everything is loaded.
if (mPendingURL) {
if (mShouldLoadHomePage)
[self loadURL: mURL];
[mURL release];
[self loadURL: mPendingURL referrer:mPendingReferrer];
[mPendingURL release];
[mPendingReferrer release];
mPendingURL = mPendingReferrer = nil;
}
[mSidebarDrawer setDelegate: self];
@ -332,7 +340,7 @@ static NSArray* sToolbarDefaults = nil;
- (void)drawerDidOpen:(NSNotification *)aNotification
{
// XXXdwh This is temporary.
// [[mSidebarBrowserView getBrowserView] loadURI: @"http://tinderbox.mozilla.org/SeaMonkey/panel.html" flags:NSLoadFlagsNone];
// [[mSidebarBrowserView getBrowserView] loadURI: @"http://tinderbox.mozilla.org/SeaMonkey/panel.html" referrer: nil flags:NSLoadFlagsNone];
// Toggle the sidebar icon.
if(mSidebarToolbarItem)
@ -346,7 +354,7 @@ static NSArray* sToolbarDefaults = nil;
[mSidebarToolbarItem setImage:[NSImage imageNamed:@"sidebarClosed"]];
// XXXdwh ignore for now.
// [[mSidebarBrowserView getBrowserView] loadURI: @"about:blank" flags:NSLoadFlagsNone];
// [[mSidebarBrowserView getBrowserView] loadURI: @"about:blank" referrer:nil flags:NSLoadFlagsNone];
if (mDrawerCachedFrame) {
mDrawerCachedFrame = NO;
@ -619,7 +627,7 @@ static NSArray* sToolbarDefaults = nil;
{
[mLocationSheetWindow orderOut:self];
[NSApp endSheet:mLocationSheetWindow returnCode:1];
[self loadURL:[mLocationSheetURLField stringValue]];
[self loadURL:[mLocationSheetURLField stringValue] referrer:nil];
// Focus and activate our content area.
[[mBrowserView getBrowserView] setActive: YES];
@ -668,7 +676,7 @@ static NSArray* sToolbarDefaults = nil;
[newView setFrame: NSZeroRect];
[newView setIsBookmarksImport: YES];
[[[self window] contentView] addSubview: newView];
[[newView getBrowserView] loadURI:aURLSpec flags:NSLoadFlagsNone];
[[newView getBrowserView] loadURI:aURLSpec referrer: nil flags:NSLoadFlagsNone];
}
- (IBAction)goToLocationFromToolbarURLField:(id)sender
@ -676,7 +684,7 @@ static NSArray* sToolbarDefaults = nil;
// trim off any whitespace around url
NSMutableString *theURL = [[NSMutableString alloc] initWithString:[sender stringValue]];
CFStringTrimWhitespace((CFMutableStringRef)theURL);
[self loadURL:theURL];
[self loadURL:theURL referrer:nil];
[theURL release];
// Focus and activate our content area.
@ -703,7 +711,7 @@ static NSArray* sToolbarDefaults = nil;
PRBool loadInBackground;
nsCOMPtr<nsIPrefBranch> pref(do_GetService("@mozilla.org/preferences-service;1"));
pref->GetBoolPref("browser.tabs.loadInBackground", &loadInBackground);
[self openNewTabWithURL: viewSource loadInBackground: loadInBackground];
[self openNewTabWithURL: viewSource referrer:nil loadInBackground: loadInBackground];
}
- (void)printDocument
@ -729,7 +737,7 @@ static NSArray* sToolbarDefaults = nil;
searchEngine = @"http://dmoz.org/";
}
[[mBrowserView getBrowserView] loadURI:searchEngine flags:NSLoadFlagsNone];
[[mBrowserView getBrowserView] loadURI:searchEngine referrer: nil flags:NSLoadFlagsNone];
}
@ -771,7 +779,7 @@ static NSArray* sToolbarDefaults = nil;
{
NSString *pageToLoad = NSLocalizedStringFromTable(@"ThrobberPageDefault", @"WebsiteDefaults", nil);
if (![pageToLoad isEqualToString:@"ThrobberPageDefault"])
[self loadURL:pageToLoad];
[self loadURL:pageToLoad referrer:nil];
}
- (void)startThrobber
@ -859,7 +867,7 @@ static NSArray* sToolbarDefaults = nil;
- (IBAction)home:(id)aSender
{
[[mBrowserView getBrowserView] loadURI:[[CHPreferenceManager sharedInstance] homePage:NO] flags:NSLoadFlagsNone];
[[mBrowserView getBrowserView] loadURI:[[CHPreferenceManager sharedInstance] homePage:NO] referrer: nil flags:NSLoadFlagsNone];
}
- (IBAction)toggleSidebar:(id)aSender
@ -877,14 +885,18 @@ static NSArray* sToolbarDefaults = nil;
[[self window] makeFirstResponder: resp];
}
-(void)loadURL:(NSString*)aURLSpec
-(void)loadURL:(NSString*)aURLSpec referrer:(NSString*)aReferrer
{
if (mInitialized) {
[[mBrowserView getBrowserView] loadURI:aURLSpec flags:NSLoadFlagsNone];
[[mBrowserView getBrowserView] loadURI:aURLSpec referrer:aReferrer flags:NSLoadFlagsNone];
}
else {
mURL = aURLSpec;
[mURL retain];
// we haven't yet initialized all the browser machinery, stash the url and referrer
// until we're ready in windowDidLoad:
mPendingURL = aURLSpec;
[mPendingURL retain];
mPendingReferrer = aReferrer;
[mPendingReferrer retain];
}
}
@ -923,7 +935,7 @@ static NSArray* sToolbarDefaults = nil;
[mTabBrowser addTabViewItem: newTab];
if (allowHomepage)
[[newView getBrowserView] loadURI: ((newTabPage == 1) ? [[CHPreferenceManager sharedInstance] homePage: NO] : @"about:blank") flags:NSLoadFlagsNone];
[[newView getBrowserView] loadURI: ((newTabPage == 1) ? [[CHPreferenceManager sharedInstance] homePage: NO] : @"about:blank") referrer:nil flags:NSLoadFlagsNone];
[mTabBrowser selectLastTabViewItem: self];
@ -990,13 +1002,13 @@ static NSArray* sToolbarDefaults = nil;
return mBrowserView;
}
-(void)openNewWindowWithURL: (NSString*)aURLSpec loadInBackground: (BOOL)aLoadInBG
-(void)openNewWindowWithURL: (NSString*)aURLSpec referrer: (NSString*)aReferrer loadInBackground: (BOOL)aLoadInBG
{
// Autosave our dimensions before we open a new window. That ensures the size ends up matching.
[self autosaveWindowFrame];
BrowserWindowController* browser = [[BrowserWindowController alloc] initWithWindowNibName: @"BrowserWindow"];
[browser loadURL: aURLSpec];
[browser loadURL: aURLSpec referrer:aReferrer];
if (aLoadInBG)
[[browser window] orderWindow: NSWindowBelow relativeTo: [[self window] windowNumber]];
else {
@ -1025,7 +1037,7 @@ static NSArray* sToolbarDefaults = nil;
[mSidebarBookmarksDataSource openBookmarkGroup: tabBrowser groupElement: aFolderElement];
}
-(void)openNewTabWithURL: (NSString*)aURLSpec loadInBackground: (BOOL)aLoadInBG
-(void)openNewTabWithURL: (NSString*)aURLSpec referrer:(NSString*)aReferrer loadInBackground: (BOOL)aLoadInBG
{
NSTabViewItem* newTab = [[[NSTabViewItem alloc] initWithIdentifier: nil] autorelease];
@ -1039,7 +1051,7 @@ static NSArray* sToolbarDefaults = nil;
[newTab setLabel: NSLocalizedString(@"TabLoading", @"")];
[newTab setView: newView];
[[newView getBrowserView] loadURI:aURLSpec flags:NSLoadFlagsNone];
[[newView getBrowserView] loadURI:aURLSpec referrer:aReferrer flags:NSLoadFlagsNone];
if (!aLoadInBG) {
[mTabBrowser selectTabViewItem: newTab];
@ -1257,10 +1269,12 @@ static NSArray* sToolbarDefaults = nil;
PRBool loadInBackground;
pref->GetBoolPref("browser.tabs.loadInBackground", &loadInBackground);
NSString* referrer = [[mBrowserView getBrowserView] getFocusedURLString];
if (aUseWindow)
[self openNewWindowWithURL: hrefStr loadInBackground: loadInBackground];
[self openNewWindowWithURL: hrefStr referrer:referrer loadInBackground: loadInBackground];
else
[self openNewTabWithURL: hrefStr loadInBackground: loadInBackground];
[self openNewTabWithURL: hrefStr referrer:referrer loadInBackground: loadInBackground];
}
- (IBAction)savePageAs:(id)aSender
@ -1330,8 +1344,9 @@ static NSArray* sToolbarDefaults = nil;
imgElement->GetSrc(url);
NSString* urlStr = [NSString stringWithCharacters: url.get() length:nsCRT::strlen(url.get())];
[self loadURL: urlStr];
NSString* referrer = [[mBrowserView getBrowserView] getFocusedURLString];
[self loadURL: urlStr referrer:referrer];
// Focus and activate our content area.
[[mBrowserView getBrowserView] setActive: YES];

Просмотреть файл

@ -85,7 +85,7 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
- (IBAction)load:(id)sender
{
[mBrowserView loadURI:[urlbar stringValue] flags:NSLoadFlagsNone];
[mBrowserView loadURI:[urlbar stringValue] referrer:nil flags:NSLoadFlagsNone];
}
-(void)disconnectView

Просмотреть файл

@ -300,12 +300,14 @@ ContentClickListener::MouseClick(nsIDOMEvent* aEvent)
pref->GetBoolPref("browser.tabs.opentabfor.middleclick", &useTab);
PRBool loadInBackground;
pref->GetBoolPref("browser.tabs.loadInBackground", &loadInBackground);
NSString* referrer = [[[mBrowserController getBrowserWrapper] getBrowserView] getFocusedURLString];
if (shiftKey)
loadInBackground = !loadInBackground;
if (useTab)
[mBrowserController openNewTabWithURL: hrefStr loadInBackground: loadInBackground];
[mBrowserController openNewTabWithURL: hrefStr referrer:referrer loadInBackground: loadInBackground];
else
[mBrowserController openNewWindowWithURL: hrefStr loadInBackground: loadInBackground];
[mBrowserController openNewWindowWithURL: hrefStr referrer:referrer loadInBackground: loadInBackground];
}
else if (altKey) {
// The user wants to save this link.

Просмотреть файл

@ -126,7 +126,7 @@ enum {
- (nsIDOMWindow*)getContentWindow;
// nsIWebNavigation methods
- (void)loadURI:(NSString *)urlSpec flags:(unsigned int)flags;
- (void)loadURI:(NSString *)urlSpec referrer:(NSString*)referrer flags:(unsigned int)flags;
- (void)reload:(unsigned int)flags;
- (BOOL)canGoBack;
- (BOOL)canGoForward;

Просмотреть файл

@ -1042,7 +1042,7 @@ nsHeaderSniffer::OnSecurityChange(nsIWebProgress *aWebProgress, nsIRequest *aReq
return window;
}
- (void)loadURI:(NSString *)urlSpec flags:(unsigned int)flags
- (void)loadURI:(NSString *)urlSpec referrer:(NSString*)referrer flags:(unsigned int)flags
{
nsCOMPtr<nsIWebNavigation> nav = do_QueryInterface(_webBrowser);
@ -1051,6 +1051,9 @@ nsHeaderSniffer::OnSecurityChange(nsIWebProgress *aWebProgress, nsIRequest *aReq
[urlSpec getCharacters:specStr];
specStr[length] = PRUnichar(0);
nsCOMPtr<nsIURI> referrerURI;
if ( referrer )
NS_NewURI(getter_AddRefs(referrerURI), [referrer cString]);
PRUint32 navFlags = nsIWebNavigation::LOAD_FLAGS_NONE;
if (flags & NSLoadFlagsDontPutInHistory) {
@ -1064,7 +1067,7 @@ nsHeaderSniffer::OnSecurityChange(nsIWebProgress *aWebProgress, nsIRequest *aReq
nsIWebNavigation::LOAD_FLAGS_BYPASS_PROXY;
}
nsresult rv = nav->LoadURI(specStr, navFlags, nsnull, nsnull, nsnull);
nsresult rv = nav->LoadURI(specStr, navFlags, referrerURI, nsnull, nsnull);
if (NS_FAILED(rv)) {
// XXX need to throw
}

Просмотреть файл

@ -148,7 +148,7 @@
valueLiteral->GetValue(getter_Copies(literalValue));
NSString* url = [NSString stringWithCharacters: literalValue.get() length: literalValue.Length()];
[[[mBrowserWindowController getBrowserWrapper] getBrowserView] loadURI: url flags: NSLoadFlagsNone];
[[[mBrowserWindowController getBrowserWrapper] getBrowserView] loadURI: url referrer: nil flags: NSLoadFlagsNone];
// Focus and activate our content area.
[[[mBrowserWindowController getBrowserWrapper] getBrowserView] setActive: YES];
}