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

Side by Side Diff: chrome/app/android/chrome_main_delegate_android.cc

Issue 1320253002: Merge ChromeMainDelegateStagingAndroid into ChromeMainDelegateAndroid. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/app/android/chrome_main_delegate_android.h" 5 #include "chrome/app/android/chrome_main_delegate_android.h"
6 6
7 #include "base/android/jni_android.h" 7 #include "base/android/jni_android.h"
8 #include "base/files/file_path.h"
9 #include "base/files/file_util.h"
10 #include "base/logging.h"
11 #include "base/path_service.h"
8 #include "base/trace_event/trace_event.h" 12 #include "base/trace_event/trace_event.h"
9 #include "chrome/browser/android/chrome_startup_flags.h" 13 #include "chrome/browser/android/chrome_startup_flags.h"
10 #include "chrome/browser/android/metrics/uma_utils.h" 14 #include "chrome/browser/android/metrics/uma_utils.h"
11 #include "chrome/browser/android/metrics/uma_utils.h" 15 #include "chrome/browser/android/metrics/uma_utils.h"
12 #include "chrome/browser/media/android/remote/remote_media_player_manager.h" 16 #include "chrome/browser/media/android/remote/remote_media_player_manager.h"
17 #include "components/policy/core/browser/android/android_combined_policy_provide r.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
13 #include "components/startup_metric_utils/startup_metric_utils.h" 18 #include "components/startup_metric_utils/startup_metric_utils.h"
14 #include "content/browser/media/android/browser_media_player_manager.h" 19 #include "content/browser/media/android/browser_media_player_manager.h"
15 #include "content/public/browser/browser_main_runner.h" 20 #include "content/public/browser/browser_main_runner.h"
16 21
22 #if defined(SAFE_BROWSING_DB_REMOTE)
23 #include "chrome/browser/safe_browsing/safe_browsing_api_handler.h"
24 #endif
25
17 namespace { 26 namespace {
18 27
19 content::BrowserMediaPlayerManager* CreateRemoteMediaPlayerManager( 28 content::BrowserMediaPlayerManager* CreateRemoteMediaPlayerManager(
20 content::RenderFrameHost* render_frame_host, 29 content::RenderFrameHost* render_frame_host,
21 content::MediaPlayersObserver* audio_monitor) { 30 content::MediaPlayersObserver* audio_monitor) {
22 return new remote_media::RemoteMediaPlayerManager(render_frame_host, 31 return new remote_media::RemoteMediaPlayerManager(render_frame_host,
23 audio_monitor); 32 audio_monitor);
24 } 33 }
25 34
26 } // namespace 35 } // namespace
27 36
28 // ChromeMainDelegateAndroid is created when the library is loaded. It is always 37 // ChromeMainDelegateAndroid is created when the library is loaded. It is always
29 // done in the process's main Java thread. But for non browser process, e.g. 38 // done in the process's main Java thread. But for non browser process, e.g.
30 // renderer process, it is not the native Chrome's main thread. 39 // renderer process, it is not the native Chrome's main thread.
31 ChromeMainDelegateAndroid::ChromeMainDelegateAndroid() { 40 ChromeMainDelegateAndroid::ChromeMainDelegateAndroid() {
32 } 41 }
33 42
34 ChromeMainDelegateAndroid::~ChromeMainDelegateAndroid() { 43 ChromeMainDelegateAndroid::~ChromeMainDelegateAndroid() {
35 } 44 }
45
46 bool ChromeMainDelegateAndroid::BasicStartupComplete(int* exit_code) {
47 #if defined(SAFE_BROWSING_DB_REMOTE)
48 safe_browsing_api_handler_.reset(CreateSafeBrowsingApiHandler());
49 SafeBrowsingApiHandler::SetInstance(safe_browsing_api_handler_.get());
50 #endif
51
52 policy::android::AndroidCombinedPolicyProvider::SetShouldWaitForPolicy(true);
53 SetChromeSpecificCommandLineFlags();
54 content::BrowserMediaPlayerManager::RegisterFactory(
55 &CreateRemoteMediaPlayerManager);
56
57 return ChromeMainDelegate::BasicStartupComplete(exit_code);
58 }
59
36 void ChromeMainDelegateAndroid::SandboxInitialized( 60 void ChromeMainDelegateAndroid::SandboxInitialized(
37 const std::string& process_type) { 61 const std::string& process_type) {
38 ChromeMainDelegate::SandboxInitialized(process_type); 62 ChromeMainDelegate::SandboxInitialized(process_type);
39 } 63 }
40 64
41 int ChromeMainDelegateAndroid::RunProcess( 65 int ChromeMainDelegateAndroid::RunProcess(
42 const std::string& process_type, 66 const std::string& process_type,
43 const content::MainFunctionParams& main_function_params) { 67 const content::MainFunctionParams& main_function_params) {
44 TRACE_EVENT0("startup", "ChromeMainDelegateAndroid::RunProcess") 68 TRACE_EVENT0("startup", "ChromeMainDelegateAndroid::RunProcess")
45 if (process_type.empty()) { 69 if (process_type.empty()) {
70 // By default, Android creates the directory accessible by others.
71 // We'd like to tighten security and make it accessible only by
72 // the browser process.
73 base::FilePath data_path;
74 bool ok = PathService::Get(base::DIR_ANDROID_APP_DATA, &data_path);
75 if (ok) {
76 int permissions;
77 ok = base::GetPosixFilePermissions(data_path, &permissions);
78 if (ok)
79 permissions &= base::FILE_PERMISSION_USER_MASK;
80 else
81 permissions = base::FILE_PERMISSION_READ_BY_USER |
82 base::FILE_PERMISSION_WRITE_BY_USER |
83 base::FILE_PERMISSION_EXECUTE_BY_USER;
84
85 ok = base::SetPosixFilePermissions(data_path, permissions);
86 }
87 if (!ok)
88 LOG(ERROR) << "Failed to set permission of " << data_path.value().c_str();
89
46 // Because the browser process can be started asynchronously as a series of 90 // Because the browser process can be started asynchronously as a series of
47 // UI thread tasks a second request to start it can come in while the 91 // UI thread tasks a second request to start it can come in while the
48 // first request is still being processed. Chrome must keep the same 92 // first request is still being processed. Chrome must keep the same
49 // browser runner for the second request. 93 // browser runner for the second request.
50 // Also only record the start time the first time round, since this is the 94 // Also only record the start time the first time round, since this is the
51 // start time of the application, and will be same for all requests. 95 // start time of the application, and will be same for all requests.
52 if (!browser_runner_.get()) { 96 if (!browser_runner_.get()) {
53 base::Time time = chrome::android::GetMainEntryPointTime(); 97 base::Time time = chrome::android::GetMainEntryPointTime();
54 startup_metric_utils::RecordMainEntryPointTime(time); 98 startup_metric_utils::RecordMainEntryPointTime(time);
55 browser_runner_.reset(content::BrowserMainRunner::Create()); 99 browser_runner_.reset(content::BrowserMainRunner::Create());
56 } 100 }
57 return browser_runner_->Initialize(main_function_params); 101 return browser_runner_->Initialize(main_function_params);
58 } 102 }
59 103
60 return ChromeMainDelegate::RunProcess(process_type, main_function_params); 104 return ChromeMainDelegate::RunProcess(process_type, main_function_params);
61 } 105 }
62 106
63 bool ChromeMainDelegateAndroid::BasicStartupComplete(int* exit_code) { 107 void ChromeMainDelegateAndroid::ProcessExiting(
64 SetChromeSpecificCommandLineFlags(); 108 const std::string& process_type) {
109 #if defined(SAFE_BROWSING_DB_REMOTE)
110 SafeBrowsingApiHandler::SetInstance(NULL);
111 #endif
112 }
65 113
66 content::BrowserMediaPlayerManager::RegisterFactory( 114 #if defined(SAFE_BROWSING_DB_REMOTE)
67 &CreateRemoteMediaPlayerManager); 115 SafeBrowsingApiHandler*
68 116 ChromeMainDelegateAndroid::CreateSafeBrowsingApiHandler() {
69 return ChromeMainDelegate::BasicStartupComplete(exit_code); 117 return NULL;
70 } 118 }
119 #endif
OLDNEW
« no previous file with comments | « chrome/app/android/chrome_main_delegate_android.h ('k') | chrome/app/android/chrome_main_delegate_android_initializer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698