Index: chrome/browser/devtools/devtools_window.cc |
diff --git a/chrome/browser/devtools/devtools_window.cc b/chrome/browser/devtools/devtools_window.cc |
index 8c9fbe1dc719d1ce6b91dac0c92b4945af8fd7ef..ac1c4528462485f785577664c800aa164dd999a7 100644 |
--- a/chrome/browser/devtools/devtools_window.cc |
+++ b/chrome/browser/devtools/devtools_window.cc |
@@ -46,6 +46,7 @@ |
#include "content/public/browser/web_contents.h" |
#include "content/public/browser/web_contents_view.h" |
#include "content/public/common/bindings_policy.h" |
+#include "content/public/common/content_client.h" |
#include "content/public/common/page_transition_types.h" |
#include "grit/generated_resources.h" |
@@ -96,6 +97,8 @@ void DevToolsWindow::RegisterUserPrefs(PrefServiceSyncable* prefs) { |
PrefServiceSyncable::UNSYNCABLE_PREF); |
prefs->RegisterDictionaryPref(prefs::kDevToolsEditedFiles, |
PrefServiceSyncable::UNSYNCABLE_PREF); |
+ prefs->RegisterDictionaryPref(prefs::kDevToolsFileSystemPaths, |
+ PrefServiceSyncable::UNSYNCABLE_PREF); |
} |
// static |
@@ -215,7 +218,7 @@ DevToolsWindow::DevToolsWindow(WebContents* web_contents, |
height_(-1) { |
frontend_host_ = DevToolsClientHost::CreateDevToolsFrontendHost(web_contents, |
this); |
- file_helper_.reset(new DevToolsFileHelper(profile)); |
+ file_helper_.reset(new DevToolsFileHelper(web_contents, profile)); |
g_instances.Get().push_back(this); |
// Wipe out page icon so that the default application icon is used. |
@@ -507,13 +510,19 @@ WebContents* DevToolsWindow::OpenURLFromTab(WebContents* source, |
} |
void DevToolsWindow::CallClientFunction(const std::string& function_name, |
- const Value* arg) { |
- std::string json; |
- if (arg) |
- base::JSONWriter::Write(arg, &json); |
- |
- string16 javascript = |
- ASCIIToUTF16(function_name + "(" + json + ");"); |
+ const Value* arg1, |
+ const Value* arg2) { |
+ std::string params; |
+ if (arg1) { |
+ std::string json; |
+ base::JSONWriter::Write(arg1, &json); |
+ params.append(json); |
+ if (arg2) { |
+ base::JSONWriter::Write(arg2, &json); |
+ params.append(", " + json); |
+ } |
+ } |
+ string16 javascript = ASCIIToUTF16(function_name + "(" + params + ");"); |
web_contents_->GetRenderViewHost()-> |
ExecuteJavascriptInWebFrame(string16(), javascript); |
} |
@@ -826,6 +835,39 @@ void DevToolsWindow::AppendToFile(const std::string& url, |
url)); |
} |
+namespace { |
+ |
+DictionaryValue* CreateFileSystemValue( |
+ DevToolsFileHelper::FileSystem file_system) { |
+ DictionaryValue* file_system_value = new DictionaryValue(); |
+ file_system_value->SetString("fileSystemId", file_system.file_system_id); |
+ file_system_value->SetString("registeredName", file_system.registered_name); |
+ file_system_value->SetString("fileSystemPath", file_system.file_system_path); |
kinuko
2013/01/10 07:33:58
A follow-up comment to https://bugs.webkit.org/sho
|
+ return file_system_value; |
+} |
+ |
+} // namespace |
+ |
+void DevToolsWindow::RequestFileSystems() { |
+ CHECK(content::GetContentClient()->HasWebUIScheme(web_contents_->GetURL())); |
+ file_helper_->RequestFileSystems( |
+ Bind(&DevToolsWindow::FileSystemsLoaded, weak_factory_.GetWeakPtr())); |
+} |
+ |
+void DevToolsWindow::AddFileSystem() { |
+ CHECK(content::GetContentClient()->HasWebUIScheme(web_contents_->GetURL())); |
+ file_helper_->AddFileSystem( |
+ Bind(&DevToolsWindow::FileSystemAdded, weak_factory_.GetWeakPtr())); |
+} |
+ |
+void DevToolsWindow::RemoveFileSystem(const std::string& file_system_path) { |
+ CHECK(content::GetContentClient()->HasWebUIScheme(web_contents_->GetURL())); |
+ file_helper_->RemoveFileSystem(file_system_path); |
+ StringValue file_system_path_value(file_system_path); |
+ CallClientFunction("InspectorFrontendAPI.fileSystemRemoved", |
+ &file_system_path_value); |
+} |
+ |
void DevToolsWindow::FileSavedAs(const std::string& url) { |
StringValue url_value(url); |
CallClientFunction("InspectorFrontendAPI.savedURL", &url_value); |
@@ -836,6 +878,30 @@ void DevToolsWindow::AppendedTo(const std::string& url) { |
CallClientFunction("InspectorFrontendAPI.appendedToURL", &url_value); |
} |
+void DevToolsWindow::FileSystemsLoaded( |
+ const std::vector<DevToolsFileHelper::FileSystem>& file_systems) { |
+ ListValue file_systems_value; |
+ for (size_t i = 0; i < file_systems.size(); ++i) { |
+ file_systems_value.Append(CreateFileSystemValue(file_systems[i])); |
+ } |
+ CallClientFunction("InspectorFrontendAPI.fileSystemsLoaded", |
+ &file_systems_value); |
+} |
+ |
+void DevToolsWindow::FileSystemAdded( |
+ std::string error_string, |
+ const DevToolsFileHelper::FileSystem& file_system) { |
+ StringValue error_string_value(error_string); |
+ DictionaryValue* file_system_value = NULL; |
+ if (!file_system.file_system_path.empty()) |
+ file_system_value = CreateFileSystemValue(file_system); |
+ CallClientFunction("InspectorFrontendAPI.fileSystemAdded", |
+ &error_string_value, |
+ file_system_value); |
+ if (file_system_value) |
+ delete file_system_value; |
+} |
+ |
content::JavaScriptDialogCreator* DevToolsWindow::GetJavaScriptDialogCreator() { |
if (inspected_web_contents_ && inspected_web_contents_->GetDelegate()) { |
return inspected_web_contents_->GetDelegate()-> |