OLD | NEW |
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/devtools/devtools_file_helper.h" | 5 #include "chrome/browser/devtools/devtools_file_helper.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 #include "chrome/browser/ui/chrome_select_file_policy.h" | 21 #include "chrome/browser/ui/chrome_select_file_policy.h" |
22 #include "chrome/common/pref_names.h" | 22 #include "chrome/common/pref_names.h" |
23 #include "content/public/browser/browser_context.h" | 23 #include "content/public/browser/browser_context.h" |
24 #include "content/public/browser/browser_thread.h" | 24 #include "content/public/browser/browser_thread.h" |
25 #include "content/public/browser/child_process_security_policy.h" | 25 #include "content/public/browser/child_process_security_policy.h" |
26 #include "content/public/browser/download_manager.h" | 26 #include "content/public/browser/download_manager.h" |
27 #include "content/public/browser/render_process_host.h" | 27 #include "content/public/browser/render_process_host.h" |
28 #include "content/public/browser/render_view_host.h" | 28 #include "content/public/browser/render_view_host.h" |
29 #include "content/public/browser/web_contents.h" | 29 #include "content/public/browser/web_contents.h" |
30 #include "content/public/common/content_client.h" | 30 #include "content/public/common/content_client.h" |
| 31 #include "content/public/common/url_constants.h" |
31 #include "grit/generated_resources.h" | 32 #include "grit/generated_resources.h" |
32 #include "ui/base/l10n/l10n_util.h" | 33 #include "ui/base/l10n/l10n_util.h" |
33 #include "ui/shell_dialogs/select_file_dialog.h" | 34 #include "ui/shell_dialogs/select_file_dialog.h" |
34 #include "webkit/fileapi/file_system_util.h" | 35 #include "webkit/fileapi/file_system_util.h" |
35 #include "webkit/fileapi/isolated_context.h" | 36 #include "webkit/fileapi/isolated_context.h" |
36 | 37 |
37 using base::Bind; | 38 using base::Bind; |
38 using base::Callback; | 39 using base::Callback; |
39 using content::BrowserContext; | 40 using content::BrowserContext; |
40 using content::BrowserThread; | 41 using content::BrowserThread; |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 fileapi::IsolatedContext* isolated_context = | 127 fileapi::IsolatedContext* isolated_context = |
127 fileapi::IsolatedContext::GetInstance(); | 128 fileapi::IsolatedContext::GetInstance(); |
128 DCHECK(isolated_context); | 129 DCHECK(isolated_context); |
129 return isolated_context; | 130 return isolated_context; |
130 } | 131 } |
131 | 132 |
132 std::string RegisterFileSystem(WebContents* web_contents, | 133 std::string RegisterFileSystem(WebContents* web_contents, |
133 const FilePath& path, | 134 const FilePath& path, |
134 std::string* registered_name) { | 135 std::string* registered_name) { |
135 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 136 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
136 CHECK(content::GetContentClient()->HasWebUIScheme(web_contents->GetURL())); | 137 CHECK(content::HasWebUIScheme(web_contents->GetURL())); |
137 std::string file_system_id = isolated_context()->RegisterFileSystemForPath( | 138 std::string file_system_id = isolated_context()->RegisterFileSystemForPath( |
138 fileapi::kFileSystemTypeNativeLocal, path, registered_name); | 139 fileapi::kFileSystemTypeNativeLocal, path, registered_name); |
139 | 140 |
140 content::ChildProcessSecurityPolicy* policy = | 141 content::ChildProcessSecurityPolicy* policy = |
141 content::ChildProcessSecurityPolicy::GetInstance(); | 142 content::ChildProcessSecurityPolicy::GetInstance(); |
142 RenderViewHost* render_view_host = web_contents->GetRenderViewHost(); | 143 RenderViewHost* render_view_host = web_contents->GetRenderViewHost(); |
143 int renderer_id = render_view_host->GetProcess()->GetID(); | 144 int renderer_id = render_view_host->GetProcess()->GetID(); |
144 policy->GrantReadFileSystem(renderer_id, file_system_id); | 145 policy->GrantReadFileSystem(renderer_id, file_system_id); |
145 policy->GrantWriteFileSystem(renderer_id, file_system_id); | 146 policy->GrantWriteFileSystem(renderer_id, file_system_id); |
146 | 147 |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
389 void DevToolsFileHelper::RemoveFileSystem(const std::string& file_system_path) { | 390 void DevToolsFileHelper::RemoveFileSystem(const std::string& file_system_path) { |
390 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 391 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
391 FilePath path = FilePath::FromUTF8Unsafe(file_system_path); | 392 FilePath path = FilePath::FromUTF8Unsafe(file_system_path); |
392 isolated_context()->RevokeFileSystemByPath(path); | 393 isolated_context()->RevokeFileSystemByPath(path); |
393 | 394 |
394 DictionaryPrefUpdate update(profile_->GetPrefs(), | 395 DictionaryPrefUpdate update(profile_->GetPrefs(), |
395 prefs::kDevToolsFileSystemPaths); | 396 prefs::kDevToolsFileSystemPaths); |
396 DictionaryValue* file_systems_paths_value = update.Get(); | 397 DictionaryValue* file_systems_paths_value = update.Get(); |
397 file_systems_paths_value->RemoveWithoutPathExpansion(file_system_path, NULL); | 398 file_systems_paths_value->RemoveWithoutPathExpansion(file_system_path, NULL); |
398 } | 399 } |
OLD | NEW |