OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 commond select dialog functionality between GTK and KDE. | 5 // This file implements commond select dialog functionality between GTK and KDE. |
6 | 6 |
7 #include "chrome/browser/ui/gtk/dialogs_common.h" | 7 #include "chrome/browser/ui/gtk/dialogs_common.h" |
8 | 8 |
| 9 #include "base/environment.h" |
9 #include "base/file_util.h" | 10 #include "base/file_util.h" |
10 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
| 12 #include "base/nix/xdg_util.h" |
11 #include "base/threading/thread.h" | 13 #include "base/threading/thread.h" |
12 #include "base/threading/thread_restrictions.h" | 14 #include "base/threading/thread_restrictions.h" |
13 #include "content/browser/browser_thread.h" | 15 #include "content/browser/browser_thread.h" |
14 | 16 |
15 FilePath* SelectFileDialogImpl::last_saved_path_ = NULL; | 17 FilePath* SelectFileDialogImpl::last_saved_path_ = NULL; |
16 FilePath* SelectFileDialogImpl::last_opened_path_ = NULL; | 18 FilePath* SelectFileDialogImpl::last_opened_path_ = NULL; |
17 | 19 |
18 // static | 20 // static |
19 SelectFileDialog* SelectFileDialog::Create(Listener* listener) { | 21 SelectFileDialog* SelectFileDialog::Create(Listener* listener) { |
20 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 22 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 23 scoped_ptr<base::Environment> env(base::Environment::Create()); |
| 24 base::nix::DesktopEnvironment desktop = |
| 25 base::nix::GetDesktopEnvironment(env.get()); |
| 26 if (desktop == base::nix::DESKTOP_ENVIRONMENT_KDE3 || |
| 27 desktop == base::nix::DESKTOP_ENVIRONMENT_KDE4) { |
| 28 return SelectFileDialogImpl::NewSelectFileDialogImplKDE(listener); |
| 29 } |
21 return SelectFileDialogImpl::NewSelectFileDialogImplGTK(listener); | 30 return SelectFileDialogImpl::NewSelectFileDialogImplGTK(listener); |
22 } | 31 } |
23 | 32 |
24 SelectFileDialogImpl::SelectFileDialogImpl(Listener* listener) | 33 SelectFileDialogImpl::SelectFileDialogImpl(Listener* listener) |
25 : SelectFileDialog(listener), | 34 : SelectFileDialog(listener), |
26 file_type_index_(0), | 35 file_type_index_(0), |
27 type_(SELECT_NONE) { | 36 type_(SELECT_NONE) { |
28 if (!last_saved_path_) { | 37 if (!last_saved_path_) { |
29 last_saved_path_ = new FilePath(); | 38 last_saved_path_ = new FilePath(); |
30 last_opened_path_ = new FilePath(); | 39 last_opened_path_ = new FilePath(); |
31 } | 40 } |
32 } | 41 } |
33 | 42 |
34 SelectFileDialogImpl::~SelectFileDialogImpl() { } | 43 SelectFileDialogImpl::~SelectFileDialogImpl() { } |
35 | 44 |
36 void SelectFileDialogImpl::ListenerDestroyed() { | 45 void SelectFileDialogImpl::ListenerDestroyed() { |
37 listener_ = NULL; | 46 listener_ = NULL; |
38 } | 47 } |
39 | 48 |
40 bool SelectFileDialogImpl::IsRunning(gfx::NativeWindow parent_window) const { | 49 bool SelectFileDialogImpl::IsRunning(gfx::NativeWindow parent_window) const { |
41 return parents_.find(parent_window) != parents_.end(); | 50 return parents_.find(parent_window) != parents_.end(); |
42 } | 51 } |
43 | 52 |
44 bool SelectFileDialogImpl::CallDirectoryExistsOnUIThread(const FilePath& path) { | 53 bool SelectFileDialogImpl::CallDirectoryExistsOnUIThread(const FilePath& path) { |
45 base::ThreadRestrictions::ScopedAllowIO allow_io; | 54 base::ThreadRestrictions::ScopedAllowIO allow_io; |
46 return file_util::DirectoryExists(path); | 55 return file_util::DirectoryExists(path); |
47 } | 56 } |
48 | 57 |
OLD | NEW |