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

Side by Side Diff: apps/app_shim/extension_app_shim_handler_mac.cc

Issue 14579005: Close all windows when app shim quits. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comment Created 7 years, 6 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/extension_app_shim_handler_mac.h ('k') | apps/apps.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_shim/app_shim_messages.h" 7 #include "apps/app_shim/app_shim_messages.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "chrome/browser/extensions/extension_host.h" 10 #include "chrome/browser/extensions/extension_host.h"
11 #include "chrome/browser/extensions/extension_service.h" 11 #include "chrome/browser/extensions/extension_service.h"
12 #include "chrome/browser/extensions/extension_system.h" 12 #include "chrome/browser/extensions/extension_system.h"
13 #include "chrome/browser/extensions/shell_window_registry.h" 13 #include "chrome/browser/extensions/shell_window_registry.h"
14 #include "chrome/browser/ui/extensions/application_launch.h" 14 #include "chrome/browser/ui/extensions/application_launch.h"
15 #include "chrome/browser/ui/extensions/native_app_window.h"
15 #include "chrome/browser/ui/extensions/shell_window.h" 16 #include "chrome/browser/ui/extensions/shell_window.h"
16 #include "ui/base/cocoa/focus_window_set.h" 17 #include "ui/base/cocoa/focus_window_set.h"
17 18
18 namespace apps { 19 namespace apps {
19 20
20 ExtensionAppShimHandler::ExtensionAppShimHandler() {} 21 ExtensionAppShimHandler::ExtensionAppShimHandler() {}
21 22
22 ExtensionAppShimHandler::~ExtensionAppShimHandler() { 23 ExtensionAppShimHandler::~ExtensionAppShimHandler() {
23 for (HostMap::iterator it = hosts_.begin(); it != hosts_.end(); ) { 24 for (HostMap::iterator it = hosts_.begin(); it != hosts_.end(); ) {
24 // Increment the iterator first as OnAppClosed may call back to OnShimClose 25 // Increment the iterator first as OnAppClosed may call back to OnShimClose
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 67
67 void ExtensionAppShimHandler::OnShimFocus(Host* host) { 68 void ExtensionAppShimHandler::OnShimFocus(Host* host) {
68 if (!host->GetProfile()) 69 if (!host->GetProfile())
69 return; 70 return;
70 71
71 extensions::ShellWindowRegistry* registry = 72 extensions::ShellWindowRegistry* registry =
72 extensions::ShellWindowRegistry::Get(host->GetProfile()); 73 extensions::ShellWindowRegistry::Get(host->GetProfile());
73 const extensions::ShellWindowRegistry::ShellWindowList windows = 74 const extensions::ShellWindowRegistry::ShellWindowList windows =
74 registry->GetShellWindowsForApp(host->GetAppId()); 75 registry->GetShellWindowsForApp(host->GetAppId());
75 std::set<gfx::NativeWindow> native_windows; 76 std::set<gfx::NativeWindow> native_windows;
76 for (extensions::ShellWindowRegistry::const_iterator i = windows.begin(); 77 for (extensions::ShellWindowRegistry::const_iterator it = windows.begin();
77 i != windows.end(); ++i) { 78 it != windows.end(); ++it) {
78 native_windows.insert((*i)->GetNativeWindow()); 79 native_windows.insert((*it)->GetNativeWindow());
79 } 80 }
80 ui::FocusWindowSet(native_windows); 81 ui::FocusWindowSet(native_windows);
81 } 82 }
82 83
84 void ExtensionAppShimHandler::OnShimQuit(Host* host) {
85 if (!host->GetProfile())
86 return;
87
88 extensions::ShellWindowRegistry::ShellWindowList windows =
89 extensions::ShellWindowRegistry::Get(host->GetProfile())->
90 GetShellWindowsForApp(host->GetAppId());
91 for (extensions::ShellWindowRegistry::const_iterator it = windows.begin();
92 it != windows.end(); ++it) {
93 (*it)->GetBaseWindow()->Close();
94 }
95 }
96
83 bool ExtensionAppShimHandler::LaunchApp(Profile* profile, 97 bool ExtensionAppShimHandler::LaunchApp(Profile* profile,
84 const std::string& app_id) { 98 const std::string& app_id) {
85 extensions::ExtensionSystem* extension_system = 99 extensions::ExtensionSystem* extension_system =
86 extensions::ExtensionSystem::Get(profile); 100 extensions::ExtensionSystem::Get(profile);
87 ExtensionServiceInterface* extension_service = 101 ExtensionServiceInterface* extension_service =
88 extension_system->extension_service(); 102 extension_system->extension_service();
89 const extensions::Extension* extension = 103 const extensions::Extension* extension =
90 extension_service->GetExtensionById(app_id, false); 104 extension_service->GetExtensionById(app_id, false);
91 if (!extension) { 105 if (!extension) {
92 LOG(ERROR) << "Attempted to launch nonexistent app with id '" 106 LOG(ERROR) << "Attempted to launch nonexistent app with id '"
(...skipping 28 matching lines...) Expand all
121 } 135 }
122 136
123 void ExtensionAppShimHandler::CloseShim(Profile* profile, 137 void ExtensionAppShimHandler::CloseShim(Profile* profile,
124 const std::string& app_id) { 138 const std::string& app_id) {
125 HostMap::const_iterator it = hosts_.find(make_pair(profile, app_id)); 139 HostMap::const_iterator it = hosts_.find(make_pair(profile, app_id));
126 if (it != hosts_.end()) 140 if (it != hosts_.end())
127 it->second->OnAppClosed(); 141 it->second->OnAppClosed();
128 } 142 }
129 143
130 } // namespace apps 144 } // namespace apps
OLDNEW
« no previous file with comments | « apps/app_shim/extension_app_shim_handler_mac.h ('k') | apps/apps.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698