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

Side by Side Diff: chrome/browser/extensions/api/file_system/file_system_api.cc

Issue 494033002: Move AppWindow to extensions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove unneeded include in chrome_shell_delegate.cc Created 6 years, 3 months 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 | Annotate | Revision Log
OLDNEW
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/file_system/file_system_api.h" 5 #include "chrome/browser/extensions/api/file_system/file_system_api.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "apps/app_window.h"
10 #include "apps/app_window_registry.h"
11 #include "apps/saved_files_service.h" 9 #include "apps/saved_files_service.h"
12 #include "base/bind.h" 10 #include "base/bind.h"
13 #include "base/files/file_path.h" 11 #include "base/files/file_path.h"
14 #include "base/files/file_util.h" 12 #include "base/files/file_util.h"
15 #include "base/logging.h" 13 #include "base/logging.h"
16 #include "base/path_service.h" 14 #include "base/path_service.h"
17 #include "base/strings/string_util.h" 15 #include "base/strings/string_util.h"
18 #include "base/strings/stringprintf.h" 16 #include "base/strings/stringprintf.h"
19 #include "base/strings/sys_string_conversions.h" 17 #include "base/strings/sys_string_conversions.h"
20 #include "base/strings/utf_string_conversions.h" 18 #include "base/strings/utf_string_conversions.h"
21 #include "base/value_conversions.h" 19 #include "base/value_conversions.h"
22 #include "base/values.h" 20 #include "base/values.h"
23 #include "chrome/browser/extensions/api/file_handlers/app_file_handler_util.h" 21 #include "chrome/browser/extensions/api/file_handlers/app_file_handler_util.h"
24 #include "chrome/browser/extensions/extension_service.h" 22 #include "chrome/browser/extensions/extension_service.h"
25 #include "chrome/browser/extensions/path_util.h" 23 #include "chrome/browser/extensions/path_util.h"
26 #include "chrome/browser/platform_util.h" 24 #include "chrome/browser/platform_util.h"
27 #include "chrome/browser/profiles/profile.h" 25 #include "chrome/browser/profiles/profile.h"
28 #include "chrome/browser/ui/apps/directory_access_confirmation_dialog.h" 26 #include "chrome/browser/ui/apps/directory_access_confirmation_dialog.h"
29 #include "chrome/browser/ui/chrome_select_file_policy.h" 27 #include "chrome/browser/ui/chrome_select_file_policy.h"
30 #include "chrome/common/chrome_paths.h" 28 #include "chrome/common/chrome_paths.h"
31 #include "chrome/common/extensions/api/file_system.h" 29 #include "chrome/common/extensions/api/file_system.h"
32 #include "chrome/grit/generated_resources.h" 30 #include "chrome/grit/generated_resources.h"
33 #include "content/public/browser/browser_thread.h" 31 #include "content/public/browser/browser_thread.h"
34 #include "content/public/browser/child_process_security_policy.h" 32 #include "content/public/browser/child_process_security_policy.h"
35 #include "content/public/browser/render_process_host.h" 33 #include "content/public/browser/render_process_host.h"
36 #include "content/public/browser/render_view_host.h" 34 #include "content/public/browser/render_view_host.h"
37 #include "content/public/browser/web_contents.h" 35 #include "content/public/browser/web_contents.h"
36 #include "extensions/browser/app_window/app_window.h"
37 #include "extensions/browser/app_window/app_window_registry.h"
38 #include "extensions/browser/extension_prefs.h" 38 #include "extensions/browser/extension_prefs.h"
39 #include "extensions/browser/extension_system.h" 39 #include "extensions/browser/extension_system.h"
40 #include "extensions/browser/granted_file_entry.h" 40 #include "extensions/browser/granted_file_entry.h"
41 #include "extensions/common/permissions/api_permission.h" 41 #include "extensions/common/permissions/api_permission.h"
42 #include "extensions/common/permissions/permissions_data.h" 42 #include "extensions/common/permissions/permissions_data.h"
43 #include "net/base/mime_util.h" 43 #include "net/base/mime_util.h"
44 #include "ui/base/l10n/l10n_util.h" 44 #include "ui/base/l10n/l10n_util.h"
45 #include "ui/shell_dialogs/select_file_dialog.h" 45 #include "ui/shell_dialogs/select_file_dialog.h"
46 #include "ui/shell_dialogs/selected_file_info.h" 46 #include "ui/shell_dialogs/selected_file_info.h"
47 #include "webkit/browser/fileapi/external_mount_points.h" 47 #include "webkit/browser/fileapi/external_mount_points.h"
48 #include "webkit/browser/fileapi/isolated_context.h" 48 #include "webkit/browser/fileapi/isolated_context.h"
49 #include "webkit/common/fileapi/file_system_types.h" 49 #include "webkit/common/fileapi/file_system_types.h"
50 #include "webkit/common/fileapi/file_system_util.h" 50 #include "webkit/common/fileapi/file_system_util.h"
51 51
52 #if defined(OS_MACOSX) 52 #if defined(OS_MACOSX)
53 #include <CoreFoundation/CoreFoundation.h> 53 #include <CoreFoundation/CoreFoundation.h>
54 #include "base/mac/foundation_util.h" 54 #include "base/mac/foundation_util.h"
55 #endif 55 #endif
56 56
57 #if defined(OS_CHROMEOS) 57 #if defined(OS_CHROMEOS)
58 #include "chrome/browser/chromeos/file_manager/filesystem_api_util.h" 58 #include "chrome/browser/chromeos/file_manager/filesystem_api_util.h"
59 #endif 59 #endif
60 60
61 using apps::SavedFileEntry; 61 using apps::SavedFileEntry;
62 using apps::SavedFilesService; 62 using apps::SavedFilesService;
63 using apps::AppWindow;
64 using storage::IsolatedContext; 63 using storage::IsolatedContext;
65 64
66 const char kInvalidCallingPage[] = "Invalid calling page. This function can't " 65 const char kInvalidCallingPage[] = "Invalid calling page. This function can't "
67 "be called from a background page."; 66 "be called from a background page.";
68 const char kUserCancelled[] = "User cancelled"; 67 const char kUserCancelled[] = "User cancelled";
69 const char kWritableFileErrorFormat[] = "Error opening %s"; 68 const char kWritableFileErrorFormat[] = "Error opening %s";
70 const char kRequiresFileSystemWriteError[] = 69 const char kRequiresFileSystemWriteError[] =
71 "Operation requires fileSystem.write permission"; 70 "Operation requires fileSystem.write permission";
72 const char kRequiresFileSystemDirectoryError[] = 71 const char kRequiresFileSystemDirectoryError[] =
73 "Operation requires fileSystem.directory permission"; 72 "Operation requires fileSystem.directory permission";
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 void FileSystemChooseEntryFunction::ShowPicker( 482 void FileSystemChooseEntryFunction::ShowPicker(
484 const ui::SelectFileDialog::FileTypeInfo& file_type_info, 483 const ui::SelectFileDialog::FileTypeInfo& file_type_info,
485 ui::SelectFileDialog::Type picker_type) { 484 ui::SelectFileDialog::Type picker_type) {
486 // TODO(asargent/benwells) - As a short term remediation for crbug.com/179010 485 // TODO(asargent/benwells) - As a short term remediation for crbug.com/179010
487 // we're adding the ability for a whitelisted extension to use this API since 486 // we're adding the ability for a whitelisted extension to use this API since
488 // chrome.fileBrowserHandler.selectFile is ChromeOS-only. Eventually we'd 487 // chrome.fileBrowserHandler.selectFile is ChromeOS-only. Eventually we'd
489 // like a better solution and likely this code will go back to being 488 // like a better solution and likely this code will go back to being
490 // platform-app only. 489 // platform-app only.
491 content::WebContents* web_contents = NULL; 490 content::WebContents* web_contents = NULL;
492 if (extension_->is_platform_app()) { 491 if (extension_->is_platform_app()) {
493 apps::AppWindowRegistry* registry = 492 AppWindowRegistry* registry = AppWindowRegistry::Get(GetProfile());
494 apps::AppWindowRegistry::Get(GetProfile());
495 DCHECK(registry); 493 DCHECK(registry);
496 AppWindow* app_window = 494 AppWindow* app_window =
497 registry->GetAppWindowForRenderViewHost(render_view_host()); 495 registry->GetAppWindowForRenderViewHost(render_view_host());
498 if (!app_window) { 496 if (!app_window) {
499 error_ = kInvalidCallingPage; 497 error_ = kInvalidCallingPage;
500 SendResponse(false); 498 SendResponse(false);
501 return; 499 return;
502 } 500 }
503 web_contents = app_window->web_contents(); 501 web_contents = app_window->web_contents();
504 } else { 502 } else {
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
604 } else { 602 } else {
605 last_choose_directory = paths[0].DirName(); 603 last_choose_directory = paths[0].DirName();
606 } 604 }
607 file_system_api::SetLastChooseEntryDirectory( 605 file_system_api::SetLastChooseEntryDirectory(
608 ExtensionPrefs::Get(GetProfile()), 606 ExtensionPrefs::Get(GetProfile()),
609 extension()->id(), 607 extension()->id(),
610 last_choose_directory); 608 last_choose_directory);
611 if (is_directory_) { 609 if (is_directory_) {
612 // Get the WebContents for the app window to be the parent window of the 610 // Get the WebContents for the app window to be the parent window of the
613 // confirmation dialog if necessary. 611 // confirmation dialog if necessary.
614 apps::AppWindowRegistry* registry = 612 AppWindowRegistry* registry = AppWindowRegistry::Get(GetProfile());
615 apps::AppWindowRegistry::Get(GetProfile());
616 DCHECK(registry); 613 DCHECK(registry);
617 AppWindow* app_window = 614 AppWindow* app_window =
618 registry->GetAppWindowForRenderViewHost(render_view_host()); 615 registry->GetAppWindowForRenderViewHost(render_view_host());
619 if (!app_window) { 616 if (!app_window) {
620 error_ = kInvalidCallingPage; 617 error_ = kInvalidCallingPage;
621 SendResponse(false); 618 SendResponse(false);
622 return; 619 return;
623 } 620 }
624 content::WebContents* web_contents = app_window->web_contents(); 621 content::WebContents* web_contents = app_window->web_contents();
625 622
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
947 return false; 944 return false;
948 } 945 }
949 946
950 bool FileSystemGetObservedEntriesFunction::RunSync() { 947 bool FileSystemGetObservedEntriesFunction::RunSync() {
951 NOTIMPLEMENTED(); 948 NOTIMPLEMENTED();
952 error_ = kUnknownIdError; 949 error_ = kUnknownIdError;
953 return false; 950 return false;
954 } 951 }
955 952
956 } // namespace extensions 953 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698