| 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 #include "chrome/browser/extensions/api/bookmarks/bookmarks_api.h" | 5 #include "chrome/browser/extensions/api/bookmarks/bookmarks_api.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 #include "base/strings/utf_string_conversions.h" | 24 #include "base/strings/utf_string_conversions.h" |
| 25 #include "base/time/time.h" | 25 #include "base/time/time.h" |
| 26 #include "build/build_config.h" | 26 #include "build/build_config.h" |
| 27 #include "chrome/browser/bookmarks/bookmark_html_writer.h" | 27 #include "chrome/browser/bookmarks/bookmark_html_writer.h" |
| 28 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 28 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
| 29 #include "chrome/browser/bookmarks/managed_bookmark_service_factory.h" | 29 #include "chrome/browser/bookmarks/managed_bookmark_service_factory.h" |
| 30 #include "chrome/browser/extensions/api/bookmarks/bookmark_api_constants.h" | 30 #include "chrome/browser/extensions/api/bookmarks/bookmark_api_constants.h" |
| 31 #include "chrome/browser/extensions/api/bookmarks/bookmark_api_helpers.h" | 31 #include "chrome/browser/extensions/api/bookmarks/bookmark_api_helpers.h" |
| 32 #include "chrome/browser/importer/external_process_importer_host.h" | 32 #include "chrome/browser/importer/external_process_importer_host.h" |
| 33 #include "chrome/browser/importer/importer_uma.h" | 33 #include "chrome/browser/importer/importer_uma.h" |
| 34 #include "chrome/browser/platform_util.h" | |
| 35 #include "chrome/browser/profiles/profile.h" | 34 #include "chrome/browser/profiles/profile.h" |
| 36 #include "chrome/browser/ui/chrome_select_file_policy.h" | 35 #include "chrome/browser/ui/chrome_select_file_policy.h" |
| 37 #include "chrome/common/chrome_paths.h" | 36 #include "chrome/common/chrome_paths.h" |
| 38 #include "chrome/common/extensions/api/bookmarks.h" | 37 #include "chrome/common/extensions/api/bookmarks.h" |
| 39 #include "chrome/common/importer/importer_data_types.h" | 38 #include "chrome/common/importer/importer_data_types.h" |
| 40 #include "chrome/common/pref_names.h" | 39 #include "chrome/common/pref_names.h" |
| 41 #include "chrome/grit/generated_resources.h" | 40 #include "chrome/grit/generated_resources.h" |
| 42 #include "components/bookmarks/browser/bookmark_model.h" | 41 #include "components/bookmarks/browser/bookmark_model.h" |
| 43 #include "components/bookmarks/browser/bookmark_utils.h" | 42 #include "components/bookmarks/browser/bookmark_utils.h" |
| 44 #include "components/bookmarks/common/bookmark_pref_names.h" | 43 #include "components/bookmarks/common/bookmark_pref_names.h" |
| 45 #include "components/bookmarks/managed/managed_bookmark_service.h" | 44 #include "components/bookmarks/managed/managed_bookmark_service.h" |
| 46 #include "components/prefs/pref_service.h" | 45 #include "components/prefs/pref_service.h" |
| 47 #include "components/user_prefs/user_prefs.h" | 46 #include "components/user_prefs/user_prefs.h" |
| 48 #include "content/public/browser/browser_context.h" | 47 #include "content/public/browser/browser_context.h" |
| 49 #include "content/public/browser/notification_service.h" | 48 #include "content/public/browser/notification_service.h" |
| 50 #include "content/public/browser/web_contents.h" | 49 #include "content/public/browser/web_contents.h" |
| 51 #include "extensions/browser/event_router.h" | 50 #include "extensions/browser/event_router.h" |
| 52 #include "extensions/browser/extension_function_dispatcher.h" | 51 #include "extensions/browser/extension_function_dispatcher.h" |
| 53 #include "extensions/browser/notification_types.h" | 52 #include "extensions/browser/notification_types.h" |
| 54 #include "ui/base/l10n/l10n_util.h" | 53 #include "ui/base/l10n/l10n_util.h" |
| 54 #include "ui/gfx/view_util.h" |
| 55 | 55 |
| 56 using bookmarks::BookmarkModel; | 56 using bookmarks::BookmarkModel; |
| 57 using bookmarks::BookmarkNode; | 57 using bookmarks::BookmarkNode; |
| 58 using bookmarks::ManagedBookmarkService; | 58 using bookmarks::ManagedBookmarkService; |
| 59 | 59 |
| 60 namespace extensions { | 60 namespace extensions { |
| 61 | 61 |
| 62 namespace keys = bookmark_api_constants; | 62 namespace keys = bookmark_api_constants; |
| 63 namespace bookmarks = api::bookmarks; | 63 namespace bookmarks = api::bookmarks; |
| 64 | 64 |
| (...skipping 709 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 774 // either FileSelectionCanceled, MultiFilesSelected, or FileSelected | 774 // either FileSelectionCanceled, MultiFilesSelected, or FileSelected |
| 775 AddRef(); | 775 AddRef(); |
| 776 | 776 |
| 777 WebContents* web_contents = GetAssociatedWebContents(); | 777 WebContents* web_contents = GetAssociatedWebContents(); |
| 778 | 778 |
| 779 select_file_dialog_ = ui::SelectFileDialog::Create( | 779 select_file_dialog_ = ui::SelectFileDialog::Create( |
| 780 this, new ChromeSelectFilePolicy(web_contents)); | 780 this, new ChromeSelectFilePolicy(web_contents)); |
| 781 ui::SelectFileDialog::FileTypeInfo file_type_info; | 781 ui::SelectFileDialog::FileTypeInfo file_type_info; |
| 782 file_type_info.extensions.resize(1); | 782 file_type_info.extensions.resize(1); |
| 783 file_type_info.extensions[0].push_back(FILE_PATH_LITERAL("html")); | 783 file_type_info.extensions[0].push_back(FILE_PATH_LITERAL("html")); |
| 784 gfx::NativeWindow owning_window = web_contents ? | 784 gfx::NativeWindow owning_window = |
| 785 platform_util::GetTopLevel(web_contents->GetNativeView()) | 785 web_contents ? gfx::GetTopLevel(web_contents->GetNativeView()) : nullptr; |
| 786 : NULL; | |
| 787 // |web_contents| can be NULL (for background pages), which is fine. In such | 786 // |web_contents| can be NULL (for background pages), which is fine. In such |
| 788 // a case if file-selection dialogs are forbidden by policy, we will not | 787 // a case if file-selection dialogs are forbidden by policy, we will not |
| 789 // show an InfoBar, which is better than letting one appear out of the blue. | 788 // show an InfoBar, which is better than letting one appear out of the blue. |
| 790 select_file_dialog_->SelectFile(type, | 789 select_file_dialog_->SelectFile(type, |
| 791 base::string16(), | 790 base::string16(), |
| 792 default_path, | 791 default_path, |
| 793 &file_type_info, | 792 &file_type_info, |
| 794 0, | 793 0, |
| 795 base::FilePath::StringType(), | 794 base::FilePath::StringType(), |
| 796 owning_window, | 795 owning_window, |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 838 } | 837 } |
| 839 | 838 |
| 840 void BookmarksExportFunction::FileSelected(const base::FilePath& path, | 839 void BookmarksExportFunction::FileSelected(const base::FilePath& path, |
| 841 int index, | 840 int index, |
| 842 void* params) { | 841 void* params) { |
| 843 bookmark_html_writer::WriteBookmarks(GetProfile(), path, NULL); | 842 bookmark_html_writer::WriteBookmarks(GetProfile(), path, NULL); |
| 844 Release(); // Balanced in BookmarksIOFunction::SelectFile() | 843 Release(); // Balanced in BookmarksIOFunction::SelectFile() |
| 845 } | 844 } |
| 846 | 845 |
| 847 } // namespace extensions | 846 } // namespace extensions |
| OLD | NEW |