Skip to content

Commit

Permalink
Revert of Move file_handlers API from //chrome to //extensions (patch…
Browse files Browse the repository at this point in the history
…set chromium#5 id:80001 of https://codereview.chromium.org/2685453002/ )

Reason for revert:
Broke compile on Linux x64. Example failure: https://build.chromium.org/p/chromium.chrome/builders/Google%20Chrome%20Linux%20x64/builds/16205

The build error is kind of confusing to me so apologizes in advance if this is the wrong CL.

Original issue's description:
> Move file_handlers API from //chrome to //extensions
>
> Largely mechanical CL via move_source_file.py, subbing some Profile usage
> for BrowserContext.
>
> Results in removing some DEPS exceptions and #includes from //apps.
>
> BUG=679870
>
> Review-Url: https://codereview.chromium.org/2685453002
> Cr-Commit-Position: refs/heads/master@{#449460}
> Committed: https://chromium.googlesource.com/chromium/src/+/10d5e4e8430e41ca148452f2f8582db517846799

TBR=benwells@chromium.org,mtomasz@chromium.org,tzik@chromium.org,michaelpg@chromium.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=679870

Review-Url: https://codereview.chromium.org/2685883008
Cr-Commit-Position: refs/heads/master@{#449465}
  • Loading branch information
bsep-chromium authored and Commit bot committed Feb 9, 2017
1 parent 29056b8 commit 9790279
Show file tree
Hide file tree
Showing 29 changed files with 136 additions and 134 deletions.
3 changes: 3 additions & 0 deletions apps/DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ include_rules = [

# Pieces of the extensions system that need to move to src/extensions.
# See http://crbug.com/162530 for details.
"+chrome/browser/extensions/api/file_handlers/app_file_handler_util.h",
"+chrome/browser/extensions/api/file_handlers/directory_util.h",
"+chrome/browser/extensions/api/file_handlers/mime_util.h",
"+chrome/browser/extensions/api/file_system/file_system_api.h",
"+chrome/browser/extensions/chrome_extension_web_contents_observer.h",
"+chrome/browser/extensions/unpacked_installer.h",
Expand Down
7 changes: 4 additions & 3 deletions apps/launcher.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,17 @@
#include "base/memory/ref_counted.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/extensions/api/file_handlers/app_file_handler_util.h"
#include "chrome/browser/extensions/api/file_handlers/directory_util.h"
#include "chrome/browser/extensions/api/file_handlers/mime_util.h"
#include "chrome/browser/extensions/api/file_system/file_system_api.h"
#include "chrome/browser/profiles/profile.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/content_switches.h"
#include "content/public/common/url_constants.h"
#include "extensions/browser/api/app_runtime/app_runtime_api.h"
#include "extensions/browser/api/file_handlers/app_file_handler_util.h"
#include "extensions/browser/api/file_handlers/directory_util.h"
#include "extensions/browser/api/file_handlers/mime_util.h"
#include "extensions/browser/entry_info.h"
#include "extensions/browser/event_router.h"
#include "extensions/browser/extension_host.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/chromeos/settings/cros_settings.h"
#include "chrome/browser/devtools/devtools_window.h"
#include "chrome/browser/extensions/api/file_handlers/mime_util.h"
#include "chrome/browser/extensions/devtools_util.h"
#include "chrome/browser/lifetime/application_lifetime.h"
#include "chrome/browser/profiles/profile.h"
Expand All @@ -49,7 +50,6 @@
#include "components/zoom/page_zoom.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/page_zoom.h"
#include "extensions/browser/api/file_handlers/mime_util.h"
#include "extensions/browser/app_window/app_window.h"
#include "extensions/browser/app_window/app_window_registry.h"
#include "google_apis/drive/auth_service.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
#include "chrome/browser/chromeos/drive/file_system_util.h"
#include "chrome/browser/chromeos/file_manager/fileapi_util.h"
#include "chrome/browser/chromeos/fileapi/file_system_backend.h"
#include "chrome/browser/extensions/api/file_handlers/directory_util.h"
#include "chrome/browser/extensions/api/file_handlers/mime_util.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/extensions/api/file_manager_private.h"
#include "chrome/common/extensions/api/file_manager_private_internal.h"
#include "content/public/browser/browser_thread.h"
#include "extensions/browser/api/file_handlers/directory_util.h"
#include "extensions/browser/api/file_handlers/mime_util.h"
#include "extensions/browser/entry_info.h"
#include "net/base/filename_util.h"
#include "storage/browser/fileapi/file_system_context.h"
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/chromeos/file_manager/file_tasks.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "chrome/browser/chromeos/file_manager/file_browser_handlers.h"
#include "chrome/browser/chromeos/file_manager/fileapi_util.h"
#include "chrome/browser/chromeos/file_manager/open_util.h"
#include "chrome/browser/extensions/api/file_handlers/mime_util.h"
#include "chrome/browser/extensions/extension_tab_util.h"
#include "chrome/browser/extensions/extension_util.h"
#include "chrome/browser/profiles/profile.h"
Expand All @@ -35,7 +36,6 @@
#include "components/mime_util/mime_util.h"
#include "components/prefs/pref_service.h"
#include "components/prefs/scoped_user_pref_update.h"
#include "extensions/browser/api/file_handlers/mime_util.h"
#include "extensions/browser/entry_info.h"
#include "extensions/browser/extension_host.h"
#include "extensions/browser/extension_registry.h"
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/chromeos/file_manager/file_tasks.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@
#include <vector>

#include "base/callback_forward.h"
#include "chrome/browser/extensions/api/file_handlers/app_file_handler_util.h"
#include "chrome/common/extensions/api/file_manager_private.h"
#include "extensions/browser/api/file_handlers/app_file_handler_util.h"
#include "url/gurl.h"

class PrefService;
Expand Down
5 changes: 2 additions & 3 deletions chrome/browser/chromeos/file_manager/open_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,10 @@
#include "chrome/browser/chromeos/file_manager/fileapi_util.h"
#include "chrome/browser/chromeos/file_manager/path_util.h"
#include "chrome/browser/chromeos/file_manager/url_util.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/extensions/api/file_handlers/directory_util.h"
#include "chrome/browser/extensions/api/file_handlers/mime_util.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/user_metrics.h"
#include "extensions/browser/api/file_handlers/directory_util.h"
#include "extensions/browser/api/file_handlers/mime_util.h"
#include "extensions/browser/entry_info.h"
#include "storage/browser/fileapi/file_system_backend.h"
#include "storage/browser/fileapi/file_system_context.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chromeos/file_manager/fileapi_util.h"
#include "chrome/browser/chromeos/fileapi/external_file_url_util.h"
#include "chrome/browser/extensions/api/file_handlers/mime_util.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "components/drive/file_system_core_util.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/storage_partition.h"
#include "content/public/common/url_constants.h"
#include "extensions/browser/api/file_handlers/mime_util.h"
#include "net/http/http_byte_range.h"
#include "net/http/http_request_headers.h"
#include "net/http/http_response_info.h"
Expand Down
6 changes: 6 additions & 0 deletions chrome/browser/extensions/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,12 @@ static_library("extensions") {
"api/feedback_private/feedback_private_api.h",
"api/feedback_private/feedback_service.cc",
"api/feedback_private/feedback_service.h",
"api/file_handlers/app_file_handler_util.cc",
"api/file_handlers/app_file_handler_util.h",
"api/file_handlers/directory_util.cc",
"api/file_handlers/directory_util.h",
"api/file_handlers/mime_util.cc",
"api/file_handlers/mime_util.h",
"api/file_handlers/non_native_file_system_delegate_chromeos.cc",
"api/file_handlers/non_native_file_system_delegate_chromeos.h",
"api/file_system/file_system_api.cc",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "chrome/browser/extensions/api/developer_private/extension_info_generator.h"
#include "chrome/browser/extensions/api/developer_private/show_permissions_dialog_helper.h"
#include "chrome/browser/extensions/api/extension_action/extension_action_api.h"
#include "chrome/browser/extensions/api/file_handlers/app_file_handler_util.h"
#include "chrome/browser/extensions/devtools_util.h"
#include "chrome/browser/extensions/extension_commands_global_registry.h"
#include "chrome/browser/extensions/extension_service.h"
Expand Down Expand Up @@ -53,7 +54,6 @@
#include "content/public/browser/site_instance.h"
#include "content/public/browser/storage_partition.h"
#include "content/public/browser/web_contents.h"
#include "extensions/browser/api/file_handlers/app_file_handler_util.h"
#include "extensions/browser/app_window/app_window.h"
#include "extensions/browser/app_window/app_window_registry.h"
#include "extensions/browser/error_map.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "extensions/browser/api/file_handlers/app_file_handler_util.h"
#include "chrome/browser/extensions/api/file_handlers/app_file_handler_util.h"

#include "extensions/browser/entry_info.h"
#include "testing/gtest/include/gtest/gtest.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "extensions/browser/api/file_handlers/app_file_handler_util.h"
#include "chrome/browser/extensions/api/file_handlers/app_file_handler_util.h"

#include "base/files/file.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "build/build_config.h"
#include "content/public/browser/browser_context.h"
#include "chrome/browser/profiles/profile.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/child_process_security_policy.h"
#include "extensions/browser/api/extensions_api_client.h"
Expand Down Expand Up @@ -102,7 +102,7 @@ class WritableFileChecker
public:
WritableFileChecker(
const std::vector<base::FilePath>& paths,
content::BrowserContext* context,
Profile* profile,
const std::set<base::FilePath>& directory_paths,
const base::Closure& on_success,
const base::Callback<void(const base::FilePath&)>& on_failure);
Expand All @@ -128,22 +128,22 @@ class WritableFileChecker
void OnPrepareFileDone(const base::FilePath& path, bool success);

const std::vector<base::FilePath> paths_;
content::BrowserContext* context_;
Profile* profile_;
const std::set<base::FilePath> directory_paths_;
size_t outstanding_tasks_;
int outstanding_tasks_;
base::FilePath error_path_;
base::Closure on_success_;
base::Callback<void(const base::FilePath&)> on_failure_;
};

WritableFileChecker::WritableFileChecker(
const std::vector<base::FilePath>& paths,
content::BrowserContext* context,
Profile* profile,
const std::set<base::FilePath>& directory_paths,
const base::Closure& on_success,
const base::Callback<void(const base::FilePath&)>& on_failure)
: paths_(paths),
context_(context),
profile_(profile),
directory_paths_(directory_paths),
outstanding_tasks_(1),
on_success_(on_success),
Expand All @@ -156,14 +156,16 @@ void WritableFileChecker::Check() {
#if defined(OS_CHROMEOS)
NonNativeFileSystemDelegate* delegate =
ExtensionsAPIClient::Get()->GetNonNativeFileSystemDelegate();
if (delegate && delegate->IsUnderNonNativeLocalPath(context_, path)) {
if (delegate && delegate->IsUnderNonNativeLocalPath(profile_, path)) {
if (is_directory) {
delegate->IsNonNativeLocalPathDirectory(
context_, path,
profile_,
path,
base::Bind(&WritableFileChecker::OnPrepareFileDone, this, path));
} else {
delegate->PrepareNonNativeLocalFileForWritableApp(
context_, path,
profile_,
path,
base::Bind(&WritableFileChecker::OnPrepareFileDone, this, path));
}
continue;
Expand Down Expand Up @@ -257,7 +259,7 @@ bool FileHandlerCanHandleEntry(const FileHandlerInfo& handler,
FileHandlerCanHandleFileWithExtension(handler, entry.path);
}

GrantedFileEntry CreateFileEntry(content::BrowserContext* context,
GrantedFileEntry CreateFileEntry(Profile* profile,
const Extension* extension,
int renderer_id,
const base::FilePath& path,
Expand Down Expand Up @@ -289,12 +291,12 @@ GrantedFileEntry CreateFileEntry(content::BrowserContext* context,

void PrepareFilesForWritableApp(
const std::vector<base::FilePath>& paths,
content::BrowserContext* context,
Profile* profile,
const std::set<base::FilePath>& directory_paths,
const base::Closure& on_success,
const base::Callback<void(const base::FilePath&)>& on_failure) {
scoped_refptr<WritableFileChecker> checker(new WritableFileChecker(
paths, context, directory_paths, on_success, on_failure));
paths, profile, directory_paths, on_success, on_failure));
checker->Check();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef EXTENSIONS_BROWSER_API_FILE_HANDLERS_APP_FILE_HANDLER_UTIL_H_
#define EXTENSIONS_BROWSER_API_FILE_HANDLERS_APP_FILE_HANDLER_UTIL_H_
#ifndef CHROME_BROWSER_EXTENSIONS_API_FILE_HANDLERS_APP_FILE_HANDLER_UTIL_H_
#define CHROME_BROWSER_EXTENSIONS_API_FILE_HANDLERS_APP_FILE_HANDLER_UTIL_H_

#include <set>
#include <string>
Expand All @@ -14,18 +14,15 @@
#include "extensions/common/extension.h"
#include "extensions/common/manifest_handlers/file_handler_info.h"

namespace content {
class BrowserContext;
}
class Profile;

namespace extensions {

struct EntryInfo;
struct FileHandlerInfo;
struct GrantedFileEntry;

// TODO(michaelpg,benwells): move this to an app-specific namespace and
// directory.
// TODO(benwells): move this to platform_apps namespace.
namespace app_file_handler_util {

extern const char kInvalidParameters[];
Expand All @@ -46,7 +43,7 @@ bool FileHandlerCanHandleEntry(const FileHandlerInfo& handler,

// Creates a new file entry and allows |renderer_id| to access |path|. This
// registers a new file system for |path|.
GrantedFileEntry CreateFileEntry(content::BrowserContext* context,
GrantedFileEntry CreateFileEntry(Profile* profile,
const Extension* extension,
int renderer_id,
const base::FilePath& path,
Expand All @@ -59,7 +56,7 @@ GrantedFileEntry CreateFileEntry(content::BrowserContext* context,
// otherwise calls |on_failure|.
void PrepareFilesForWritableApp(
const std::vector<base::FilePath>& paths,
content::BrowserContext* context,
Profile* profile,
const std::set<base::FilePath>& directory_paths,
const base::Closure& on_success,
const base::Callback<void(const base::FilePath&)>& on_failure);
Expand All @@ -79,4 +76,4 @@ bool ValidateFileEntryAndGetPath(const std::string& filesystem_name,

} // namespace extensions

#endif // EXTENSIONS_BROWSER_API_FILE_HANDLERS_APP_FILE_HANDLER_UTIL_H_
#endif // CHROME_BROWSER_EXTENSIONS_API_FILE_HANDLERS_APP_FILE_HANDLER_UTIL_H_
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "extensions/browser/api/file_handlers/directory_util.h"
#include "chrome/browser/extensions/api/file_handlers/directory_util.h"

#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/threading/thread_task_runner_handle.h"
#include "content/public/browser/browser_context.h"
#include "chrome/browser/profiles/profile.h"
#include "content/public/browser/browser_thread.h"
#include "net/base/filename_util.h"
#include "storage/browser/fileapi/file_system_url.h"
Expand Down Expand Up @@ -37,14 +37,14 @@ void OnGetIsDirectoryFromFileInfoCompleted(
// The callback parameter contains the result and is required to support
// both native local directories to avoid UI thread and non native local
// path directories for the IsNonNativeLocalPathDirectory API.
void EntryIsDirectory(content::BrowserContext* context,
void EntryIsDirectory(Profile* profile,
const base::FilePath& path,
const base::Callback<void(bool)>& callback) {
#if defined(OS_CHROMEOS)
NonNativeFileSystemDelegate* delegate =
ExtensionsAPIClient::Get()->GetNonNativeFileSystemDelegate();
if (delegate && delegate->IsUnderNonNativeLocalPath(context, path)) {
delegate->IsNonNativeLocalPathDirectory(context, path, callback);
if (delegate && delegate->IsUnderNonNativeLocalPath(profile, path)) {
delegate->IsNonNativeLocalPathDirectory(profile, path, callback);
return;
}
#endif
Expand All @@ -61,8 +61,8 @@ void EntryIsDirectory(content::BrowserContext* context,

} // namespace

IsDirectoryCollector::IsDirectoryCollector(content::BrowserContext* context)
: context_(context), left_(0), weak_ptr_factory_(this) {}
IsDirectoryCollector::IsDirectoryCollector(Profile* profile)
: profile_(profile), left_(0), weak_ptr_factory_(this) {}

IsDirectoryCollector::~IsDirectoryCollector() {}

Expand All @@ -86,7 +86,7 @@ void IsDirectoryCollector::CollectForEntriesPaths(
}

for (size_t i = 0; i < paths.size(); ++i) {
EntryIsDirectory(context_, paths[i],
EntryIsDirectory(profile_, paths[i],
base::Bind(&IsDirectoryCollector::OnIsDirectoryCollected,
weak_ptr_factory_.GetWeakPtr(), i));
}
Expand Down
Loading

0 comments on commit 9790279

Please sign in to comment.