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/files/file_path.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "base/threading/non_thread_safe.h" | 13 #include "base/threading/non_thread_safe.h" |
14 #include "chrome/browser/ui/app_list/profile_loader.h" | |
tapted
2013/06/11 05:31:44
Hmm. This makes something of a circular dependency
jackhou1
2013/06/12 09:41:32
Done.
| |
14 #include "ipc/ipc_listener.h" | 15 #include "ipc/ipc_listener.h" |
15 #include "ipc/ipc_sender.h" | 16 #include "ipc/ipc_sender.h" |
16 | 17 |
17 class Profile; | 18 class Profile; |
18 | 19 |
19 namespace IPC { | 20 namespace IPC { |
20 struct ChannelHandle; | 21 struct ChannelHandle; |
21 class ChannelProxy; | 22 class ChannelProxy; |
22 class Message; | 23 class Message; |
23 } // namespace IPC | 24 } // namespace IPC |
24 | 25 |
25 // This is the counterpart to AppShimController in | 26 // This is the counterpart to AppShimController in |
26 // chrome/app/chrome_main_app_mode_mac.mm. The AppShimHost owns itself, and is | 27 // 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 // destroyed when the app it corresponds to is closed or when the channel |
28 // connected to the app shim is closed. | 29 // connected to the app shim is closed. |
29 class AppShimHost : public IPC::Listener, | 30 class AppShimHost : public IPC::Listener, |
30 public IPC::Sender, | 31 public IPC::Sender, |
31 public apps::AppShimHandler::Host, | 32 public apps::AppShimHandler::Host, |
32 public base::NonThreadSafe { | 33 public base::NonThreadSafe { |
33 public: | 34 public: |
34 AppShimHost(); | 35 AppShimHost(); |
35 virtual ~AppShimHost(); | 36 virtual ~AppShimHost(); |
36 | 37 |
37 // Creates a new server-side IPC channel at |handle|, which should contain a | 38 // 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 // file descriptor of a channel created by an IPC::ChannelFactory, and begins |
39 // listening for messages on it. | 40 // listening for messages on it. |
40 void ServeChannel(const IPC::ChannelHandle& handle); | 41 void ServeChannel(const IPC::ChannelHandle& handle); |
41 | 42 |
42 protected: | 43 protected: |
44 virtual void LoadProfile(const base::FilePath& profile_dir, | |
45 base::Callback<void(Profile*)> callback); | |
43 | 46 |
44 // Used internally; virtual so they can be mocked for testing. | 47 virtual void LaunchAppWithProfile(const std::string& app_id, |
45 virtual Profile* FetchProfileForDirectory(const base::FilePath& profile_dir); | 48 apps::AppShimLaunchType launch_type, |
49 Profile* profile); | |
46 | 50 |
47 // IPC::Listener implementation. | 51 // IPC::Listener implementation. |
48 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 52 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
49 virtual void OnChannelError() OVERRIDE; | 53 virtual void OnChannelError() OVERRIDE; |
50 | 54 |
51 // IPC::Sender implementation. | 55 // IPC::Sender implementation. |
52 virtual bool Send(IPC::Message* message) OVERRIDE; | 56 virtual bool Send(IPC::Message* message) OVERRIDE; |
53 | 57 |
54 private: | 58 private: |
55 // The app shim process is requesting to be associated with the given profile | 59 // The app shim process is requesting to be associated with the given profile |
(...skipping 16 matching lines...) Expand all Loading... | |
72 virtual void OnAppClosed() OVERRIDE; | 76 virtual void OnAppClosed() OVERRIDE; |
73 virtual Profile* GetProfile() const OVERRIDE; | 77 virtual Profile* GetProfile() const OVERRIDE; |
74 virtual std::string GetAppId() const OVERRIDE; | 78 virtual std::string GetAppId() const OVERRIDE; |
75 | 79 |
76 // Closes the channel and destroys the AppShimHost. | 80 // Closes the channel and destroys the AppShimHost. |
77 void Close(); | 81 void Close(); |
78 | 82 |
79 scoped_ptr<IPC::ChannelProxy> channel_; | 83 scoped_ptr<IPC::ChannelProxy> channel_; |
80 std::string app_id_; | 84 std::string app_id_; |
81 Profile* profile_; | 85 Profile* profile_; |
86 ProfileLoader profile_loader_; | |
87 base::WeakPtrFactory<AppShimHost> weak_factory_; | |
82 }; | 88 }; |
83 | 89 |
84 #endif // CHROME_BROWSER_WEB_APPLICATIONS_APP_SHIM_HOST_MAC_H_ | 90 #endif // CHROME_BROWSER_WEB_APPLICATIONS_APP_SHIM_HOST_MAC_H_ |
OLD | NEW |