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

Unified Diff: apps/app_shim/app_shim_host.h

Issue 12623005: [mac] App shims (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Move app_shim code to apps/ 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 side-by-side diff with in-line comments
Download patch
Index: apps/app_shim/app_shim_host.h
diff --git a/apps/app_shim/app_shim_host.h b/apps/app_shim/app_shim_host.h
new file mode 100644
index 0000000000000000000000000000000000000000..de11305c7e774e8913048b94e50e6f27917d35d5
--- /dev/null
+++ b/apps/app_shim/app_shim_host.h
@@ -0,0 +1,79 @@
+// 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 CHROME_BROWSER_WEB_APPLICATIONS_APP_SHIM_HOST_H_
+#define CHROME_BROWSER_WEB_APPLICATIONS_APP_SHIM_HOST_H_
+
+#include <string>
+
+#include "base/threading/non_thread_safe.h"
+#include "content/public/browser/notification_observer.h"
+#include "content/public/browser/notification_registrar.h"
+#include "ipc/ipc_listener.h"
+#include "ipc/ipc_sender.h"
+
+class Profile;
+
+namespace IPC {
+struct ChannelHandle;
+class ChannelProxy;
+class Message;
+} // namespace IPC
+
+// This is the counterpart to AppShimController in
+// chrome/app/chrome_main_app_mode_mac.mm. The AppShimHost owns itself, and is
+// destroyed when the app it corresponds to is closed or when the channel
+// 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
+class AppShimHost : public IPC::Listener,
+ public IPC::Sender,
+ public content::NotificationObserver,
+ public base::NonThreadSafe {
+ public:
+ AppShimHost();
+ virtual ~AppShimHost();
+
+ // Creates a new server-side IPC channel at |handle|, which should contain a
+ // file descriptor of a channel created by an IPC::ChannelFactory, and begins
+ // listening for messages on it.
+ void ServeChannel(const IPC::ChannelHandle& handle);
+
+ 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.
+ const Profile* profile() { return profile_; }
+
+ protected:
+ // Used internally; virtual so they can be mocked for testing.
+ virtual Profile* FetchProfileForDirectory(const std::string& profile_dir);
+ virtual bool LaunchApp(Profile* profile, const std::string& app_id);
+
+ // IPC::Listener implementation.
+ virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
+
+ // IPC::Sender implementation.
+ virtual bool Send(IPC::Message* message) OVERRIDE;
+
+ private:
+ // The app shim process is requesting that an app be launched. Once it has
+ // 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.
+ // the app shim relate to the app it launched. It is an error for the app
+ // shim to send multiple launch messages.
+ void OnLaunchApp(std::string profile, std::string app_id);
+
+ bool LaunchAppImpl(const std::string& profile_dir, const std::string& app_id);
+
+ // 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.
+ // the app shim to tell it to quit.
+ virtual void Observe(int type,
+ const content::NotificationSource& source,
+ const content::NotificationDetails& details) OVERRIDE;
+
+ // Closes the channel and destroys the AppShimHost.
+ void Close();
+
+ IPC::ChannelProxy* channel_;
+ std::string app_id_;
+ Profile* profile_;
+ content::NotificationRegistrar registrar_;
+};
+
+#endif // CHROME_BROWSER_WEB_APPLICATIONS_APP_SHIM_HOST_H_

Powered by Google App Engine
This is Rietveld 408576698