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 998e27f298eb09fd56865adebc8d4161a1e48574..db4f1a5a1c48ffb9788eb5c8874b940c94b80eb1 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::kDevToolsSavedFileSystemPathes, |
|
pfeldman
2012/12/24 19:01:03
Paths
|
| + PrefServiceSyncable::UNSYNCABLE_PREF); |
| } |
| // static |
| @@ -216,6 +218,9 @@ DevToolsWindow::DevToolsWindow(WebContents* web_contents, |
| frontend_host_ = DevToolsClientHost::CreateDevToolsFrontendHost(web_contents, |
| this); |
| file_helper_.reset(new DevToolsFileHelper(profile, this)); |
| + file_system_helper_ = new DevToolsFileSystemHelper(web_contents, |
| + profile, |
| + this); |
| g_instances.Get().push_back(this); |
| // Wipe out page icon so that the default application icon is used. |
| @@ -507,13 +512,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); |
| } |
| @@ -822,6 +833,36 @@ void DevToolsWindow::AppendToFile(const std::string& url, |
| file_helper_->Append(url, content); |
| } |
| +namespace { |
| + |
| +DictionaryValue* CreateFileSystemValue( |
|
pfeldman
2012/12/24 19:01:03
You should also make this function static instead
|
| + DevToolsFileSystemHelper::FileSystem file_system) { |
| + DictionaryValue* file_system_value = new DictionaryValue(); |
| + file_system_value->SetString("fileSystemId", file_system.filesystem_id); |
| + file_system_value->SetString("registeredName", file_system.registered_name); |
| + file_system_value->SetString("fileSystemPath", file_system.file_system_path); |
| + return file_system_value; |
| +} |
| + |
| +} // namespace |
| + |
| +void DevToolsWindow::RequestFileSystemPermissions() { |
| + file_system_helper_->RequestPermissions(); |
| +} |
| + |
| +void DevToolsWindow::SelectFolderAndGrantFileSystemPermission() { |
| + file_system_helper_->SelectFolderAndGrantPermission(); |
| +} |
| + |
| +void DevToolsWindow::RevokeFileSystemPermission( |
| + const std::string& file_system_path) { |
| + file_system_helper_->RevokePermission(file_system_path); |
| + |
| + StringValue file_system_path_value(file_system_path); |
| + CallClientFunction("InspectorFrontendAPI.fileSystemFolderPermissionsRevoked", |
| + &file_system_path_value); |
| +} |
| + |
| void DevToolsWindow::FileSavedAs(const std::string& url) { |
| StringValue url_value(url); |
| CallClientFunction("InspectorFrontendAPI.savedURL", &url_value); |
| @@ -832,6 +873,36 @@ void DevToolsWindow::AppendedTo(const std::string& url) { |
| CallClientFunction("InspectorFrontendAPI.appendedToURL", &url_value); |
| } |
| +void DevToolsWindow::FileSystemPermissionsLoaded( |
| + std::vector<DevToolsFileSystemHelper::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.fileSystemPermissionsLoaded", |
| + &file_systems_value); |
| +} |
| + |
| +void DevToolsWindow::FileSystemFolderSelected( |
| + DevToolsFileSystemHelper::FileSystem file_system) { |
| + DictionaryValue* file_system_value = CreateFileSystemValue(file_system); |
| + StringValue error_string_value(""); |
| + CallClientFunction("InspectorFrontendAPI.fileSystemFolderSelected", |
| + &error_string_value, |
| + file_system_value); |
| + delete file_system_value; |
| +} |
| + |
| +void DevToolsWindow::FileSystemFolderSelectionCanceled() { |
| + CallClientFunction("InspectorFrontendAPI.fileSystemFolderSelected"); |
| +} |
| + |
| +void DevToolsWindow::FileSystemFolderSelectionError(std::string error_string) { |
| + StringValue error_string_value(error_string); |
| + CallClientFunction("InspectorFrontendAPI.fileSystemFolderSelected", |
| + &error_string_value); |
| +} |
| + |
| content::JavaScriptDialogCreator* DevToolsWindow::GetJavaScriptDialogCreator() { |
| if (inspected_web_contents_ && inspected_web_contents_->GetDelegate()) { |
| return inspected_web_contents_->GetDelegate()-> |