summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
Diffstat (limited to 'chrome')
-rw-r--r--chrome/app/app-Info.plist140
-rw-r--r--chrome/browser/app_controller_mac.mm62
-rw-r--r--chrome/browser/browser_init.h16
3 files changed, 209 insertions, 9 deletions
diff --git a/chrome/app/app-Info.plist b/chrome/app/app-Info.plist
index 9b83981..d8472b6 100644
--- a/chrome/app/app-Info.plist
+++ b/chrome/app/app-Info.plist
@@ -4,6 +4,116 @@
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
+ <key>CFBundleDocumentTypes</key>
+ <array>
+ <dict>
+ <key>CFBundleTypeExtensions</key>
+ <array>
+ <string>gif</string>
+ </array>
+ <key>CFBundleTypeMIMETypes</key>
+ <array>
+ <string>image/gif</string>
+ </array>
+ <key>CFBundleTypeName</key>
+ <string>GIF image</string>
+ <key>CFBundleTypeOSTypes</key>
+ <array>
+ <string>GIFf</string>
+ </array>
+ <key>CFBundleTypeRole</key>
+ <string>Viewer</string>
+ </dict>
+ <dict>
+ <key>CFBundleTypeExtensions</key>
+ <array>
+ <string>html</string>
+ <string>htm</string>
+ </array>
+ <key>CFBundleTypeMIMETypes</key>
+ <array>
+ <string>text/html</string>
+ </array>
+ <key>CFBundleTypeName</key>
+ <string>HTML document</string>
+ <key>CFBundleTypeOSTypes</key>
+ <array>
+ <string>HTML</string>
+ </array>
+ <key>CFBundleTypeRole</key>
+ <string>Viewer</string>
+ </dict>
+ <dict>
+ <key>CFBundleTypeExtensions</key>
+ <array>
+ <string>js</string>
+ </array>
+ <key>CFBundleTypeMIMETypes</key>
+ <array>
+ <string>application/x-javascript</string>
+ </array>
+ <key>CFBundleTypeName</key>
+ <string>JavaScript script</string>
+ <key>CFBundleTypeRole</key>
+ <string>Viewer</string>
+ </dict>
+ <dict>
+ <key>CFBundleTypeExtensions</key>
+ <array>
+ <string>jpg</string>
+ <string>jpeg</string>
+ </array>
+ <key>CFBundleTypeMIMETypes</key>
+ <array>
+ <string>image/jpeg</string>
+ </array>
+ <key>CFBundleTypeName</key>
+ <string>JPEG image</string>
+ <key>CFBundleTypeOSTypes</key>
+ <array>
+ <string>JPEG</string>
+ </array>
+ <key>CFBundleTypeRole</key>
+ <string>Viewer</string>
+ </dict>
+ <dict>
+ <key>CFBundleTypeExtensions</key>
+ <array>
+ <string>txt</string>
+ <string>text</string>
+ </array>
+ <key>CFBundleTypeMIMETypes</key>
+ <array>
+ <string>text/plain</string>
+ </array>
+ <key>CFBundleTypeName</key>
+ <string>Plain text document</string>
+ <key>CFBundleTypeOSTypes</key>
+ <array>
+ <string>TEXT</string>
+ </array>
+ <key>CFBundleTypeRole</key>
+ <string>Viewer</string>
+ </dict>
+ <dict>
+ <key>CFBundleTypeExtensions</key>
+ <array>
+ <string>png</string>
+ </array>
+ <key>CFBundleTypeMIMETypes</key>
+ <array>
+ <string>image/png</string>
+ </array>
+ <key>CFBundleTypeName</key>
+ <string>PNG image</string>
+ <key>CFBundleTypeOSTypes</key>
+ <array>
+ <string>PNGf</string>
+ </array>
+ <key>CFBundleTypeRole</key>
+ <string>Viewer</string>
+ </dict>
+ </array>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIconFile</key>
@@ -16,8 +126,38 @@
<string>APPL</string>
<key>CFBundleSignature</key>
<string>????</string>
+ <key>CFBundleURLTypes</key>
+ <array>
+ <dict>
+ <key>CFBundleURLName</key>
+ <string>Web site URL</string>
+ <key>CFBundleURLSchemes</key>
+ <array>
+ <string>http</string>
+ <string>https</string>
+ </array>
+ </dict>
+ <dict>
+ <key>CFBundleURLName</key>
+ <string>FTP site URL</string>
+ <key>CFBundleURLSchemes</key>
+ <array>
+ <string>ftp</string>
+ </array>
+ </dict>
+ <dict>
+ <key>CFBundleURLName</key>
+ <string>Local file URL</string>
+ <key>CFBundleURLSchemes</key>
+ <array>
+ <string>file</string>
+ </array>
+ </dict>
+ </array>
<key>CFBundleVersion</key>
<string>0.1</string>
+ <key>LSFileQuarantineEnabled</key>
+ <true/>
<key>LSUIElement</key>
<string>1</string>
<key>NSMainNibFile</key>
diff --git a/chrome/browser/app_controller_mac.mm b/chrome/browser/app_controller_mac.mm
index 71eb508..6b2bf48 100644
--- a/chrome/browser/app_controller_mac.mm
+++ b/chrome/browser/app_controller_mac.mm
@@ -4,9 +4,12 @@
#import "chrome/browser/app_controller_mac.h"
+#include "base/command_line.h"
#include "base/message_loop.h"
+#include "base/sys_string_conversions.h"
#include "chrome/app/chrome_dll_resource.h"
#include "chrome/browser/browser.h"
+#include "chrome/browser/browser_init.h"
#include "chrome/browser/browser_list.h"
#include "chrome/browser/browser_shutdown.h"
#import "chrome/browser/cocoa/bookmark_menu_bridge.h"
@@ -16,6 +19,8 @@
@interface AppController(PRIVATE)
- (void)initMenuState;
+- (void)getUrl:(NSAppleEventDescriptor*)event
+ withReply:(NSAppleEventDescriptor*)reply;
@end
@implementation AppController
@@ -32,6 +37,16 @@
// will be the signal to exit.
DCHECK(g_browser_process);
g_browser_process->AddRefModule();
+
+ NSAppleEventManager* em = [NSAppleEventManager sharedAppleEventManager];
+ [em setEventHandler:self
+ andSelector:@selector(getUrl:withReply:)
+ forEventClass:kInternetEventClass
+ andEventID:kAEGetURL];
+ [em setEventHandler:self
+ andSelector:@selector(getUrl:withReply:)
+ forEventClass:'WWW!' // A particularly ancient AppleEvent that dates
+ andEventID:'OURL']; // back to the Spyglass days.
}
- (void)dealloc {
@@ -52,6 +67,12 @@
// handle it. If it says to continue, post the quit message, otherwise
// go back to normal.
+ NSAppleEventManager* em = [NSAppleEventManager sharedAppleEventManager];
+ [em removeEventHandlerForEventClass:kInternetEventClass
+ andEventID:kAEGetURL];
+ [em removeEventHandlerForEventClass:'WWW!'
+ andEventID:'OURL'];
+
// TODO(pinkerton): Not sure where this should live, including it here
// causes all sorts of asserts from the open renderers. On Windows, it
// lives in Browser::OnWindowClosing, but that's not appropriate on Mac
@@ -134,10 +155,49 @@
// TODO(jrg): DCHECK() to confirm that.
// TODO(jrg): Find a better way to get the "default" profile.
if (g_browser_process->profile_manager())
- return *g_browser_process->profile_manager()->begin();
+ return* g_browser_process->profile_manager()->begin();
return NULL;
}
+// Various methods to open URLs that we get in a native fashion. We use
+// BrowserInit here because on the other platforms, URLs to open come through
+// the ProcessSingleton, and it calls BrowserInit. It's best to bottleneck the
+// openings through that for uniform handling.
+
+namespace {
+
+void OpenURLs(const std::vector<GURL>& urls) {
+ CommandLine dummy((std::wstring()));
+ BrowserInit::LaunchWithProfile launch(std::wstring(), dummy);
+ launch.OpenURLsInBrowser(BrowserList::GetLastActive(), false, urls);
+}
+
+}
+
+- (void)getUrl:(NSAppleEventDescriptor*)event
+ withReply:(NSAppleEventDescriptor*)reply {
+ NSString* urlStr = [[event paramDescriptorForKeyword:keyDirectObject]
+ stringValue];
+
+ GURL gurl(base::SysNSStringToUTF8(urlStr));
+ std::vector<GURL> gurlVector;
+ gurlVector.push_back(gurl);
+
+ OpenURLs(gurlVector);
+}
+
+- (void)application:(NSApplication*)sender
+ openFiles:(NSArray*)filenames {
+ std::vector<GURL> gurlVector;
+
+ for (NSString* filename in filenames) {
+ NSURL* fileURL = [NSURL fileURLWithPath:filename];
+ GURL gurl(base::SysNSStringToUTF8([fileURL absoluteString]));
+ gurlVector.push_back(gurl);
+ }
+
+ OpenURLs(gurlVector);
+}
@end
diff --git a/chrome/browser/browser_init.h b/chrome/browser/browser_init.h
index 290ec12..a456d5d 100644
--- a/chrome/browser/browser_init.h
+++ b/chrome/browser/browser_init.h
@@ -41,6 +41,14 @@ class BrowserInit {
// already running and the user wants to launch another instance.
bool Launch(Profile* profile, bool process_startup);
+ // Opens the list of urls. If browser is non-null and a tabbed browser, the
+ // URLs are opened in it. Otherwise a new tabbed browser is created and the
+ // URLs are added to it. The browser the tabs are added to is returned,
+ // which is either |browser| or the newly created browser.
+ Browser* OpenURLsInBrowser(Browser* browser,
+ bool process_startup,
+ const std::vector<GURL>& urls);
+
private:
// If the process was launched with the web application command line flag,
// e.g. --app=http://www.google.com/, opens a web application browser and
@@ -59,14 +67,6 @@ class BrowserInit {
bool OpenStartupURLs(bool is_process_startup,
const std::vector<GURL>& urls_to_open);
- // Opens the list of urls. If browser is non-null and a tabbed browser, the
- // URLs are opened in it. Otherwise a new tabbed browser is created and the
- // URLs are added to it. The browser the tabs are added to is returned,
- // which is either |browser| or the newly created browser.
- Browser* OpenURLsInBrowser(Browser* browser,
- bool process_startup,
- const std::vector<GURL>& urls);
-
// If the last session didn't exit cleanly and tab is a web contents tab,
// an infobar is added allowing the user to restore the last session.
void AddCrashedInfoBarIfNecessary(TabContents* tab);