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