| 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 <set> | 5 #include <set> |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/nix/mime_util_xdg.h" | 11 #include "base/nix/mime_util_xdg.h" |
| 12 #include "base/nix/xdg_util.h" | 12 #include "base/nix/xdg_util.h" |
| 13 #include "base/process_util.h" | 13 #include "base/process_util.h" |
| 14 #include "base/string_number_conversions.h" | 14 #include "base/string_number_conversions.h" |
| 15 #include "base/string_util.h" | 15 #include "base/string_util.h" |
| 16 #include "base/threading/thread_restrictions.h" | 16 #include "base/threading/thread_restrictions.h" |
| 17 #include "base/utf_string_conversions.h" | 17 #include "base/utf_string_conversions.h" |
| 18 #include "chrome/browser/ui/gtk/select_file_dialog_impl.h" | 18 #include "chrome/browser/ui/gtk/select_file_dialog_impl.h" |
| 19 | |
| 20 // TODO(erg): Move all of this into WorkerPool. | |
| 21 #include "content/public/browser/browser_thread.h" | 19 #include "content/public/browser/browser_thread.h" |
| 22 #include "grit/generated_resources.h" | 20 #include "grit/generated_resources.h" |
| 23 #include "ui/base/l10n/l10n_util.h" | 21 #include "ui/base/l10n/l10n_util.h" |
| 24 | 22 |
| 25 // These conflict with base/tracked_objects.h, so need to come last. | 23 // These conflict with base/tracked_objects.h, so need to come last. |
| 26 #include <gdk/gdkx.h> | 24 #include <gdk/gdkx.h> |
| 27 #include <gtk/gtk.h> | 25 #include <gtk/gtk.h> |
| 28 | 26 |
| 29 using content::BrowserThread; | 27 using content::BrowserThread; |
| 30 | 28 |
| 31 namespace { | 29 namespace { |
| 32 | 30 |
| 33 std::string GetTitle(const std::string& title, int message_id) { | 31 std::string GetTitle(const std::string& title, int message_id) { |
| 34 return title.empty() ? l10n_util::GetStringUTF8(message_id) : title; | 32 return title.empty() ? l10n_util::GetStringUTF8(message_id) : title; |
| 35 } | 33 } |
| 36 | 34 |
| 37 const char kKdialogBinary[] = "kdialog"; | 35 const char kKdialogBinary[] = "kdialog"; |
| 38 | 36 |
| 39 } // namespace | 37 } // namespace |
| 40 | 38 |
| 41 // Implementation of SelectFileDialog that shows a KDE common dialog for | 39 // Implementation of SelectFileDialog that shows a KDE common dialog for |
| 42 // choosing a file or folder. This acts as a modal dialog. | 40 // choosing a file or folder. This acts as a modal dialog. |
| 43 class SelectFileDialogImplKDE : public SelectFileDialogImpl { | 41 class SelectFileDialogImplKDE : public SelectFileDialogImpl { |
| 44 public: | 42 public: |
| 45 SelectFileDialogImplKDE(Listener* listener, | 43 SelectFileDialogImplKDE(Listener* listener, |
| 46 ui::SelectFilePolicy* policy, | |
| 47 base::nix::DesktopEnvironment desktop); | 44 base::nix::DesktopEnvironment desktop); |
| 48 | 45 |
| 49 protected: | 46 protected: |
| 50 virtual ~SelectFileDialogImplKDE(); | 47 virtual ~SelectFileDialogImplKDE(); |
| 51 | 48 |
| 52 // SelectFileDialog implementation. | 49 // SelectFileDialog implementation. |
| 53 // |params| is user data we pass back via the Listener interface. | 50 // |params| is user data we pass back via the Listener interface. |
| 54 virtual void SelectFileImpl(Type type, | 51 virtual void SelectFileImpl(Type type, |
| 55 const string16& title, | 52 const string16& title, |
| 56 const FilePath& default_path, | 53 const FilePath& default_path, |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 CommandLine::StringVector cmd_vector; | 149 CommandLine::StringVector cmd_vector; |
| 153 cmd_vector.push_back(kKdialogBinary); | 150 cmd_vector.push_back(kKdialogBinary); |
| 154 cmd_vector.push_back("--version"); | 151 cmd_vector.push_back("--version"); |
| 155 CommandLine command_line(cmd_vector); | 152 CommandLine command_line(cmd_vector); |
| 156 std::string dummy; | 153 std::string dummy; |
| 157 return base::GetAppOutput(command_line, &dummy); | 154 return base::GetAppOutput(command_line, &dummy); |
| 158 } | 155 } |
| 159 | 156 |
| 160 // static | 157 // static |
| 161 SelectFileDialogImpl* SelectFileDialogImpl::NewSelectFileDialogImplKDE( | 158 SelectFileDialogImpl* SelectFileDialogImpl::NewSelectFileDialogImplKDE( |
| 162 Listener* listener, | 159 Listener* listener, base::nix::DesktopEnvironment desktop) { |
| 163 ui::SelectFilePolicy* policy, | 160 return new SelectFileDialogImplKDE(listener, desktop); |
| 164 base::nix::DesktopEnvironment desktop) { | |
| 165 return new SelectFileDialogImplKDE(listener, policy, desktop); | |
| 166 } | 161 } |
| 167 | 162 |
| 168 SelectFileDialogImplKDE::SelectFileDialogImplKDE( | 163 SelectFileDialogImplKDE::SelectFileDialogImplKDE( |
| 169 Listener* listener, | 164 Listener* listener, |
| 170 ui::SelectFilePolicy* policy, | |
| 171 base::nix::DesktopEnvironment desktop) | 165 base::nix::DesktopEnvironment desktop) |
| 172 : SelectFileDialogImpl(listener, policy), | 166 : SelectFileDialogImpl(listener), |
| 173 desktop_(desktop) { | 167 desktop_(desktop) { |
| 174 DCHECK(desktop_ == base::nix::DESKTOP_ENVIRONMENT_KDE3 || | 168 DCHECK(desktop_ == base::nix::DESKTOP_ENVIRONMENT_KDE3 || |
| 175 desktop_ == base::nix::DESKTOP_ENVIRONMENT_KDE4); | 169 desktop_ == base::nix::DESKTOP_ENVIRONMENT_KDE4); |
| 176 } | 170 } |
| 177 | 171 |
| 178 SelectFileDialogImplKDE::~SelectFileDialogImplKDE() { | 172 SelectFileDialogImplKDE::~SelectFileDialogImplKDE() { |
| 179 } | 173 } |
| 180 | 174 |
| 181 // We ignore |default_extension|. | 175 // We ignore |default_extension|. |
| 182 void SelectFileDialogImplKDE::SelectFileImpl( | 176 void SelectFileDialogImplKDE::SelectFileImpl( |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 458 continue; | 452 continue; |
| 459 filenames_fp.push_back(path); | 453 filenames_fp.push_back(path); |
| 460 } | 454 } |
| 461 | 455 |
| 462 if (filenames_fp.empty()) { | 456 if (filenames_fp.empty()) { |
| 463 FileNotSelected(params); | 457 FileNotSelected(params); |
| 464 return; | 458 return; |
| 465 } | 459 } |
| 466 MultiFilesSelected(filenames_fp, params); | 460 MultiFilesSelected(filenames_fp, params); |
| 467 } | 461 } |
| OLD | NEW |