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

Side by Side 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: Sync and rebase 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef APPS_APP_SHIM_EXTENSION_APP_SHIM_HANDLER_H_
6 #define APPS_APP_SHIM_EXTENSION_APP_SHIM_HANDLER_H_
7
8 #include <map>
9 #include <string>
10
11 #include "apps/app_shim/app_shim_handler_mac.h"
12 #include "content/public/browser/notification_observer.h"
13 #include "content/public/browser/notification_registrar.h"
14
15 class Profile;
16
17 namespace apps {
18
19 // This app shim handler that handles events for app shims that correspond to an
20 // extension.
21 class ExtensionAppShimHandler : public AppShimHandler,
22 public content::NotificationObserver {
23 public:
24 ExtensionAppShimHandler();
25 virtual ~ExtensionAppShimHandler();
26
27 // AppShimHandler overrides:
28 virtual bool OnShimLaunch(Host* host) OVERRIDE;
29 virtual void OnShimClose(Host* host) OVERRIDE;
30 virtual void OnShimFocus(Host* host) OVERRIDE;
31
32 protected:
33 typedef std::map<std::pair<Profile*, std::string>, AppShimHandler::Host*>
34 HostMap;
35
36 // Exposed for testing.
37 HostMap& hosts() { return hosts_; }
38 content::NotificationRegistrar& registrar() { return registrar_; }
39
40 private:
41 virtual bool LaunchApp(Profile* profile, const std::string& app_id);
42
43 // Listen to the NOTIFICATION_EXTENSION_HOST_DESTROYED message to detect when
44 // an app closes. When that happens, call OnAppClosed on the relevant
45 // AppShimHandler::Host which causes the app shim process to quit.
46 // The host will call OnShimClose on this.
47 virtual void Observe(int type,
48 const content::NotificationSource& source,
49 const content::NotificationDetails& details) OVERRIDE;
50
51 void CloseShim(Profile* profile, const std::string& app_id);
52
53 HostMap hosts_;
54
55 content::NotificationRegistrar registrar_;
56 };
57
58 } // namespace apps
59
60 #endif // APPS_APP_SHIM_EXTENSION_APP_SHIM_HANDLER_H_
OLDNEW
« no previous file with comments | « apps/app_shim/app_shim_host_manager_mac.mm ('k') | apps/app_shim/extension_app_shim_handler_mac.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698