diff options
author | jamescook@chromium.org <jamescook@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-31 01:54:38 +0000 |
---|---|---|
committer | jamescook@chromium.org <jamescook@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-31 01:54:38 +0000 |
commit | e3a8ebb9866a207a123d7a5f165d35c2f7019b7d (patch) | |
tree | 590cb6c1e3af05fceeaab487c041b17e09cf4d66 | |
parent | 64304a7356d23cbbe30cc7a61d2a63cc4de90990 (diff) | |
download | chromium_src-e3a8ebb9866a207a123d7a5f165d35c2f7019b7d.zip chromium_src-e3a8ebb9866a207a123d7a5f165d35c2f7019b7d.tar.gz chromium_src-e3a8ebb9866a207a123d7a5f165d35c2f7019b7d.tar.bz2 |
Introduce apps API target in //apps and move app.runtime API into it
This breaks a dependency from //apps onto //chrome, getting us closer to
an app_shell build that does not include chrome.
* Introduce apps/browser/api and apps/common/api to mirror extensions.
* Introduce an apps_api build target.
* Hook up schema and function registration in chrome and app_shell.
* Move app_runtime_api.h/cc into //apps and switch to apps namespace.
* Eliminate AppEventRouter dependencies on Chrome:
** Use ExtensionsBrowserClient to determine if we're in kiosk mode.
** Introduce apps::file_handler_util for GrantedFileEntry (anticipating
more code from app_file_handler_util to move there in the future).
BUG=357818
TEST=browser_tests *PlatformApp*
Review URL: https://codereview.chromium.org/217533006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@260480 0039d316-1c4b-4281-b951-d872f2087c98
27 files changed, 197 insertions, 88 deletions
@@ -26,14 +26,12 @@ 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/app_runtime/app_runtime_api.h", "+chrome/browser/extensions/api/file_handlers/app_file_handler_util.h", "+chrome/browser/extensions/api/file_system/file_system_api.h", "+chrome/browser/extensions/chrome_extension_web_contents_observer.h", "+chrome/browser/extensions/extension_icon_image.h", "+chrome/browser/extensions/suggest_permission_util.h", "+chrome/browser/extensions/unpacked_installer.h", - "+chrome/common/extensions/api/app_runtime.h", "+chrome/common/extensions/api/app_window.h", "+chrome/common/extensions/manifest_handlers/icons_handler.h", ] diff --git a/apps/app_restore_service.cc b/apps/app_restore_service.cc index d3d1302..e92fd2c 100644 --- a/apps/app_restore_service.cc +++ b/apps/app_restore_service.cc @@ -7,10 +7,10 @@ #include "apps/app_lifetime_monitor_factory.h" #include "apps/app_restore_service_factory.h" #include "apps/app_window.h" +#include "apps/browser/api/app_runtime/app_runtime_api.h" #include "apps/launcher.h" #include "apps/saved_files_service.h" #include "chrome/browser/chrome_notification_types.h" -#include "chrome/browser/extensions/api/app_runtime/app_runtime_api.h" #include "chrome/browser/profiles/profile.h" #include "extensions/browser/extension_host.h" #include "extensions/browser/extension_prefs.h" diff --git a/apps/apps.gypi b/apps/apps.gypi index 9a295bf..3662fdf 100644 --- a/apps/apps.gypi +++ b/apps/apps.gypi @@ -16,6 +16,7 @@ 'dependencies': [ 'browser_extensions', 'common/extensions/api/api.gyp:chrome_api', + '../apps/common/api/api.gyp:apps_api', '../skia/skia.gyp:skia', ], 'include_dirs': [ @@ -47,6 +48,10 @@ 'apps_client.h', 'browser_context_keyed_service_factories.cc', 'browser_context_keyed_service_factories.h', + 'browser/api/app_runtime/app_runtime_api.cc', + 'browser/api/app_runtime/app_runtime_api.h', + 'browser/file_handler_util.cc', + 'browser/file_handler_util.h', 'launcher.cc', 'launcher.h', 'metrics_names.h', diff --git a/chrome/browser/extensions/api/app_runtime/app_runtime_api.cc b/apps/browser/api/app_runtime/app_runtime_api.cc index ff40876..5b52100 100644 --- a/chrome/browser/extensions/api/app_runtime/app_runtime_api.cc +++ b/apps/browser/api/app_runtime/app_runtime_api.cc @@ -1,26 +1,27 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Copyright 2014 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/extensions/api/app_runtime/app_runtime_api.h" +#include "apps/browser/api/app_runtime/app_runtime_api.h" +#include "apps/browser/file_handler_util.h" +#include "apps/common/api/app_runtime.h" #include "base/time/time.h" #include "base/values.h" -#include "chrome/browser/extensions/api/file_handlers/app_file_handler_util.h" -#include "chrome/common/extensions/api/app_runtime.h" #include "extensions/browser/event_router.h" #include "extensions/browser/extension_prefs.h" #include "extensions/browser/extension_system.h" +#include "extensions/browser/extensions_browser_client.h" #include "extensions/common/extension.h" #include "url/gurl.h" -#if defined(OS_CHROMEOS) -#include "chrome/browser/chromeos/login/user_manager.h" -#endif - using content::BrowserContext; +using extensions::Event; +using extensions::Extension; +using extensions::ExtensionPrefs; +using extensions::ExtensionSystem; -namespace extensions { +namespace apps { namespace app_runtime = api::app_runtime; @@ -29,17 +30,15 @@ namespace { void DispatchOnLaunchedEventImpl(const std::string& extension_id, scoped_ptr<base::DictionaryValue> launch_data, BrowserContext* context) { -#if defined(OS_CHROMEOS) - launch_data->SetBoolean("isKioskSession", - chromeos::UserManager::Get()->IsLoggedInAsKioskApp()); -#else - launch_data->SetBoolean("isKioskSession", false); -#endif + // "Forced app mode" is true for Chrome OS kiosk mode. + launch_data->SetBoolean( + "isKioskSession", + extensions::ExtensionsBrowserClient::Get()->IsRunningInForcedAppMode()); scoped_ptr<base::ListValue> args(new base::ListValue()); args->Append(launch_data.release()); ExtensionSystem* system = ExtensionSystem::Get(context); - scoped_ptr<Event> event(new Event(app_runtime::OnLaunched::kEventName, - args.Pass())); + scoped_ptr<Event> event( + new Event(app_runtime::OnLaunched::kEventName, args.Pass())); event->restrict_to_browser_context = context; event->can_load_ephemeral_apps = true; system->event_router()->DispatchEventWithLazyListener(extension_id, @@ -61,8 +60,8 @@ void AppEventRouter::DispatchOnLaunchedEvent(BrowserContext* context, void AppEventRouter::DispatchOnRestartedEvent(BrowserContext* context, const Extension* extension) { scoped_ptr<base::ListValue> arguments(new base::ListValue()); - scoped_ptr<Event> event(new Event(app_runtime::OnRestarted::kEventName, - arguments.Pass())); + scoped_ptr<Event> event( + new Event(app_runtime::OnRestarted::kEventName, arguments.Pass())); event->restrict_to_browser_context = context; event->can_load_ephemeral_apps = true; extensions::ExtensionSystem::Get(context) @@ -76,7 +75,7 @@ void AppEventRouter::DispatchOnLaunchedEventWithFileEntry( const Extension* extension, const std::string& handler_id, const std::string& mime_type, - const extensions::app_file_handler_util::GrantedFileEntry& file_entry) { + const file_handler_util::GrantedFileEntry& file_entry) { // TODO(sergeygs): Use the same way of creating an event (using the generated // boilerplate) as below in DispatchOnLaunchedEventWithUrl. scoped_ptr<base::DictionaryValue> launch_data(new base::DictionaryValue); @@ -107,4 +106,4 @@ void AppEventRouter::DispatchOnLaunchedEventWithUrl( extension->id(), launch_data.ToValue().Pass(), context); } -} // namespace extensions +} // namespace apps diff --git a/chrome/browser/extensions/api/app_runtime/app_runtime_api.h b/apps/browser/api/app_runtime/app_runtime_api.h index c34e0a9..829becf 100644 --- a/chrome/browser/extensions/api/app_runtime/app_runtime_api.h +++ b/apps/browser/api/app_runtime/app_runtime_api.h @@ -1,9 +1,9 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Copyright 2014 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_EXTENSIONS_API_APP_RUNTIME_APP_RUNTIME_API_H_ -#define CHROME_BROWSER_EXTENSIONS_API_APP_RUNTIME_APP_RUNTIME_API_H_ +#ifndef APPS_BROWSER_API_APP_RUNTIME_APP_RUNTIME_API_H_ +#define APPS_BROWSER_API_APP_RUNTIME_APP_RUNTIME_API_H_ #include <string> @@ -15,10 +15,12 @@ class WebContents; } namespace extensions { - class Extension; +} + +namespace apps { -namespace app_file_handler_util { +namespace file_handler_util { struct GrantedFileEntry; } @@ -26,12 +28,12 @@ class AppEventRouter { public: // Dispatches the onLaunched event to the given app. static void DispatchOnLaunchedEvent(content::BrowserContext* context, - const Extension* extension); + const extensions::Extension* extension); // Dispatches the onRestarted event to the given app, providing a list of // restored file entries from the previous run. static void DispatchOnRestartedEvent(content::BrowserContext* context, - const Extension* extension); + const extensions::Extension* extension); // TODO(benwells): Update this comment, it is out of date. // Dispatches the onLaunched event to the given app, providing launch data of @@ -50,20 +52,21 @@ class AppEventRouter { // manifest that resulted in a match which triggered this launch. static void DispatchOnLaunchedEventWithFileEntry( content::BrowserContext* context, - const Extension* extension, + const extensions::Extension* extension, const std::string& handler_id, const std::string& mime_type, - const extensions::app_file_handler_util::GrantedFileEntry& file_entry); + const file_handler_util::GrantedFileEntry& file_entry); // |handler_id| corresponds to the id of the url_handlers item // in the manifest that resulted in a match which triggered this launch. - static void DispatchOnLaunchedEventWithUrl(content::BrowserContext* context, - const Extension* extension, - const std::string& handler_id, - const GURL& url, - const GURL& referrer_url); + static void DispatchOnLaunchedEventWithUrl( + content::BrowserContext* context, + const extensions::Extension* extension, + const std::string& handler_id, + const GURL& url, + const GURL& referrer_url); }; -} // namespace extensions +} // namespace apps -#endif // CHROME_BROWSER_EXTENSIONS_API_APP_RUNTIME_APP_RUNTIME_API_H_ +#endif // APPS_BROWSER_API_APP_RUNTIME_APP_RUNTIME_API_H_ diff --git a/apps/browser/file_handler_util.cc b/apps/browser/file_handler_util.cc new file mode 100644 index 0000000..073760a --- /dev/null +++ b/apps/browser/file_handler_util.cc @@ -0,0 +1,15 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "apps/browser/file_handler_util.h" + +namespace apps { +namespace file_handler_util { + +GrantedFileEntry::GrantedFileEntry() {} + +GrantedFileEntry::~GrantedFileEntry() {} + +} // namespace file_handler_util +} // namespace apps diff --git a/apps/browser/file_handler_util.h b/apps/browser/file_handler_util.h new file mode 100644 index 0000000..1d0cfa3 --- /dev/null +++ b/apps/browser/file_handler_util.h @@ -0,0 +1,26 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef APPS_BROWSER_FILE_HANDLER_UTIL_H_ +#define APPS_BROWSER_FILE_HANDLER_UTIL_H_ + +#include <string> + +namespace apps { +namespace file_handler_util { + +// Refers to a file entry that a renderer has been given access to. +struct GrantedFileEntry { + GrantedFileEntry(); + ~GrantedFileEntry(); + + std::string id; + std::string filesystem_id; + std::string registered_name; +}; + +} // namespace file_handler_util +} // namespace apps + +#endif // APPS_BROWSER_FILE_HANDLER_UTIL_H_ diff --git a/apps/common/api/api.gyp b/apps/common/api/api.gyp new file mode 100644 index 0000000..5f1fb93 --- /dev/null +++ b/apps/common/api/api.gyp @@ -0,0 +1,36 @@ +# Copyright 2014 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +{ + 'targets': [ + { + 'target_name': 'apps_api', + 'type': 'static_library', + 'sources': [ + '<@(schema_files)', + ], + # TODO(jschuh): http://crbug.com/167187 size_t -> int + 'msvs_disabled_warnings': [ 4267 ], + 'includes': [ + '../../../build/json_schema_bundle_compile.gypi', + '../../../build/json_schema_compile.gypi', + ], + 'variables': { + 'chromium_code': 1, + 'non_compiled_schema_files': [ + ], + # TODO: Eliminate these on Android. See crbug.com/305852. + 'schema_files': [ + 'app_runtime.idl', + ], + 'cc_dir': 'apps/common/api', + 'root_namespace': 'apps::api', + 'impl_dir': 'apps/browser/api', + }, + 'dependencies': [ + # None yet, but some may need to be added as more APIs move in. + ], + }, + ], +} diff --git a/chrome/common/extensions/api/app_runtime.idl b/apps/common/api/app_runtime.idl index b1bd050..b094c98 100644 --- a/chrome/common/extensions/api/app_runtime.idl +++ b/apps/common/api/app_runtime.idl @@ -1,4 +1,4 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Copyright 2014 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/apps/common/api/dummy.idl b/apps/common/api/dummy.idl deleted file mode 100644 index ac622b5..0000000 --- a/apps/common/api/dummy.idl +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright 2014 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// TODO(jamescook): Remove this once actual APIs live here. -// This is a placeholder IDL so the docserver doesn't choke on an empty -// apps API path. -namespace dummy { -} - diff --git a/apps/launcher.cc b/apps/launcher.cc index b19d9a2..845b259 100644 --- a/apps/launcher.cc +++ b/apps/launcher.cc @@ -5,6 +5,9 @@ #include "apps/launcher.h" #include "apps/apps_client.h" +#include "apps/browser/api/app_runtime/app_runtime_api.h" +#include "apps/browser/file_handler_util.h" +#include "apps/common/api/app_runtime.h" #include "base/command_line.h" #include "base/file_util.h" #include "base/files/file_path.h" @@ -12,11 +15,9 @@ #include "base/memory/ref_counted.h" #include "base/strings/string_util.h" #include "base/strings/utf_string_conversions.h" -#include "chrome/browser/extensions/api/app_runtime/app_runtime_api.h" #include "chrome/browser/extensions/api/file_handlers/app_file_handler_util.h" #include "chrome/browser/extensions/api/file_system/file_system_api.h" #include "chrome/browser/profiles/profile.h" -#include "chrome/common/extensions/api/app_runtime.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/render_process_host.h" #include "content/public/browser/web_contents.h" @@ -44,15 +45,15 @@ #include "win8/util/win8_util.h" #endif -namespace app_runtime = extensions::api::app_runtime; +namespace app_runtime = apps::api::app_runtime; +using apps::file_handler_util::GrantedFileEntry; using content::BrowserThread; using extensions::app_file_handler_util::CheckWritableFiles; using extensions::app_file_handler_util::FileHandlerForId; using extensions::app_file_handler_util::FileHandlerCanHandleFile; using extensions::app_file_handler_util::FirstFileHandlerForFile; using extensions::app_file_handler_util::CreateFileEntry; -using extensions::app_file_handler_util::GrantedFileEntry; using extensions::app_file_handler_util::HasFileSystemWritePermission; using extensions::EventRouter; using extensions::Extension; @@ -104,7 +105,7 @@ bool GetAbsolutePathFromCommandLine(const CommandLine& command_line, // load or obtain file launch data. void LaunchPlatformAppWithNoData(Profile* profile, const Extension* extension) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - extensions::AppEventRouter::DispatchOnLaunchedEvent(profile, extension); + AppEventRouter::DispatchOnLaunchedEvent(profile, extension); } // Class to handle launching of platform apps to open a specific path. @@ -292,7 +293,7 @@ class PlatformAppPathLauncher host->render_process_host()->GetID(), file_path_, false); - extensions::AppEventRouter::DispatchOnLaunchedEventWithFileEntry( + AppEventRouter::DispatchOnLaunchedEventWithFileEntry( profile_, extension_, handler_id_, mime_type, file_entry); } @@ -384,7 +385,7 @@ void RestartPlatformApp(Profile* profile, const Extension* extension) { app_runtime::OnRestarted::kEventName); if (listening_to_restart) { - extensions::AppEventRouter::DispatchOnRestartedEvent(profile, extension); + AppEventRouter::DispatchOnRestartedEvent(profile, extension); return; } @@ -405,7 +406,7 @@ void LaunchPlatformAppWithUrl(Profile* profile, const std::string& handler_id, const GURL& url, const GURL& referrer_url) { - extensions::AppEventRouter::DispatchOnLaunchedEventWithUrl( + AppEventRouter::DispatchOnLaunchedEventWithUrl( profile, extension, handler_id, url, referrer_url); } diff --git a/apps/shell/browser/shell_extension_system.cc b/apps/shell/browser/shell_extension_system.cc index 6defb0e..ff74ae5 100644 --- a/apps/shell/browser/shell_extension_system.cc +++ b/apps/shell/browser/shell_extension_system.cc @@ -75,7 +75,7 @@ bool ShellExtensionSystem::LoadAndLaunchApp(const base::FilePath& app_dir) { content::NotificationService::NoDetails()); // This is effectively the same behavior as - // extensions::AppEventRouter::DispatchOnLaunchedEvent without any dependency + // apps::AppEventRouter::DispatchOnLaunchedEvent without any dependency // on ExtensionSystem or Profile. scoped_ptr<base::DictionaryValue> launch_data(new base::DictionaryValue()); launch_data->SetBoolean("isKioskSession", false); diff --git a/apps/shell/browser/shell_extensions_browser_client.cc b/apps/shell/browser/shell_extensions_browser_client.cc index 13321ec..76d9667 100644 --- a/apps/shell/browser/shell_extensions_browser_client.cc +++ b/apps/shell/browser/shell_extensions_browser_client.cc @@ -4,6 +4,7 @@ #include "apps/shell/browser/shell_extensions_browser_client.h" +#include "apps/common/api/generated_api.h" #include "apps/shell/browser/shell_app_sorting.h" #include "apps/shell/browser/shell_extension_system_factory.h" #include "apps/shell/browser/shell_extension_web_contents_observer.h" @@ -197,7 +198,10 @@ ShellExtensionsBrowserClient::GetExtensionSystemFactory() { void ShellExtensionsBrowserClient::RegisterExtensionFunctions( ExtensionFunctionRegistry* registry) const { + // Generated APIs from lower-level modules. extensions::core_api::GeneratedFunctionRegistry::RegisterAll(registry); + apps::api::GeneratedFunctionRegistry::RegisterAll(registry); + // TODO(rockot): Remove dependency on src/chrome once we have some core APIs // moved out. See http://crbug.com/349042. extensions::api::GeneratedFunctionRegistry::RegisterAll(registry); diff --git a/apps/shell/common/shell_extensions_client.cc b/apps/shell/common/shell_extensions_client.cc index 4172816..61d3933 100644 --- a/apps/shell/common/shell_extensions_client.cc +++ b/apps/shell/common/shell_extensions_client.cc @@ -4,6 +4,7 @@ #include "apps/shell/common/shell_extensions_client.h" +#include "apps/common/api/generated_schemas.h" #include "base/logging.h" #include "chrome/common/extensions/api/generated_schemas.h" #include "chrome/common/extensions/features/base_feature_provider.h" @@ -155,7 +156,8 @@ bool ShellExtensionsClient::IsAPISchemaGenerated( // TODO(rockot): Remove dependency on src/chrome once we have some core APIs // moved out. See http://crbug.com/349042. return extensions::api::GeneratedSchemas::IsGenerated(name) || - extensions::core_api::GeneratedSchemas::IsGenerated(name); + extensions::core_api::GeneratedSchemas::IsGenerated(name) || + apps::api::GeneratedSchemas::IsGenerated(name); } base::StringPiece ShellExtensionsClient::GetAPISchema( @@ -164,7 +166,11 @@ base::StringPiece ShellExtensionsClient::GetAPISchema( // moved out. See http://crbug.com/349042. if (extensions::api::GeneratedSchemas::IsGenerated(name)) return extensions::api::GeneratedSchemas::Get(name); - return extensions::core_api::GeneratedSchemas::Get(name); + + if (extensions::core_api::GeneratedSchemas::IsGenerated(name)) + return extensions::core_api::GeneratedSchemas::Get(name); + + return apps::api::GeneratedSchemas::Get(name); } } // namespace apps diff --git a/chrome/browser/apps/app_browsertest.cc b/chrome/browser/apps/app_browsertest.cc index 10c6636c..da15e6f 100644 --- a/chrome/browser/apps/app_browsertest.cc +++ b/chrome/browser/apps/app_browsertest.cc @@ -4,6 +4,7 @@ #include "apps/app_window.h" #include "apps/app_window_registry.h" +#include "apps/common/api/app_runtime.h" #include "apps/launcher.h" #include "apps/ui/native_app_window.h" #include "base/bind.h" @@ -29,7 +30,6 @@ #include "chrome/browser/ui/tabs/tab_strip_model.h" #include "chrome/browser/ui/webui/print_preview/print_preview_ui.h" #include "chrome/common/chrome_switches.h" -#include "chrome/common/extensions/api/app_runtime.h" #include "chrome/common/pref_names.h" #include "chrome/common/url_constants.h" #include "chrome/test/base/test_switches.h" @@ -61,9 +61,9 @@ using apps::AppWindowRegistry; using content::WebContents; using web_modal::WebContentsModalDialogManager; -namespace extensions { +namespace app_runtime = apps::api::app_runtime; -namespace app_runtime = api::app_runtime; +namespace extensions { namespace { diff --git a/chrome/browser/apps/app_launch_for_metro_restart_win.cc b/chrome/browser/apps/app_launch_for_metro_restart_win.cc index f4e8a1d..50c3ce8 100644 --- a/chrome/browser/apps/app_launch_for_metro_restart_win.cc +++ b/chrome/browser/apps/app_launch_for_metro_restart_win.cc @@ -4,6 +4,7 @@ #include "chrome/browser/apps/app_launch_for_metro_restart_win.h" +#include "apps/browser/api/app_runtime/app_runtime_api.h" #include "apps/launcher.h" #include "apps/pref_names.h" #include "base/bind.h" @@ -13,7 +14,6 @@ #include "base/prefs/pref_service.h" #include "base/time/time.h" #include "chrome/browser/browser_process.h" -#include "chrome/browser/extensions/api/app_runtime/app_runtime_api.h" #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile_manager.h" @@ -40,7 +40,7 @@ void LaunchAppWithId(Profile* profile, if (!extension) return; - extensions::AppEventRouter::DispatchOnLaunchedEvent(profile, extension); + apps::AppEventRouter::DispatchOnLaunchedEvent(profile, extension); } } // namespace diff --git a/chrome/browser/extensions/DEPS b/chrome/browser/extensions/DEPS index b4ab256..b603eef 100644 --- a/chrome/browser/extensions/DEPS +++ b/chrome/browser/extensions/DEPS @@ -16,3 +16,11 @@ include_rules = [ # For access to testing command line switches. "+ppapi/shared_impl", ] + +specific_include_rules = { + # The extensions client interface is the master arbiter of which + # API functions exist, so it needs to know about app APIs. + "chrome_extensions_browser_client\.cc": [ + "+apps/common/api/generated_api.h", + ], +} diff --git a/chrome/browser/extensions/api/file_handlers/app_file_handler_util.cc b/chrome/browser/extensions/api/file_handlers/app_file_handler_util.cc index 2cea377..d27ccac 100644 --- a/chrome/browser/extensions/api/file_handlers/app_file_handler_util.cc +++ b/chrome/browser/extensions/api/file_handlers/app_file_handler_util.cc @@ -4,6 +4,7 @@ #include "chrome/browser/extensions/api/file_handlers/app_file_handler_util.h" +#include "apps/browser/file_handler_util.h" #include "base/file_util.h" #include "base/files/file.h" #include "base/files/file_path.h" @@ -20,6 +21,8 @@ #include "chrome/browser/chromeos/drive/file_system_util.h" #endif +using apps::file_handler_util::GrantedFileEntry; + namespace extensions { namespace app_file_handler_util { @@ -348,8 +351,6 @@ void CheckWritableFiles( checker->Check(); } -GrantedFileEntry::GrantedFileEntry() {} - bool HasFileSystemWritePermission(const Extension* extension) { return extension->HasAPIPermission(APIPermission::kFileSystemWrite); } diff --git a/chrome/browser/extensions/api/file_handlers/app_file_handler_util.h b/chrome/browser/extensions/api/file_handlers/app_file_handler_util.h index 4dd7300..14bd11c 100644 --- a/chrome/browser/extensions/api/file_handlers/app_file_handler_util.h +++ b/chrome/browser/extensions/api/file_handlers/app_file_handler_util.h @@ -16,6 +16,12 @@ class Profile; +namespace apps { +namespace file_handler_util { +struct GrantedFileEntry; +} +} + namespace extensions { class ExtensionPrefs; @@ -51,18 +57,9 @@ bool FileHandlerCanHandleFile( const std::string& mime_type, const base::FilePath& path); -// Refers to a file entry that a renderer has been given access to. -struct GrantedFileEntry { - GrantedFileEntry(); - - std::string id; - std::string filesystem_id; - std::string registered_name; -}; - // Creates a new file entry and allows |renderer_id| to access |path|. This // registers a new file system for |path|. -GrantedFileEntry CreateFileEntry( +apps::file_handler_util::GrantedFileEntry CreateFileEntry( Profile* profile, const Extension* extension, int renderer_id, diff --git a/chrome/browser/extensions/api/file_system/file_system_api.cc b/chrome/browser/extensions/api/file_system/file_system_api.cc index 2e4d2e2..cff70ff 100644 --- a/chrome/browser/extensions/api/file_system/file_system_api.cc +++ b/chrome/browser/extensions/api/file_system/file_system_api.cc @@ -6,6 +6,7 @@ #include "apps/app_window.h" #include "apps/app_window_registry.h" +#include "apps/browser/file_handler_util.h" #include "apps/saved_files_service.h" #include "base/bind.h" #include "base/file_util.h" @@ -322,7 +323,7 @@ void FileSystemEntryFunction::AddEntryToResponse( const base::FilePath& path, const std::string& id_override) { DCHECK(response_); - extensions::app_file_handler_util::GrantedFileEntry file_entry = + apps::file_handler_util::GrantedFileEntry file_entry = extensions::app_file_handler_util::CreateFileEntry( GetProfile(), GetExtension(), diff --git a/chrome/browser/extensions/chrome_extensions_browser_client.cc b/chrome/browser/extensions/chrome_extensions_browser_client.cc index 88d497f..67d76bd 100644 --- a/chrome/browser/extensions/chrome_extensions_browser_client.cc +++ b/chrome/browser/extensions/chrome_extensions_browser_client.cc @@ -4,6 +4,7 @@ #include "chrome/browser/extensions/chrome_extensions_browser_client.h" +#include "apps/common/api/generated_api.h" #include "base/command_line.h" #include "base/version.h" #include "chrome/browser/app_mode/app_mode_utils.h" @@ -228,8 +229,11 @@ void ChromeExtensionsBrowserClient::RegisterExtensionFunctions( registry->RegisterFunction< extensions::chromedirectsetting::ClearDirectSettingFunction>(); - // Generated APIs. + // Generated APIs from lower-level modules. extensions::core_api::GeneratedFunctionRegistry::RegisterAll(registry); + apps::api::GeneratedFunctionRegistry::RegisterAll(registry); + + // Generated APIs from Chrome. extensions::api::GeneratedFunctionRegistry::RegisterAll(registry); #endif } diff --git a/chrome/chrome_browser_extensions.gypi b/chrome/chrome_browser_extensions.gypi index 6b36a4c..3039efc 100644 --- a/chrome/chrome_browser_extensions.gypi +++ b/chrome/chrome_browser_extensions.gypi @@ -29,6 +29,7 @@ 'safe_browsing_proto', 'sync_file_system_proto', '../third_party/re2/re2.gyp:re2', + '../apps/common/api/api.gyp:apps_api', '../components/components.gyp:onc_component', '../components/components.gyp:url_matcher', '../components/components.gyp:wifi_component', @@ -126,8 +127,6 @@ 'browser/extensions/api/alarms/alarms_api.h', 'browser/extensions/api/app_current_window_internal/app_current_window_internal_api.cc', 'browser/extensions/api/app_current_window_internal/app_current_window_internal_api.h', - 'browser/extensions/api/app_runtime/app_runtime_api.cc', - 'browser/extensions/api/app_runtime/app_runtime_api.h', 'browser/extensions/api/app_window/app_window_api.cc', 'browser/extensions/api/app_window/app_window_api.h', 'browser/extensions/api/audio/audio_api.cc', diff --git a/chrome/chrome_common.gypi b/chrome/chrome_common.gypi index de0b25a..4c2821e 100644 --- a/chrome/chrome_common.gypi +++ b/chrome/chrome_common.gypi @@ -392,7 +392,7 @@ }], ['OS != "ios"', { 'dependencies': [ - '<(DEPTH)/third_party/re2/re2.gyp:re2', + '<(DEPTH)/apps/common/api/api.gyp:apps_api', '<(DEPTH)/chrome/common/extensions/api/api.gyp:chrome_api', '<(DEPTH)/components/components.gyp:autofill_core_common', '<(DEPTH)/components/components.gyp:autofill_content_common', @@ -404,6 +404,7 @@ '<(DEPTH)/extensions/extensions.gyp:extensions_common', '<(DEPTH)/ipc/ipc.gyp:ipc', '<(DEPTH)/third_party/adobe/flash/flash_player.gyp:flapper_version_h', + '<(DEPTH)/third_party/re2/re2.gyp:re2', '<(DEPTH)/third_party/widevine/cdm/widevine_cdm.gyp:widevine_cdm_version_h', ], 'export_dependent_settings': [ diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi index 61b6c1b..d0f287b 100644 --- a/chrome/chrome_tests.gypi +++ b/chrome/chrome_tests.gypi @@ -875,6 +875,7 @@ 'test/perf/perf_test.gyp:*', 'test_support_common', 'test_support_sync_integration', + '../apps/common/api/api.gyp:apps_api', '../base/base.gyp:base', '../base/base.gyp:base_i18n', '../base/base.gyp:test_support_base', diff --git a/chrome/common/extensions/DEPS b/chrome/common/extensions/DEPS index cce9b4d..cf4620f 100644 --- a/chrome/common/extensions/DEPS +++ b/chrome/common/extensions/DEPS @@ -6,3 +6,11 @@ include_rules = [ "+ppapi/c", # For various types. "+skia", ] + +specific_include_rules = { + # The extensions client interface is the master arbiter of which + # API schemas exist, so it needs to know about app APIs. + "chrome_extensions_client\.cc": [ + "+apps/common/api/generated_schemas.h", + ], +} diff --git a/chrome/common/extensions/api/api.gyp b/chrome/common/extensions/api/api.gyp index fdfc3e7..4cb70de 100644 --- a/chrome/common/extensions/api/api.gyp +++ b/chrome/common/extensions/api/api.gyp @@ -38,7 +38,6 @@ 'activity_log_private.json', 'alarms.idl', 'app_current_window_internal.idl', - 'app_runtime.idl', 'app_window.idl', 'audio.idl', 'automation_internal.idl', @@ -133,7 +132,6 @@ # These should be eliminated. See crbug.com/305852. 'activity_log_private.json', 'alarms.idl', - 'app_runtime.idl', 'app_window.idl', 'context_menus.json', 'downloads.idl', diff --git a/chrome/common/extensions/chrome_extensions_client.cc b/chrome/common/extensions/chrome_extensions_client.cc index 5d82845..28ab995 100644 --- a/chrome/common/extensions/chrome_extensions_client.cc +++ b/chrome/common/extensions/chrome_extensions_client.cc @@ -4,6 +4,7 @@ #include "chrome/common/extensions/chrome_extensions_client.h" +#include "apps/common/api/generated_schemas.h" #include "base/command_line.h" #include "chrome/common/extensions/api/generated_schemas.h" #include "chrome/common/extensions/chrome_manifest_handlers.h" @@ -154,15 +155,22 @@ bool ChromeExtensionsClient::IsScriptableURL( bool ChromeExtensionsClient::IsAPISchemaGenerated( const std::string& name) const { + // Test from most common to least common. return extensions::api::GeneratedSchemas::IsGenerated(name) || - extensions::core_api::GeneratedSchemas::IsGenerated(name); + extensions::core_api::GeneratedSchemas::IsGenerated(name) || + apps::api::GeneratedSchemas::IsGenerated(name); } base::StringPiece ChromeExtensionsClient::GetAPISchema( const std::string& name) const { + // Test from most common to least common. if (extensions::api::GeneratedSchemas::IsGenerated(name)) return extensions::api::GeneratedSchemas::Get(name); - return extensions::core_api::GeneratedSchemas::Get(name); + + if (extensions::core_api::GeneratedSchemas::IsGenerated(name)) + return extensions::core_api::GeneratedSchemas::Get(name); + + return apps::api::GeneratedSchemas::Get(name); } // static |