Skip to content

Commit

Permalink
Move AppWindowContentsImpl to extensions
Browse files Browse the repository at this point in the history
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}
  • Loading branch information
hashimoto authored and Commit bot committed Sep 3, 2014
1 parent 3485d1a commit 5c34ceb
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 48 deletions.
2 changes: 0 additions & 2 deletions apps/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 0 additions & 2 deletions apps/apps.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
5 changes: 2 additions & 3 deletions chrome/browser/apps/app_browsertest_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

#include "chrome/browser/apps/app_browsertest_util.h"

#include "apps/app_window_contents.h"
#include "base/command_line.h"
#include "base/strings/stringprintf.h"
#include "chrome/browser/extensions/api/tabs/tabs_api.h"
Expand All @@ -16,6 +15,7 @@
#include "content/public/browser/notification_service.h"
#include "content/public/test/browser_test_utils.h"
#include "content/public/test/test_utils.h"
#include "extensions/browser/app_window/app_window_contents.h"
#include "extensions/browser/app_window/app_window_registry.h"
#include "extensions/browser/app_window/native_app_window.h"
#include "extensions/common/switches.h"
Expand Down Expand Up @@ -201,8 +201,7 @@ AppWindow* PlatformAppBrowserTest::CreateAppWindowFromParams(
const AppWindow::CreateParams& params) {
AppWindow* window =
new AppWindow(browser()->profile(), new ChromeAppDelegate(), extension);
window->Init(
GURL(std::string()), new apps::AppWindowContentsImpl(window), params);
window->Init(GURL(std::string()), new AppWindowContentsImpl(window), params);
return window;
}

Expand Down
5 changes: 2 additions & 3 deletions chrome/browser/extensions/api/app_window/app_window_api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

#include "chrome/browser/extensions/api/app_window/app_window_api.h"

#include "apps/app_window_contents.h"
#include "base/command_line.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
Expand All @@ -18,6 +17,7 @@
#include "content/public/browser/web_contents.h"
#include "content/public/common/url_constants.h"
#include "extensions/browser/app_window/app_window.h"
#include "extensions/browser/app_window/app_window_contents.h"
#include "extensions/browser/app_window/app_window_registry.h"
#include "extensions/browser/app_window/apps_client.h"
#include "extensions/browser/app_window/native_app_window.h"
Expand Down Expand Up @@ -280,8 +280,7 @@ bool AppWindowCreateFunction::RunAsync() {

AppWindow* app_window =
AppsClient::Get()->CreateAppWindow(browser_context(), extension());
app_window->Init(
url, new apps::AppWindowContentsImpl(app_window), create_params);
app_window->Init(url, new AppWindowContentsImpl(app_window), create_params);

if (ExtensionsBrowserClient::Get()->IsRunningInForcedAppMode())
app_window->ForcedFullscreen();
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/power/process_power_collector_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

#include "chrome/browser/power/process_power_collector.h"

#include "apps/app_window_contents.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/ui/apps/chrome_app_delegate.h"
#include "chrome/browser/ui/browser_commands.h"
Expand All @@ -17,6 +16,7 @@
#include "content/public/browser/site_instance.h"
#include "content/public/test/browser_test_utils.h"
#include "content/public/test/mock_render_process_host.h"
#include "extensions/browser/app_window/app_window_contents.h"
#include "extensions/browser/app_window/app_window_registry.h"
#include "extensions/browser/app_window/apps_client.h"
#include "extensions/browser/app_window/native_app_window.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
#include "ui/base/models/menu_model.h"

#if defined(OS_CHROMEOS)
#include "apps/app_window_contents.h"
#include "ash/test/test_session_state_delegate.h"
#include "ash/test/test_shell_delegate.h"
#include "chrome/browser/chromeos/login/users/fake_user_manager.h"
Expand All @@ -64,6 +63,7 @@
#include "chrome/test/base/testing_profile_manager.h"
#include "content/public/browser/web_contents_observer.h"
#include "content/public/test/test_utils.h"
#include "extensions/browser/app_window/app_window_contents.h"
#include "extensions/browser/app_window/app_window_registry.h"
#include "extensions/browser/app_window/native_app_window.h"
#include "ui/aura/window.h"
Expand Down Expand Up @@ -747,7 +747,7 @@ class V2App {
extensions::AppWindow::CreateParams params =
extensions::AppWindow::CreateParams();
window_->Init(GURL(std::string()),
new apps::AppWindowContentsImpl(window_), params);
new extensions::AppWindowContentsImpl(window_), params);
}

virtual ~V2App() {
Expand Down
2 changes: 2 additions & 0 deletions extensions/browser/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ source_set("browser") {
"app_window/app_web_contents_helper.h",
"app_window/app_window.cc",
"app_window/app_window.h",
"app_window/app_window_contents.cc",
"app_window/app_window_contents.h",
"app_window/app_window_geometry_cache.cc",
"app_window/app_window_geometry_cache.h",
"app_window/app_window_registry.cc",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@
// 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 "extensions/browser/app_window/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"
Expand All @@ -20,10 +18,7 @@
#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 {
namespace extensions {

AppWindowContentsImpl::AppWindowContentsImpl(AppWindow* host) : host_(host) {}

Expand All @@ -34,7 +29,7 @@ void AppWindowContentsImpl::Initialize(content::BrowserContext* context,
url_ = url;

extension_function_dispatcher_.reset(
new extensions::ExtensionFunctionDispatcher(context, this));
new ExtensionFunctionDispatcher(context, this));

web_contents_.reset(
content::WebContents::Create(content::WebContents::CreateParams(
Expand Down Expand Up @@ -66,7 +61,7 @@ void AppWindowContentsImpl::LoadContents(int32 creator_process_id) {
}

void AppWindowContentsImpl::NativeWindowChanged(
extensions::NativeAppWindow* native_app_window) {
NativeAppWindow* native_app_window) {
base::ListValue args;
base::DictionaryValue* dictionary = new base::DictionaryValue();
args.Append(dictionary);
Expand Down Expand Up @@ -112,8 +107,7 @@ bool AppWindowContentsImpl::OnMessageReceived(const IPC::Message& message) {
return handled;
}

extensions::WindowController*
AppWindowContentsImpl::GetExtensionWindowController() const {
WindowController* AppWindowContentsImpl::GetExtensionWindowController() const {
return NULL;
}

Expand All @@ -128,7 +122,7 @@ void AppWindowContentsImpl::OnRequest(
}

void AppWindowContentsImpl::UpdateDraggableRegions(
const std::vector<extensions::DraggableRegion>& regions) {
const std::vector<DraggableRegion>& regions) {
host_->UpdateDraggableRegions(regions);
}

Expand All @@ -142,4 +136,4 @@ void AppWindowContentsImpl::SuspendRenderViewHost(
rvh->GetProcess()->GetID(), rvh->GetRoutingID()));
}

} // namespace apps
} // namespace extensions
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 APPS_APP_WINDOW_CONTENTS_H_
#define APPS_APP_WINDOW_CONTENTS_H_
#ifndef EXTENSIONS_BROWSER_APP_WINDOW_APP_WINDOW_CONTENTS_H_
#define EXTENSIONS_BROWSER_APP_WINDOW_APP_WINDOW_CONTENTS_H_

#include "base/basictypes.h"
#include "base/memory/scoped_ptr.h"
Expand All @@ -18,28 +18,24 @@ class BrowserContext;
}

namespace extensions {
struct DraggableRegion;
}

namespace apps {
struct DraggableRegion;

// 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 {
class AppWindowContentsImpl : public AppWindowContents,
public content::WebContentsObserver,
public ExtensionFunctionDispatcher::Delegate {
public:
explicit AppWindowContentsImpl(extensions::AppWindow* host);
explicit AppWindowContentsImpl(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 NativeWindowChanged(NativeAppWindow* native_app_window) OVERRIDE;
virtual void NativeWindowClosed() OVERRIDE;
virtual void DispatchWindowShownForTests() const OVERRIDE;
virtual content::WebContents* GetWebContents() const OVERRIDE;
Expand All @@ -48,25 +44,22 @@ class AppWindowContentsImpl
// content::WebContentsObserver
virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;

// extensions::ExtensionFunctionDispatcher::Delegate
virtual extensions::WindowController* GetExtensionWindowController() const
OVERRIDE;
// ExtensionFunctionDispatcher::Delegate
virtual 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 UpdateDraggableRegions(const std::vector<DraggableRegion>& regions);
void SuspendRenderViewHost(content::RenderViewHost* rvh);

extensions::AppWindow* host_; // This class is owned by |host_|
AppWindow* host_; // This class is owned by |host_|
GURL url_;
scoped_ptr<content::WebContents> web_contents_;
scoped_ptr<extensions::ExtensionFunctionDispatcher>
extension_function_dispatcher_;
scoped_ptr<ExtensionFunctionDispatcher> extension_function_dispatcher_;

DISALLOW_COPY_AND_ASSIGN(AppWindowContentsImpl);
};

} // namespace apps
} // namespace extensions

#endif // APPS_APP_WINDOW_CONTENTS_H_
#endif // EXTENSIONS_BROWSER_APP_WINDOW_APP_WINDOW_CONTENTS_H_
2 changes: 2 additions & 0 deletions extensions/extensions.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,8 @@
'browser/app_window/app_web_contents_helper.h',
'browser/app_window/app_window.cc',
'browser/app_window/app_window.h',
'browser/app_window/app_window_contents.cc',
'browser/app_window/app_window_contents.h',
'browser/app_window/app_window_geometry_cache.cc',
'browser/app_window/app_window_geometry_cache.h',
'browser/app_window/app_window_registry.cc',
Expand Down

0 comments on commit 5c34ceb

Please sign in to comment.