Skip to content

Commit

Permalink
Move app.window API implementation to extensions
Browse files Browse the repository at this point in the history
Move files:
-Move chrome/browser/extensions/api/app_window/* to extensions/browser.
-Move app_window.idl, app_window_custom_bindings.{cc,h}, app_window_custom_bindings.js to extensions.
-Move window_controls.js and window_controls_template.html to extensions.

Move switches and code:
- Move kEnableAppWindowControls switch to extensions/common/switches.h.
- Move dummy WebContentsModalDialogManager::CreateNativeWebModalManager implementation from athena's web_contents_view_delegate_factory_impl.cc to a new file shell_web_contents_modal_dialog_manager.cc.

Fix dispatchers:
- Move code from chrome_extensions_dispatcher_delegate.cc to extensions/renderer/dispatcher.cc

BUG=387288

Review URL: https://codereview.chromium.org/534163002

Cr-Commit-Position: refs/heads/master@{#293409}
  • Loading branch information
hashimoto authored and Commit bot committed Sep 5, 2014
1 parent 8114597 commit f784afd
Show file tree
Hide file tree
Showing 35 changed files with 81 additions and 71 deletions.
1 change: 0 additions & 1 deletion apps/DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ include_rules = [
"+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",
"+chrome/common/extensions/api/app_window.h",
]

specific_include_rules = {
Expand Down
13 changes: 0 additions & 13 deletions athena/content/web_contents_view_delegate_factory_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -140,16 +140,3 @@ content::WebContentsViewDelegate* CreateWebContentsViewDelegate(
}

} // namespace athena

namespace web_modal {

SingleWebContentsDialogManager*
WebContentsModalDialogManager::CreateNativeWebModalManager(
NativeWebContentsModalDialog dialog,
SingleWebContentsDialogManagerDelegate* native_delegate) {
// TODO(oshima): Investigate if we need to implement this.
NOTREACHED();
return NULL;
}

} // namespace web_modal
2 changes: 1 addition & 1 deletion chrome/browser/about_flags.cc
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,7 @@ const Experiment kExperiments[] = {
IDS_FLAGS_ENABLE_APP_WINDOW_CONTROLS_NAME,
IDS_FLAGS_ENABLE_APP_WINDOW_CONTROLS_DESCRIPTION,
kOsDesktop,
SINGLE_VALUE_TYPE(switches::kEnableAppWindowControls)
SINGLE_VALUE_TYPE(extensions::switches::kEnableAppWindowControls)
},
{
"disable-hyperlink-auditing",
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/apps/window_controls_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
#include "chrome/browser/apps/app_browsertest_util.h"
#include "chrome/browser/extensions/extension_test_message_listener.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/chrome_switches.h"
#include "content/public/test/browser_test_utils.h"
#include "extensions/browser/process_manager.h"
#include "extensions/common/switches.h"

class WindowControlsTest : public extensions::PlatformAppBrowserTest {
protected:
virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
extensions::PlatformAppBrowserTest::SetUpCommandLine(command_line);
command_line->AppendSwitch(switches::kEnableAppWindowControls);
command_line->AppendSwitch(extensions::switches::kEnableAppWindowControls);
}
content::WebContents* GetWebContentsForExtensionWindow(
const extensions::Extension* extension);
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/chrome_content_browser_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1331,6 +1331,7 @@ void ChromeContentBrowserClient::AppendExtraCommandLineSwitches(
extensions::switches::kAllowHTTPBackgroundPage,
extensions::switches::kAllowLegacyExtensionManifests,
extensions::switches::kEnableAppView,
extensions::switches::kEnableAppWindowControls,
extensions::switches::kEnableEmbeddedExtensionOptions,
extensions::switches::kEnableExperimentalExtensionApis,
extensions::switches::kEnableScriptsRequireAction,
Expand All @@ -1341,7 +1342,6 @@ void ChromeContentBrowserClient::AppendExtraCommandLineSwitches(
switches::kCloudPrintURL,
switches::kCloudPrintXmppEndpoint,
switches::kDisableBundledPpapiFlash,
switches::kEnableAppWindowControls,
switches::kEnableBenchmarking,
switches::kEnableNaCl,
#if !defined(DISABLE_NACL)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include "base/command_line.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/extensions/api/app_current_window_internal.h"
#include "chrome/common/extensions/api/app_window.h"
#include "chrome/common/extensions/features/feature_channel.h"
#include "extensions/browser/app_window/app_window.h"
#include "extensions/browser/app_window/app_window_registry.h"
Expand Down
2 changes: 0 additions & 2 deletions chrome/chrome_browser_extensions.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,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_window/app_window_api.cc',
'browser/extensions/api/app_window/app_window_api.h',
'browser/extensions/api/audio/audio_api.cc',
'browser/extensions/api/audio/audio_api.h',
'browser/extensions/api/audio/audio_service.h',
Expand Down
3 changes: 0 additions & 3 deletions chrome/chrome_renderer.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,6 @@
'chrome_renderer_extensions_sources': [
'renderer/extensions/app_bindings.cc',
'renderer/extensions/app_bindings.h',
'renderer/extensions/app_window_custom_bindings.cc',
'renderer/extensions/app_window_custom_bindings.h',
'renderer/extensions/automation_internal_custom_bindings.cc',
'renderer/extensions/automation_internal_custom_bindings.h',
'renderer/extensions/chrome_v8_extension_handler.cc',
Expand All @@ -149,7 +147,6 @@
'renderer/extensions/webstore_bindings.h',
'renderer/resources/extensions/app_custom_bindings.js',
'renderer/resources/extensions/app_view.js',
'renderer/resources/extensions/app_window_custom_bindings.js',
'renderer/resources/extensions/automation_custom_bindings.js',
'renderer/resources/extensions/browser_action_custom_bindings.js',
'renderer/resources/extensions/chrome_direct_setting.js',
Expand Down
2 changes: 1 addition & 1 deletion chrome/chrome_tests.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -879,6 +879,7 @@
'../components/autofill/content/renderer/test_password_generation_agent.h',
'../components/autofill/content/renderer/test_password_generation_agent.cc',
# TODO(rockot): Remove this once extensions_browsertests exists.
'../extensions/browser/api/app_window/app_window_apitest.cc',
'../extensions/browser/api/bluetooth/bluetooth_apitest.cc',
'../extensions/browser/api/bluetooth/bluetooth_private_apitest.cc',
'../extensions/browser/api/bluetooth_low_energy/bluetooth_low_energy_apitest.cc',
Expand Down Expand Up @@ -1075,7 +1076,6 @@
'browser/extensions/alert_apitest.cc',
'browser/extensions/all_urls_apitest.cc',
'browser/extensions/api/activity_log_private/activity_log_private_apitest.cc',
'browser/extensions/api/app_window/app_window_apitest.cc',
'browser/extensions/api/audio/audio_apitest.cc',
'browser/extensions/api/automation/automation_apitest.cc',
'browser/extensions/api/autotest_private/autotest_private_apitest.cc',
Expand Down
3 changes: 0 additions & 3 deletions chrome/common/chrome_switches.cc
Original file line number Diff line number Diff line change
Expand Up @@ -399,9 +399,6 @@ extern const char kEasyUnlockAppPath[] = "easy-unlock-app-path";
// If set, the app list will be enabled as if enabled from CWS.
const char kEnableAppList[] = "enable-app-list";

// Enables the <window-controls> tag in platform apps.
const char kEnableAppWindowControls[] = "enable-app-window-controls";

// Enable OS integration for Chrome app file associations.
const char kEnableAppsFileAssociations[] = "enable-apps-file-associations";

Expand Down
1 change: 0 additions & 1 deletion chrome/common/chrome_switches.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ extern const char kDnsPrefetchDisable[];
extern const char kDumpBrowserHistograms[];
extern const char kEasyUnlockAppPath[];
extern const char kEnableAppList[];
extern const char kEnableAppWindowControls[];
extern const char kEnableAppsFileAssociations[];
extern const char kEnableAsyncDns[];
extern const char kEnableAuthNegotiatePort[];
Expand Down
1 change: 0 additions & 1 deletion chrome/common/extensions/api/schemas.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
'activity_log_private.json',
'alarms.idl',
'app_current_window_internal.idl',
'app_window.idl',
'audio.idl',
'automation.idl',
'automation_internal.idl',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#include "chrome/common/url_constants.h"
#include "chrome/grit/renderer_resources.h"
#include "chrome/renderer/extensions/app_bindings.h"
#include "chrome/renderer/extensions/app_window_custom_bindings.h"
#include "chrome/renderer/extensions/automation_internal_custom_bindings.h"
#include "chrome/renderer/extensions/chrome_v8_context.h"
#include "chrome/renderer/extensions/enterprise_platform_keys_natives.h"
Expand Down Expand Up @@ -97,10 +96,6 @@ void ChromeExtensionsDispatcherDelegate::RegisterNativeHandlers(
"app",
scoped_ptr<NativeHandler>(
new extensions::AppBindings(dispatcher, context)));
module_system->RegisterNativeHandler(
"app_window_natives",
scoped_ptr<NativeHandler>(
new extensions::AppWindowCustomBindings(dispatcher, context)));
module_system->RegisterNativeHandler(
"sync_file_system",
scoped_ptr<NativeHandler>(
Expand Down Expand Up @@ -151,7 +146,6 @@ void ChromeExtensionsDispatcherDelegate::PopulateSourceMap(
extensions::ResourceBundleSourceMap* source_map) {
// Custom bindings.
source_map->RegisterSource("app", IDR_APP_CUSTOM_BINDINGS_JS);
source_map->RegisterSource("app.window", IDR_APP_WINDOW_CUSTOM_BINDINGS_JS);
source_map->RegisterSource("automation", IDR_AUTOMATION_CUSTOM_BINDINGS_JS);
source_map->RegisterSource("automationEvent", IDR_AUTOMATION_EVENT_JS);
source_map->RegisterSource("automationNode", IDR_AUTOMATION_NODE_JS);
Expand Down Expand Up @@ -224,7 +218,6 @@ void ChromeExtensionsDispatcherDelegate::PopulateSourceMap(
IDR_CAST_STREAMING_UDP_TRANSPORT_CUSTOM_BINDINGS_JS);
#endif
source_map->RegisterSource("webstore", IDR_WEBSTORE_CUSTOM_BINDINGS_JS);
source_map->RegisterSource("windowControls", IDR_WINDOW_CONTROLS_JS);

// Custom types sources.
source_map->RegisterSource("ChromeSetting", IDR_CHROME_SETTING_JS);
Expand Down Expand Up @@ -268,7 +261,7 @@ void ChromeExtensionsDispatcherDelegate::RequireAdditionalModules(
is_within_platform_app &&
extensions::GetCurrentChannel() <= chrome::VersionInfo::CHANNEL_DEV &&
CommandLine::ForCurrentProcess()->HasSwitch(
::switches::kEnableAppWindowControls)) {
extensions::switches::kEnableAppWindowControls)) {
module_system->Require("windowControls");
}

Expand Down
3 changes: 0 additions & 3 deletions chrome/renderer/resources/renderer_resources.grd
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
<include name="IDR_APP_CUSTOM_BINDINGS_JS" file="extensions\app_custom_bindings.js" type="BINDATA" />
<include name="IDR_APP_VIEW_DENY_JS" file="extensions\app_view_deny.js" type="BINDATA" />
<include name="IDR_APP_VIEW_JS" file="extensions\app_view.js" type="BINDATA" />
<include name="IDR_APP_WINDOW_CUSTOM_BINDINGS_JS" file="extensions\app_window_custom_bindings.js" type="BINDATA" />
<include name="IDR_AUTOMATION_CUSTOM_BINDINGS_JS" file="extensions\automation_custom_bindings.js" type="BINDATA" />
<include name="IDR_AUTOMATION_EVENT_JS" file="extensions\automation\automation_event.js" type="BINDATA" />
<include name="IDR_AUTOMATION_NODE_JS" file="extensions\automation\automation_node.js" type="BINDATA" />
Expand Down Expand Up @@ -82,8 +81,6 @@
<include name="IDR_TAG_WATCHER_JS" file="extensions\tag_watcher.js" type="BINDATA" />
<include name="IDR_TTS_CUSTOM_BINDINGS_JS" file="extensions\tts_custom_bindings.js" type="BINDATA" />
<include name="IDR_TTS_ENGINE_CUSTOM_BINDINGS_JS" file="extensions\tts_engine_custom_bindings.js" type="BINDATA" />
<include name="IDR_WINDOW_CONTROLS_JS" file="extensions\window_controls.js" type="BINDATA" />
<include name="IDR_WINDOW_CONTROLS_TEMPLATE_HTML" file="extensions\window_controls_template.html" type="BINDATA" />
<include name="IDR_WEB_REQUEST_CUSTOM_BINDINGS_JS" file="extensions\web_request_custom_bindings.js" type="BINDATA" />
<include name="IDR_WEB_REQUEST_INTERNAL_CUSTOM_BINDINGS_JS" file="extensions\web_request_internal_custom_bindings.js" type="BINDATA" />
<include name="IDR_WEBSTORE_CUSTOM_BINDINGS_JS" file="extensions\webstore_custom_bindings.js" type="BINDATA" />
Expand Down
2 changes: 2 additions & 0 deletions extensions/browser/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ source_set("browser") {
"api/app_runtime/app_runtime_api.h",
"api/app_view/app_view_internal_api.cc",
"api/app_view/app_view_internal_api.h",
"api/app_window/app_window_api.cc",
"api/app_window/app_window_api.h",
"api/guest_view/guest_view_internal_api.cc",
"api/guest_view/guest_view_internal_api.h",
"api/async_api_function.cc",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
benwells@chromium.org
scheib@chromium.org
jackhou@chromium.org
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@
// 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_window/app_window_api.h"
#include "extensions/browser/api/app_window/app_window_api.h"

#include "base/command_line.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/time/time.h"
#include "base/values.h"
#include "chrome/common/extensions/api/app_window.h"
#include "content/public/browser/notification_registrar.h"
#include "content/public/browser/notification_types.h"
#include "content/public/browser/render_process_host.h"
Expand All @@ -23,6 +22,7 @@
#include "extensions/browser/app_window/native_app_window.h"
#include "extensions/browser/extensions_browser_client.h"
#include "extensions/browser/image_util.h"
#include "extensions/common/api/app_window.h"
#include "extensions/common/features/simple_feature.h"
#include "extensions/common/permissions/permissions_data.h"
#include "extensions/common/switches.h"
Expand All @@ -31,7 +31,7 @@
#include "ui/gfx/rect.h"
#include "url/gurl.h"

namespace app_window = extensions::api::app_window;
namespace app_window = extensions::core_api::app_window;
namespace Create = app_window::Create;

namespace extensions {
Expand Down Expand Up @@ -83,9 +83,8 @@ bool CheckBoundsConflict(const scoped_ptr<int>& inner_property,

// Copy over the bounds specification properties from the API to the
// AppWindow::CreateParams.
void CopyBoundsSpec(
const extensions::api::app_window::BoundsSpecification* input_spec,
AppWindow::BoundsSpecification* create_spec) {
void CopyBoundsSpec(const app_window::BoundsSpecification* input_spec,
AppWindow::BoundsSpecification* create_spec) {
if (!input_spec)
return;

Expand Down Expand Up @@ -195,7 +194,7 @@ bool AppWindowCreateFunction::RunAsync() {

if (!AppsClient::Get()->IsCurrentChannelOlderThanDev() ||
extension()->location() == extensions::Manifest::COMPONENT) {
if (options->type == extensions::api::app_window::WINDOW_TYPE_PANEL) {
if (options->type == app_window::WINDOW_TYPE_PANEL) {
create_params.window_type = AppWindow::WINDOW_TYPE_PANEL;
}
}
Expand Down Expand Up @@ -257,18 +256,18 @@ bool AppWindowCreateFunction::RunAsync() {
if (options->focused.get())
create_params.focused = *options->focused.get();

if (options->type != extensions::api::app_window::WINDOW_TYPE_PANEL) {
if (options->type != app_window::WINDOW_TYPE_PANEL) {
switch (options->state) {
case extensions::api::app_window::STATE_NONE:
case extensions::api::app_window::STATE_NORMAL:
case app_window::STATE_NONE:
case app_window::STATE_NORMAL:
break;
case extensions::api::app_window::STATE_FULLSCREEN:
case app_window::STATE_FULLSCREEN:
create_params.state = ui::SHOW_STATE_FULLSCREEN;
break;
case extensions::api::app_window::STATE_MAXIMIZED:
case app_window::STATE_MAXIMIZED:
create_params.state = ui::SHOW_STATE_MAXIMIZED;
break;
case extensions::api::app_window::STATE_MINIMIZED:
case app_window::STATE_MINIMIZED:
create_params.state = ui::SHOW_STATE_MINIMIZED;
break;
}
Expand Down Expand Up @@ -314,7 +313,7 @@ bool AppWindowCreateFunction::RunAsync() {
}

bool AppWindowCreateFunction::GetBoundsSpec(
const extensions::api::app_window::CreateWindowOptions& options,
const app_window::CreateWindowOptions& options,
AppWindow::CreateParams* params,
std::string* error) {
DCHECK(params);
Expand All @@ -325,9 +324,9 @@ bool AppWindowCreateFunction::GetBoundsSpec(
// new API, the deprecated fields will be ignored - do not attempt to merge
// them.

const extensions::api::app_window::BoundsSpecification* inner_bounds =
const app_window::BoundsSpecification* inner_bounds =
options.inner_bounds.get();
const extensions::api::app_window::BoundsSpecification* outer_bounds =
const app_window::BoundsSpecification* outer_bounds =
options.outer_bounds.get();
if (inner_bounds && outer_bounds) {
if (!CheckBoundsConflict(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
// 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_WINDOW_APP_WINDOW_API_H_
#define CHROME_BROWSER_EXTENSIONS_API_APP_WINDOW_APP_WINDOW_API_H_
#ifndef EXTENSIONS_BROWSER_API_APP_WINDOW_APP_WINDOW_API_H_
#define EXTENSIONS_BROWSER_API_APP_WINDOW_APP_WINDOW_API_H_

#include "extensions/browser/app_window/app_window.h"
#include "extensions/browser/extension_function.h"

namespace extensions {

namespace api {
namespace core_api {
namespace app_window {
struct CreateWindowOptions;
}
Expand All @@ -27,13 +27,13 @@ class AppWindowCreateFunction : public AsyncExtensionFunction {

private:
bool GetBoundsSpec(
const extensions::api::app_window::CreateWindowOptions& options,
const extensions::core_api::app_window::CreateWindowOptions& options,
AppWindow::CreateParams* params,
std::string* error);

AppWindow::Frame GetFrameFromString(const std::string& frame_string);
bool GetFrameOptions(
const extensions::api::app_window::CreateWindowOptions& options,
const extensions::core_api::app_window::CreateWindowOptions& options,
AppWindow::CreateParams* create_params);
void UpdateFrameOptionsForChannel(AppWindow::CreateParams* create_params);

Expand All @@ -42,4 +42,4 @@ class AppWindowCreateFunction : public AsyncExtensionFunction {

} // namespace extensions

#endif // CHROME_BROWSER_EXTENSIONS_API_APP_WINDOW_APP_WINDOW_API_H_
#endif // EXTENSIONS_BROWSER_API_APP_WINDOW_APP_WINDOW_API_H_
File renamed without changes.
1 change: 1 addition & 0 deletions extensions/common/api/schemas.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
'main_schema_files': [
'app_runtime.idl',
'app_view_internal.json',
'app_window.idl',
'bluetooth.idl',
'bluetooth_low_energy.idl',
'bluetooth_private.json',
Expand Down
5 changes: 4 additions & 1 deletion extensions/common/switches.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,15 @@ const char kEmbeddedExtensionOptions[] = "embedded-extension-options";
// Show apps windows after the first paint. Windows will be shown significantly
// later for heavy apps loading resources synchronously but it will be
// insignificant for apps that load most of their resources asynchronously.
const char kEnableAppsShowOnFirstPaint[] = "enable-apps-show-on-first-paint";
const char kEnableAppsShowOnFirstPaint[] = "enable-apps-show-on-first-paint";

// Hack so that feature switch can work with about_flags. See
// kEnableScriptsRequireAction.
const char kEnableAppView[] = "enable-app-view";

// Enables the <window-controls> tag in platform apps.
const char kEnableAppWindowControls[] = "enable-app-window-controls";

// Hack so that feature switch can work with about_flags. See
// kEnableScriptsRequireAction.
const char kEnableEmbeddedExtensionOptions[] =
Expand Down
1 change: 1 addition & 0 deletions extensions/common/switches.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ extern const char kAppView[];
extern const char kEmbeddedExtensionOptions[];
extern const char kEnableAppsShowOnFirstPaint[];
extern const char kEnableAppView[];
extern const char kEnableAppWindowControls[];
extern const char kEnableEmbeddedExtensionOptions[];
extern const char kEnableExperimentalExtensionApis[];
extern const char kEnableExtensionActionRedesign[];
Expand Down
Loading

0 comments on commit f784afd

Please sign in to comment.