Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(425)

Unified Diff: apps/app_shim/extension_app_shim_handler_mac.h

Issue 15269003: Refactor extension handling code from AppShimHost into ExtensionAppShimHandler. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments. Instantiate ExtensionAppShimHandler in AppShimHostManager. Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: apps/app_shim/extension_app_shim_handler_mac.h
diff --git a/apps/app_shim/extension_app_shim_handler_mac.h b/apps/app_shim/extension_app_shim_handler_mac.h
new file mode 100644
index 0000000000000000000000000000000000000000..90459483316d9df2e867ad575edafe52b536f810
--- /dev/null
+++ b/apps/app_shim/extension_app_shim_handler_mac.h
@@ -0,0 +1,68 @@
+// 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_SHIM_EXTENSION_APP_SHIM_HANDLER_H_
+#define APPS_APP_SHIM_EXTENSION_APP_SHIM_HANDLER_H_
+
+#include <map>
+#include <string>
+
+#include "apps/app_shim/app_shim_handler_mac.h"
+#include "base/memory/scoped_ptr.h"
tapted 2013/05/23 02:29:39 I think this can go?
jackhou1 2013/05/23 06:10:19 Done.
+#include "base/observer_list.h"
+#include "content/public/browser/notification_observer.h"
+#include "content/public/browser/notification_registrar.h"
+
+class Profile;
+
+namespace apps {
+
+// This app shim handler that handles events for app shims that correspond to an
+// extension.
+class ExtensionAppShimHandler : public apps::AppShimHandler,
tapted 2013/05/23 02:29:39 nit: no longer need apps:: prefix
jackhou1 2013/05/23 06:10:19 Done.
+ public content::NotificationObserver{
+ public:
+ ExtensionAppShimHandler();
+ virtual ~ExtensionAppShimHandler();
+
+ // AppShimHandler overrides:
+ virtual bool OnShimLaunch(Host* host) OVERRIDE;
+ virtual void OnShimClose(Host* host) OVERRIDE;
+ virtual void OnShimFocus(Host* host) OVERRIDE;
+
+ protected:
+ typedef std::map<std::pair<Profile*, std::string>,
+ ObserverList<apps::AppShimHandler::Host>* > HostMap;
tapted 2013/05/23 02:29:39 s/apps:://
jackhou1 2013/05/23 06:10:19 Done.
+
+ ObserverList<apps::AppShimHandler::Host>*
tapted 2013/05/23 02:29:39 s/apps:://
jackhou1 2013/05/23 06:10:19 Done.
+ FindObserverList(Profile* profile, const std::string& app_id);
+
+ ObserverList<apps::AppShimHandler::Host>*
tapted 2013/05/23 02:29:39 s/apps:://
jackhou1 2013/05/23 06:10:19 Done.
+ FindOrInsertObserverList(Profile* profile, const std::string& app_id);
+
+ bool RemoveObserverList(Profile* profile, const std::string& app_id);
+
+ content::NotificationRegistrar* registrar() { return &registrar_; }
tapted 2013/05/23 02:29:39 nit: a reference is probably better here, since it
jackhou1 2013/05/23 06:10:19 Done.
+
+ private:
+ virtual bool LaunchApp(Profile* profile, const std::string& app_id);
+
+ // Listen to the NOTIFICATION_EXTENSION_HOST_DESTROYED message to detect when
+ // an app closes. When that happens, call OnAppClosed on the relevant
+ // AppShimHandler::Host which causes the app shim process to quit.
+ // The host will call OnShimClose on this.
+ virtual void Observe(int type,
+ const content::NotificationSource& source,
+ const content::NotificationDetails& details) OVERRIDE;
+
+ void Close(Profile* profile, const std::string& app_id);
tapted 2013/05/23 02:29:39 Maybe CloseShim, since it's not the handler that's
jackhou1 2013/05/23 06:10:19 Done.
+
+ HostMap hosts_;
+
+ content::NotificationRegistrar registrar_;
+};
+
+} // namespace apps
+
+#endif // APPS_APP_SHIM_EXTENSION_APP_SHIM_HANDLER_H_

Powered by Google App Engine
This is Rietveld 408576698