Skip to content

Commit

Permalink
Move AppWindow to extensions
Browse files Browse the repository at this point in the history
Move AppWindow, AppWindowRegistry and AppsClient from apps/ to extensions/browser/app_window
Change the namespace from apps to extensions.
Fix GYP and DEPS.

BUG=403726
TBR=sky@chromium.org for include and namespace changes

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

Cr-Commit-Position: refs/heads/master@{#292599}
  • Loading branch information
hashimoto authored and Commit bot committed Aug 29, 2014
1 parent fe5226e commit ad3c687
Show file tree
Hide file tree
Showing 117 changed files with 655 additions and 689 deletions.
6 changes: 0 additions & 6 deletions apps/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,8 @@ static_library("apps") {
"app_restore_service.h",
"app_restore_service_factory.cc",
"app_restore_service_factory.h",
"app_window.cc",
"app_window.h",
"app_window_contents.cc",
"app_window_contents.h",
"app_window_registry.cc",
"app_window_registry.h",
"browser_context_keyed_service_factories.cc",
"browser_context_keyed_service_factories.h",
"custom_launcher_page_contents.cc",
Expand All @@ -38,8 +34,6 @@ static_library("apps") {
"saved_files_service_factory.h",
"switches.cc",
"switches.h",
"ui/apps_client.cc",
"ui/apps_client.h",
]

configs += [ "//build/config/compiler:wexit_time_destructors" ]
Expand Down
4 changes: 3 additions & 1 deletion apps/app_lifetime_monitor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,19 @@

#include "apps/app_lifetime_monitor.h"

#include "apps/app_window.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/profiles/profile.h"
#include "content/public/browser/notification_details.h"
#include "content/public/browser/notification_service.h"
#include "extensions/browser/app_window/app_window.h"
#include "extensions/browser/extension_host.h"
#include "extensions/browser/notification_types.h"
#include "extensions/common/extension.h"

namespace apps {

using extensions::AppWindow;
using extensions::AppWindowRegistry;
using extensions::Extension;
using extensions::ExtensionHost;

Expand Down
14 changes: 7 additions & 7 deletions apps/app_lifetime_monitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
#include <string>
#include <vector>

#include "apps/app_window_registry.h"
#include "base/observer_list.h"
#include "components/keyed_service/core/keyed_service.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
#include "extensions/browser/app_window/app_window_registry.h"

namespace extensions {
class Extension;
Expand All @@ -26,7 +26,7 @@ namespace apps {
// events.
class AppLifetimeMonitor : public KeyedService,
public content::NotificationObserver,
public AppWindowRegistry::Observer {
public extensions::AppWindowRegistry::Observer {
public:
class Observer {
public:
Expand Down Expand Up @@ -60,15 +60,15 @@ class AppLifetimeMonitor : public KeyedService,
const content::NotificationSource& source,
const content::NotificationDetails& details) OVERRIDE;

// AppWindowRegistry::Observer overrides:
virtual void OnAppWindowRemoved(AppWindow* app_window) OVERRIDE;
virtual void OnAppWindowHidden(apps::AppWindow* app_window) OVERRIDE;
virtual void OnAppWindowShown(apps::AppWindow* app_window) OVERRIDE;
// extensions::AppWindowRegistry::Observer overrides:
virtual void OnAppWindowRemoved(extensions::AppWindow* app_window) OVERRIDE;
virtual void OnAppWindowHidden(extensions::AppWindow* app_window) OVERRIDE;
virtual void OnAppWindowShown(extensions::AppWindow* app_window) OVERRIDE;

// KeyedService overrides:
virtual void Shutdown() OVERRIDE;

bool HasVisibleAppWindows(apps::AppWindow* app_window) const;
bool HasVisibleAppWindows(extensions::AppWindow* app_window) const;

void NotifyAppStart(const std::string& app_id);
void NotifyAppActivated(const std::string& app_id);
Expand Down
4 changes: 2 additions & 2 deletions apps/app_lifetime_monitor_factory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
#include "apps/app_lifetime_monitor_factory.h"

#include "apps/app_lifetime_monitor.h"
#include "apps/app_window_registry.h"
#include "chrome/browser/profiles/profile.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h"
#include "extensions/browser/app_window/app_window_registry.h"
#include "extensions/browser/extensions_browser_client.h"

namespace apps {
Expand All @@ -26,7 +26,7 @@ AppLifetimeMonitorFactory::AppLifetimeMonitorFactory()
: BrowserContextKeyedServiceFactory(
"AppLifetimeMonitor",
BrowserContextDependencyManager::GetInstance()) {
DependsOn(AppWindowRegistry::Factory::GetInstance());
DependsOn(extensions::AppWindowRegistry::Factory::GetInstance());
}

AppLifetimeMonitorFactory::~AppLifetimeMonitorFactory() {}
Expand Down
2 changes: 1 addition & 1 deletion apps/app_load_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@

#include "apps/app_load_service_factory.h"
#include "apps/app_restore_service.h"
#include "apps/app_window_registry.h"
#include "apps/launcher.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/unpacked_installer.h"
#include "chrome/browser/profiles/profile.h"
#include "content/public/browser/notification_details.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_types.h"
#include "extensions/browser/app_window/app_window_registry.h"
#include "extensions/browser/extension_host.h"
#include "extensions/browser/extension_prefs.h"
#include "extensions/browser/extension_system.h"
Expand Down
4 changes: 2 additions & 2 deletions apps/app_load_service_factory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
#include "apps/app_load_service_factory.h"

#include "apps/app_load_service.h"
#include "apps/app_window_registry.h"
#include "chrome/browser/profiles/profile.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h"
#include "extensions/browser/app_window/app_window_registry.h"
#include "extensions/browser/extension_prefs_factory.h"
#include "extensions/browser/extension_system_provider.h"
#include "extensions/browser/extensions_browser_client.h"
Expand All @@ -31,7 +31,7 @@ AppLoadServiceFactory::AppLoadServiceFactory()
DependsOn(
extensions::ExtensionsBrowserClient::Get()->GetExtensionSystemFactory());
DependsOn(extensions::ExtensionPrefsFactory::GetInstance());
DependsOn(AppWindowRegistry::Factory::GetInstance());
DependsOn(extensions::AppWindowRegistry::Factory::GetInstance());
}

AppLoadServiceFactory::~AppLoadServiceFactory() {
Expand Down
2 changes: 1 addition & 1 deletion apps/app_restore_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@

#include "apps/app_lifetime_monitor_factory.h"
#include "apps/app_restore_service_factory.h"
#include "apps/app_window.h"
#include "apps/launcher.h"
#include "apps/saved_files_service.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/profiles/profile.h"
#include "extensions/browser/app_window/app_window.h"
#include "extensions/browser/extension_host.h"
#include "extensions/browser/extension_prefs.h"
#include "extensions/browser/extension_registry.h"
Expand Down
2 changes: 1 addition & 1 deletion apps/app_restore_service.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
#include <vector>

#include "apps/app_lifetime_monitor.h"
#include "apps/app_window_registry.h"
#include "components/keyed_service/core/keyed_service.h"
#include "extensions/browser/app_window/app_window_registry.h"

namespace extensions {
class Extension;
Expand Down
4 changes: 2 additions & 2 deletions apps/app_shim/app_shim_handler_mac.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

#include <map>

#include "apps/app_window_registry.h"
#include "base/bind.h"
#include "base/logging.h"
#include "base/memory/singleton.h"
Expand All @@ -17,14 +16,15 @@
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
#include "content/public/browser/notification_service.h"
#include "extensions/browser/app_window/app_window_registry.h"

namespace apps {

namespace {

void TerminateIfNoAppWindows() {
bool app_windows_left =
apps::AppWindowRegistry::IsAppWindowRegisteredInAnyProfile(0);
extensions::AppWindowRegistry::IsAppWindowRegisteredInAnyProfile(0);
if (!app_windows_left &&
!AppListService::Get(chrome::HOST_DESKTOP_TYPE_NATIVE)
->IsAppListVisible()) {
Expand Down
13 changes: 7 additions & 6 deletions apps/app_shim/extension_app_shim_handler_mac.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
#include "apps/app_lifetime_monitor_factory.h"
#include "apps/app_shim/app_shim_host_manager_mac.h"
#include "apps/app_shim/app_shim_messages.h"
#include "apps/app_window.h"
#include "apps/app_window_registry.h"
#include "apps/launcher.h"
#include "base/files/file_path.h"
#include "base/logging.h"
Expand All @@ -25,16 +23,20 @@
#include "content/public/browser/notification_details.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_source.h"
#include "extensions/browser/app_window/app_window.h"
#include "extensions/browser/app_window/app_window_registry.h"
#include "extensions/browser/app_window/native_app_window.h"
#include "extensions/browser/extension_host.h"
#include "extensions/browser/extension_registry.h"
#include "ui/base/cocoa/focus_window_set.h"

using extensions::AppWindow;
using extensions::AppWindowRegistry;
using extensions::ExtensionRegistry;

namespace {

typedef apps::AppWindowRegistry::AppWindowList AppWindowList;
typedef AppWindowRegistry::AppWindowList AppWindowList;

void ProfileLoadedCallback(base::Callback<void(Profile*)> callback,
Profile* profile,
Expand All @@ -50,7 +52,7 @@ void ProfileLoadedCallback(base::Callback<void(Profile*)> callback,

void SetAppHidden(Profile* profile, const std::string& app_id, bool hidden) {
AppWindowList windows =
apps::AppWindowRegistry::Get(profile)->GetAppWindowsForApp(app_id);
AppWindowRegistry::Get(profile)->GetAppWindowsForApp(app_id);
for (AppWindowList::const_reverse_iterator it = windows.rbegin();
it != windows.rend();
++it) {
Expand Down Expand Up @@ -262,8 +264,7 @@ void ExtensionAppShimHandler::FocusAppForWindow(AppWindow* app_window) {
APP_SHIM_FOCUS_NORMAL,
std::vector<base::FilePath>());
} else {
FocusWindows(
apps::AppWindowRegistry::Get(profile)->GetAppWindowsForApp(app_id));
FocusWindows(AppWindowRegistry::Get(profile)->GetAppWindowsForApp(app_id));
}
}

Expand Down
18 changes: 9 additions & 9 deletions apps/app_shim/extension_app_shim_handler_mac.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@

#include "apps/app_lifetime_monitor.h"
#include "apps/app_shim/app_shim_handler_mac.h"
#include "apps/app_window_registry.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
#include "extensions/browser/app_window/app_window_registry.h"

class Profile;

Expand All @@ -28,13 +28,12 @@ class WebContents;
}

namespace extensions {
class AppWindow;
class Extension;
}

namespace apps {

class AppWindow;

// This app shim handler that handles events for app shims that correspond to an
// extension.
class ExtensionAppShimHandler : public AppShimHandler,
Expand All @@ -50,7 +49,7 @@ class ExtensionAppShimHandler : public AppShimHandler,
virtual void LoadProfileAsync(const base::FilePath& path,
base::Callback<void(Profile*)> callback);

virtual AppWindowRegistry::AppWindowList GetWindows(
virtual extensions::AppWindowRegistry::AppWindowList GetWindows(
Profile* profile,
const std::string& extension_id);

Expand All @@ -73,20 +72,21 @@ class ExtensionAppShimHandler : public AppShimHandler,

AppShimHandler::Host* FindHost(Profile* profile, const std::string& app_id);

static void QuitAppForWindow(AppWindow* app_window);
static void QuitAppForWindow(extensions::AppWindow* app_window);

static void HideAppForWindow(AppWindow* app_window);
static void HideAppForWindow(extensions::AppWindow* app_window);

static void FocusAppForWindow(AppWindow* app_window);
static void FocusAppForWindow(extensions::AppWindow* app_window);

// Brings the window to the front without showing it and instructs the shim to
// request user attention. If there is no shim, show the app and return false.
static bool ActivateAndRequestUserAttentionForWindow(AppWindow* app_window);
static bool ActivateAndRequestUserAttentionForWindow(
extensions::AppWindow* app_window);

// Instructs the shim to request user attention. Returns false if there is no
// shim for this window.
static void RequestUserAttentionForWindow(
AppWindow* app_window,
extensions::AppWindow* app_window,
AppShimAttentionType attention_type);

// Called by AppControllerMac when Chrome hides.
Expand Down
4 changes: 2 additions & 2 deletions apps/app_shim/extension_app_shim_handler_mac_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
namespace apps {

using extensions::Extension;
typedef AppWindowRegistry::AppWindowList AppWindowList;
typedef extensions::AppWindowRegistry::AppWindowList AppWindowList;

using ::testing::_;
using ::testing::Invoke;
Expand Down Expand Up @@ -176,7 +176,7 @@ class ExtensionAppShimHandlerTest : public testing::Test {
// In most tests, we don't care about the result of GetWindows, it just
// needs to be non-empty.
AppWindowList app_window_list;
app_window_list.push_back(static_cast<AppWindow*>(NULL));
app_window_list.push_back(static_cast<extensions::AppWindow*>(NULL));
EXPECT_CALL(*delegate_, GetWindows(_, _))
.WillRepeatedly(Return(app_window_list));

Expand Down
1 change: 1 addition & 0 deletions apps/app_window_contents.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "extensions/common/extension_messages.h"

namespace app_window = extensions::api::app_window;
using extensions::AppWindow;

namespace apps {

Expand Down
8 changes: 4 additions & 4 deletions apps/app_window_contents.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
#ifndef APPS_APP_WINDOW_CONTENTS_H_
#define APPS_APP_WINDOW_CONTENTS_H_

#include "apps/app_window.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"

Expand All @@ -27,11 +27,11 @@ namespace apps {
// WebContents instance and observes it for the purpose of passing
// messages to the extensions system.
class AppWindowContentsImpl
: public AppWindowContents,
: public extensions::AppWindowContents,
public content::WebContentsObserver,
public extensions::ExtensionFunctionDispatcher::Delegate {
public:
explicit AppWindowContentsImpl(AppWindow* host);
explicit AppWindowContentsImpl(extensions::AppWindow* host);
virtual ~AppWindowContentsImpl();

// AppWindowContents
Expand All @@ -58,7 +58,7 @@ class AppWindowContentsImpl
const std::vector<extensions::DraggableRegion>& regions);
void SuspendRenderViewHost(content::RenderViewHost* rvh);

AppWindow* host_; // This class is owned by |host_|
extensions::AppWindow* host_; // This class is owned by |host_|
GURL url_;
scoped_ptr<content::WebContents> web_contents_;
scoped_ptr<extensions::ExtensionFunctionDispatcher>
Expand Down
6 changes: 0 additions & 6 deletions apps/apps.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,8 @@
'app_restore_service.h',
'app_restore_service_factory.cc',
'app_restore_service_factory.h',
'app_window.cc',
'app_window.h',
'app_window_contents.cc',
'app_window_contents.h',
'app_window_registry.cc',
'app_window_registry.h',
'browser_context_keyed_service_factories.cc',
'browser_context_keyed_service_factories.h',
'custom_launcher_page_contents.cc',
Expand All @@ -57,8 +53,6 @@
'saved_files_service_factory.h',
'switches.cc',
'switches.h',
'ui/apps_client.cc',
'ui/apps_client.h',
'ui/views/app_window_frame_view.cc',
'ui/views/app_window_frame_view.h',
'ui/views/native_app_window_views.cc',
Expand Down
Loading

0 comments on commit ad3c687

Please sign in to comment.