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/gtk/select_file_dialog_impl.h" | 7 #include "ui/base/dialogs/gtk/select_file_dialog_impl.h" |
8 | 8 |
9 #include "base/environment.h" | 9 #include "base/environment.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
11 #include "base/nix/xdg_util.h" | 11 #include "base/nix/xdg_util.h" |
12 #include "base/threading/thread_restrictions.h" | 12 #include "base/threading/thread_restrictions.h" |
13 #include "content/public/browser/browser_thread.h" | |
14 | |
15 using content::BrowserThread; | |
16 | 13 |
17 namespace { | 14 namespace { |
18 | 15 |
19 enum UseKdeFileDialogStatus { | 16 enum UseKdeFileDialogStatus { |
20 UNKNOWN, | 17 UNKNOWN, |
21 NO_KDE, | 18 NO_KDE, |
22 YES_KDE | 19 YES_KDE |
23 }; | 20 }; |
24 | 21 |
25 UseKdeFileDialogStatus use_kde_ = UNKNOWN; | 22 UseKdeFileDialogStatus use_kde_ = UNKNOWN; |
26 | 23 |
27 } // namespace | 24 } // namespace |
28 | 25 |
| 26 namespace ui { |
| 27 |
29 FilePath* SelectFileDialogImpl::last_saved_path_ = NULL; | 28 FilePath* SelectFileDialogImpl::last_saved_path_ = NULL; |
30 FilePath* SelectFileDialogImpl::last_opened_path_ = NULL; | 29 FilePath* SelectFileDialogImpl::last_opened_path_ = NULL; |
31 | 30 |
32 // static | 31 // static |
33 SelectFileDialog* SelectFileDialog::Create(Listener* listener, | 32 SelectFileDialog* CreateLinuxSelectFileDialog( |
34 ui::SelectFilePolicy* policy) { | 33 SelectFileDialog::Listener* listener, |
35 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 34 SelectFilePolicy* policy) { |
36 if (use_kde_ == UNKNOWN) { | 35 if (use_kde_ == UNKNOWN) { |
37 // Start out assumimg we are not going to use KDE. | 36 // Start out assumimg we are not going to use KDE. |
38 use_kde_ = NO_KDE; | 37 use_kde_ = NO_KDE; |
39 | 38 |
40 // Check to see if KDE is the desktop environment. | 39 // Check to see if KDE is the desktop environment. |
41 scoped_ptr<base::Environment> env(base::Environment::Create()); | 40 scoped_ptr<base::Environment> env(base::Environment::Create()); |
42 base::nix::DesktopEnvironment desktop = | 41 base::nix::DesktopEnvironment desktop = |
43 base::nix::GetDesktopEnvironment(env.get()); | 42 base::nix::GetDesktopEnvironment(env.get()); |
44 if (desktop == base::nix::DESKTOP_ENVIRONMENT_KDE3 || | 43 if (desktop == base::nix::DESKTOP_ENVIRONMENT_KDE3 || |
45 desktop == base::nix::DESKTOP_ENVIRONMENT_KDE4) { | 44 desktop == base::nix::DESKTOP_ENVIRONMENT_KDE4) { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 } | 80 } |
82 | 81 |
83 bool SelectFileDialogImpl::IsRunning(gfx::NativeWindow parent_window) const { | 82 bool SelectFileDialogImpl::IsRunning(gfx::NativeWindow parent_window) const { |
84 return parents_.find(parent_window) != parents_.end(); | 83 return parents_.find(parent_window) != parents_.end(); |
85 } | 84 } |
86 | 85 |
87 bool SelectFileDialogImpl::CallDirectoryExistsOnUIThread(const FilePath& path) { | 86 bool SelectFileDialogImpl::CallDirectoryExistsOnUIThread(const FilePath& path) { |
88 base::ThreadRestrictions::ScopedAllowIO allow_io; | 87 base::ThreadRestrictions::ScopedAllowIO allow_io; |
89 return file_util::DirectoryExists(path); | 88 return file_util::DirectoryExists(path); |
90 } | 89 } |
| 90 |
| 91 } // namespace ui |
OLD | NEW |