Chromium Code Reviews| Index: chrome/app/android/chrome_main_delegate_android.cc |
| diff --git a/chrome/app/android/chrome_main_delegate_android.cc b/chrome/app/android/chrome_main_delegate_android.cc |
| index 48c8b0923b21088d75cf387fbe2ede7bbff92404..c496093f3ad6fbeaf7534209475f910c76f72ce5 100644 |
| --- a/chrome/app/android/chrome_main_delegate_android.cc |
| +++ b/chrome/app/android/chrome_main_delegate_android.cc |
| @@ -5,15 +5,24 @@ |
| #include "chrome/app/android/chrome_main_delegate_android.h" |
| #include "base/android/jni_android.h" |
| +#include "base/files/file_path.h" |
| +#include "base/files/file_util.h" |
| +#include "base/logging.h" |
| +#include "base/path_service.h" |
| #include "base/trace_event/trace_event.h" |
| #include "chrome/browser/android/chrome_startup_flags.h" |
| #include "chrome/browser/android/metrics/uma_utils.h" |
| #include "chrome/browser/android/metrics/uma_utils.h" |
| #include "chrome/browser/media/android/remote/remote_media_player_manager.h" |
| +#include "components/policy/core/browser/android/android_combined_policy_provider.h" |
|
newt (away)
2015/08/31 22:56:26
presubmit complained about this include being "ill
Yaron
2015/09/01 15:06:19
Why was it ok in the previous location? This is ju
newt (away)
2015/09/01 21:52:25
This code used to be in chrome_main_delegate_stagi
|
| #include "components/startup_metric_utils/startup_metric_utils.h" |
| #include "content/browser/media/android/browser_media_player_manager.h" |
| #include "content/public/browser/browser_main_runner.h" |
| +#if defined(SAFE_BROWSING_DB_REMOTE) |
| +#include "chrome/browser/safe_browsing/safe_browsing_api_handler.h" |
| +#endif |
| + |
| namespace { |
| content::BrowserMediaPlayerManager* CreateRemoteMediaPlayerManager( |
| @@ -33,6 +42,21 @@ ChromeMainDelegateAndroid::ChromeMainDelegateAndroid() { |
| ChromeMainDelegateAndroid::~ChromeMainDelegateAndroid() { |
| } |
| + |
| +bool ChromeMainDelegateAndroid::BasicStartupComplete(int* exit_code) { |
| +#if defined(SAFE_BROWSING_DB_REMOTE) |
| + safe_browsing_api_handler_.reset(CreateSafeBrowsingApiHandler()); |
| + SafeBrowsingApiHandler::SetInstance(safe_browsing_api_handler_.get()); |
| +#endif |
| + |
| + policy::android::AndroidCombinedPolicyProvider::SetShouldWaitForPolicy(true); |
| + SetChromeSpecificCommandLineFlags(); |
| + content::BrowserMediaPlayerManager::RegisterFactory( |
| + &CreateRemoteMediaPlayerManager); |
| + |
| + return ChromeMainDelegate::BasicStartupComplete(exit_code); |
| +} |
| + |
| void ChromeMainDelegateAndroid::SandboxInitialized( |
| const std::string& process_type) { |
| ChromeMainDelegate::SandboxInitialized(process_type); |
| @@ -43,6 +67,26 @@ int ChromeMainDelegateAndroid::RunProcess( |
| const content::MainFunctionParams& main_function_params) { |
| TRACE_EVENT0("startup", "ChromeMainDelegateAndroid::RunProcess") |
| if (process_type.empty()) { |
| + // By default, Android creates the directory accessible by others. |
| + // We'd like to tighten security and make it accessible only by |
| + // the browser process. |
| + base::FilePath data_path; |
| + bool ok = PathService::Get(base::DIR_ANDROID_APP_DATA, &data_path); |
| + if (ok) { |
| + int permissions; |
| + ok = base::GetPosixFilePermissions(data_path, &permissions); |
| + if (ok) |
| + permissions &= base::FILE_PERMISSION_USER_MASK; |
| + else |
| + permissions = base::FILE_PERMISSION_READ_BY_USER | |
| + base::FILE_PERMISSION_WRITE_BY_USER | |
| + base::FILE_PERMISSION_EXECUTE_BY_USER; |
| + |
| + ok = base::SetPosixFilePermissions(data_path, permissions); |
| + } |
| + if (!ok) |
| + LOG(ERROR) << "Failed to set permission of " << data_path.value().c_str(); |
| + |
| // Because the browser process can be started asynchronously as a series of |
| // UI thread tasks a second request to start it can come in while the |
| // first request is still being processed. Chrome must keep the same |
| @@ -60,11 +104,16 @@ int ChromeMainDelegateAndroid::RunProcess( |
| return ChromeMainDelegate::RunProcess(process_type, main_function_params); |
| } |
| -bool ChromeMainDelegateAndroid::BasicStartupComplete(int* exit_code) { |
| - SetChromeSpecificCommandLineFlags(); |
| - |
| - content::BrowserMediaPlayerManager::RegisterFactory( |
| - &CreateRemoteMediaPlayerManager); |
| +void ChromeMainDelegateAndroid::ProcessExiting( |
| + const std::string& process_type) { |
| +#if defined(SAFE_BROWSING_DB_REMOTE) |
| + SafeBrowsingApiHandler::SetInstance(NULL); |
| +#endif |
| +} |
| - return ChromeMainDelegate::BasicStartupComplete(exit_code); |
| +#if defined(SAFE_BROWSING_DB_REMOTE) |
| +SafeBrowsingApiHandler* |
| +ChromeMainDelegateAndroid::CreateSafeBrowsingApiHandler() { |
| + return NULL; |
| } |
| +#endif |