diff options
author | hashimoto <hashimoto@chromium.org> | 2014-09-03 00:37:27 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-09-03 07:38:49 +0000 |
commit | 5c34ceb43fe742c953e76f73052e9119705a71a6 (patch) | |
tree | a0d828e7356a9bb99a3bd402ef3bcccf4d487103 /apps | |
parent | 3485d1a05e0cc3ad01d363cdfea6786d2368080b (diff) | |
download | chromium_src-5c34ceb43fe742c953e76f73052e9119705a71a6.zip chromium_src-5c34ceb43fe742c953e76f73052e9119705a71a6.tar.gz chromium_src-5c34ceb43fe742c953e76f73052e9119705a71a6.tar.bz2 |
Move AppWindowContentsImpl to extensions
Remove unneeded include from app_window_contents.cc
Move app_window_contents.{cc,h} to extensions/browser/app_window
Change the namespace from apps to extensions.
BUG=403726
TBR=derat@chromium.org for include&namespace fix
Review URL: https://codereview.chromium.org/527693002
Cr-Commit-Position: refs/heads/master@{#293094}
Diffstat (limited to 'apps')
-rw-r--r-- | apps/BUILD.gn | 2 | ||||
-rw-r--r-- | apps/app_window_contents.cc | 145 | ||||
-rw-r--r-- | apps/app_window_contents.h | 72 | ||||
-rw-r--r-- | apps/apps.gypi | 2 |
4 files changed, 0 insertions, 221 deletions
diff --git a/apps/BUILD.gn b/apps/BUILD.gn index acbfe889..6b519ab 100644 --- a/apps/BUILD.gn +++ b/apps/BUILD.gn @@ -19,8 +19,6 @@ static_library("apps") { "app_restore_service.h", "app_restore_service_factory.cc", "app_restore_service_factory.h", - "app_window_contents.cc", - "app_window_contents.h", "browser_context_keyed_service_factories.cc", "browser_context_keyed_service_factories.h", "custom_launcher_page_contents.cc", diff --git a/apps/app_window_contents.cc b/apps/app_window_contents.cc deleted file mode 100644 index 8461e24..0000000 --- a/apps/app_window_contents.cc +++ /dev/null @@ -1,145 +0,0 @@ -// Copyright 2013 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/app_window_contents.h" - -#include <string> -#include <utility> - -#include "chrome/browser/chrome_notification_types.h" -#include "chrome/common/extensions/api/app_window.h" -#include "content/public/browser/browser_context.h" -#include "content/public/browser/browser_thread.h" -#include "content/public/browser/render_process_host.h" -#include "content/public/browser/render_view_host.h" -#include "content/public/browser/resource_dispatcher_host.h" -#include "content/public/browser/site_instance.h" -#include "content/public/browser/web_contents.h" -#include "content/public/common/renderer_preferences.h" -#include "extensions/browser/app_window/native_app_window.h" -#include "extensions/common/extension_messages.h" - -namespace app_window = extensions::api::app_window; -using extensions::AppWindow; - -namespace apps { - -AppWindowContentsImpl::AppWindowContentsImpl(AppWindow* host) : host_(host) {} - -AppWindowContentsImpl::~AppWindowContentsImpl() {} - -void AppWindowContentsImpl::Initialize(content::BrowserContext* context, - const GURL& url) { - url_ = url; - - extension_function_dispatcher_.reset( - new extensions::ExtensionFunctionDispatcher(context, this)); - - web_contents_.reset( - content::WebContents::Create(content::WebContents::CreateParams( - context, content::SiteInstance::CreateForURL(context, url_)))); - - Observe(web_contents_.get()); - web_contents_->GetMutableRendererPrefs()-> - browser_handles_all_top_level_requests = true; - web_contents_->GetRenderViewHost()->SyncRendererPrefs(); -} - -void AppWindowContentsImpl::LoadContents(int32 creator_process_id) { - // If the new view is in the same process as the creator, block the created - // RVH from loading anything until the background page has had a chance to - // do any initialization it wants. If it's a different process, the new RVH - // shouldn't communicate with the background page anyway (e.g. sandboxed). - if (web_contents_->GetRenderViewHost()->GetProcess()->GetID() == - creator_process_id) { - SuspendRenderViewHost(web_contents_->GetRenderViewHost()); - } else { - VLOG(1) << "AppWindow created in new process (" - << web_contents_->GetRenderViewHost()->GetProcess()->GetID() - << ") != creator (" << creator_process_id << "). Routing disabled."; - } - - web_contents_->GetController().LoadURL( - url_, content::Referrer(), content::PAGE_TRANSITION_LINK, - std::string()); -} - -void AppWindowContentsImpl::NativeWindowChanged( - extensions::NativeAppWindow* native_app_window) { - base::ListValue args; - base::DictionaryValue* dictionary = new base::DictionaryValue(); - args.Append(dictionary); - host_->GetSerializedState(dictionary); - - content::RenderViewHost* rvh = web_contents_->GetRenderViewHost(); - rvh->Send(new ExtensionMsg_MessageInvoke(rvh->GetRoutingID(), - host_->extension_id(), - "app.window", - "updateAppWindowProperties", - args, - false)); -} - -void AppWindowContentsImpl::NativeWindowClosed() { - content::RenderViewHost* rvh = web_contents_->GetRenderViewHost(); - rvh->Send(new ExtensionMsg_AppWindowClosed(rvh->GetRoutingID())); -} - -void AppWindowContentsImpl::DispatchWindowShownForTests() const { - base::ListValue args; - content::RenderViewHost* rvh = web_contents_->GetRenderViewHost(); - rvh->Send(new ExtensionMsg_MessageInvoke(rvh->GetRoutingID(), - host_->extension_id(), - "app.window", - "appWindowShownForTests", - args, - false)); -} - -content::WebContents* AppWindowContentsImpl::GetWebContents() const { - return web_contents_.get(); -} - -bool AppWindowContentsImpl::OnMessageReceived(const IPC::Message& message) { - bool handled = true; - IPC_BEGIN_MESSAGE_MAP(AppWindowContentsImpl, message) - IPC_MESSAGE_HANDLER(ExtensionHostMsg_Request, OnRequest) - IPC_MESSAGE_HANDLER(ExtensionHostMsg_UpdateDraggableRegions, - UpdateDraggableRegions) - IPC_MESSAGE_UNHANDLED(handled = false) - IPC_END_MESSAGE_MAP() - return handled; -} - -extensions::WindowController* -AppWindowContentsImpl::GetExtensionWindowController() const { - return NULL; -} - -content::WebContents* AppWindowContentsImpl::GetAssociatedWebContents() const { - return web_contents_.get(); -} - -void AppWindowContentsImpl::OnRequest( - const ExtensionHostMsg_Request_Params& params) { - extension_function_dispatcher_->Dispatch( - params, web_contents_->GetRenderViewHost()); -} - -void AppWindowContentsImpl::UpdateDraggableRegions( - const std::vector<extensions::DraggableRegion>& regions) { - host_->UpdateDraggableRegions(regions); -} - -void AppWindowContentsImpl::SuspendRenderViewHost( - content::RenderViewHost* rvh) { - DCHECK(rvh); - content::BrowserThread::PostTask( - content::BrowserThread::IO, FROM_HERE, - base::Bind(&content::ResourceDispatcherHost::BlockRequestsForRoute, - base::Unretained(content::ResourceDispatcherHost::Get()), - rvh->GetProcess()->GetID(), rvh->GetRoutingID())); -} - -} // namespace apps diff --git a/apps/app_window_contents.h b/apps/app_window_contents.h deleted file mode 100644 index fb3534e..0000000 --- a/apps/app_window_contents.h +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright 2013 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_APP_WINDOW_CONTENTS_H_ -#define APPS_APP_WINDOW_CONTENTS_H_ - -#include "base/basictypes.h" -#include "base/memory/scoped_ptr.h" -#include "content/public/browser/notification_observer.h" -#include "content/public/browser/web_contents_observer.h" -#include "extensions/browser/app_window/app_window.h" -#include "extensions/browser/extension_function_dispatcher.h" -#include "url/gurl.h" - -namespace content { -class BrowserContext; -} - -namespace extensions { -struct DraggableRegion; -} - -namespace apps { - -// AppWindowContents class specific to app windows. It maintains a -// WebContents instance and observes it for the purpose of passing -// messages to the extensions system. -class AppWindowContentsImpl - : public extensions::AppWindowContents, - public content::WebContentsObserver, - public extensions::ExtensionFunctionDispatcher::Delegate { - public: - explicit AppWindowContentsImpl(extensions::AppWindow* host); - virtual ~AppWindowContentsImpl(); - - // AppWindowContents - virtual void Initialize(content::BrowserContext* context, - const GURL& url) OVERRIDE; - virtual void LoadContents(int32 creator_process_id) OVERRIDE; - virtual void NativeWindowChanged( - extensions::NativeAppWindow* native_app_window) OVERRIDE; - virtual void NativeWindowClosed() OVERRIDE; - virtual void DispatchWindowShownForTests() const OVERRIDE; - virtual content::WebContents* GetWebContents() const OVERRIDE; - - private: - // content::WebContentsObserver - virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; - - // extensions::ExtensionFunctionDispatcher::Delegate - virtual extensions::WindowController* GetExtensionWindowController() const - OVERRIDE; - virtual content::WebContents* GetAssociatedWebContents() const OVERRIDE; - - void OnRequest(const ExtensionHostMsg_Request_Params& params); - void UpdateDraggableRegions( - const std::vector<extensions::DraggableRegion>& regions); - void SuspendRenderViewHost(content::RenderViewHost* rvh); - - extensions::AppWindow* host_; // This class is owned by |host_| - GURL url_; - scoped_ptr<content::WebContents> web_contents_; - scoped_ptr<extensions::ExtensionFunctionDispatcher> - extension_function_dispatcher_; - - DISALLOW_COPY_AND_ASSIGN(AppWindowContentsImpl); -}; - -} // namespace apps - -#endif // APPS_APP_WINDOW_CONTENTS_H_ diff --git a/apps/apps.gypi b/apps/apps.gypi index ddf0c99..2268184 100644 --- a/apps/apps.gypi +++ b/apps/apps.gypi @@ -38,8 +38,6 @@ 'app_restore_service.h', 'app_restore_service_factory.cc', 'app_restore_service_factory.h', - 'app_window_contents.cc', - 'app_window_contents.h', 'browser_context_keyed_service_factories.cc', 'browser_context_keyed_service_factories.h', 'custom_launcher_page_contents.cc', |