Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2911)

Unified Diff: chrome/app/app_mode_loader_mac.mm

Issue 265163006: [Mac] Rebuild app shims when they fail to dyload Chrome Framework. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Write code that compiles Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/ui/app_list/app_list_service.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/app/app_mode_loader_mac.mm
diff --git a/chrome/app/app_mode_loader_mac.mm b/chrome/app/app_mode_loader_mac.mm
index 402aea80391101a2660b19e36bedbf6aafcb30c8..d83ea10840c43b01507ade1e02d78aab1b2ed442 100644
--- a/chrome/app/app_mode_loader_mac.mm
+++ b/chrome/app/app_mode_loader_mac.mm
@@ -20,7 +20,9 @@
#include "base/mac/foundation_util.h"
#include "base/mac/launch_services_util.h"
#include "base/mac/scoped_nsautorelease_pool.h"
+#include "base/process/launch.h"
#include "base/strings/sys_string_conversions.h"
+#include "chrome/common/chrome_switches.h"
#import "chrome/common/mac/app_mode_chrome_locator.h"
#include "chrome/common/mac/app_mode_common.h"
@@ -67,11 +69,15 @@ int LoadFrameworkAndStart(app_mode::ChromeAppModeInfo* info) {
}
// ** 2: Read information from the Chrome bundle.
+ base::FilePath executable_path;
base::string16 raw_version_str;
base::FilePath version_path;
base::FilePath framework_shlib_path;
- if (!app_mode::GetChromeBundleInfo(cr_bundle_path, &raw_version_str,
- &version_path, &framework_shlib_path)) {
+ if (!app_mode::GetChromeBundleInfo(cr_bundle_path,
+ &executable_path,
+ &raw_version_str,
+ &version_path,
+ &framework_shlib_path)) {
LOG(FATAL) << "Couldn't ready Chrome bundle info";
}
base::FilePath app_mode_bundle_path =
@@ -115,28 +121,44 @@ int LoadFrameworkAndStart(app_mode::ChromeAppModeInfo* info) {
LOG(ERROR) << "Couldn't load framework: " << dlerror();
}
- if (ChromeAppModeStart) {
+ if (ChromeAppModeStart)
return ChromeAppModeStart(info);
- } else {
- LOG(ERROR) << "Loading Chrome failed, launching with command line.";
- // Launch Chrome instead and have it update this app_mode_loader bundle.
- CommandLine command_line(CommandLine::NO_PROGRAM);
+
+ LOG(ERROR) << "Loading Chrome failed, launching Chrome with command line";
+ CommandLine command_line(executable_path);
+ if (CommandLine::ForCurrentProcess()->HasSwitch(
+ app_mode::kLaunchedByChromeProcessId) ||
+ info->app_mode_id == app_mode::kAppListModeId) {
+ // Pass --app-shim-error to have Chrome rebuild this shim.
command_line.AppendSwitchPath(app_mode::kAppShimError,
app_mode_bundle_path);
- if (!base::mac::OpenApplicationWithPath(
- cr_bundle_path, command_line, kLSLaunchDefaults, NULL)) {
- LOG(ERROR) << "Could not launch Chrome from: " << cr_bundle_path.value();
- return 1;
- }
-
- return 0;
+ } else {
+ // If the shim was launched directly (instead of by Chrome), first ask
+ // Chrome to launch the app. Chrome will launch the shim again, the same
+ // error will occur and be handled above. This approach allows the app to be
+ // started without blocking on fixing the shim and guarantees that the
+ // profile is loaded when Chrome receives --app-shim-error.
+ command_line.AppendSwitchPath(switches::kProfileDirectory,
+ info->profile_dir);
+ command_line.AppendSwitchASCII(switches::kAppId, info->app_mode_id);
+ }
+ // Launch the executable directly since base::mac::OpenApplicationWithPath
+ // uses LSOpenApplication which doesn't pass command line arguments if the
+ // application is already running.
Nico 2014/05/07 23:45:44 If chrome's running already, this depends on the p
+ if (!base::LaunchProcess(command_line, base::LaunchOptions(), NULL)) {
+ LOG(ERROR) << "Could not launch Chrome: "
+ << command_line.GetCommandLineString();
+ return 1;
}
+
+ return 0;
}
} // namespace
__attribute__((visibility("default")))
int main(int argc, char** argv) {
+ CommandLine::Init(argc, argv);
app_mode::ChromeAppModeInfo info;
// Hard coded info parameters.
« no previous file with comments | « no previous file | chrome/browser/ui/app_list/app_list_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698