diff options
20 files changed, 106 insertions, 112 deletions
@@ -47,7 +47,6 @@ specific_include_rules = { "+chrome/browser/extensions/extension_browsertest.h", "+chrome/browser/extensions/extension_test_message_listener.h", "+chrome/browser/extensions/test_extension_environment.h", - "+chrome/browser/extensions/test_extension_prefs.h", "+chrome/browser/ui/browser.h", "+chrome/test/base/in_process_browser_test.h", "+chrome/test/base/interactive_test_utils.h", diff --git a/apps/app_window.cc b/apps/app_window.cc index 1fa8139..a87e355 100644 --- a/apps/app_window.cc +++ b/apps/app_window.cc @@ -8,9 +8,6 @@ #include <string> #include <vector> -#include "apps/app_delegate.h" -#include "apps/app_web_contents_helper.h" -#include "apps/app_window_geometry_cache.h" #include "apps/app_window_registry.h" #include "apps/ui/apps_client.h" #include "apps/ui/web_contents_sizer.h" @@ -32,6 +29,9 @@ #include "content/public/browser/web_contents.h" #include "content/public/common/content_switches.h" #include "content/public/common/media_stream_request.h" +#include "extensions/browser/app_window/app_delegate.h" +#include "extensions/browser/app_window/app_web_contents_helper.h" +#include "extensions/browser/app_window/app_window_geometry_cache.h" #include "extensions/browser/app_window/native_app_window.h" #include "extensions/browser/app_window/size_constraints.h" #include "extensions/browser/extension_registry.h" @@ -228,7 +228,7 @@ gfx::Size AppWindow::CreateParams::GetWindowMaximumSize( // AppWindow AppWindow::AppWindow(BrowserContext* context, - AppDelegate* app_delegate, + extensions::AppDelegate* app_delegate, const extensions::Extension* extension) : browser_context_(context), extension_id_(extension->id()), @@ -285,7 +285,7 @@ void AppWindow::Init(const GURL& url, native_app_window_.reset( apps_client->CreateNativeAppWindow(this, new_params)); - helper_.reset(new AppWebContentsHelper( + helper_.reset(new extensions::AppWebContentsHelper( browser_context_, extension_id_, web_contents, app_delegate_.get())); popup_manager_.reset( @@ -440,7 +440,7 @@ void AppWindow::RequestToLockMouse(WebContents* web_contents, bool AppWindow::PreHandleGestureEvent(WebContents* source, const blink::WebGestureEvent& event) { - return AppWebContentsHelper::ShouldSuppressGestureEvent(event); + return extensions::AppWebContentsHelper::ShouldSuppressGestureEvent(event); } void AppWindow::DidFirstVisuallyNonEmptyPaint() { @@ -989,8 +989,8 @@ void AppWindow::SaveWindowPosition() { if (!native_app_window_) return; - AppWindowGeometryCache* cache = - AppWindowGeometryCache::Get(browser_context()); + extensions::AppWindowGeometryCache* cache = + extensions::AppWindowGeometryCache::Get(browser_context()); gfx::Rect bounds = native_app_window_->GetRestoredBounds(); gfx::Rect screen_bounds = @@ -1047,8 +1047,8 @@ AppWindow::CreateParams AppWindow::LoadDefaults(CreateParams params) // Load cached state if it exists. if (!params.window_key.empty()) { - AppWindowGeometryCache* cache = - AppWindowGeometryCache::Get(browser_context()); + extensions::AppWindowGeometryCache* cache = + extensions::AppWindowGeometryCache::Get(browser_context()); gfx::Rect cached_bounds; gfx::Rect cached_screen_bounds; diff --git a/apps/app_window.h b/apps/app_window.h index 87c3c45..a7f2293 100644 --- a/apps/app_window.h +++ b/apps/app_window.h @@ -35,6 +35,8 @@ class WebContents; } namespace extensions { +class AppDelegate; +class AppWebContentsHelper; class Extension; class NativeAppWindow; class PlatformAppBrowserTest; @@ -49,9 +51,6 @@ class BaseWindow; namespace apps { -class AppDelegate; -class AppWebContentsHelper; - // Manages the web contents for app windows. The implementation for this // class should create and maintain the WebContents for the window, and handle // any message passing between the web contents and the extension system or @@ -207,7 +206,7 @@ class AppWindow : public content::NotificationObserver, // Normally AppWindow::Create should be used. // Takes ownership of |app_delegate| and |delegate|. AppWindow(content::BrowserContext* context, - AppDelegate* app_delegate, + extensions::AppDelegate* app_delegate, const extensions::Extension* extension); // Initializes the render interface, web contents, and native window. @@ -503,8 +502,8 @@ class AppWindow : public content::NotificationObserver, scoped_ptr<extensions::NativeAppWindow> native_app_window_; scoped_ptr<AppWindowContents> app_window_contents_; - scoped_ptr<AppDelegate> app_delegate_; - scoped_ptr<AppWebContentsHelper> helper_; + scoped_ptr<extensions::AppDelegate> app_delegate_; + scoped_ptr<extensions::AppWebContentsHelper> helper_; // Manages popup windows (bubbles, tab-modals) visible overlapping the // app window. diff --git a/apps/apps.gypi b/apps/apps.gypi index e6580c5..73a288f 100644 --- a/apps/apps.gypi +++ b/apps/apps.gypi @@ -23,7 +23,6 @@ '<(grit_out_dir)', ], 'sources': [ - 'app_delegate.h', 'app_lifetime_monitor.cc', 'app_lifetime_monitor.h', 'app_lifetime_monitor_factory.cc', @@ -40,12 +39,8 @@ 'app_window.h', 'app_window_contents.cc', 'app_window_contents.h', - 'app_window_geometry_cache.cc', - 'app_window_geometry_cache.h', 'app_window_registry.cc', 'app_window_registry.h', - 'app_web_contents_helper.cc', - 'app_web_contents_helper.h', 'browser_context_keyed_service_factories.cc', 'browser_context_keyed_service_factories.h', 'custom_launcher_page_contents.cc', diff --git a/apps/browser_context_keyed_service_factories.cc b/apps/browser_context_keyed_service_factories.cc index a55f411..77e0239 100644 --- a/apps/browser_context_keyed_service_factories.cc +++ b/apps/browser_context_keyed_service_factories.cc @@ -6,14 +6,14 @@ #include "apps/app_load_service_factory.h" #include "apps/app_restore_service_factory.h" -#include "apps/app_window_geometry_cache.h" +#include "extensions/browser/app_window/app_window_geometry_cache.h" namespace apps { void EnsureBrowserContextKeyedServiceFactoriesBuilt() { apps::AppLoadServiceFactory::GetInstance(); apps::AppRestoreServiceFactory::GetInstance(); - apps::AppWindowGeometryCache::Factory::GetInstance(); + extensions::AppWindowGeometryCache::Factory::GetInstance(); } } // namespace apps diff --git a/apps/custom_launcher_page_contents.cc b/apps/custom_launcher_page_contents.cc index 1c5eeae..023c305 100644 --- a/apps/custom_launcher_page_contents.cc +++ b/apps/custom_launcher_page_contents.cc @@ -6,21 +6,21 @@ #include <string> -#include "apps/app_delegate.h" -#include "apps/app_web_contents_helper.h" #include "chrome/browser/chrome_notification_types.h" #include "chrome/browser/extensions/chrome_extension_web_contents_observer.h" #include "content/public/browser/render_view_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/app_delegate.h" +#include "extensions/browser/app_window/app_web_contents_helper.h" #include "extensions/browser/view_type_utils.h" #include "extensions/common/extension_messages.h" namespace apps { CustomLauncherPageContents::CustomLauncherPageContents( - scoped_ptr<AppDelegate> app_delegate, + scoped_ptr<extensions::AppDelegate> app_delegate, const std::string& extension_id) : app_delegate_(app_delegate.Pass()), extension_id_(extension_id) { } @@ -42,7 +42,7 @@ void CustomLauncherPageContents::Initialize(content::BrowserContext* context, ->browser_handles_all_top_level_requests = true; web_contents_->GetRenderViewHost()->SyncRendererPrefs(); - helper_.reset(new AppWebContentsHelper( + helper_.reset(new extensions::AppWebContentsHelper( context, extension_id_, web_contents_.get(), app_delegate_.get())); web_contents_->SetDelegate(this); @@ -94,7 +94,7 @@ bool CustomLauncherPageContents::ShouldSuppressDialogs() { bool CustomLauncherPageContents::PreHandleGestureEvent( content::WebContents* source, const blink::WebGestureEvent& event) { - return AppWebContentsHelper::ShouldSuppressGestureEvent(event); + return extensions::AppWebContentsHelper::ShouldSuppressGestureEvent(event); } content::ColorChooser* CustomLauncherPageContents::OpenColorChooser( diff --git a/apps/custom_launcher_page_contents.h b/apps/custom_launcher_page_contents.h index 38e1cda..36e7f79 100644 --- a/apps/custom_launcher_page_contents.h +++ b/apps/custom_launcher_page_contents.h @@ -16,10 +16,12 @@ namespace content { class BrowserContext; } -namespace apps { - +namespace extensions { class AppDelegate; class AppWebContentsHelper; +} + +namespace apps { // Manages the web contents for extension-hosted launcher pages. The // implementation for this class should create and maintain the WebContents for @@ -30,7 +32,7 @@ class CustomLauncherPageContents public content::WebContentsObserver, public extensions::ExtensionFunctionDispatcher::Delegate { public: - CustomLauncherPageContents(scoped_ptr<AppDelegate> app_delegate, + CustomLauncherPageContents(scoped_ptr<extensions::AppDelegate> app_delegate, const std::string& extension_id); virtual ~CustomLauncherPageContents(); @@ -84,8 +86,8 @@ class CustomLauncherPageContents scoped_ptr<content::WebContents> web_contents_; scoped_ptr<extensions::ExtensionFunctionDispatcher> extension_function_dispatcher_; - scoped_ptr<AppDelegate> app_delegate_; - scoped_ptr<AppWebContentsHelper> helper_; + scoped_ptr<extensions::AppDelegate> app_delegate_; + scoped_ptr<extensions::AppWebContentsHelper> helper_; std::string extension_id_; diff --git a/chrome/browser/apps/app_window_browsertest.cc b/chrome/browser/apps/app_window_browsertest.cc index 2a0ad43..95e6bc8 100644 --- a/chrome/browser/apps/app_window_browsertest.cc +++ b/chrome/browser/apps/app_window_browsertest.cc @@ -2,7 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "apps/app_window_geometry_cache.h" #include "chrome/browser/apps/app_browsertest_util.h" #include "chrome/browser/extensions/extension_test_message_listener.h" #include "chrome/browser/profiles/profile.h" @@ -10,10 +9,11 @@ #include "chrome/browser/ui/extensions/application_launch.h" #include "content/public/browser/notification_service.h" #include "content/public/test/test_utils.h" +#include "extensions/browser/app_window/app_window_geometry_cache.h" #include "extensions/common/constants.h" #include "extensions/common/extension.h" -using apps::AppWindowGeometryCache; +using extensions::AppWindowGeometryCache; // This helper class can be used to wait for changes in the app window // geometry cache registry for a specific window in a specific extension. diff --git a/chrome/browser/ui/app_list/app_list_view_delegate.cc b/chrome/browser/ui/app_list/app_list_view_delegate.cc index f842227..4d55c94 100644 --- a/chrome/browser/ui/app_list/app_list_view_delegate.cc +++ b/chrome/browser/ui/app_list/app_list_view_delegate.cc @@ -206,7 +206,8 @@ AppListViewDelegate::AppListViewDelegate(Profile* profile, std::string extension_id = it->host(); apps::CustomLauncherPageContents* page_contents = new apps::CustomLauncherPageContents( - scoped_ptr<apps::AppDelegate>(new ChromeAppDelegate), extension_id); + scoped_ptr<extensions::AppDelegate>(new ChromeAppDelegate), + extension_id); page_contents->Initialize(profile, *it); custom_page_contents_.push_back(page_contents); } diff --git a/chrome/browser/ui/apps/chrome_app_delegate.h b/chrome/browser/ui/apps/chrome_app_delegate.h index 1c083aa..bc63fa1 100644 --- a/chrome/browser/ui/apps/chrome_app_delegate.h +++ b/chrome/browser/ui/apps/chrome_app_delegate.h @@ -5,8 +5,8 @@ #ifndef CHROME_BROWSER_UI_APPS_CHROME_APP_DELEGATE_H_ #define CHROME_BROWSER_UI_APPS_CHROME_APP_DELEGATE_H_ -#include "apps/app_delegate.h" #include "base/memory/scoped_ptr.h" +#include "extensions/browser/app_window/app_delegate.h" #include "ui/base/window_open_disposition.h" #include "ui/gfx/rect.h" @@ -15,7 +15,7 @@ class BrowserContext; class WebContents; } -class ChromeAppDelegate : public apps::AppDelegate { +class ChromeAppDelegate : public extensions::AppDelegate { public: ChromeAppDelegate(); virtual ~ChromeAppDelegate(); @@ -25,7 +25,7 @@ class ChromeAppDelegate : public apps::AppDelegate { private: class NewWindowContentsDelegate; - // apps::AppDelegate: + // extensions::AppDelegate: virtual void InitWebContents(content::WebContents* web_contents) OVERRIDE; virtual content::WebContents* OpenURLFromTab( content::BrowserContext* context, diff --git a/chrome/chrome_tests_unit.gypi b/chrome/chrome_tests_unit.gypi index 12533f7..8577704 100644 --- a/chrome/chrome_tests_unit.gypi +++ b/chrome/chrome_tests_unit.gypi @@ -515,7 +515,6 @@ 'sources': [ '../apps/app_shim/app_shim_host_mac_unittest.cc', '../apps/app_shim/extension_app_shim_handler_mac_unittest.cc', - '../apps/app_window_geometry_cache_unittest.cc', '../apps/saved_files_service_unittest.cc', '../components/autofill/content/renderer/test_password_autofill_agent.cc', '../components/autofill/content/renderer/test_password_autofill_agent.h', @@ -534,6 +533,7 @@ '../extensions/browser/api/storage/settings_test_util.h', '../extensions/browser/api/storage/storage_api_unittest.cc', '../extensions/browser/api/storage/storage_frontend_unittest.cc', + '../extensions/browser/app_window/app_window_geometry_cache_unittest.cc', '../extensions/browser/error_map_unittest.cc', '../extensions/browser/extension_error_test_util.cc', '../extensions/browser/extension_error_test_util.h', diff --git a/extensions/DEPS b/extensions/DEPS index 7e2496a..98f9058 100644 --- a/extensions/DEPS +++ b/extensions/DEPS @@ -32,6 +32,7 @@ specific_include_rules = { "+chrome/browser/extensions/extension_service.h", "+chrome/browser/extensions/extension_service_test_base.h", "+chrome/browser/extensions/test_extension_dir.h", + "+chrome/browser/extensions/test_extension_prefs.h", "+chrome/browser/extensions/test_extension_system.h", "+chrome/browser/ui/browser.h", "+chrome/common/chrome_paths.h", diff --git a/extensions/browser/BUILD.gn b/extensions/browser/BUILD.gn index 6bf06fb..954ba9b 100644 --- a/extensions/browser/BUILD.gn +++ b/extensions/browser/BUILD.gn @@ -126,6 +126,11 @@ source_set("browser") { "api/usb/usb_device_resource.h", "api_activity_monitor.h", "app_sorting.h", + "app_window/app_delegate.h", + "app_window/app_web_contents_helper.cc", + "app_window/app_web_contents_helper.h", + "app_window/app_window_geometry_cache.cc", + "app_window/app_window_geometry_cache.h", "app_window/native_app_window.h", "app_window/size_constraints.cc", "app_window/size_constraints.h", diff --git a/apps/app_delegate.h b/extensions/browser/app_window/app_delegate.h index bb7f2a4..de78627 100644 --- a/apps/app_delegate.h +++ b/extensions/browser/app_window/app_delegate.h @@ -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_DELEGATE_H_ -#define APPS_APP_DELEGATE_H_ +#ifndef EXTENSIONS_BROWSER_APP_WINDOW_APP_DELEGATE_H_ +#define EXTENSIONS_BROWSER_APP_WINDOW_APP_DELEGATE_H_ #include "content/public/common/media_stream_request.h" #include "third_party/skia/include/core/SkColor.h" @@ -18,15 +18,13 @@ struct OpenURLParams; class WebContents; } -namespace extensions { -class Extension; -} - namespace gfx { class Rect; } -namespace apps { +namespace extensions { + +class Extension; // Interface to give packaged apps access to services in the browser, for things // like handling links and showing UI prompts to the user. @@ -59,7 +57,7 @@ class AppDelegate { content::WebContents* web_contents, const content::MediaStreamRequest& request, const content::MediaResponseCallback& callback, - const extensions::Extension* extension) = 0; + const Extension* extension) = 0; virtual int PreferredIconSize() = 0; virtual gfx::ImageSkia GetAppDefaultIcon() = 0; @@ -69,6 +67,6 @@ class AppDelegate { virtual bool IsWebContentsVisible(content::WebContents* web_contents) = 0; }; -} // namespace apps +} // namespace extensions -#endif // APPS_APP_DELEGATE_H_ +#endif // EXTENSIONS_BROWSER_APP_WINDOW_APP_DELEGATE_H_ diff --git a/apps/app_web_contents_helper.cc b/extensions/browser/app_window/app_web_contents_helper.cc index 7c7b293..54153ac 100644 --- a/apps/app_web_contents_helper.cc +++ b/extensions/browser/app_window/app_web_contents_helper.cc @@ -2,20 +2,20 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "apps/app_web_contents_helper.h" +#include "extensions/browser/app_window/app_web_contents_helper.h" -#include "apps/app_delegate.h" #include "base/strings/stringprintf.h" #include "content/public/browser/native_web_keyboard_event.h" #include "content/public/browser/page_navigator.h" #include "content/public/browser/render_view_host.h" #include "content/public/browser/web_contents.h" +#include "extensions/browser/app_window/app_delegate.h" #include "extensions/browser/extension_registry.h" #include "extensions/browser/suggest_permission_util.h" #include "extensions/common/extension_messages.h" #include "extensions/common/permissions/api_permission.h" -namespace apps { +namespace extensions { AppWebContentsHelper::AppWebContentsHelper( content::BrowserContext* browser_context, @@ -74,12 +74,12 @@ content::WebContents* AppWebContentsHelper::OpenURLFromTab( } void AppWebContentsHelper::RequestToLockMouse() const { - const extensions::Extension* extension = GetExtension(); + const Extension* extension = GetExtension(); if (!extension) return; bool has_permission = IsExtensionWithPermissionOrSuggestInConsole( - extensions::APIPermission::kPointerLock, + APIPermission::kPointerLock, extension, web_contents_->GetRenderViewHost()); @@ -89,7 +89,7 @@ void AppWebContentsHelper::RequestToLockMouse() const { void AppWebContentsHelper::RequestMediaAccessPermission( const content::MediaStreamRequest& request, const content::MediaResponseCallback& callback) const { - const extensions::Extension* extension = GetExtension(); + const Extension* extension = GetExtension(); if (!extension) return; @@ -97,8 +97,8 @@ void AppWebContentsHelper::RequestMediaAccessPermission( web_contents_, request, callback, extension); } -const extensions::Extension* AppWebContentsHelper::GetExtension() const { - return extensions::ExtensionRegistry::Get(browser_context_) +const Extension* AppWebContentsHelper::GetExtension() const { + return ExtensionRegistry::Get(browser_context_) ->enabled_extensions() .GetByID(extension_id_); } @@ -111,4 +111,4 @@ void AppWebContentsHelper::AddMessageToDevToolsConsole( rvh->GetRoutingID(), level, message)); } -} // namespace apps +} // namespace extensions diff --git a/apps/app_web_contents_helper.h b/extensions/browser/app_window/app_web_contents_helper.h index 01f349b..3d17851 100644 --- a/apps/app_web_contents_helper.h +++ b/extensions/browser/app_window/app_web_contents_helper.h @@ -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_WEB_CONTENTS_HELPER_H_ -#define APPS_APP_WEB_CONTENTS_HELPER_H_ +#ifndef EXTENSIONS_BROWSER_APP_WINDOW_APP_WEB_CONTENTS_HELPER_H_ +#define EXTENSIONS_BROWSER_APP_WINDOW_APP_WEB_CONTENTS_HELPER_H_ #include "content/public/common/console_message_level.h" #include "content/public/common/media_stream_request.h" @@ -19,12 +19,9 @@ class WebContents; } namespace extensions { -class Extension; -} - -namespace apps { class AppDelegate; +class Extension; // Provides common functionality for apps and launcher pages to respond to // messages from a WebContents. @@ -52,7 +49,7 @@ class AppWebContentsHelper { const content::MediaResponseCallback& callback) const; private: - const extensions::Extension* GetExtension() const; + const Extension* GetExtension() const; // Helper method to add a message to the renderer's DevTools console. void AddMessageToDevToolsConsole(content::ConsoleMessageLevel level, @@ -71,6 +68,6 @@ class AppWebContentsHelper { DISALLOW_COPY_AND_ASSIGN(AppWebContentsHelper); }; -} // namespace apps +} // namespace extensions -#endif // APPS_APP_WEB_CONTENTS_HELPER_H_ +#endif // EXTENSIONS_BROWSER_APP_WINDOW_APP_WEB_CONTENTS_HELPER_H_ diff --git a/apps/app_window_geometry_cache.cc b/extensions/browser/app_window/app_window_geometry_cache.cc index 667595f..3c3ec53 100644 --- a/apps/app_window_geometry_cache.cc +++ b/extensions/browser/app_window/app_window_geometry_cache.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "apps/app_window_geometry_cache.h" +#include "extensions/browser/app_window/app_window_geometry_cache.h" #include "base/bind.h" #include "base/stl_util.h" @@ -22,15 +22,14 @@ const int kSyncTimeoutMilliseconds = 1000; } // namespace -namespace apps { +namespace extensions { -AppWindowGeometryCache::AppWindowGeometryCache( - content::BrowserContext* context, - extensions::ExtensionPrefs* prefs) +AppWindowGeometryCache::AppWindowGeometryCache(content::BrowserContext* context, + ExtensionPrefs* prefs) : prefs_(prefs), sync_delay_(base::TimeDelta::FromMilliseconds(kSyncTimeoutMilliseconds)), extension_registry_observer_(this) { - extension_registry_observer_.Add(extensions::ExtensionRegistry::Get(context)); + extension_registry_observer_.Add(ExtensionRegistry::Get(context)); } AppWindowGeometryCache::~AppWindowGeometryCache() {} @@ -186,14 +185,14 @@ AppWindowGeometryCache::WindowData::~WindowData() {} void AppWindowGeometryCache::OnExtensionLoaded( content::BrowserContext* browser_context, - const extensions::Extension* extension) { + const Extension* extension) { LoadGeometryFromStorage(extension->id()); } void AppWindowGeometryCache::OnExtensionUnloaded( content::BrowserContext* browser_context, - const extensions::Extension* extension, - extensions::UnloadedExtensionInfo::Reason reason) { + const Extension* extension, + UnloadedExtensionInfo::Reason reason) { SyncToStorage(); cache_.erase(extension->id()); } @@ -275,15 +274,14 @@ AppWindowGeometryCache::Factory::Factory() : BrowserContextKeyedServiceFactory( "AppWindowGeometryCache", BrowserContextDependencyManager::GetInstance()) { - DependsOn(extensions::ExtensionPrefsFactory::GetInstance()); + DependsOn(ExtensionPrefsFactory::GetInstance()); } AppWindowGeometryCache::Factory::~Factory() {} KeyedService* AppWindowGeometryCache::Factory::BuildServiceInstanceFor( content::BrowserContext* context) const { - return new AppWindowGeometryCache(context, - extensions::ExtensionPrefs::Get(context)); + return new AppWindowGeometryCache(context, ExtensionPrefs::Get(context)); } bool AppWindowGeometryCache::Factory::ServiceIsNULLWhileTesting() const { @@ -293,8 +291,7 @@ bool AppWindowGeometryCache::Factory::ServiceIsNULLWhileTesting() const { content::BrowserContext* AppWindowGeometryCache::Factory::GetBrowserContextToUse( content::BrowserContext* context) const { - return extensions::ExtensionsBrowserClient::Get()->GetOriginalContext( - context); + return ExtensionsBrowserClient::Get()->GetOriginalContext(context); } void AppWindowGeometryCache::AddObserver(Observer* observer) { @@ -305,4 +302,4 @@ void AppWindowGeometryCache::RemoveObserver(Observer* observer) { observers_.RemoveObserver(observer); } -} // namespace apps +} // namespace extensions diff --git a/apps/app_window_geometry_cache.h b/extensions/browser/app_window/app_window_geometry_cache.h index 30f3ad0..f73ae48 100644 --- a/apps/app_window_geometry_cache.h +++ b/extensions/browser/app_window/app_window_geometry_cache.h @@ -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_GEOMETRY_CACHE_H_ -#define APPS_APP_WINDOW_GEOMETRY_CACHE_H_ +#ifndef EXTENSIONS_BROWSER_APP_WINDOW_APP_WINDOW_GEOMETRY_CACHE_H_ +#define EXTENSIONS_BROWSER_APP_WINDOW_APP_WINDOW_GEOMETRY_CACHE_H_ #include <map> #include <set> @@ -23,17 +23,15 @@ #include "ui/gfx/rect.h" namespace extensions { + class ExtensionPrefs; class ExtensionRegistry; -} - -namespace apps { // A cache for persisted geometry of app windows, both to not have to wait // for IO when creating a new window, and to not cause IO on every window // geometry change. class AppWindowGeometryCache : public KeyedService, - public extensions::ExtensionRegistryObserver { + public ExtensionRegistryObserver { public: class Factory : public BrowserContextKeyedServiceFactory { public: @@ -68,7 +66,7 @@ class AppWindowGeometryCache : public KeyedService, }; AppWindowGeometryCache(content::BrowserContext* context, - extensions::ExtensionPrefs* prefs); + ExtensionPrefs* prefs); virtual ~AppWindowGeometryCache(); @@ -123,19 +121,18 @@ class AppWindowGeometryCache : public KeyedService, typedef std::map<std::string, WindowData> ExtensionData; // ExtensionRegistryObserver implementation. - virtual void OnExtensionLoaded( - content::BrowserContext* browser_context, - const extensions::Extension* extension) OVERRIDE; + virtual void OnExtensionLoaded(content::BrowserContext* browser_context, + const Extension* extension) OVERRIDE; virtual void OnExtensionUnloaded( content::BrowserContext* browser_context, - const extensions::Extension* extension, - extensions::UnloadedExtensionInfo::Reason reason) OVERRIDE; + const Extension* extension, + UnloadedExtensionInfo::Reason reason) OVERRIDE; void LoadGeometryFromStorage(const std::string& extension_id); void SyncToStorage(); // Preferences storage. - extensions::ExtensionPrefs* prefs_; + ExtensionPrefs* prefs_; // Cached data. std::map<std::string, ExtensionData> cache_; @@ -150,13 +147,12 @@ class AppWindowGeometryCache : public KeyedService, base::TimeDelta sync_delay_; // Listen to extension load, unloaded notifications. - ScopedObserver<extensions::ExtensionRegistry, - extensions::ExtensionRegistryObserver> + ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> extension_registry_observer_; ObserverList<Observer> observers_; }; -} // namespace apps +} // namespace extensions -#endif // APPS_APP_WINDOW_GEOMETRY_CACHE_H_ +#endif // EXTENSIONS_BROWSER_APP_WINDOW_APP_WINDOW_GEOMETRY_CACHE_H_ diff --git a/apps/app_window_geometry_cache_unittest.cc b/extensions/browser/app_window/app_window_geometry_cache_unittest.cc index 50240c7..a526e7d 100644 --- a/apps/app_window_geometry_cache_unittest.cc +++ b/extensions/browser/app_window/app_window_geometry_cache_unittest.cc @@ -2,7 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "apps/app_window_geometry_cache.h" #include "base/memory/scoped_ptr.h" #include "base/prefs/mock_pref_change_callback.h" #include "base/strings/string_number_conversions.h" @@ -10,6 +9,7 @@ #include "chrome/test/base/testing_profile.h" #include "content/public/test/test_browser_thread.h" #include "content/public/test/test_utils.h" +#include "extensions/browser/app_window/app_window_geometry_cache.h" #include "extensions/browser/extension_prefs.h" #include "extensions/common/extension_builder.h" #include "extensions/common/value_builder.h" @@ -17,16 +17,16 @@ using content::BrowserThread; -namespace apps { +namespace extensions { namespace { const char kWindowId[] = "windowid"; const char kWindowId2[] = "windowid2"; // Create a very simple extension with id. -scoped_refptr<extensions::Extension> CreateExtension(const std::string& id) { - return extensions::ExtensionBuilder() - .SetManifest(extensions::DictionaryBuilder().Set("name", "test").Set( +scoped_refptr<Extension> CreateExtension(const std::string& id) { + return ExtensionBuilder() + .SetManifest(DictionaryBuilder().Set("name", "test").Set( "version", "0.1")) .SetID(id) .Build(); @@ -40,7 +40,7 @@ class AppWindowGeometryCacheTest : public testing::Test { AppWindowGeometryCacheTest() : profile_(new TestingProfile), ui_thread_(BrowserThread::UI, &ui_message_loop_) { - prefs_.reset(new extensions::TestExtensionPrefs( + prefs_.reset(new TestExtensionPrefs( ui_message_loop_.message_loop_proxy().get())); cache_.reset(new AppWindowGeometryCache(profile_.get(), prefs_->prefs())); cache_->SetSyncDelayForTests(0); @@ -63,7 +63,7 @@ class AppWindowGeometryCacheTest : public testing::Test { scoped_ptr<TestingProfile> profile_; base::MessageLoopForUI ui_message_loop_; content::TestBrowserThread ui_thread_; - scoped_ptr<extensions::TestExtensionPrefs> prefs_; + scoped_ptr<TestExtensionPrefs> prefs_; scoped_ptr<AppWindowGeometryCache> cache_; }; @@ -101,12 +101,11 @@ void AppWindowGeometryCacheTest::LoadExtension( void AppWindowGeometryCacheTest::UnloadExtension( const std::string& extension_id) { - scoped_refptr<extensions::Extension> extension = - CreateExtension(extension_id); + scoped_refptr<Extension> extension = CreateExtension(extension_id); cache_->OnExtensionUnloaded( profile_.get(), extension.get(), - extensions::UnloadedExtensionInfo::REASON_DISABLE); + UnloadedExtensionInfo::REASON_DISABLE); WaitForSync(); } @@ -362,4 +361,4 @@ TEST_F(AppWindowGeometryCacheTest, MaxWindows) { } } -} // namespace apps +} // namespace extensions diff --git a/extensions/extensions.gyp b/extensions/extensions.gyp index 83f680f..3481eeb 100644 --- a/extensions/extensions.gyp +++ b/extensions/extensions.gyp @@ -376,6 +376,11 @@ 'browser/api/usb_private/usb_private_api.h', 'browser/api_activity_monitor.h', 'browser/app_sorting.h', + 'browser/app_window/app_delegate.h', + 'browser/app_window/app_web_contents_helper.cc', + 'browser/app_window/app_web_contents_helper.h', + 'browser/app_window/app_window_geometry_cache.cc', + 'browser/app_window/app_window_geometry_cache.h', 'browser/app_window/native_app_window.h', 'browser/app_window/size_constraints.cc', 'browser/app_window/size_constraints.h', |