| OLD | NEW |
| 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 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/ui/webui/settings/downloads_handler.h" | 5 #include "chrome/browser/ui/webui/settings/downloads_handler.h" |
| 6 | 6 |
| 7 #include "base/metrics/user_metrics.h" | 7 #include "base/metrics/user_metrics.h" |
| 8 #include "base/values.h" | 8 #include "base/values.h" |
| 9 #include "chrome/browser/download/download_prefs.h" | 9 #include "chrome/browser/download/download_prefs.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 void DownloadsHandler::HandleInitialize(const base::ListValue* args) { | 60 void DownloadsHandler::HandleInitialize(const base::ListValue* args) { |
| 61 AllowJavascript(); | 61 AllowJavascript(); |
| 62 SendAutoOpenDownloadsToJavascript(); | 62 SendAutoOpenDownloadsToJavascript(); |
| 63 } | 63 } |
| 64 | 64 |
| 65 void DownloadsHandler::SendAutoOpenDownloadsToJavascript() { | 65 void DownloadsHandler::SendAutoOpenDownloadsToJavascript() { |
| 66 content::DownloadManager* manager = | 66 content::DownloadManager* manager = |
| 67 content::BrowserContext::GetDownloadManager(profile_); | 67 content::BrowserContext::GetDownloadManager(profile_); |
| 68 bool auto_open_downloads = | 68 bool auto_open_downloads = |
| 69 DownloadPrefs::FromDownloadManager(manager)->IsAutoOpenUsed(); | 69 DownloadPrefs::FromDownloadManager(manager)->IsAutoOpenUsed(); |
| 70 CallJavascriptFunction("cr.webUIListenerCallback", | 70 FireWebUIListener("auto-open-downloads-changed", |
| 71 base::Value("auto-open-downloads-changed"), | 71 base::Value(auto_open_downloads)); |
| 72 base::Value(auto_open_downloads)); | |
| 73 } | 72 } |
| 74 | 73 |
| 75 void DownloadsHandler::HandleResetAutoOpenFileTypes( | 74 void DownloadsHandler::HandleResetAutoOpenFileTypes( |
| 76 const base::ListValue* args) { | 75 const base::ListValue* args) { |
| 77 base::RecordAction(UserMetricsAction("Options_ResetAutoOpenFiles")); | 76 base::RecordAction(UserMetricsAction("Options_ResetAutoOpenFiles")); |
| 78 content::DownloadManager* manager = | 77 content::DownloadManager* manager = |
| 79 content::BrowserContext::GetDownloadManager(profile_); | 78 content::BrowserContext::GetDownloadManager(profile_); |
| 80 DownloadPrefs::FromDownloadManager(manager)->ResetAutoOpen(); | 79 DownloadPrefs::FromDownloadManager(manager)->ResetAutoOpen(); |
| 81 } | 80 } |
| 82 | 81 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 98 void DownloadsHandler::FileSelected(const base::FilePath& path, | 97 void DownloadsHandler::FileSelected(const base::FilePath& path, |
| 99 int index, | 98 int index, |
| 100 void* params) { | 99 void* params) { |
| 101 base::RecordAction(UserMetricsAction("Options_SetDownloadDirectory")); | 100 base::RecordAction(UserMetricsAction("Options_SetDownloadDirectory")); |
| 102 PrefService* pref_service = profile_->GetPrefs(); | 101 PrefService* pref_service = profile_->GetPrefs(); |
| 103 pref_service->SetFilePath(prefs::kDownloadDefaultDirectory, path); | 102 pref_service->SetFilePath(prefs::kDownloadDefaultDirectory, path); |
| 104 pref_service->SetFilePath(prefs::kSaveFileDefaultDirectory, path); | 103 pref_service->SetFilePath(prefs::kSaveFileDefaultDirectory, path); |
| 105 } | 104 } |
| 106 | 105 |
| 107 } // namespace settings | 106 } // namespace settings |
| OLD | NEW |