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

Side by Side Diff: chrome/browser/debugger/devtools_file_helper.cc

Issue 10815024: Revert 147594 - NaCl: Remove two uses of '#include "nacl/nacl_log.h"' (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 5 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 | Annotate | Revision Log
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/browser/debugger/devtools_file_helper.h" 5 #include "chrome/browser/debugger/devtools_file_helper.h"
6 6
7 #include <vector>
8
7 #include "base/bind.h" 9 #include "base/bind.h"
8 #include "base/callback.h" 10 #include "base/callback.h"
9 #include "base/file_util.h" 11 #include "base/file_util.h"
10 #include "base/lazy_instance.h" 12 #include "base/lazy_instance.h"
11 #include "base/md5.h" 13 #include "base/md5.h"
12 #include "base/value_conversions.h" 14 #include "base/value_conversions.h"
13 #include "chrome/browser/browser_process.h" 15 #include "chrome/browser/browser_process.h"
14 #include "chrome/browser/download/download_prefs.h" 16 #include "chrome/browser/download/download_prefs.h"
15 #include "chrome/browser/prefs/pref_service.h" 17 #include "chrome/browser/prefs/pref_service.h"
16 #include "chrome/browser/prefs/scoped_user_pref_update.h" 18 #include "chrome/browser/prefs/scoped_user_pref_update.h"
17 #include "chrome/browser/profiles/profile.h" 19 #include "chrome/browser/profiles/profile.h"
18 #include "chrome/browser/ui/chrome_select_file_policy.h" 20 #include "chrome/browser/ui/chrome_select_file_policy.h"
19 #include "chrome/browser/ui/select_file_dialog.h" 21 #include "chrome/browser/ui/select_file_dialog.h"
20 #include "chrome/common/pref_names.h" 22 #include "chrome/common/pref_names.h"
23 #include "content/public/browser/browser_context.h"
24 #include "content/public/browser/download_manager.h"
21 25
26 using content::BrowserContext;
22 using content::BrowserThread; 27 using content::BrowserThread;
28 using content::DownloadManager;
23 29
24 namespace { 30 namespace {
25 31
26 base::LazyInstance<FilePath>::Leaky 32 base::LazyInstance<FilePath>::Leaky
27 g_last_save_path = LAZY_INSTANCE_INITIALIZER; 33 g_last_save_path = LAZY_INSTANCE_INITIALIZER;
28 34
29 } // namespace 35 } // namespace
30 36
31 class DevToolsFileHelper::SaveAsDialog : public SelectFileDialog::Listener, 37 class DevToolsFileHelper::SaveAsDialog : public SelectFileDialog::Listener,
32 public base::RefCounted<SaveAsDialog> { 38 public base::RefCounted<SaveAsDialog> {
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 std::string suggested_file_name = gurl.is_valid() ? 146 std::string suggested_file_name = gurl.is_valid() ?
141 gurl.ExtractFileName() : url; 147 gurl.ExtractFileName() : url;
142 148
143 if (suggested_file_name.length() > 20) 149 if (suggested_file_name.length() > 20)
144 suggested_file_name = suggested_file_name.substr(0, 20); 150 suggested_file_name = suggested_file_name.substr(0, 20);
145 151
146 if (!g_last_save_path.Pointer()->empty()) { 152 if (!g_last_save_path.Pointer()->empty()) {
147 initial_path = g_last_save_path.Pointer()->DirName().AppendASCII( 153 initial_path = g_last_save_path.Pointer()->DirName().AppendASCII(
148 suggested_file_name); 154 suggested_file_name);
149 } else { 155 } else {
150 DownloadPrefs prefs(profile_->GetPrefs()); 156 FilePath download_path = DownloadPrefs::FromDownloadManager(
151 initial_path = prefs.download_path().AppendASCII(suggested_file_name); 157 BrowserContext::GetDownloadManager(profile_))->DownloadPath();
158 initial_path = download_path.AppendASCII(suggested_file_name);
152 } 159 }
153 } 160 }
154 161
155 save_as_dialog_ = new SaveAsDialog(this); 162 save_as_dialog_ = new SaveAsDialog(this);
156 save_as_dialog_->Show(url, initial_path, content); 163 save_as_dialog_->Show(url, initial_path, content);
157 } 164 }
158 165
159 void DevToolsFileHelper::Append(const std::string& url, 166 void DevToolsFileHelper::Append(const std::string& url,
160 const std::string& content) { 167 const std::string& content) {
161 PathsMap::iterator it = saved_files_.find(url); 168 PathsMap::iterator it = saved_files_.find(url);
(...skipping 21 matching lines...) Expand all
183 files_map->SetWithoutPathExpansion(base::MD5String(url), 190 files_map->SetWithoutPathExpansion(base::MD5String(url),
184 base::CreateFilePathValue(path)); 191 base::CreateFilePathValue(path));
185 delegate_->FileSavedAs(url); 192 delegate_->FileSavedAs(url);
186 193
187 BrowserThread::PostTask( 194 BrowserThread::PostTask(
188 BrowserThread::FILE, FROM_HERE, 195 BrowserThread::FILE, FROM_HERE,
189 base::Bind(&DevToolsFileHelper::WriteFile, 196 base::Bind(&DevToolsFileHelper::WriteFile,
190 path, 197 path,
191 content)); 198 content));
192 } 199 }
OLDNEW
« no previous file with comments | « chrome/browser/automation/testing_automation_provider.cc ('k') | chrome/browser/download/chrome_download_manager_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698