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
|
@ -7,6 +7,7 @@
|
||||||
'target_name': 'brightray',
|
'target_name': 'brightray',
|
||||||
'type': 'static_library',
|
'type': 'static_library',
|
||||||
'include_dirs': [
|
'include_dirs': [
|
||||||
|
'.',
|
||||||
'<(libchromiumcontent_include_dir)',
|
'<(libchromiumcontent_include_dir)',
|
||||||
],
|
],
|
||||||
'direct_dependent_settings': {
|
'direct_dependent_settings': {
|
||||||
|
@ -28,6 +29,8 @@
|
||||||
'browser/network_delegate.h',
|
'browser/network_delegate.h',
|
||||||
'browser/url_request_context_getter.cc',
|
'browser/url_request_context_getter.cc',
|
||||||
'browser/url_request_context_getter.h',
|
'browser/url_request_context_getter.h',
|
||||||
|
'common/application_name.h',
|
||||||
|
'common/application_name_mac.mm',
|
||||||
'common/main_delegate.cc',
|
'common/main_delegate.cc',
|
||||||
'common/main_delegate.h',
|
'common/main_delegate.h',
|
||||||
'common/main_delegate_mac.mm',
|
'common/main_delegate_mac.mm',
|
||||||
|
|
|
@ -4,6 +4,8 @@
|
||||||
|
|
||||||
#include "browser_context.h"
|
#include "browser_context.h"
|
||||||
|
|
||||||
|
#include "common/application_name.h"
|
||||||
|
|
||||||
#include "base/files/file_path.h"
|
#include "base/files/file_path.h"
|
||||||
#include "base/path_service.h"
|
#include "base/path_service.h"
|
||||||
#include "content/public/browser/browser_thread.h"
|
#include "content/public/browser/browser_thread.h"
|
||||||
|
@ -53,10 +55,9 @@ net::URLRequestContextGetter* BrowserContext::CreateRequestContext(content::Prot
|
||||||
}
|
}
|
||||||
|
|
||||||
base::FilePath BrowserContext::GetPath() {
|
base::FilePath BrowserContext::GetPath() {
|
||||||
// FIXME: This should be an application-specific path.
|
|
||||||
base::FilePath path;
|
base::FilePath path;
|
||||||
CHECK(PathService::Get(base::DIR_APP_DATA, &path));
|
CHECK(PathService::Get(base::DIR_APP_DATA, &path));
|
||||||
return path.Append("Brightray");
|
return path.Append(GetApplicationName());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BrowserContext::IsOffTheRecord() const {
|
bool BrowserContext::IsOffTheRecord() const {
|
||||||
|
|
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"
|
#import "main_delegate.h"
|
||||||
|
|
||||||
|
#include "common/application_name.h"
|
||||||
#include "base/mac/bundle_locations.h"
|
#include "base/mac/bundle_locations.h"
|
||||||
#include "base/mac/foundation_util.h"
|
#include "base/mac/foundation_util.h"
|
||||||
#include "base/path_service.h"
|
#include "base/path_service.h"
|
||||||
|
@ -35,23 +36,19 @@ base::FilePath GetFrameworksPath() {
|
||||||
return path.Append("Frameworks");
|
return path.Append("Frameworks");
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string OuterBundleName() {
|
|
||||||
return [[base::mac::OuterBundle().infoDictionary objectForKey:base::mac::CFToNSCast(kCFBundleNameKey)] UTF8String];
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainDelegate::OverrideFrameworkBundlePath() {
|
void MainDelegate::OverrideFrameworkBundlePath() {
|
||||||
base::FilePath helper_path = GetFrameworksPath().Append(OuterBundleName() + ".framework");
|
base::FilePath helper_path = GetFrameworksPath().Append(GetApplicationName() + ".framework");
|
||||||
|
|
||||||
base::mac::SetOverrideFrameworkBundlePath(helper_path);
|
base::mac::SetOverrideFrameworkBundlePath(helper_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainDelegate::OverrideChildProcessPath() {
|
void MainDelegate::OverrideChildProcessPath() {
|
||||||
base::FilePath helper_path = GetFrameworksPath().Append(OuterBundleName() + " Helper.app")
|
base::FilePath helper_path = GetFrameworksPath().Append(GetApplicationName() + " Helper.app")
|
||||||
.Append("Contents")
|
.Append("Contents")
|
||||||
.Append("MacOS")
|
.Append("MacOS")
|
||||||
.Append(OuterBundleName() + " Helper");
|
.Append(GetApplicationName() + " Helper");
|
||||||
|
|
||||||
PathService::Override(content::CHILD_PROCESS_EXE, helper_path);
|
PathService::Override(content::CHILD_PROCESS_EXE, helper_path);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue