| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_WEB_APPLICATIONS_APP_SHIM_HOST_MAC_H_ | 5 #ifndef CHROME_BROWSER_WEB_APPLICATIONS_APP_SHIM_HOST_MAC_H_ |
| 6 #define CHROME_BROWSER_WEB_APPLICATIONS_APP_SHIM_HOST_MAC_H_ | 6 #define CHROME_BROWSER_WEB_APPLICATIONS_APP_SHIM_HOST_MAC_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "apps/app_shim/app_shim_handler_mac.h" | 10 #include "apps/app_shim/app_shim_handler_mac.h" |
| 11 #include "base/files/file_path.h" |
| 11 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/threading/non_thread_safe.h" | 13 #include "base/threading/non_thread_safe.h" |
| 13 #include "ipc/ipc_listener.h" | 14 #include "ipc/ipc_listener.h" |
| 14 #include "ipc/ipc_sender.h" | 15 #include "ipc/ipc_sender.h" |
| 15 | 16 |
| 16 class Profile; | 17 class Profile; |
| 17 | 18 |
| 18 namespace IPC { | 19 namespace IPC { |
| 19 struct ChannelHandle; | 20 struct ChannelHandle; |
| 20 class ChannelProxy; | 21 class ChannelProxy; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 34 virtual ~AppShimHost(); | 35 virtual ~AppShimHost(); |
| 35 | 36 |
| 36 // Creates a new server-side IPC channel at |handle|, which should contain a | 37 // 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 // file descriptor of a channel created by an IPC::ChannelFactory, and begins |
| 38 // listening for messages on it. | 39 // listening for messages on it. |
| 39 void ServeChannel(const IPC::ChannelHandle& handle); | 40 void ServeChannel(const IPC::ChannelHandle& handle); |
| 40 | 41 |
| 41 protected: | 42 protected: |
| 42 | 43 |
| 43 // Used internally; virtual so they can be mocked for testing. | 44 // Used internally; virtual so they can be mocked for testing. |
| 44 virtual Profile* FetchProfileForDirectory(const std::string& profile_dir); | 45 virtual Profile* FetchProfileForDirectory(const base::FilePath& profile_dir); |
| 45 | 46 |
| 46 // IPC::Listener implementation. | 47 // IPC::Listener implementation. |
| 47 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 48 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
| 48 virtual void OnChannelError() OVERRIDE; | 49 virtual void OnChannelError() OVERRIDE; |
| 49 | 50 |
| 50 // IPC::Sender implementation. | 51 // IPC::Sender implementation. |
| 51 virtual bool Send(IPC::Message* message) OVERRIDE; | 52 virtual bool Send(IPC::Message* message) OVERRIDE; |
| 52 | 53 |
| 53 private: | 54 private: |
| 54 // The app shim process is requesting that an app be launched. Once it has | 55 // The app shim process is requesting to be associated with the given profile |
| 55 // done so the |profile| and |app_id| are stored, and all future messages | 56 // and app_id. Once the profile and app_id are stored, and all future |
| 56 // from the app shim relate to the app it launched. It is an error for the | 57 // messages from the app shim relate to this app. The app is launched |
| 57 // app shim to send multiple launch messages. | 58 // immediately if |launch_now| is true. |
| 58 void OnLaunchApp(std::string profile, std::string app_id); | 59 void OnLaunchApp(base::FilePath profile_dir, |
| 60 std::string app_id, |
| 61 bool launch_now); |
| 59 | 62 |
| 60 // Called when the app shim process notifies that the app should be brought | 63 // Called when the app shim process notifies that the app should be brought |
| 61 // to the front (i.e. the user has clicked on the app's icon in the dock or | 64 // to the front (i.e. the user has clicked on the app's icon in the dock or |
| 62 // Cmd+Tabbed to it.) | 65 // Cmd+Tabbed to it.) |
| 63 void OnFocus(); | 66 void OnFocus(); |
| 64 | 67 |
| 65 // apps::AppShimHandler::Host overrides: | 68 // apps::AppShimHandler::Host overrides: |
| 66 virtual void OnAppClosed() OVERRIDE; | 69 virtual void OnAppClosed() OVERRIDE; |
| 67 virtual Profile* GetProfile() const OVERRIDE; | 70 virtual Profile* GetProfile() const OVERRIDE; |
| 68 virtual std::string GetAppId() const OVERRIDE; | 71 virtual std::string GetAppId() const OVERRIDE; |
| 69 | 72 |
| 70 // Closes the channel and destroys the AppShimHost. | 73 // Closes the channel and destroys the AppShimHost. |
| 71 void Close(); | 74 void Close(); |
| 72 | 75 |
| 73 scoped_ptr<IPC::ChannelProxy> channel_; | 76 scoped_ptr<IPC::ChannelProxy> channel_; |
| 74 std::string app_id_; | 77 std::string app_id_; |
| 75 Profile* profile_; | 78 Profile* profile_; |
| 76 }; | 79 }; |
| 77 | 80 |
| 78 #endif // CHROME_BROWSER_WEB_APPLICATIONS_APP_SHIM_HOST_MAC_H_ | 81 #endif // CHROME_BROWSER_WEB_APPLICATIONS_APP_SHIM_HOST_MAC_H_ |
| OLD | NEW |