| 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 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 #include "components/bookmarks/managed/managed_bookmark_service.h" | 45 #include "components/bookmarks/managed/managed_bookmark_service.h" |
| 46 #include "components/user_prefs/user_prefs.h" | 46 #include "components/user_prefs/user_prefs.h" |
| 47 #include "content/public/browser/browser_context.h" | 47 #include "content/public/browser/browser_context.h" |
| 48 #include "content/public/browser/notification_service.h" | 48 #include "content/public/browser/notification_service.h" |
| 49 #include "content/public/browser/web_contents.h" | 49 #include "content/public/browser/web_contents.h" |
| 50 #include "extensions/browser/event_router.h" | 50 #include "extensions/browser/event_router.h" |
| 51 #include "extensions/browser/extension_function_dispatcher.h" | 51 #include "extensions/browser/extension_function_dispatcher.h" |
| 52 #include "extensions/browser/notification_types.h" | 52 #include "extensions/browser/notification_types.h" |
| 53 #include "ui/base/l10n/l10n_util.h" | 53 #include "ui/base/l10n/l10n_util.h" |
| 54 | 54 |
| 55 #if defined(OS_WIN) |
| 56 #include "ui/aura/remote_window_tree_host_win.h" |
| 57 #endif |
| 58 |
| 55 using bookmarks::BookmarkModel; | 59 using bookmarks::BookmarkModel; |
| 56 using bookmarks::BookmarkNode; | 60 using bookmarks::BookmarkNode; |
| 57 using bookmarks::ManagedBookmarkService; | 61 using bookmarks::ManagedBookmarkService; |
| 58 | 62 |
| 59 namespace extensions { | 63 namespace extensions { |
| 60 | 64 |
| 61 namespace keys = bookmark_api_constants; | 65 namespace keys = bookmark_api_constants; |
| 62 namespace bookmarks = api::bookmarks; | 66 namespace bookmarks = api::bookmarks; |
| 63 | 67 |
| 64 using bookmarks::BookmarkTreeNode; | 68 using bookmarks::BookmarkTreeNode; |
| (...skipping 722 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 787 WebContents* web_contents = GetAssociatedWebContents(); | 791 WebContents* web_contents = GetAssociatedWebContents(); |
| 788 | 792 |
| 789 select_file_dialog_ = ui::SelectFileDialog::Create( | 793 select_file_dialog_ = ui::SelectFileDialog::Create( |
| 790 this, new ChromeSelectFilePolicy(web_contents)); | 794 this, new ChromeSelectFilePolicy(web_contents)); |
| 791 ui::SelectFileDialog::FileTypeInfo file_type_info; | 795 ui::SelectFileDialog::FileTypeInfo file_type_info; |
| 792 file_type_info.extensions.resize(1); | 796 file_type_info.extensions.resize(1); |
| 793 file_type_info.extensions[0].push_back(FILE_PATH_LITERAL("html")); | 797 file_type_info.extensions[0].push_back(FILE_PATH_LITERAL("html")); |
| 794 gfx::NativeWindow owning_window = web_contents ? | 798 gfx::NativeWindow owning_window = web_contents ? |
| 795 platform_util::GetTopLevel(web_contents->GetNativeView()) | 799 platform_util::GetTopLevel(web_contents->GetNativeView()) |
| 796 : NULL; | 800 : NULL; |
| 801 #if defined(OS_WIN) |
| 802 if (!owning_window && |
| 803 chrome::GetActiveDesktop() == chrome::HOST_DESKTOP_TYPE_ASH) |
| 804 owning_window = aura::RemoteWindowTreeHostWin::Instance()->GetAshWindow(); |
| 805 #endif |
| 797 // |web_contents| can be NULL (for background pages), which is fine. In such | 806 // |web_contents| can be NULL (for background pages), which is fine. In such |
| 798 // a case if file-selection dialogs are forbidden by policy, we will not | 807 // a case if file-selection dialogs are forbidden by policy, we will not |
| 799 // show an InfoBar, which is better than letting one appear out of the blue. | 808 // show an InfoBar, which is better than letting one appear out of the blue. |
| 800 select_file_dialog_->SelectFile(type, | 809 select_file_dialog_->SelectFile(type, |
| 801 base::string16(), | 810 base::string16(), |
| 802 default_path, | 811 default_path, |
| 803 &file_type_info, | 812 &file_type_info, |
| 804 0, | 813 0, |
| 805 base::FilePath::StringType(), | 814 base::FilePath::StringType(), |
| 806 owning_window, | 815 owning_window, |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 848 } | 857 } |
| 849 | 858 |
| 850 void BookmarksExportFunction::FileSelected(const base::FilePath& path, | 859 void BookmarksExportFunction::FileSelected(const base::FilePath& path, |
| 851 int index, | 860 int index, |
| 852 void* params) { | 861 void* params) { |
| 853 bookmark_html_writer::WriteBookmarks(GetProfile(), path, NULL); | 862 bookmark_html_writer::WriteBookmarks(GetProfile(), path, NULL); |
| 854 Release(); // Balanced in BookmarksIOFunction::SelectFile() | 863 Release(); // Balanced in BookmarksIOFunction::SelectFile() |
| 855 } | 864 } |
| 856 | 865 |
| 857 } // namespace extensions | 866 } // namespace extensions |
| OLD | NEW |