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:
Adam Roben 2013-03-13 16:45:00 -04:00
Родитель 65dd011fa3
Коммит e1b5e5e1bf
5 изменённых файлов: 34 добавлений и 9 удалений

Просмотреть файл

@ -7,6 +7,7 @@
'target_name': 'brightray',
'type': 'static_library',
'include_dirs': [
'.',
'<(libchromiumcontent_include_dir)',
],
'direct_dependent_settings': {
@ -28,6 +29,8 @@
'browser/network_delegate.h',
'browser/url_request_context_getter.cc',
'browser/url_request_context_getter.h',
'common/application_name.h',
'common/application_name_mac.mm',
'common/main_delegate.cc',
'common/main_delegate.h',
'common/main_delegate_mac.mm',

Просмотреть файл

@ -4,6 +4,8 @@
#include "browser_context.h"
#include "common/application_name.h"
#include "base/files/file_path.h"
#include "base/path_service.h"
#include "content/public/browser/browser_thread.h"
@ -53,10 +55,9 @@ net::URLRequestContextGetter* BrowserContext::CreateRequestContext(content::Prot
}
base::FilePath BrowserContext::GetPath() {
// FIXME: This should be an application-specific path.
base::FilePath path;
CHECK(PathService::Get(base::DIR_APP_DATA, &path));
return path.Append("Brightray");
return path.Append(GetApplicationName());
}
bool BrowserContext::IsOffTheRecord() const {

Просмотреть файл

@ -0,0 +1,12 @@
#ifndef BRIGHTRAY_COMMON_APPLICATION_NAME_H_
#define BRIGHTRAY_COMMON_APPLICATION_NAME_H_
#include <string>
namespace brightray {
std::string GetApplicationName();
}
#endif

Просмотреть файл

@ -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);
}