Chromium Code Reviews| 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..68eead2af5c01b3c9aae786bfbdc0d99c36b4568 100644 |
| --- a/chrome/browser/devtools/devtools_window.cc |
| +++ b/chrome/browser/devtools/devtools_window.cc |
| @@ -96,6 +96,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 +217,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 +509,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 +834,36 @@ void DevToolsWindow::AppendToFile(const std::string& url, |
| url)); |
| } |
| +namespace { |
| + |
| +DictionaryValue* CreateFilesystemValue( |
| + DevToolsFileHelper::Filesystem filesystem) { |
| + DictionaryValue* filesystem_value = new DictionaryValue(); |
| + filesystem_value->SetString("filesystemId", filesystem.filesystem_id); |
| + filesystem_value->SetString("registeredName", filesystem.registered_name); |
| + filesystem_value->SetString("filesystemPath", filesystem.filesystem_path); |
| + return filesystem_value; |
| +} |
| + |
| +} // namespace |
| + |
| +void DevToolsWindow::RequestFilesystems() { |
| + file_helper_->RequestFilesystems( |
|
pfeldman
2012/12/29 10:23:02
RestoreFilesystems
new DevToolsFileHelper(web_con
|
| + Bind(&DevToolsWindow::FilesystemsLoaded, weak_factory_.GetWeakPtr())); |
| +} |
| + |
| +void DevToolsWindow::AddFilesystem() { |
| + file_helper_->AddFilesystem( |
| + Bind(&DevToolsWindow::FilesystemAdded, weak_factory_.GetWeakPtr())); |
| +} |
| + |
| +void DevToolsWindow::RemoveFilesystem(const std::string& filesystem_path) { |
| + file_helper_->RemoveFilesystem(filesystem_path); |
| + StringValue filesystem_path_value(filesystem_path); |
| + CallClientFunction("InspectorFrontendAPI.filesystemRemoved", |
| + &filesystem_path_value); |
| +} |
| + |
| void DevToolsWindow::FileSavedAs(const std::string& url) { |
| StringValue url_value(url); |
| CallClientFunction("InspectorFrontendAPI.savedURL", &url_value); |
| @@ -836,6 +874,30 @@ void DevToolsWindow::AppendedTo(const std::string& url) { |
| CallClientFunction("InspectorFrontendAPI.appendedToURL", &url_value); |
| } |
| +void DevToolsWindow::FilesystemsLoaded( |
| + const std::vector<DevToolsFileHelper::Filesystem>& filesystems) { |
| + ListValue filesystems_value; |
| + for (size_t i = 0; i < filesystems.size(); ++i) { |
| + filesystems_value.Append(CreateFilesystemValue(filesystems[i])); |
| + } |
| + CallClientFunction("InspectorFrontendAPI.filesystemsLoaded", |
| + &filesystems_value); |
| +} |
| + |
| +void DevToolsWindow::FilesystemAdded( |
| + std::string error_string, |
| + const DevToolsFileHelper::Filesystem& filesystem) { |
| + StringValue error_string_value(error_string); |
| + DictionaryValue* filesystem_value = NULL; |
| + if (!filesystem.filesystem_path.empty()) |
| + filesystem_value = CreateFilesystemValue(filesystem); |
| + CallClientFunction("InspectorFrontendAPI.filesystemAdded", |
| + &error_string_value, |
| + filesystem_value); |
| + if (filesystem_value) |
| + delete filesystem_value; |
| +} |
| + |
| content::JavaScriptDialogCreator* DevToolsWindow::GetJavaScriptDialogCreator() { |
| if (inspected_web_contents_ && inspected_web_contents_->GetDelegate()) { |
| return inspected_web_contents_->GetDelegate()-> |