| 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 // This file implements common select dialog functionality between GTK and KDE. | 5 // This file implements common select dialog functionality between GTK and KDE. |
| 6 | 6 |
| 7 #include "chrome/browser/ui/libgtk2ui/select_file_dialog_impl.h" | 7 #include "chrome/browser/ui/libgtk2ui/select_file_dialog_impl.h" |
| 8 | 8 |
| 9 #include "base/environment.h" | 9 #include "base/environment.h" |
| 10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 // static | 34 // static |
| 35 ui::SelectFileDialog* SelectFileDialogImpl::Create( | 35 ui::SelectFileDialog* SelectFileDialogImpl::Create( |
| 36 ui::SelectFileDialog::Listener* listener, | 36 ui::SelectFileDialog::Listener* listener, |
| 37 ui::SelectFilePolicy* policy) { | 37 ui::SelectFilePolicy* policy) { |
| 38 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 38 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 39 if (use_kde_ == UNKNOWN) { | 39 if (use_kde_ == UNKNOWN) { |
| 40 // Start out assumimg we are not going to use KDE. | 40 // Start out assumimg we are not going to use KDE. |
| 41 use_kde_ = NO_KDE; | 41 use_kde_ = NO_KDE; |
| 42 | 42 |
| 43 // Check to see if KDE is the desktop environment. | 43 // Check to see if KDE is the desktop environment. |
| 44 scoped_ptr<base::Environment> env(base::Environment::Create()); | 44 std::unique_ptr<base::Environment> env(base::Environment::Create()); |
| 45 base::nix::DesktopEnvironment desktop = | 45 base::nix::DesktopEnvironment desktop = |
| 46 base::nix::GetDesktopEnvironment(env.get()); | 46 base::nix::GetDesktopEnvironment(env.get()); |
| 47 if (desktop == base::nix::DESKTOP_ENVIRONMENT_KDE3 || | 47 if (desktop == base::nix::DESKTOP_ENVIRONMENT_KDE3 || |
| 48 desktop == base::nix::DESKTOP_ENVIRONMENT_KDE4 || | 48 desktop == base::nix::DESKTOP_ENVIRONMENT_KDE4 || |
| 49 desktop == base::nix::DESKTOP_ENVIRONMENT_KDE5) { | 49 desktop == base::nix::DESKTOP_ENVIRONMENT_KDE5) { |
| 50 // Check to see if the user dislikes the KDE file dialog. | 50 // Check to see if the user dislikes the KDE file dialog. |
| 51 if (!env->HasVar("NO_CHROME_KDE_FILE_DIALOG")) { | 51 if (!env->HasVar("NO_CHROME_KDE_FILE_DIALOG")) { |
| 52 // Check to see if the KDE dialog works. | 52 // Check to see if the KDE dialog works. |
| 53 if (SelectFileDialogImpl::CheckKDEDialogWorksOnUIThread()) { | 53 if (SelectFileDialogImpl::CheckKDEDialogWorksOnUIThread()) { |
| 54 use_kde_ = YES_KDE; | 54 use_kde_ = YES_KDE; |
| 55 } | 55 } |
| 56 } | 56 } |
| 57 } | 57 } |
| 58 } | 58 } |
| 59 | 59 |
| 60 if (use_kde_ == NO_KDE) | 60 if (use_kde_ == NO_KDE) |
| 61 return SelectFileDialogImpl::NewSelectFileDialogImplGTK(listener, policy); | 61 return SelectFileDialogImpl::NewSelectFileDialogImplGTK(listener, policy); |
| 62 | 62 |
| 63 scoped_ptr<base::Environment> env(base::Environment::Create()); | 63 std::unique_ptr<base::Environment> env(base::Environment::Create()); |
| 64 base::nix::DesktopEnvironment desktop = | 64 base::nix::DesktopEnvironment desktop = |
| 65 base::nix::GetDesktopEnvironment(env.get()); | 65 base::nix::GetDesktopEnvironment(env.get()); |
| 66 return SelectFileDialogImpl::NewSelectFileDialogImplKDE( | 66 return SelectFileDialogImpl::NewSelectFileDialogImplKDE( |
| 67 listener, policy, desktop); | 67 listener, policy, desktop); |
| 68 } | 68 } |
| 69 | 69 |
| 70 SelectFileDialogImpl::SelectFileDialogImpl(Listener* listener, | 70 SelectFileDialogImpl::SelectFileDialogImpl(Listener* listener, |
| 71 ui::SelectFilePolicy* policy) | 71 ui::SelectFilePolicy* policy) |
| 72 : SelectFileDialog(listener, policy), | 72 : SelectFileDialog(listener, policy), |
| 73 file_type_index_(0), | 73 file_type_index_(0), |
| (...skipping 10 matching lines...) Expand all Loading... |
| 84 listener_ = NULL; | 84 listener_ = NULL; |
| 85 } | 85 } |
| 86 | 86 |
| 87 bool SelectFileDialogImpl::CallDirectoryExistsOnUIThread( | 87 bool SelectFileDialogImpl::CallDirectoryExistsOnUIThread( |
| 88 const base::FilePath& path) { | 88 const base::FilePath& path) { |
| 89 base::ThreadRestrictions::ScopedAllowIO allow_io; | 89 base::ThreadRestrictions::ScopedAllowIO allow_io; |
| 90 return base::DirectoryExists(path); | 90 return base::DirectoryExists(path); |
| 91 } | 91 } |
| 92 | 92 |
| 93 } // namespace libgtk2ui | 93 } // namespace libgtk2ui |
| OLD | NEW |