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

Side by Side Diff: apps/app_shim/app_shim_host_mac.h

Issue 12623005: [mac] App shims (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: -> _mac Created 7 years, 9 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
« no previous file with comments | « apps/app_shim/OWNERS ('k') | apps/app_shim/app_shim_host_mac.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 CHROME_BROWSER_WEB_APPLICATIONS_APP_SHIM_HOST_MAC_H_
6 #define CHROME_BROWSER_WEB_APPLICATIONS_APP_SHIM_HOST_MAC_H_
7
8 #include <string>
9
10 #include "base/memory/scoped_ptr.h"
11 #include "base/threading/non_thread_safe.h"
12 #include "content/public/browser/notification_observer.h"
13 #include "content/public/browser/notification_registrar.h"
14 #include "ipc/ipc_listener.h"
15 #include "ipc/ipc_sender.h"
16
17 class Profile;
18
19 namespace IPC {
20 struct ChannelHandle;
21 class ChannelProxy;
22 class Message;
23 } // namespace IPC
24
25 // This is the counterpart to AppShimController in
26 // chrome/app/chrome_main_app_mode_mac.mm. The AppShimHost owns itself, and is
27 // destroyed when the app it corresponds to is closed or when the channel
28 // connected to the app shim is closed.
29 class AppShimHost : public IPC::Listener,
30 public IPC::Sender,
31 public content::NotificationObserver,
32 public base::NonThreadSafe {
33 public:
34 AppShimHost();
35 virtual ~AppShimHost();
36
37 // Creates a new server-side IPC channel at |handle|, which should contain a
38 // file descriptor of a channel created by an IPC::ChannelFactory, and begins
39 // listening for messages on it.
40 void ServeChannel(const IPC::ChannelHandle& handle);
41
42 const std::string& app_id() const { return app_id_; }
43 const Profile* profile() const { return profile_; }
44
45 protected:
46 // Used internally; virtual so they can be mocked for testing.
47 virtual Profile* FetchProfileForDirectory(const std::string& profile_dir);
48 virtual bool LaunchApp(Profile* profile, const std::string& app_id);
49
50 // IPC::Listener implementation.
51 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
52
53 // IPC::Sender implementation.
54 virtual bool Send(IPC::Message* message) OVERRIDE;
55
56 private:
57 // The app shim process is requesting that an app be launched. Once it has
58 // done so the |profile| and |app_id| are stored, and all future messages
59 // from the app shim relate to the app it launched. It is an error for the
60 // app shim to send multiple launch messages.
61 void OnLaunchApp(std::string profile, std::string app_id);
62
63 bool LaunchAppImpl(const std::string& profile_dir, const std::string& app_id);
64
65 // The AppShimHost listens to the NOTIFICATION_EXTENSION_HOST_DESTROYED
66 // message to detect when the app closes. When that happens, the AppShimHost
67 // closes the channel, which causes the app shim process to quit.
68 virtual void Observe(int type,
69 const content::NotificationSource& source,
70 const content::NotificationDetails& details) OVERRIDE;
71
72 // Closes the channel and destroys the AppShimHost.
73 void Close();
74
75 scoped_ptr<IPC::ChannelProxy> channel_;
76 std::string app_id_;
77 Profile* profile_;
78 content::NotificationRegistrar registrar_;
79 };
80
81 #endif // CHROME_BROWSER_WEB_APPLICATIONS_APP_SHIM_HOST_MAC_H_
OLDNEW
« no previous file with comments | « apps/app_shim/OWNERS ('k') | apps/app_shim/app_shim_host_mac.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698