Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(174)

Side by Side Diff: chrome/browser/ui/libgtk2ui/select_file_dialog_impl.cc

Issue 2449243002: Gtk3 ui: Add libgtk3ui as a separate build component (Closed)
Patch Set: Add theme_properties dep to //chrome/browser/ui Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4 //
5 // This file implements common select dialog functionality between GTK and KDE.
6
7 #include "chrome/browser/ui/libgtk2ui/select_file_dialog_impl.h"
8
9 #include "base/environment.h"
10 #include "base/files/file_util.h"
11 #include "base/nix/xdg_util.h"
12 #include "base/threading/thread_restrictions.h"
13 #include "content/public/browser/browser_thread.h"
14
15 using content::BrowserThread;
16
17 namespace {
18
19 enum UseKdeFileDialogStatus {
20 UNKNOWN,
21 NO_KDE,
22 YES_KDE
23 };
24
25 UseKdeFileDialogStatus use_kde_ = UNKNOWN;
26
27 } // namespace
28
29 namespace libgtk2ui {
30
31 base::FilePath* SelectFileDialogImpl::last_saved_path_ = NULL;
32 base::FilePath* SelectFileDialogImpl::last_opened_path_ = NULL;
33
34 // static
35 ui::SelectFileDialog* SelectFileDialogImpl::Create(
36 ui::SelectFileDialog::Listener* listener,
37 ui::SelectFilePolicy* policy) {
38 DCHECK_CURRENTLY_ON(BrowserThread::UI);
39 if (use_kde_ == UNKNOWN) {
40 // Start out assumimg we are not going to use KDE.
41 use_kde_ = NO_KDE;
42
43 // Check to see if KDE is the desktop environment.
44 std::unique_ptr<base::Environment> env(base::Environment::Create());
45 base::nix::DesktopEnvironment desktop =
46 base::nix::GetDesktopEnvironment(env.get());
47 if (desktop == base::nix::DESKTOP_ENVIRONMENT_KDE3 ||
48 desktop == base::nix::DESKTOP_ENVIRONMENT_KDE4 ||
49 desktop == base::nix::DESKTOP_ENVIRONMENT_KDE5) {
50 // Check to see if the user dislikes the KDE file dialog.
51 if (!env->HasVar("NO_CHROME_KDE_FILE_DIALOG")) {
52 // Check to see if the KDE dialog works.
53 if (SelectFileDialogImpl::CheckKDEDialogWorksOnUIThread()) {
54 use_kde_ = YES_KDE;
55 }
56 }
57 }
58 }
59
60 if (use_kde_ == NO_KDE)
61 return SelectFileDialogImpl::NewSelectFileDialogImplGTK(listener, policy);
62
63 std::unique_ptr<base::Environment> env(base::Environment::Create());
64 base::nix::DesktopEnvironment desktop =
65 base::nix::GetDesktopEnvironment(env.get());
66 return SelectFileDialogImpl::NewSelectFileDialogImplKDE(
67 listener, policy, desktop);
68 }
69
70 SelectFileDialogImpl::SelectFileDialogImpl(Listener* listener,
71 ui::SelectFilePolicy* policy)
72 : SelectFileDialog(listener, policy),
73 file_type_index_(0),
74 type_(SELECT_NONE) {
75 if (!last_saved_path_) {
76 last_saved_path_ = new base::FilePath();
77 last_opened_path_ = new base::FilePath();
78 }
79 }
80
81 SelectFileDialogImpl::~SelectFileDialogImpl() { }
82
83 void SelectFileDialogImpl::ListenerDestroyed() {
84 listener_ = NULL;
85 }
86
87 bool SelectFileDialogImpl::CallDirectoryExistsOnUIThread(
88 const base::FilePath& path) {
89 base::ThreadRestrictions::ScopedAllowIO allow_io;
90 return base::DirectoryExists(path);
91 }
92
93 } // namespace libgtk2ui
OLDNEW
« no previous file with comments | « chrome/browser/ui/libgtk2ui/select_file_dialog_impl.h ('k') | chrome/browser/ui/libgtk2ui/select_file_dialog_impl_gtk2.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698