OLD | NEW |
---|---|
(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 CHROME_BROWSER_WEB_APPLICATIONS_APP_SHIM_HOST_H_ | |
6 #define CHROME_BROWSER_WEB_APPLICATIONS_APP_SHIM_HOST_H_ | |
7 | |
8 #include <string> | |
9 | |
10 #include "base/threading/non_thread_safe.h" | |
11 #include "content/public/browser/notification_observer.h" | |
12 #include "content/public/browser/notification_registrar.h" | |
13 #include "ipc/ipc_listener.h" | |
14 #include "ipc/ipc_sender.h" | |
15 | |
16 class Profile; | |
17 | |
18 namespace IPC { | |
19 struct ChannelHandle; | |
20 class ChannelProxy; | |
21 class Message; | |
22 } // namespace IPC | |
23 | |
24 // This is the counterpart to AppShimController in | |
25 // chrome/app/chrome_main_app_mode_mac.mm. The AppShimHost owns itself, and is | |
26 // destroyed when the app it corresponds to is closed or when the channel | |
27 // connected to the app shim is closed. | |
koz (OOO until 15th September)
2013/03/14 23:51:05
Perhaps add something explaining that this service
| |
28 class AppShimHost : public IPC::Listener, | |
29 public IPC::Sender, | |
30 public content::NotificationObserver, | |
31 public base::NonThreadSafe { | |
32 public: | |
33 AppShimHost(); | |
34 virtual ~AppShimHost(); | |
35 | |
36 // Creates a new server-side IPC channel at |handle|, which should contain a | |
37 // file descriptor of a channel created by an IPC::ChannelFactory, and begins | |
38 // listening for messages on it. | |
39 void ServeChannel(const IPC::ChannelHandle& handle); | |
40 | |
41 const std::string& app_id() { return app_id_; } | |
palmer
2013/03/14 19:05:04
The methods themselves, as well as their return va
jeremya
2013/03/14 23:33:01
Done.
| |
42 const Profile* profile() { return profile_; } | |
43 | |
44 protected: | |
45 // Used internally; virtual so they can be mocked for testing. | |
46 virtual Profile* FetchProfileForDirectory(const std::string& profile_dir); | |
47 virtual bool LaunchApp(Profile* profile, const std::string& app_id); | |
48 | |
49 // IPC::Listener implementation. | |
50 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | |
51 | |
52 // IPC::Sender implementation. | |
53 virtual bool Send(IPC::Message* message) OVERRIDE; | |
54 | |
55 private: | |
56 // The app shim process is requesting that an app be launched. Once it has | |
57 // done so the profile and app id are stored, and all future messages from | |
palmer
2013/03/14 19:05:04
NIT: I would say "|profile|" and "|app_id|".
jeremya
2013/03/14 23:33:01
Done.
| |
58 // the app shim relate to the app it launched. It is an error for the app | |
59 // shim to send multiple launch messages. | |
60 void OnLaunchApp(std::string profile, std::string app_id); | |
61 | |
62 bool LaunchAppImpl(const std::string& profile_dir, const std::string& app_id); | |
63 | |
64 // When the app closes, a signal is sent (by way of closing the channel) to | |
palmer
2013/03/14 19:05:04
Not sure what this means.
1. Is the signal sent b
jeremya
2013/03/14 23:33:01
Made a better comment.
| |
65 // the app shim to tell it to quit. | |
66 virtual void Observe(int type, | |
67 const content::NotificationSource& source, | |
68 const content::NotificationDetails& details) OVERRIDE; | |
69 | |
70 // Closes the channel and destroys the AppShimHost. | |
71 void Close(); | |
72 | |
73 IPC::ChannelProxy* channel_; | |
74 std::string app_id_; | |
75 Profile* profile_; | |
76 content::NotificationRegistrar registrar_; | |
77 }; | |
78 | |
79 #endif // CHROME_BROWSER_WEB_APPLICATIONS_APP_SHIM_HOST_H_ | |
OLD | NEW |