Store the disk cache in an app-specific location
We deduce the name of the application from the CFBundleName of the .app bundle and use a path based on that. Similar logic should be implementable for other platforms. Fixes #3.
This commit is contained in:
parent
65dd011fa3
commit
e1b5e5e1bf
5 changed files with 34 additions and 9 deletions
12
brightray/common/application_name.h
Normal file
12
brightray/common/application_name.h
Normal file
|
@ -0,0 +1,12 @@
|
|||
#ifndef BRIGHTRAY_COMMON_APPLICATION_NAME_H_
|
||||
#define BRIGHTRAY_COMMON_APPLICATION_NAME_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace brightray {
|
||||
|
||||
std::string GetApplicationName();
|
||||
|
||||
}
|
||||
|
||||
#endif
|
12
brightray/common/application_name_mac.mm
Normal file
12
brightray/common/application_name_mac.mm
Normal file
|
@ -0,0 +1,12 @@
|
|||
#import "common/application_name.h"
|
||||
|
||||
#import "base/mac/bundle_locations.h"
|
||||
#import "base/mac/foundation_util.h"
|
||||
|
||||
namespace brightray {
|
||||
|
||||
std::string GetApplicationName() {
|
||||
return [[base::mac::OuterBundle().infoDictionary objectForKey:base::mac::CFToNSCast(kCFBundleNameKey)] UTF8String];
|
||||
}
|
||||
|
||||
}
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
#import "main_delegate.h"
|
||||
|
||||
#include "common/application_name.h"
|
||||
#include "base/mac/bundle_locations.h"
|
||||
#include "base/mac/foundation_util.h"
|
||||
#include "base/path_service.h"
|
||||
|
@ -35,23 +36,19 @@ base::FilePath GetFrameworksPath() {
|
|||
return path.Append("Frameworks");
|
||||
}
|
||||
|
||||
std::string OuterBundleName() {
|
||||
return [[base::mac::OuterBundle().infoDictionary objectForKey:base::mac::CFToNSCast(kCFBundleNameKey)] UTF8String];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void MainDelegate::OverrideFrameworkBundlePath() {
|
||||
base::FilePath helper_path = GetFrameworksPath().Append(OuterBundleName() + ".framework");
|
||||
base::FilePath helper_path = GetFrameworksPath().Append(GetApplicationName() + ".framework");
|
||||
|
||||
base::mac::SetOverrideFrameworkBundlePath(helper_path);
|
||||
}
|
||||
|
||||
void MainDelegate::OverrideChildProcessPath() {
|
||||
base::FilePath helper_path = GetFrameworksPath().Append(OuterBundleName() + " Helper.app")
|
||||
base::FilePath helper_path = GetFrameworksPath().Append(GetApplicationName() + " Helper.app")
|
||||
.Append("Contents")
|
||||
.Append("MacOS")
|
||||
.Append(OuterBundleName() + " Helper");
|
||||
.Append(GetApplicationName() + " Helper");
|
||||
|
||||
PathService::Override(content::CHILD_PROCESS_EXE, helper_path);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue