From 0700f08d6da7c7c7cabb18a878a3fc63efdb2346 Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Sun, 26 Jul 2015 16:08:29 +0800 Subject: [PATCH] Copy pref_names files from Chromium. --- atom/browser/web_dialog_helper.cc | 7 +++---- chromium_src/chrome/common/pref_names.cc | 11 +++++++++++ chromium_src/chrome/common/pref_names.h | 11 +++++++++++ filenames.gypi | 2 ++ 4 files changed, 27 insertions(+), 4 deletions(-) create mode 100644 chromium_src/chrome/common/pref_names.cc diff --git a/atom/browser/web_dialog_helper.cc b/atom/browser/web_dialog_helper.cc index 93cb32cba7c7..7b467cfcdfcb 100644 --- a/atom/browser/web_dialog_helper.cc +++ b/atom/browser/web_dialog_helper.cc @@ -15,6 +15,7 @@ #include "base/files/file_path.h" #include "base/prefs/pref_service.h" #include "base/strings/utf_string_conversions.h" +#include "chrome/common/pref_names.h" #include "content/public/browser/render_view_host.h" #include "content/public/browser/web_contents.h" #include "content/public/common/file_chooser_file_info.h" @@ -23,8 +24,6 @@ namespace { -const char kSelectFileLastDirectory[] = "selectfile.last_directory"; - file_dialog::Filters GetFileTypesFromAcceptType( const std::vector& accept_types) { file_dialog::Filters filters; @@ -111,7 +110,7 @@ void WebDialogHelper::RunFileChooser(content::WebContents* web_contents, AtomBrowserContext* browser_context = static_cast( window_->web_contents()->GetBrowserContext()); base::FilePath default_file_path = browser_context->prefs()->GetFilePath( - kSelectFileLastDirectory).Append(params.default_file_name); + prefs::kSelectFileLastDirectory).Append(params.default_file_name); if (file_dialog::ShowOpenDialog(window_, base::UTF16ToUTF8(params.title), default_file_path, @@ -125,7 +124,7 @@ void WebDialogHelper::RunFileChooser(content::WebContents* web_contents, result.push_back(info); } if (!paths.empty()) { - browser_context->prefs()->SetFilePath(kSelectFileLastDirectory, + browser_context->prefs()->SetFilePath(prefs::kSelectFileLastDirectory, paths[0].DirName()); } } diff --git a/chromium_src/chrome/common/pref_names.cc b/chromium_src/chrome/common/pref_names.cc new file mode 100644 index 000000000000..3871fde2c2f0 --- /dev/null +++ b/chromium_src/chrome/common/pref_names.cc @@ -0,0 +1,11 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/common/pref_names.h" + +namespace prefs { + +const char kSelectFileLastDirectory[] = "selectfile.last_directory"; + +} // namespace prefs diff --git a/chromium_src/chrome/common/pref_names.h b/chromium_src/chrome/common/pref_names.h index e69de29bb2d1..78bd2a04800b 100644 --- a/chromium_src/chrome/common/pref_names.h +++ b/chromium_src/chrome/common/pref_names.h @@ -0,0 +1,11 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Constants for the names of various preferences, for easier changing. + +namespace prefs { + +extern const char kSelectFileLastDirectory[]; + +} // namespace prefs diff --git a/filenames.gypi b/filenames.gypi index ed51fc8fb47b..82f9ea95d078 100644 --- a/filenames.gypi +++ b/filenames.gypi @@ -364,6 +364,8 @@ 'chromium_src/chrome/browser/ui/views/frame/global_menu_bar_registrar_x11.cc', 'chromium_src/chrome/browser/ui/views/frame/global_menu_bar_registrar_x11.h', 'chromium_src/chrome/common/chrome_utility_messages.h', + 'chromium_src/chrome/common/pref_names.cc', + 'chromium_src/chrome/common/pref_names.h', 'chromium_src/chrome/common/print_messages.cc', 'chromium_src/chrome/common/print_messages.h', 'chromium_src/chrome/common/tts_messages.h',