1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef CHROME_COMMON_MAC_APP_MODE_COMMON_H_ 6 #define CHROME_COMMON_MAC_APP_MODE_COMMON_H_ 7 8 #import <Foundation/Foundation.h> 9 10 #include "base/files/file_path.h" 11 #include "base/strings/string16.h" 12 13 // This file contains constants, interfaces, etc. which are common to the 14 // browser application and the app mode loader (a.k.a. shim). 15 16 namespace app_mode { 17 18 // These are keys for an Apple Event ping that the app shim process sends to 19 // Chrome to get confirmation that Chrome is alive. The main Chrome process 20 // doesn't need to register any handlers for them -- the event is just sent for 21 // the empty reply that's automatically returned by the system. 22 const AEEventClass kAEChromeAppClass = 'cApp'; 23 const AEEventID kAEChromeAppPing = 'ping'; 24 25 // The IPC socket used to communicate between app shims and Chrome will be 26 // created under a temporary directory with this name. 27 extern const char kAppShimSocketShortName[]; 28 // A symlink to allow the app shim to find the socket will be created under the 29 // user data dir with this name. 30 extern const char kAppShimSocketSymlinkName[]; 31 32 // A symlink used to store the version string of the currently running Chrome. 33 // The shim will read this to determine which version of the framework to load. 34 extern const char kRunningChromeVersionSymlinkName[]; 35 36 // Special app mode id used for the App Launcher. 37 extern const char kAppListModeId[]; 38 39 // The process ID of the Chrome process that launched the app shim. 40 // The presence of this switch instructs the app shim to send LaunchApp with 41 // launch_now = false. This associates the shim without launching the app. 42 extern const char kLaunchedByChromeProcessId[]; 43 44 // Indicates to the shim that it was launched for a test, so don't attempt to 45 // launch Chrome. 46 extern const char kLaunchedForTest[]; 47 48 // Indicates to the shim that this Chrome has rebuilt it once already, i.e. if 49 // it fails to launch again, don't trigger another rebuild. 50 extern const char kLaunchedAfterRebuild[]; 51 52 // Path to an app shim bundle. Indicates to Chrome that this shim attempted to 53 // launch but failed. 54 extern const char kAppShimError[]; 55 56 // Keys for specifying the file types handled by an app. 57 extern NSString* const kCFBundleDocumentTypesKey; 58 extern NSString* const kCFBundleTypeExtensionsKey; 59 extern NSString* const kCFBundleTypeIconFileKey; 60 extern NSString* const kCFBundleTypeNameKey; 61 extern NSString* const kCFBundleTypeMIMETypesKey; 62 extern NSString* const kCFBundleTypeRoleKey; 63 extern NSString* const kBundleTypeRoleViewer; 64 65 // The display name of the bundle as shown in Finder and the Dock. For localized 66 // bundles, this overrides the bundle's file name. 67 extern NSString* const kCFBundleDisplayNameKey; 68 69 // The Chrome version string in the app shim bundle. 70 extern NSString* const kCFBundleShortVersionStringKey; 71 72 // The key specifying whether the display name should be localized. This makes 73 // Finder look in localization folders in the app bundle for a display name. 74 // (e.g. Content/Resources/en.lproj/) 75 extern NSString* const kLSHasLocalizedDisplayNameKey; 76 77 // The key under which the browser's bundle ID will be stored in the 78 // app mode launcher bundle's Info.plist. 79 extern NSString* const kBrowserBundleIDKey; 80 81 // Key for the shortcut ID. 82 extern NSString* const kCrAppModeShortcutIDKey; 83 84 // Key for the app's name. 85 extern NSString* const kCrAppModeShortcutNameKey; 86 87 // Key for the app's URL. 88 extern NSString* const kCrAppModeShortcutURLKey; 89 90 // Key for the app user data directory. 91 extern NSString* const kCrAppModeUserDataDirKey; 92 93 // Key for the app's extension path. 94 extern NSString* const kCrAppModeProfileDirKey; 95 96 // Key for the app's profile display name. 97 extern NSString* const kCrAppModeProfileNameKey; 98 99 // When the Chrome browser is run, it stores its location in the defaults 100 // system using this key. 101 extern NSString* const kLastRunAppBundlePathPrefsKey; 102 103 // Placeholders used in the app mode loader bundle' Info.plist: 104 extern NSString* const kShortcutIdPlaceholder; // Extension shortcut ID. 105 extern NSString* const kShortcutNamePlaceholder; // Extension name. 106 extern NSString* const kShortcutURLPlaceholder; 107 // Bundle ID of the Chrome browser bundle. 108 extern NSString* const kShortcutBrowserBundleIDPlaceholder; 109 110 // Current major/minor version numbers of |ChromeAppModeInfo| (defined below). 111 const unsigned kCurrentChromeAppModeInfoMajorVersion = 1; 112 const unsigned kCurrentChromeAppModeInfoMinorVersion = 3; 113 114 // The structure used to pass information from the app mode loader to the 115 // (browser) framework. This is versioned using major and minor version numbers, 116 // written below as v<major>.<minor>. Version-number checking is done by the 117 // framework, and the framework must accept all structures with the same major 118 // version number. It may refuse to load if the major version of the structure 119 // is different from the one it accepts. 120 struct ChromeAppModeInfo { 121 public: 122 ChromeAppModeInfo(); 123 ~ChromeAppModeInfo(); 124 125 // Major and minor version number of this structure. 126 unsigned major_version; // Required: all versions 127 unsigned minor_version; // Required: all versions 128 129 // Original |argc| and |argv|. 130 int argc; // Required: v1.0 131 char** argv; // Required: v1.0 132 133 // Versioned path to the browser which is being loaded. 134 base::FilePath chrome_versioned_path; // Required: v1.0 135 136 // Path to Chrome app bundle. 137 base::FilePath chrome_outer_bundle_path; // Required: v1.0 138 139 // Information about the App Mode shortcut: 140 141 // Path to the App Mode Loader application bundle that launched the process. 142 base::FilePath app_mode_bundle_path; // Optional: v1.0 143 144 // Short ID string, preferably derived from |app_mode_short_name|. Should be 145 // safe for the file system. 146 std::string app_mode_id; // Required: v1.0 147 148 // Unrestricted (e.g., several-word) UTF8-encoded name for the shortcut. 149 base::string16 app_mode_name; // Optional: v1.0 150 151 // URL for the shortcut. Must be a valid URL. 152 std::string app_mode_url; // Required: v1.0 153 154 // Path to the app's user data directory. 155 base::FilePath user_data_dir; 156 157 // Directory of the profile associated with the app. 158 base::FilePath profile_dir; 159 }; 160 161 // Check that the socket and its parent directory have the correct permissions 162 // and are owned by the user. 163 void VerifySocketPermissions(const base::FilePath& socket_path); 164 165 } // namespace app_mode 166 167 #endif // CHROME_COMMON_MAC_APP_MODE_COMMON_H_ 168