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

Side by Side Diff: chrome/browser/extensions/api/log_private/log_private_api_chromeos.cc

Issue 2838923004: logPrivate API: prevent log dump from trying to use a non-native path (Closed)
Patch Set: Created 3 years, 8 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/browser/extensions/api/log_private/log_private_api.h" 5 #include "chrome/browser/extensions/api/log_private/log_private_api.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 21 matching lines...) Expand all
32 #include "content/public/browser/render_frame_host.h" 32 #include "content/public/browser/render_frame_host.h"
33 #include "content/public/browser/render_process_host.h" 33 #include "content/public/browser/render_process_host.h"
34 #include "extensions/browser/api/file_handlers/app_file_handler_util.h" 34 #include "extensions/browser/api/file_handlers/app_file_handler_util.h"
35 #include "extensions/browser/event_router.h" 35 #include "extensions/browser/event_router.h"
36 #include "extensions/browser/extension_function.h" 36 #include "extensions/browser/extension_function.h"
37 #include "extensions/browser/extension_registry.h" 37 #include "extensions/browser/extension_registry.h"
38 #include "extensions/browser/granted_file_entry.h" 38 #include "extensions/browser/granted_file_entry.h"
39 #include "net/log/net_log_entry.h" 39 #include "net/log/net_log_entry.h"
40 40
41 #if defined(OS_CHROMEOS) 41 #if defined(OS_CHROMEOS)
42 #include "chrome/browser/chromeos/file_manager/filesystem_api_util.h"
42 #include "chrome/browser/chromeos/system_logs/debug_log_writer.h" 43 #include "chrome/browser/chromeos/system_logs/debug_log_writer.h"
43 #endif 44 #endif
44 45
45 using content::BrowserThread; 46 using content::BrowserThread;
46 47
47 namespace events { 48 namespace events {
48 const char kOnCapturedEvents[] = "logPrivate.onCapturedEvents"; 49 const char kOnCapturedEvents[] = "logPrivate.onCapturedEvents";
49 } // namespace events 50 } // namespace events
50 51
51 namespace extensions { 52 namespace extensions {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 // logPrivate.startEventRecorder() calls - /home/chronos/user/log/apps 105 // logPrivate.startEventRecorder() calls - /home/chronos/user/log/apps
105 base::FilePath GetAppLogDirectory() { 106 base::FilePath GetAppLogDirectory() {
106 return logging::GetSessionLogDir(*base::CommandLine::ForCurrentProcess()) 107 return logging::GetSessionLogDir(*base::CommandLine::ForCurrentProcess())
107 .Append(kAppLogsSubdir); 108 .Append(kAppLogsSubdir);
108 } 109 }
109 110
110 // Returns directory location where logs dumps initiated with chrome.dumpLogs 111 // Returns directory location where logs dumps initiated with chrome.dumpLogs
111 // will be stored - /home/chronos/<user_profile_dir>/Downloads/log_dumps 112 // will be stored - /home/chronos/<user_profile_dir>/Downloads/log_dumps
112 base::FilePath GetLogDumpDirectory(content::BrowserContext* context) { 113 base::FilePath GetLogDumpDirectory(content::BrowserContext* context) {
113 const DownloadPrefs* const prefs = DownloadPrefs::FromBrowserContext(context); 114 const DownloadPrefs* const prefs = DownloadPrefs::FromBrowserContext(context);
114 return prefs->DownloadPath().Append(kLogDumpsSubdir); 115 base::FilePath path = prefs->DownloadPath();
116
117 #if defined(OS_CHROMEOS)
118 Profile* profile = Profile::FromBrowserContext(context);
119 if (file_manager::util::IsUnderNonNativeLocalPath(profile, path))
120 path = prefs->GetDefaultDownloadDirectoryForProfile();
121 #endif
122
123 return path.Append(kLogDumpsSubdir);
115 } 124 }
116 125
117 // Removes direcotry content of |logs_dumps| and |app_logs_dir| (only for the 126 // Removes direcotry content of |logs_dumps| and |app_logs_dir| (only for the
118 // primary profile). 127 // primary profile).
119 void CleanUpLeftoverLogs(bool is_primary_profile, 128 void CleanUpLeftoverLogs(bool is_primary_profile,
120 const base::FilePath& app_logs_dir, 129 const base::FilePath& app_logs_dir,
121 const base::FilePath& logs_dumps) { 130 const base::FilePath& logs_dumps) {
122 LOG(WARNING) << "Deleting " << app_logs_dir.value(); 131 LOG(WARNING) << "Deleting " << app_logs_dir.value();
123 LOG(WARNING) << "Deleting " << logs_dumps.value(); 132 LOG(WARNING) << "Deleting " << logs_dumps.value();
124 133
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 entry->SetBoolean("isDirectory", false); 555 entry->SetBoolean("isDirectory", false);
547 auto entry_list = base::MakeUnique<base::ListValue>(); 556 auto entry_list = base::MakeUnique<base::ListValue>();
548 entry_list->Append(std::move(entry)); 557 entry_list->Append(std::move(entry));
549 response->Set("entries", std::move(entry_list)); 558 response->Set("entries", std::move(entry_list));
550 response->SetBoolean("multiple", false); 559 response->SetBoolean("multiple", false);
551 SetResult(std::move(response)); 560 SetResult(std::move(response));
552 SendResponse(succeeded); 561 SendResponse(succeeded);
553 } 562 }
554 563
555 } // namespace extensions 564 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698