diff options
author | jamescook <jamescook@chromium.org> | 2014-09-15 11:27:13 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-09-15 18:31:44 +0000 |
commit | 877e2ab661da959e844d0f0f1e71f815d32d8c77 (patch) | |
tree | 5fc270aa7330836c0e8070f2c0a642cb973438d5 /extensions/shell/renderer | |
parent | e380f604301c5cdde7d0fad496a5d46c80233afc (diff) | |
download | chromium_src-877e2ab661da959e844d0f0f1e71f815d32d8c77.zip chromium_src-877e2ab661da959e844d0f0f1e71f815d32d8c77.tar.gz chromium_src-877e2ab661da959e844d0f0f1e71f815d32d8c77.tar.bz2 |
Remove app_shell chrome.shell API and ShellAppWindow
The chrome.app.window API has been moved to src/extensions, so app_shell
no longer needs its custom chrome.shell API to open windows.
* Remove the API implementation -- mostly a manual revert of https://codereview.chromium.org/254473011/
* Remove app_shell_resources.grd since there are no more app_shell resources
* Remove athena's support for ShellAppWindow
* Fix example apps to remove the chrome.shell workaround.
No presubmit because it has a false-positive warning about the enum rename in extension_function_histogram_value.h
No try because no presubmit doesn't seem to work by itself.
BUG=413164
TEST=extensions_unittests, app_shell_unittests, app_shell_browsertests
TBR=isherman@chromium.org for deprecating an extension function histogram
NOPRESUBMIT=true
NOTRY=true
Review URL: https://codereview.chromium.org/571643003
Cr-Commit-Position: refs/heads/master@{#294852}
Diffstat (limited to 'extensions/shell/renderer')
6 files changed, 2 insertions, 230 deletions
diff --git a/extensions/shell/renderer/shell_content_renderer_client.cc b/extensions/shell/renderer/shell_content_renderer_client.cc index 254f9fe..8525983 100644 --- a/extensions/shell/renderer/shell_content_renderer_client.cc +++ b/extensions/shell/renderer/shell_content_renderer_client.cc @@ -9,10 +9,10 @@ #include "content/public/renderer/render_frame_observer_tracker.h" #include "content/public/renderer/render_thread.h" #include "extensions/common/extensions_client.h" +#include "extensions/renderer/default_dispatcher_delegate.h" #include "extensions/renderer/dispatcher.h" #include "extensions/renderer/extension_helper.h" #include "extensions/shell/common/shell_extensions_client.h" -#include "extensions/shell/renderer/shell_dispatcher_delegate.h" #include "extensions/shell/renderer/shell_extensions_renderer_client.h" #include "third_party/WebKit/public/web/WebLocalFrame.h" @@ -83,7 +83,7 @@ void ShellContentRendererClient::RenderThreadStarted() { extensions_renderer_client_.reset(new ShellExtensionsRendererClient); ExtensionsRendererClient::Set(extensions_renderer_client_.get()); - extension_dispatcher_delegate_.reset(new ShellDispatcherDelegate()); + extension_dispatcher_delegate_.reset(new DefaultDispatcherDelegate()); // Must be initialized after ExtensionsRendererClient. extension_dispatcher_.reset( diff --git a/extensions/shell/renderer/shell_custom_bindings.cc b/extensions/shell/renderer/shell_custom_bindings.cc deleted file mode 100644 index 40965ca..0000000 --- a/extensions/shell/renderer/shell_custom_bindings.cc +++ /dev/null @@ -1,57 +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. - -#include "extensions/shell/renderer/shell_custom_bindings.h" - -#include "content/public/renderer/render_thread.h" -#include "content/public/renderer/render_view.h" -#include "content/public/renderer/v8_value_converter.h" -#include "extensions/common/extension_messages.h" -#include "extensions/renderer/script_context.h" -#include "extensions/renderer/script_context_set.h" -#include "third_party/WebKit/public/web/WebFrame.h" -#include "third_party/WebKit/public/web/WebView.h" -#include "v8/include/v8.h" - -namespace extensions { - -ShellCustomBindings::ShellCustomBindings(ScriptContext* context) - : ObjectBackedNativeHandler(context) { - RouteFunction( - "GetView", - base::Bind(&ShellCustomBindings::GetView, base::Unretained(this))); -} - -void ShellCustomBindings::GetView( - const v8::FunctionCallbackInfo<v8::Value>& args) { - if (args.Length() != 1 || !args[0]->IsInt32()) - return; - - int view_id = args[0]->Int32Value(); - if (view_id == MSG_ROUTING_NONE) - return; - - content::RenderView* view = content::RenderView::FromRoutingID(view_id); - if (!view) - return; - - // Set the opener so we have a security origin set up before returning the DOM - // reference. - content::RenderView* render_view = context()->GetRenderView(); - if (!render_view) - return; - blink::WebFrame* opener = render_view->GetWebView()->mainFrame(); - blink::WebFrame* frame = view->GetWebView()->mainFrame(); - frame->setOpener(opener); - - // Resume resource requests. - content::RenderThread::Get()->Send( - new ExtensionHostMsg_ResumeRequests(view->GetRoutingID())); - - // Return the script context. - v8::Local<v8::Value> window = frame->mainWorldScriptContext()->Global(); - args.GetReturnValue().Set(window); -} - -} // namespace extensions diff --git a/extensions/shell/renderer/shell_custom_bindings.h b/extensions/shell/renderer/shell_custom_bindings.h deleted file mode 100644 index aaa4abe..0000000 --- a/extensions/shell/renderer/shell_custom_bindings.h +++ /dev/null @@ -1,25 +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. - -#ifndef EXTENSIONS_SHELL_RENDERER_SHELL_CUSTOM_BINDINGS_H_ -#define EXTENSIONS_SHELL_RENDERER_SHELL_CUSTOM_BINDINGS_H_ - -#include "extensions/renderer/object_backed_native_handler.h" - -namespace extensions { - -// Implements custom bindings for the chrome.shell API. -class ShellCustomBindings : public ObjectBackedNativeHandler { - public: - ShellCustomBindings(ScriptContext* context); - - private: - void GetView(const v8::FunctionCallbackInfo<v8::Value>& args); - - DISALLOW_COPY_AND_ASSIGN(ShellCustomBindings); -}; - -} // namespace extensions - -#endif // EXTENSIONS_SHELL_RENDERER_SHELL_CUSTOM_BINDINGS_H_ diff --git a/extensions/shell/renderer/shell_custom_bindings.js b/extensions/shell/renderer/shell_custom_bindings.js deleted file mode 100644 index 5fe9a9ae..0000000 --- a/extensions/shell/renderer/shell_custom_bindings.js +++ /dev/null @@ -1,78 +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. - -var shellNatives = requireNative('shell_natives'); -var Binding = require('binding').Binding; -var forEach = require('utils').forEach; -var renderViewObserverNatives = requireNative('renderViewObserverNatives'); - -var currentAppWindow = null; - -var shell = Binding.create('shell'); -shell.registerCustomHook(function(bindingsAPI) { - var apiFunctions = bindingsAPI.apiFunctions; - - apiFunctions.setCustomCallback('createWindow', - function(name, request, windowParams) { - var view = null; - - // When window creation fails, |windowParams| will be undefined. - if (windowParams && windowParams.viewId) { - view = shellNatives.GetView(windowParams.viewId); - } - - if (!view) { - // No route to created window. If given a callback, trigger it with an - // undefined object. - if (request.callback) { - request.callback(undefined); - delete request.callback; - } - return; - } - - // Initialize the app window in the newly created JS context - view.chrome.shell.initializeAppWindow(); - - var callback = request.callback; - if (callback) { - delete request.callback; - - var willCallback = - renderViewObserverNatives.OnDocumentElementCreated( - windowParams.viewId, - function(success) { - if (success) { - callback(view.chrome.shell.currentWindow()); - } else { - callback(undefined); - } - }); - if (!willCallback) { - callback(undefined); - } - } - }); - - apiFunctions.setHandleRequest('currentWindow', function() { - if (!currentAppWindow) { - console.error( - 'The JavaScript context calling chrome.shell.currentWindow() has' + - ' no associated AppWindow.'); - return null; - } - return currentAppWindow; - }); - - // This is an internal function, but needs to be bound into a closure - // so the correct JS context is used for global variables such as - // currentAppWindow. - apiFunctions.setHandleRequest('initializeAppWindow', function() { - var AppWindow = function() {}; - AppWindow.prototype.contentWindow = window; - currentAppWindow = new AppWindow; - }); -}); - -exports.binding = shell.generate(); diff --git a/extensions/shell/renderer/shell_dispatcher_delegate.cc b/extensions/shell/renderer/shell_dispatcher_delegate.cc deleted file mode 100644 index 0f6b04b..0000000 --- a/extensions/shell/renderer/shell_dispatcher_delegate.cc +++ /dev/null @@ -1,35 +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. - -#include "extensions/shell/renderer/shell_dispatcher_delegate.h" - -#include "extensions/renderer/module_system.h" -#include "extensions/renderer/resource_bundle_source_map.h" -#include "extensions/renderer/script_context.h" -#include "extensions/shell/renderer/shell_custom_bindings.h" -#include "grit/app_shell_resources.h" - -namespace extensions { - -ShellDispatcherDelegate::ShellDispatcherDelegate() { -} - -ShellDispatcherDelegate::~ShellDispatcherDelegate() { -} - -void ShellDispatcherDelegate::RegisterNativeHandlers( - Dispatcher* dispatcher, - ModuleSystem* module_system, - ScriptContext* context) { - module_system->RegisterNativeHandler( - "shell_natives", - scoped_ptr<NativeHandler>(new ShellCustomBindings(context))); -} - -void ShellDispatcherDelegate::PopulateSourceMap( - ResourceBundleSourceMap* source_map) { - source_map->RegisterSource("shell", IDR_SHELL_CUSTOM_BINDINGS_JS); -} - -} // namespace extensions diff --git a/extensions/shell/renderer/shell_dispatcher_delegate.h b/extensions/shell/renderer/shell_dispatcher_delegate.h deleted file mode 100644 index 5009ce7..0000000 --- a/extensions/shell/renderer/shell_dispatcher_delegate.h +++ /dev/null @@ -1,33 +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. - -#ifndef EXTENSIONS_SHELL_RENDERER_SHELL_DISPATCHER_DELEGATE_H_ -#define EXTENSIONS_SHELL_RENDERER_SHELL_DISPATCHER_DELEGATE_H_ - -#include "base/macros.h" -#include "extensions/renderer/default_dispatcher_delegate.h" - -namespace extensions { - -// app_shell's implementation of DispatcherDelegate. This inherits the behavior -// of the default delegate while augmenting its own script resources and native -// native handlers. -class ShellDispatcherDelegate : public DefaultDispatcherDelegate { - public: - ShellDispatcherDelegate(); - virtual ~ShellDispatcherDelegate(); - - // DispatcherDelegate implementation. - virtual void RegisterNativeHandlers(Dispatcher* dispatcher, - ModuleSystem* module_system, - ScriptContext* context) OVERRIDE; - virtual void PopulateSourceMap(ResourceBundleSourceMap* source_map) OVERRIDE; - - private: - DISALLOW_COPY_AND_ASSIGN(ShellDispatcherDelegate); -}; - -} // namespace extensions - -#endif // EXTENSIONS_SHELL_RENDERER_SHELL_DISPATCHER_DELEGATE_H_ |