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

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: added components/policy to chrome/app/DEPS 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"
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 return new remote_media::RemoteMediaPlayerManager(render_frame_host); 30 return new remote_media::RemoteMediaPlayerManager(render_frame_host);
22 } 31 }
23 32
24 } // namespace 33 } // namespace
25 34
26 // ChromeMainDelegateAndroid is created when the library is loaded. It is always 35 // ChromeMainDelegateAndroid is created when the library is loaded. It is always
27 // done in the process's main Java thread. But for non browser process, e.g. 36 // done in the process's main Java thread. But for non browser process, e.g.
28 // renderer process, it is not the native Chrome's main thread. 37 // renderer process, it is not the native Chrome's main thread.
29 ChromeMainDelegateAndroid::ChromeMainDelegateAndroid() { 38 ChromeMainDelegateAndroid::ChromeMainDelegateAndroid() {
30 } 39 }
31 40
32 ChromeMainDelegateAndroid::~ChromeMainDelegateAndroid() { 41 ChromeMainDelegateAndroid::~ChromeMainDelegateAndroid() {
33 } 42 }
43
44 bool ChromeMainDelegateAndroid::BasicStartupComplete(int* exit_code) {
45 #if defined(SAFE_BROWSING_DB_REMOTE)
46 safe_browsing_api_handler_.reset(CreateSafeBrowsingApiHandler());
47 SafeBrowsingApiHandler::SetInstance(safe_browsing_api_handler_.get());
48 #endif
49
50 policy::android::AndroidCombinedPolicyProvider::SetShouldWaitForPolicy(true);
51 SetChromeSpecificCommandLineFlags();
52 content::BrowserMediaPlayerManager::RegisterFactory(
53 &CreateRemoteMediaPlayerManager);
54
55 return ChromeMainDelegate::BasicStartupComplete(exit_code);
56 }
57
34 void ChromeMainDelegateAndroid::SandboxInitialized( 58 void ChromeMainDelegateAndroid::SandboxInitialized(
35 const std::string& process_type) { 59 const std::string& process_type) {
36 ChromeMainDelegate::SandboxInitialized(process_type); 60 ChromeMainDelegate::SandboxInitialized(process_type);
37 } 61 }
38 62
39 int ChromeMainDelegateAndroid::RunProcess( 63 int ChromeMainDelegateAndroid::RunProcess(
40 const std::string& process_type, 64 const std::string& process_type,
41 const content::MainFunctionParams& main_function_params) { 65 const content::MainFunctionParams& main_function_params) {
42 TRACE_EVENT0("startup", "ChromeMainDelegateAndroid::RunProcess") 66 TRACE_EVENT0("startup", "ChromeMainDelegateAndroid::RunProcess")
43 if (process_type.empty()) { 67 if (process_type.empty()) {
68 // By default, Android creates the directory accessible by others.
69 // We'd like to tighten security and make it accessible only by
70 // the browser process.
71 base::FilePath data_path;
72 bool ok = PathService::Get(base::DIR_ANDROID_APP_DATA, &data_path);
bartfab (slow) 2015/09/03 09:51:56 Nit: #include "base/base_paths_android.h"
newt (away) 2015/09/03 18:35:24 Done.
73 if (ok) {
74 int permissions;
75 ok = base::GetPosixFilePermissions(data_path, &permissions);
76 if (ok)
77 permissions &= base::FILE_PERMISSION_USER_MASK;
78 else
bartfab (slow) 2015/09/03 09:51:57 Nit: Curly braces are required for multi-line cond
newt (away) 2015/09/03 18:35:24 Done.
79 permissions = base::FILE_PERMISSION_READ_BY_USER |
80 base::FILE_PERMISSION_WRITE_BY_USER |
81 base::FILE_PERMISSION_EXECUTE_BY_USER;
82
83 ok = base::SetPosixFilePermissions(data_path, permissions);
84 }
85 if (!ok)
86 LOG(ERROR) << "Failed to set permission of " << data_path.value().c_str();
bartfab (slow) 2015/09/03 09:51:57 Nit: #include <string> to be able to call c_str()
newt (away) 2015/09/03 18:35:24 Just removed c_str()
87
44 // Because the browser process can be started asynchronously as a series of 88 // Because the browser process can be started asynchronously as a series of
45 // UI thread tasks a second request to start it can come in while the 89 // UI thread tasks a second request to start it can come in while the
46 // first request is still being processed. Chrome must keep the same 90 // first request is still being processed. Chrome must keep the same
47 // browser runner for the second request. 91 // browser runner for the second request.
48 // Also only record the start time the first time round, since this is the 92 // Also only record the start time the first time round, since this is the
49 // start time of the application, and will be same for all requests. 93 // start time of the application, and will be same for all requests.
50 if (!browser_runner_.get()) { 94 if (!browser_runner_.get()) {
51 base::Time time = chrome::android::GetMainEntryPointTime(); 95 base::Time time = chrome::android::GetMainEntryPointTime();
52 startup_metric_utils::RecordMainEntryPointTime(time); 96 startup_metric_utils::RecordMainEntryPointTime(time);
53 browser_runner_.reset(content::BrowserMainRunner::Create()); 97 browser_runner_.reset(content::BrowserMainRunner::Create());
54 } 98 }
55 return browser_runner_->Initialize(main_function_params); 99 return browser_runner_->Initialize(main_function_params);
56 } 100 }
57 101
58 return ChromeMainDelegate::RunProcess(process_type, main_function_params); 102 return ChromeMainDelegate::RunProcess(process_type, main_function_params);
59 } 103 }
60 104
61 bool ChromeMainDelegateAndroid::BasicStartupComplete(int* exit_code) { 105 void ChromeMainDelegateAndroid::ProcessExiting(
62 SetChromeSpecificCommandLineFlags(); 106 const std::string& process_type) {
107 #if defined(SAFE_BROWSING_DB_REMOTE)
108 SafeBrowsingApiHandler::SetInstance(NULL);
bartfab (slow) 2015/09/03 09:51:56 Nit: s/NULL/nullptr/
109 #endif
110 }
63 111
64 content::BrowserMediaPlayerManager::RegisterFactory( 112 #if defined(SAFE_BROWSING_DB_REMOTE)
65 &CreateRemoteMediaPlayerManager); 113 SafeBrowsingApiHandler*
66 114 ChromeMainDelegateAndroid::CreateSafeBrowsingApiHandler() {
67 return ChromeMainDelegate::BasicStartupComplete(exit_code); 115 return NULL;
bartfab (slow) 2015/09/03 09:51:56 Nit: s/NULL/nullptr/
68 } 116 }
117 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698