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 #include "apps/app_shim/extension_app_shim_handler_mac.h" | 5 #include "apps/app_shim/extension_app_shim_handler_mac.h" |
6 | 6 |
7 #include "apps/app_lifetime_monitor_factory.h" | 7 #include "apps/app_lifetime_monitor_factory.h" |
8 #include "apps/app_shim/app_shim_host_manager_mac.h" | 8 #include "apps/app_shim/app_shim_host_manager_mac.h" |
9 #include "apps/app_shim/app_shim_messages.h" | 9 #include "apps/app_shim/app_shim_messages.h" |
10 #include "apps/app_window.h" | |
11 #include "apps/app_window_registry.h" | |
12 #include "apps/launcher.h" | 10 #include "apps/launcher.h" |
13 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
14 #include "base/logging.h" | 12 #include "base/logging.h" |
15 #include "chrome/browser/browser_process.h" | 13 #include "chrome/browser/browser_process.h" |
16 #include "chrome/browser/chrome_notification_types.h" | 14 #include "chrome/browser/chrome_notification_types.h" |
17 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
18 #include "chrome/browser/profiles/profile_manager.h" | 16 #include "chrome/browser/profiles/profile_manager.h" |
19 #include "chrome/browser/ui/extensions/extension_enable_flow.h" | 17 #include "chrome/browser/ui/extensions/extension_enable_flow.h" |
20 #include "chrome/browser/ui/extensions/extension_enable_flow_delegate.h" | 18 #include "chrome/browser/ui/extensions/extension_enable_flow_delegate.h" |
21 #include "chrome/browser/ui/webui/ntp/core_app_launcher_handler.h" | 19 #include "chrome/browser/ui/webui/ntp/core_app_launcher_handler.h" |
22 #include "chrome/browser/web_applications/web_app_mac.h" | 20 #include "chrome/browser/web_applications/web_app_mac.h" |
23 #include "chrome/common/extensions/extension_constants.h" | 21 #include "chrome/common/extensions/extension_constants.h" |
24 #include "components/crx_file/id_util.h" | 22 #include "components/crx_file/id_util.h" |
25 #include "content/public/browser/notification_details.h" | 23 #include "content/public/browser/notification_details.h" |
26 #include "content/public/browser/notification_service.h" | 24 #include "content/public/browser/notification_service.h" |
27 #include "content/public/browser/notification_source.h" | 25 #include "content/public/browser/notification_source.h" |
| 26 #include "extensions/browser/app_window/app_window.h" |
| 27 #include "extensions/browser/app_window/app_window_registry.h" |
28 #include "extensions/browser/app_window/native_app_window.h" | 28 #include "extensions/browser/app_window/native_app_window.h" |
29 #include "extensions/browser/extension_host.h" | 29 #include "extensions/browser/extension_host.h" |
30 #include "extensions/browser/extension_registry.h" | 30 #include "extensions/browser/extension_registry.h" |
31 #include "ui/base/cocoa/focus_window_set.h" | 31 #include "ui/base/cocoa/focus_window_set.h" |
32 | 32 |
| 33 using extensions::AppWindow; |
| 34 using extensions::AppWindowRegistry; |
33 using extensions::ExtensionRegistry; | 35 using extensions::ExtensionRegistry; |
34 | 36 |
35 namespace { | 37 namespace { |
36 | 38 |
37 typedef apps::AppWindowRegistry::AppWindowList AppWindowList; | 39 typedef AppWindowRegistry::AppWindowList AppWindowList; |
38 | 40 |
39 void ProfileLoadedCallback(base::Callback<void(Profile*)> callback, | 41 void ProfileLoadedCallback(base::Callback<void(Profile*)> callback, |
40 Profile* profile, | 42 Profile* profile, |
41 Profile::CreateStatus status) { | 43 Profile::CreateStatus status) { |
42 if (status == Profile::CREATE_STATUS_INITIALIZED) { | 44 if (status == Profile::CREATE_STATUS_INITIALIZED) { |
43 callback.Run(profile); | 45 callback.Run(profile); |
44 return; | 46 return; |
45 } | 47 } |
46 | 48 |
47 // This should never get an error since it only loads existing profiles. | 49 // This should never get an error since it only loads existing profiles. |
48 DCHECK_EQ(Profile::CREATE_STATUS_CREATED, status); | 50 DCHECK_EQ(Profile::CREATE_STATUS_CREATED, status); |
49 } | 51 } |
50 | 52 |
51 void SetAppHidden(Profile* profile, const std::string& app_id, bool hidden) { | 53 void SetAppHidden(Profile* profile, const std::string& app_id, bool hidden) { |
52 AppWindowList windows = | 54 AppWindowList windows = |
53 apps::AppWindowRegistry::Get(profile)->GetAppWindowsForApp(app_id); | 55 AppWindowRegistry::Get(profile)->GetAppWindowsForApp(app_id); |
54 for (AppWindowList::const_reverse_iterator it = windows.rbegin(); | 56 for (AppWindowList::const_reverse_iterator it = windows.rbegin(); |
55 it != windows.rend(); | 57 it != windows.rend(); |
56 ++it) { | 58 ++it) { |
57 if (hidden) | 59 if (hidden) |
58 (*it)->GetBaseWindow()->HideWithApp(); | 60 (*it)->GetBaseWindow()->HideWithApp(); |
59 else | 61 else |
60 (*it)->GetBaseWindow()->ShowWithApp(); | 62 (*it)->GetBaseWindow()->ShowWithApp(); |
61 } | 63 } |
62 } | 64 } |
63 | 65 |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 void ExtensionAppShimHandler::FocusAppForWindow(AppWindow* app_window) { | 257 void ExtensionAppShimHandler::FocusAppForWindow(AppWindow* app_window) { |
256 ExtensionAppShimHandler* handler = GetInstance(); | 258 ExtensionAppShimHandler* handler = GetInstance(); |
257 Profile* profile = Profile::FromBrowserContext(app_window->browser_context()); | 259 Profile* profile = Profile::FromBrowserContext(app_window->browser_context()); |
258 const std::string& app_id = app_window->extension_id(); | 260 const std::string& app_id = app_window->extension_id(); |
259 Host* host = handler->FindHost(profile, app_id); | 261 Host* host = handler->FindHost(profile, app_id); |
260 if (host) { | 262 if (host) { |
261 handler->OnShimFocus(host, | 263 handler->OnShimFocus(host, |
262 APP_SHIM_FOCUS_NORMAL, | 264 APP_SHIM_FOCUS_NORMAL, |
263 std::vector<base::FilePath>()); | 265 std::vector<base::FilePath>()); |
264 } else { | 266 } else { |
265 FocusWindows( | 267 FocusWindows(AppWindowRegistry::Get(profile)->GetAppWindowsForApp(app_id)); |
266 apps::AppWindowRegistry::Get(profile)->GetAppWindowsForApp(app_id)); | |
267 } | 268 } |
268 } | 269 } |
269 | 270 |
270 // static | 271 // static |
271 bool ExtensionAppShimHandler::ActivateAndRequestUserAttentionForWindow( | 272 bool ExtensionAppShimHandler::ActivateAndRequestUserAttentionForWindow( |
272 AppWindow* app_window) { | 273 AppWindow* app_window) { |
273 ExtensionAppShimHandler* handler = GetInstance(); | 274 ExtensionAppShimHandler* handler = GetInstance(); |
274 Profile* profile = Profile::FromBrowserContext(app_window->browser_context()); | 275 Profile* profile = Profile::FromBrowserContext(app_window->browser_context()); |
275 Host* host = handler->FindHost(profile, app_window->extension_id()); | 276 Host* host = handler->FindHost(profile, app_window->extension_id()); |
276 if (host) { | 277 if (host) { |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
547 if (hosts_.empty()) | 548 if (hosts_.empty()) |
548 delegate_->MaybeTerminate(); | 549 delegate_->MaybeTerminate(); |
549 } | 550 } |
550 | 551 |
551 void ExtensionAppShimHandler::OnAppStop(Profile* profile, | 552 void ExtensionAppShimHandler::OnAppStop(Profile* profile, |
552 const std::string& app_id) {} | 553 const std::string& app_id) {} |
553 | 554 |
554 void ExtensionAppShimHandler::OnChromeTerminating() {} | 555 void ExtensionAppShimHandler::OnChromeTerminating() {} |
555 | 556 |
556 } // namespace apps | 557 } // namespace apps |
OLD | NEW |