зеркало из https://github.com/mozilla/pjs.git
More work on importing of bookmarks.
This commit is contained in:
Родитель
36d969697c
Коммит
1656ccbcf9
|
@ -97,6 +97,8 @@ class nsIAtom;
|
|||
- (id)copyWithZone:(NSZone *)aZone;
|
||||
@end
|
||||
|
||||
class nsIDOMHTMLDocument;
|
||||
|
||||
class BookmarksService
|
||||
{
|
||||
public:
|
||||
|
@ -125,6 +127,8 @@ public:
|
|||
|
||||
static void EnsureToolbarRoot();
|
||||
|
||||
static void ImportBookmarks(nsIDOMHTMLDocument* aHTMLDoc);
|
||||
|
||||
static void GetTitleAndHrefForBrowserView(id aBrowserView, nsString& aTitle, nsString& aHref);
|
||||
static void OpenBookmarkGroup(id aTabView, nsIDOMElement* aFolder);
|
||||
|
||||
|
|
|
@ -979,6 +979,12 @@ BookmarksService::OpenMenuBookmark(BrowserWindowController* aController, id aMen
|
|||
[[[aController getBrowserWrapper] getBrowserView] setActive: YES];
|
||||
}
|
||||
|
||||
void
|
||||
BookmarksService::ImportBookmarks(nsIDOMHTMLDocument* aHTMLDoc)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
BookmarksService::OpenBookmarkGroup(id aTabView, nsIDOMElement* aFolder)
|
||||
{
|
||||
|
|
|
@ -138,6 +138,7 @@ class nsIDOMNode;
|
|||
|
||||
- (void)addBookmarkExtended: (BOOL)aIsFromMenu isFolder:(BOOL)aIsFolder;
|
||||
- (IBAction)manageBookmarks: (id)aSender;
|
||||
- (void)importBookmarks: (NSURL*)aURL;
|
||||
- (IBAction)toggleSidebar:(id)aSender;
|
||||
|
||||
- (void)newTab;
|
||||
|
|
|
@ -472,6 +472,19 @@ static NSString *PrintToolbarItemIdentifier = @"Print Toolbar Item";
|
|||
[mSidebarTabView selectFirstTabViewItem:self];
|
||||
}
|
||||
|
||||
- (void)importBookmarks: (NSURL*)aURL
|
||||
{
|
||||
// Open the bookmarks sidebar.
|
||||
[self manageBookmarks: self];
|
||||
|
||||
// Now do the importing.
|
||||
CHBrowserWrapper* newView = [[[CHBrowserWrapper alloc] initWithTab: nil andWindow: [self window]] autorelease];
|
||||
[newView setFrame: NSZeroRect];
|
||||
[newView setIsBookmarksImport: YES];
|
||||
[[[self window] contentView] addSubview: newView];
|
||||
[[newView getBrowserView] loadURI:aURL flags:NSLoadFlagsNone];
|
||||
}
|
||||
|
||||
- (IBAction)goToLocationFromToolbarURLField:(id)sender
|
||||
{
|
||||
[self loadURL:[NSURL URLWithString:[sender stringValue]]];
|
||||
|
|
|
@ -57,6 +57,8 @@
|
|||
BOOL mOffline;
|
||||
BOOL mListenersAttached; // We hook up our click and context menu listeners lazily.
|
||||
// If we never become the primary view, we don't bother creating the listeners.
|
||||
BOOL mIsBookmarksImport; // This view was created for the purpose of importing bookmarks. Upon
|
||||
// completion, we need to do the import and then destroy ourselves.
|
||||
}
|
||||
|
||||
- (IBAction)load:(id)sender;
|
||||
|
@ -74,8 +76,8 @@
|
|||
-(void)setTab: (NSTabViewItem*)tab;
|
||||
|
||||
-(NSWindow*)getNativeWindow;
|
||||
|
||||
-(NSMenu*)getContextMenu;
|
||||
-(void)setIsBookmarksImport:(BOOL)aIsImport;
|
||||
|
||||
-(id)initWithTab:(id)aTab andWindow:(NSWindow*)aWindow;
|
||||
|
||||
|
|
|
@ -37,12 +37,16 @@
|
|||
|
||||
#import "CHBrowserWrapper.h"
|
||||
#import "BrowserWindowController.h"
|
||||
#import "BookmarksService.h"
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIIOService.h"
|
||||
#include "ContentClickListener.h"
|
||||
#include "nsIDOMWindow.h"
|
||||
#include "nsIWebBrowser.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIDOMHTMLDocument.h"
|
||||
#include "nsIChromeEventHandler.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
#include "nsIDOMEventReceiver.h"
|
||||
|
@ -98,6 +102,7 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
|||
{
|
||||
mTab = aTab;
|
||||
mWindow = aWindow;
|
||||
mIsBookmarksImport = NO;
|
||||
return [self initWithFrame: NSZeroRect];
|
||||
}
|
||||
|
||||
|
@ -219,9 +224,6 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
|||
|
||||
if (mWindowController)
|
||||
[mWindowController updateToolbarItems];
|
||||
else {
|
||||
printf("background load.\n");
|
||||
}
|
||||
}
|
||||
|
||||
- (void)onLoadingCompleted:(BOOL)succeeded
|
||||
|
@ -239,7 +241,22 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
|||
}
|
||||
|
||||
mIsBusy = NO;
|
||||
|
||||
|
||||
if (mIsBookmarksImport) {
|
||||
nsCOMPtr<nsIDOMWindow> domWindow;
|
||||
nsCOMPtr<nsIWebBrowser> webBrowser = getter_AddRefs([mBrowserView getWebBrowser]);
|
||||
webBrowser->GetContentDOMWindow(getter_AddRefs(domWindow));
|
||||
if (domWindow) {
|
||||
nsCOMPtr<nsIDOMDocument> domDocument;
|
||||
domWindow->GetDocument(getter_AddRefs(domDocument));
|
||||
nsCOMPtr<nsIDOMHTMLDocument> htmlDoc(do_QueryInterface(domDocument));
|
||||
if (htmlDoc)
|
||||
BookmarksService::ImportBookmarks(htmlDoc);
|
||||
}
|
||||
[self windowClosed];
|
||||
[self removeFromSuperview];
|
||||
}
|
||||
|
||||
if (mWindowController)
|
||||
[mWindowController updateToolbarItems];
|
||||
}
|
||||
|
@ -346,6 +363,11 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
|||
return nil;
|
||||
}
|
||||
|
||||
-(void)setIsBookmarksImport:(BOOL)aIsImport
|
||||
{
|
||||
mIsBookmarksImport = aIsImport;
|
||||
}
|
||||
|
||||
- (void)offlineModeChanged: (NSNotification*)aNotification
|
||||
{
|
||||
nsCOMPtr<nsIIOService> ioService(do_GetService(ioServiceContractID));
|
||||
|
|
|
@ -130,7 +130,7 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
|||
|
||||
-(IBAction) openFile:(id)aSender
|
||||
{
|
||||
NSOpenPanel* openPanel = [[NSOpenPanel alloc] init];
|
||||
NSOpenPanel* openPanel = [[[NSOpenPanel alloc] init] autorelease];
|
||||
[openPanel setCanChooseFiles: YES];
|
||||
[openPanel setCanChooseDirectories: NO];
|
||||
[openPanel setAllowsMultipleSelection: NO];
|
||||
|
@ -293,7 +293,7 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
|||
// IE favorites: ~/Library/Preferences/Explorer/Favorites.html
|
||||
// Omniweb favorites: ~/Library/Application Support/Omniweb/Bookmarks.html
|
||||
// For now, open the panel to IE's favorites.
|
||||
NSOpenPanel* openPanel = [[NSOpenPanel alloc] init];
|
||||
NSOpenPanel* openPanel = [[[NSOpenPanel alloc] init] autorelease];
|
||||
[openPanel setCanChooseFiles: YES];
|
||||
[openPanel setCanChooseDirectories: NO];
|
||||
[openPanel setAllowsMultipleSelection: NO];
|
||||
|
@ -306,6 +306,14 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
|||
if ([urlArray count] == 0)
|
||||
return;
|
||||
NSURL* url = [urlArray objectAtIndex: 0];
|
||||
|
||||
NSWindow* window = [mApplication mainWindow];
|
||||
if (!window) {
|
||||
[self newWindow: self];
|
||||
window = [mApplication mainWindow];
|
||||
}
|
||||
|
||||
[[window windowController] importBookmarks: url];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -130,7 +130,7 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
|||
|
||||
-(IBAction) openFile:(id)aSender
|
||||
{
|
||||
NSOpenPanel* openPanel = [[NSOpenPanel alloc] init];
|
||||
NSOpenPanel* openPanel = [[[NSOpenPanel alloc] init] autorelease];
|
||||
[openPanel setCanChooseFiles: YES];
|
||||
[openPanel setCanChooseDirectories: NO];
|
||||
[openPanel setAllowsMultipleSelection: NO];
|
||||
|
@ -293,7 +293,7 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
|||
// IE favorites: ~/Library/Preferences/Explorer/Favorites.html
|
||||
// Omniweb favorites: ~/Library/Application Support/Omniweb/Bookmarks.html
|
||||
// For now, open the panel to IE's favorites.
|
||||
NSOpenPanel* openPanel = [[NSOpenPanel alloc] init];
|
||||
NSOpenPanel* openPanel = [[[NSOpenPanel alloc] init] autorelease];
|
||||
[openPanel setCanChooseFiles: YES];
|
||||
[openPanel setCanChooseDirectories: NO];
|
||||
[openPanel setAllowsMultipleSelection: NO];
|
||||
|
@ -306,6 +306,14 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
|||
if ([urlArray count] == 0)
|
||||
return;
|
||||
NSURL* url = [urlArray objectAtIndex: 0];
|
||||
|
||||
NSWindow* window = [mApplication mainWindow];
|
||||
if (!window) {
|
||||
[self newWindow: self];
|
||||
window = [mApplication mainWindow];
|
||||
}
|
||||
|
||||
[[window windowController] importBookmarks: url];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -97,6 +97,8 @@ class nsIAtom;
|
|||
- (id)copyWithZone:(NSZone *)aZone;
|
||||
@end
|
||||
|
||||
class nsIDOMHTMLDocument;
|
||||
|
||||
class BookmarksService
|
||||
{
|
||||
public:
|
||||
|
@ -125,6 +127,8 @@ public:
|
|||
|
||||
static void EnsureToolbarRoot();
|
||||
|
||||
static void ImportBookmarks(nsIDOMHTMLDocument* aHTMLDoc);
|
||||
|
||||
static void GetTitleAndHrefForBrowserView(id aBrowserView, nsString& aTitle, nsString& aHref);
|
||||
static void OpenBookmarkGroup(id aTabView, nsIDOMElement* aFolder);
|
||||
|
||||
|
|
|
@ -979,6 +979,12 @@ BookmarksService::OpenMenuBookmark(BrowserWindowController* aController, id aMen
|
|||
[[[aController getBrowserWrapper] getBrowserView] setActive: YES];
|
||||
}
|
||||
|
||||
void
|
||||
BookmarksService::ImportBookmarks(nsIDOMHTMLDocument* aHTMLDoc)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
BookmarksService::OpenBookmarkGroup(id aTabView, nsIDOMElement* aFolder)
|
||||
{
|
||||
|
|
|
@ -138,6 +138,7 @@ class nsIDOMNode;
|
|||
|
||||
- (void)addBookmarkExtended: (BOOL)aIsFromMenu isFolder:(BOOL)aIsFolder;
|
||||
- (IBAction)manageBookmarks: (id)aSender;
|
||||
- (void)importBookmarks: (NSURL*)aURL;
|
||||
- (IBAction)toggleSidebar:(id)aSender;
|
||||
|
||||
- (void)newTab;
|
||||
|
|
|
@ -472,6 +472,19 @@ static NSString *PrintToolbarItemIdentifier = @"Print Toolbar Item";
|
|||
[mSidebarTabView selectFirstTabViewItem:self];
|
||||
}
|
||||
|
||||
- (void)importBookmarks: (NSURL*)aURL
|
||||
{
|
||||
// Open the bookmarks sidebar.
|
||||
[self manageBookmarks: self];
|
||||
|
||||
// Now do the importing.
|
||||
CHBrowserWrapper* newView = [[[CHBrowserWrapper alloc] initWithTab: nil andWindow: [self window]] autorelease];
|
||||
[newView setFrame: NSZeroRect];
|
||||
[newView setIsBookmarksImport: YES];
|
||||
[[[self window] contentView] addSubview: newView];
|
||||
[[newView getBrowserView] loadURI:aURL flags:NSLoadFlagsNone];
|
||||
}
|
||||
|
||||
- (IBAction)goToLocationFromToolbarURLField:(id)sender
|
||||
{
|
||||
[self loadURL:[NSURL URLWithString:[sender stringValue]]];
|
||||
|
|
|
@ -57,6 +57,8 @@
|
|||
BOOL mOffline;
|
||||
BOOL mListenersAttached; // We hook up our click and context menu listeners lazily.
|
||||
// If we never become the primary view, we don't bother creating the listeners.
|
||||
BOOL mIsBookmarksImport; // This view was created for the purpose of importing bookmarks. Upon
|
||||
// completion, we need to do the import and then destroy ourselves.
|
||||
}
|
||||
|
||||
- (IBAction)load:(id)sender;
|
||||
|
@ -74,8 +76,8 @@
|
|||
-(void)setTab: (NSTabViewItem*)tab;
|
||||
|
||||
-(NSWindow*)getNativeWindow;
|
||||
|
||||
-(NSMenu*)getContextMenu;
|
||||
-(void)setIsBookmarksImport:(BOOL)aIsImport;
|
||||
|
||||
-(id)initWithTab:(id)aTab andWindow:(NSWindow*)aWindow;
|
||||
|
||||
|
|
|
@ -37,12 +37,16 @@
|
|||
|
||||
#import "CHBrowserWrapper.h"
|
||||
#import "BrowserWindowController.h"
|
||||
#import "BookmarksService.h"
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIIOService.h"
|
||||
#include "ContentClickListener.h"
|
||||
#include "nsIDOMWindow.h"
|
||||
#include "nsIWebBrowser.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIDOMHTMLDocument.h"
|
||||
#include "nsIChromeEventHandler.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
#include "nsIDOMEventReceiver.h"
|
||||
|
@ -98,6 +102,7 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
|||
{
|
||||
mTab = aTab;
|
||||
mWindow = aWindow;
|
||||
mIsBookmarksImport = NO;
|
||||
return [self initWithFrame: NSZeroRect];
|
||||
}
|
||||
|
||||
|
@ -219,9 +224,6 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
|||
|
||||
if (mWindowController)
|
||||
[mWindowController updateToolbarItems];
|
||||
else {
|
||||
printf("background load.\n");
|
||||
}
|
||||
}
|
||||
|
||||
- (void)onLoadingCompleted:(BOOL)succeeded
|
||||
|
@ -239,7 +241,22 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
|||
}
|
||||
|
||||
mIsBusy = NO;
|
||||
|
||||
|
||||
if (mIsBookmarksImport) {
|
||||
nsCOMPtr<nsIDOMWindow> domWindow;
|
||||
nsCOMPtr<nsIWebBrowser> webBrowser = getter_AddRefs([mBrowserView getWebBrowser]);
|
||||
webBrowser->GetContentDOMWindow(getter_AddRefs(domWindow));
|
||||
if (domWindow) {
|
||||
nsCOMPtr<nsIDOMDocument> domDocument;
|
||||
domWindow->GetDocument(getter_AddRefs(domDocument));
|
||||
nsCOMPtr<nsIDOMHTMLDocument> htmlDoc(do_QueryInterface(domDocument));
|
||||
if (htmlDoc)
|
||||
BookmarksService::ImportBookmarks(htmlDoc);
|
||||
}
|
||||
[self windowClosed];
|
||||
[self removeFromSuperview];
|
||||
}
|
||||
|
||||
if (mWindowController)
|
||||
[mWindowController updateToolbarItems];
|
||||
}
|
||||
|
@ -346,6 +363,11 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
|||
return nil;
|
||||
}
|
||||
|
||||
-(void)setIsBookmarksImport:(BOOL)aIsImport
|
||||
{
|
||||
mIsBookmarksImport = aIsImport;
|
||||
}
|
||||
|
||||
- (void)offlineModeChanged: (NSNotification*)aNotification
|
||||
{
|
||||
nsCOMPtr<nsIIOService> ioService(do_GetService(ioServiceContractID));
|
||||
|
|
|
@ -97,6 +97,8 @@ class nsIAtom;
|
|||
- (id)copyWithZone:(NSZone *)aZone;
|
||||
@end
|
||||
|
||||
class nsIDOMHTMLDocument;
|
||||
|
||||
class BookmarksService
|
||||
{
|
||||
public:
|
||||
|
@ -125,6 +127,8 @@ public:
|
|||
|
||||
static void EnsureToolbarRoot();
|
||||
|
||||
static void ImportBookmarks(nsIDOMHTMLDocument* aHTMLDoc);
|
||||
|
||||
static void GetTitleAndHrefForBrowserView(id aBrowserView, nsString& aTitle, nsString& aHref);
|
||||
static void OpenBookmarkGroup(id aTabView, nsIDOMElement* aFolder);
|
||||
|
||||
|
|
|
@ -979,6 +979,12 @@ BookmarksService::OpenMenuBookmark(BrowserWindowController* aController, id aMen
|
|||
[[[aController getBrowserWrapper] getBrowserView] setActive: YES];
|
||||
}
|
||||
|
||||
void
|
||||
BookmarksService::ImportBookmarks(nsIDOMHTMLDocument* aHTMLDoc)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
BookmarksService::OpenBookmarkGroup(id aTabView, nsIDOMElement* aFolder)
|
||||
{
|
||||
|
|
|
@ -138,6 +138,7 @@ class nsIDOMNode;
|
|||
|
||||
- (void)addBookmarkExtended: (BOOL)aIsFromMenu isFolder:(BOOL)aIsFolder;
|
||||
- (IBAction)manageBookmarks: (id)aSender;
|
||||
- (void)importBookmarks: (NSURL*)aURL;
|
||||
- (IBAction)toggleSidebar:(id)aSender;
|
||||
|
||||
- (void)newTab;
|
||||
|
|
|
@ -472,6 +472,19 @@ static NSString *PrintToolbarItemIdentifier = @"Print Toolbar Item";
|
|||
[mSidebarTabView selectFirstTabViewItem:self];
|
||||
}
|
||||
|
||||
- (void)importBookmarks: (NSURL*)aURL
|
||||
{
|
||||
// Open the bookmarks sidebar.
|
||||
[self manageBookmarks: self];
|
||||
|
||||
// Now do the importing.
|
||||
CHBrowserWrapper* newView = [[[CHBrowserWrapper alloc] initWithTab: nil andWindow: [self window]] autorelease];
|
||||
[newView setFrame: NSZeroRect];
|
||||
[newView setIsBookmarksImport: YES];
|
||||
[[[self window] contentView] addSubview: newView];
|
||||
[[newView getBrowserView] loadURI:aURL flags:NSLoadFlagsNone];
|
||||
}
|
||||
|
||||
- (IBAction)goToLocationFromToolbarURLField:(id)sender
|
||||
{
|
||||
[self loadURL:[NSURL URLWithString:[sender stringValue]]];
|
||||
|
|
|
@ -57,6 +57,8 @@
|
|||
BOOL mOffline;
|
||||
BOOL mListenersAttached; // We hook up our click and context menu listeners lazily.
|
||||
// If we never become the primary view, we don't bother creating the listeners.
|
||||
BOOL mIsBookmarksImport; // This view was created for the purpose of importing bookmarks. Upon
|
||||
// completion, we need to do the import and then destroy ourselves.
|
||||
}
|
||||
|
||||
- (IBAction)load:(id)sender;
|
||||
|
@ -74,8 +76,8 @@
|
|||
-(void)setTab: (NSTabViewItem*)tab;
|
||||
|
||||
-(NSWindow*)getNativeWindow;
|
||||
|
||||
-(NSMenu*)getContextMenu;
|
||||
-(void)setIsBookmarksImport:(BOOL)aIsImport;
|
||||
|
||||
-(id)initWithTab:(id)aTab andWindow:(NSWindow*)aWindow;
|
||||
|
||||
|
|
|
@ -37,12 +37,16 @@
|
|||
|
||||
#import "CHBrowserWrapper.h"
|
||||
#import "BrowserWindowController.h"
|
||||
#import "BookmarksService.h"
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIIOService.h"
|
||||
#include "ContentClickListener.h"
|
||||
#include "nsIDOMWindow.h"
|
||||
#include "nsIWebBrowser.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIDOMHTMLDocument.h"
|
||||
#include "nsIChromeEventHandler.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
#include "nsIDOMEventReceiver.h"
|
||||
|
@ -98,6 +102,7 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
|||
{
|
||||
mTab = aTab;
|
||||
mWindow = aWindow;
|
||||
mIsBookmarksImport = NO;
|
||||
return [self initWithFrame: NSZeroRect];
|
||||
}
|
||||
|
||||
|
@ -219,9 +224,6 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
|||
|
||||
if (mWindowController)
|
||||
[mWindowController updateToolbarItems];
|
||||
else {
|
||||
printf("background load.\n");
|
||||
}
|
||||
}
|
||||
|
||||
- (void)onLoadingCompleted:(BOOL)succeeded
|
||||
|
@ -239,7 +241,22 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
|||
}
|
||||
|
||||
mIsBusy = NO;
|
||||
|
||||
|
||||
if (mIsBookmarksImport) {
|
||||
nsCOMPtr<nsIDOMWindow> domWindow;
|
||||
nsCOMPtr<nsIWebBrowser> webBrowser = getter_AddRefs([mBrowserView getWebBrowser]);
|
||||
webBrowser->GetContentDOMWindow(getter_AddRefs(domWindow));
|
||||
if (domWindow) {
|
||||
nsCOMPtr<nsIDOMDocument> domDocument;
|
||||
domWindow->GetDocument(getter_AddRefs(domDocument));
|
||||
nsCOMPtr<nsIDOMHTMLDocument> htmlDoc(do_QueryInterface(domDocument));
|
||||
if (htmlDoc)
|
||||
BookmarksService::ImportBookmarks(htmlDoc);
|
||||
}
|
||||
[self windowClosed];
|
||||
[self removeFromSuperview];
|
||||
}
|
||||
|
||||
if (mWindowController)
|
||||
[mWindowController updateToolbarItems];
|
||||
}
|
||||
|
@ -346,6 +363,11 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
|||
return nil;
|
||||
}
|
||||
|
||||
-(void)setIsBookmarksImport:(BOOL)aIsImport
|
||||
{
|
||||
mIsBookmarksImport = aIsImport;
|
||||
}
|
||||
|
||||
- (void)offlineModeChanged: (NSNotification*)aNotification
|
||||
{
|
||||
nsCOMPtr<nsIIOService> ioService(do_GetService(ioServiceContractID));
|
||||
|
|
|
@ -130,7 +130,7 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
|||
|
||||
-(IBAction) openFile:(id)aSender
|
||||
{
|
||||
NSOpenPanel* openPanel = [[NSOpenPanel alloc] init];
|
||||
NSOpenPanel* openPanel = [[[NSOpenPanel alloc] init] autorelease];
|
||||
[openPanel setCanChooseFiles: YES];
|
||||
[openPanel setCanChooseDirectories: NO];
|
||||
[openPanel setAllowsMultipleSelection: NO];
|
||||
|
@ -293,7 +293,7 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
|||
// IE favorites: ~/Library/Preferences/Explorer/Favorites.html
|
||||
// Omniweb favorites: ~/Library/Application Support/Omniweb/Bookmarks.html
|
||||
// For now, open the panel to IE's favorites.
|
||||
NSOpenPanel* openPanel = [[NSOpenPanel alloc] init];
|
||||
NSOpenPanel* openPanel = [[[NSOpenPanel alloc] init] autorelease];
|
||||
[openPanel setCanChooseFiles: YES];
|
||||
[openPanel setCanChooseDirectories: NO];
|
||||
[openPanel setAllowsMultipleSelection: NO];
|
||||
|
@ -306,6 +306,14 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
|||
if ([urlArray count] == 0)
|
||||
return;
|
||||
NSURL* url = [urlArray objectAtIndex: 0];
|
||||
|
||||
NSWindow* window = [mApplication mainWindow];
|
||||
if (!window) {
|
||||
[self newWindow: self];
|
||||
window = [mApplication mainWindow];
|
||||
}
|
||||
|
||||
[[window windowController] importBookmarks: url];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -130,7 +130,7 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
|||
|
||||
-(IBAction) openFile:(id)aSender
|
||||
{
|
||||
NSOpenPanel* openPanel = [[NSOpenPanel alloc] init];
|
||||
NSOpenPanel* openPanel = [[[NSOpenPanel alloc] init] autorelease];
|
||||
[openPanel setCanChooseFiles: YES];
|
||||
[openPanel setCanChooseDirectories: NO];
|
||||
[openPanel setAllowsMultipleSelection: NO];
|
||||
|
@ -293,7 +293,7 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
|||
// IE favorites: ~/Library/Preferences/Explorer/Favorites.html
|
||||
// Omniweb favorites: ~/Library/Application Support/Omniweb/Bookmarks.html
|
||||
// For now, open the panel to IE's favorites.
|
||||
NSOpenPanel* openPanel = [[NSOpenPanel alloc] init];
|
||||
NSOpenPanel* openPanel = [[[NSOpenPanel alloc] init] autorelease];
|
||||
[openPanel setCanChooseFiles: YES];
|
||||
[openPanel setCanChooseDirectories: NO];
|
||||
[openPanel setAllowsMultipleSelection: NO];
|
||||
|
@ -306,6 +306,14 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
|||
if ([urlArray count] == 0)
|
||||
return;
|
||||
NSURL* url = [urlArray objectAtIndex: 0];
|
||||
|
||||
NSWindow* window = [mApplication mainWindow];
|
||||
if (!window) {
|
||||
[self newWindow: self];
|
||||
window = [mApplication mainWindow];
|
||||
}
|
||||
|
||||
[[window windowController] importBookmarks: url];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -97,6 +97,8 @@ class nsIAtom;
|
|||
- (id)copyWithZone:(NSZone *)aZone;
|
||||
@end
|
||||
|
||||
class nsIDOMHTMLDocument;
|
||||
|
||||
class BookmarksService
|
||||
{
|
||||
public:
|
||||
|
@ -125,6 +127,8 @@ public:
|
|||
|
||||
static void EnsureToolbarRoot();
|
||||
|
||||
static void ImportBookmarks(nsIDOMHTMLDocument* aHTMLDoc);
|
||||
|
||||
static void GetTitleAndHrefForBrowserView(id aBrowserView, nsString& aTitle, nsString& aHref);
|
||||
static void OpenBookmarkGroup(id aTabView, nsIDOMElement* aFolder);
|
||||
|
||||
|
|
|
@ -979,6 +979,12 @@ BookmarksService::OpenMenuBookmark(BrowserWindowController* aController, id aMen
|
|||
[[[aController getBrowserWrapper] getBrowserView] setActive: YES];
|
||||
}
|
||||
|
||||
void
|
||||
BookmarksService::ImportBookmarks(nsIDOMHTMLDocument* aHTMLDoc)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
BookmarksService::OpenBookmarkGroup(id aTabView, nsIDOMElement* aFolder)
|
||||
{
|
||||
|
|
|
@ -138,6 +138,7 @@ class nsIDOMNode;
|
|||
|
||||
- (void)addBookmarkExtended: (BOOL)aIsFromMenu isFolder:(BOOL)aIsFolder;
|
||||
- (IBAction)manageBookmarks: (id)aSender;
|
||||
- (void)importBookmarks: (NSURL*)aURL;
|
||||
- (IBAction)toggleSidebar:(id)aSender;
|
||||
|
||||
- (void)newTab;
|
||||
|
|
|
@ -472,6 +472,19 @@ static NSString *PrintToolbarItemIdentifier = @"Print Toolbar Item";
|
|||
[mSidebarTabView selectFirstTabViewItem:self];
|
||||
}
|
||||
|
||||
- (void)importBookmarks: (NSURL*)aURL
|
||||
{
|
||||
// Open the bookmarks sidebar.
|
||||
[self manageBookmarks: self];
|
||||
|
||||
// Now do the importing.
|
||||
CHBrowserWrapper* newView = [[[CHBrowserWrapper alloc] initWithTab: nil andWindow: [self window]] autorelease];
|
||||
[newView setFrame: NSZeroRect];
|
||||
[newView setIsBookmarksImport: YES];
|
||||
[[[self window] contentView] addSubview: newView];
|
||||
[[newView getBrowserView] loadURI:aURL flags:NSLoadFlagsNone];
|
||||
}
|
||||
|
||||
- (IBAction)goToLocationFromToolbarURLField:(id)sender
|
||||
{
|
||||
[self loadURL:[NSURL URLWithString:[sender stringValue]]];
|
||||
|
|
|
@ -57,6 +57,8 @@
|
|||
BOOL mOffline;
|
||||
BOOL mListenersAttached; // We hook up our click and context menu listeners lazily.
|
||||
// If we never become the primary view, we don't bother creating the listeners.
|
||||
BOOL mIsBookmarksImport; // This view was created for the purpose of importing bookmarks. Upon
|
||||
// completion, we need to do the import and then destroy ourselves.
|
||||
}
|
||||
|
||||
- (IBAction)load:(id)sender;
|
||||
|
@ -74,8 +76,8 @@
|
|||
-(void)setTab: (NSTabViewItem*)tab;
|
||||
|
||||
-(NSWindow*)getNativeWindow;
|
||||
|
||||
-(NSMenu*)getContextMenu;
|
||||
-(void)setIsBookmarksImport:(BOOL)aIsImport;
|
||||
|
||||
-(id)initWithTab:(id)aTab andWindow:(NSWindow*)aWindow;
|
||||
|
||||
|
|
|
@ -37,12 +37,16 @@
|
|||
|
||||
#import "CHBrowserWrapper.h"
|
||||
#import "BrowserWindowController.h"
|
||||
#import "BookmarksService.h"
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIIOService.h"
|
||||
#include "ContentClickListener.h"
|
||||
#include "nsIDOMWindow.h"
|
||||
#include "nsIWebBrowser.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIDOMHTMLDocument.h"
|
||||
#include "nsIChromeEventHandler.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
#include "nsIDOMEventReceiver.h"
|
||||
|
@ -98,6 +102,7 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
|||
{
|
||||
mTab = aTab;
|
||||
mWindow = aWindow;
|
||||
mIsBookmarksImport = NO;
|
||||
return [self initWithFrame: NSZeroRect];
|
||||
}
|
||||
|
||||
|
@ -219,9 +224,6 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
|||
|
||||
if (mWindowController)
|
||||
[mWindowController updateToolbarItems];
|
||||
else {
|
||||
printf("background load.\n");
|
||||
}
|
||||
}
|
||||
|
||||
- (void)onLoadingCompleted:(BOOL)succeeded
|
||||
|
@ -239,7 +241,22 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
|||
}
|
||||
|
||||
mIsBusy = NO;
|
||||
|
||||
|
||||
if (mIsBookmarksImport) {
|
||||
nsCOMPtr<nsIDOMWindow> domWindow;
|
||||
nsCOMPtr<nsIWebBrowser> webBrowser = getter_AddRefs([mBrowserView getWebBrowser]);
|
||||
webBrowser->GetContentDOMWindow(getter_AddRefs(domWindow));
|
||||
if (domWindow) {
|
||||
nsCOMPtr<nsIDOMDocument> domDocument;
|
||||
domWindow->GetDocument(getter_AddRefs(domDocument));
|
||||
nsCOMPtr<nsIDOMHTMLDocument> htmlDoc(do_QueryInterface(domDocument));
|
||||
if (htmlDoc)
|
||||
BookmarksService::ImportBookmarks(htmlDoc);
|
||||
}
|
||||
[self windowClosed];
|
||||
[self removeFromSuperview];
|
||||
}
|
||||
|
||||
if (mWindowController)
|
||||
[mWindowController updateToolbarItems];
|
||||
}
|
||||
|
@ -346,6 +363,11 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
|||
return nil;
|
||||
}
|
||||
|
||||
-(void)setIsBookmarksImport:(BOOL)aIsImport
|
||||
{
|
||||
mIsBookmarksImport = aIsImport;
|
||||
}
|
||||
|
||||
- (void)offlineModeChanged: (NSNotification*)aNotification
|
||||
{
|
||||
nsCOMPtr<nsIIOService> ioService(do_GetService(ioServiceContractID));
|
||||
|
|
Загрузка…
Ссылка в новой задаче