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

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 comments 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
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"
17 #include "content/public/browser/web_contents.h"
tapted 2013/05/27 06:44:29 is this used?
jackhou1 2013/05/28 07:30:22 Nope, removed.
16 #include "ui/base/cocoa/focus_window_set.h" 18 #include "ui/base/cocoa/focus_window_set.h"
17 19
18 namespace apps { 20 namespace apps {
19 21
20 ExtensionAppShimHandler::ExtensionAppShimHandler() {} 22 ExtensionAppShimHandler::ExtensionAppShimHandler() {}
21 23
22 ExtensionAppShimHandler::~ExtensionAppShimHandler() { 24 ExtensionAppShimHandler::~ExtensionAppShimHandler() {
23 for (HostMap::iterator it = hosts_.begin(); it != hosts_.end(); ) { 25 for (HostMap::iterator it = hosts_.begin(); it != hosts_.end(); ) {
24 // Increment the iterator first as OnAppClosed may call back to OnShimClose 26 // Increment the iterator first as OnAppClosed may call back to OnShimClose
25 // and invalidate the iterator. 27 // and invalidate the iterator.
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 68
67 void ExtensionAppShimHandler::OnShimFocus(Host* host) { 69 void ExtensionAppShimHandler::OnShimFocus(Host* host) {
68 if (!host->GetProfile()) 70 if (!host->GetProfile())
69 return; 71 return;
70 72
71 extensions::ShellWindowRegistry* registry = 73 extensions::ShellWindowRegistry* registry =
72 extensions::ShellWindowRegistry::Get(host->GetProfile()); 74 extensions::ShellWindowRegistry::Get(host->GetProfile());
73 const extensions::ShellWindowRegistry::ShellWindowList windows = 75 const extensions::ShellWindowRegistry::ShellWindowList windows =
74 registry->GetShellWindowsForApp(host->GetAppId()); 76 registry->GetShellWindowsForApp(host->GetAppId());
75 std::set<gfx::NativeWindow> native_windows; 77 std::set<gfx::NativeWindow> native_windows;
76 for (extensions::ShellWindowRegistry::const_iterator i = windows.begin(); 78 for (extensions::ShellWindowRegistry::const_iterator it = windows.begin();
77 i != windows.end(); ++i) { 79 it != windows.end(); ++it) {
78 native_windows.insert((*i)->GetNativeWindow()); 80 native_windows.insert((*it)->GetNativeWindow());
79 } 81 }
80 ui::FocusWindowSet(native_windows); 82 ui::FocusWindowSet(native_windows);
81 } 83 }
82 84
85 void ExtensionAppShimHandler::OnShimQuit(Host* host) {
86 if (!host->GetProfile())
87 return;
88
89 extensions::ShellWindowRegistry::ShellWindowList windows =
90 extensions::ShellWindowRegistry::Get(host->GetProfile())->
91 GetShellWindowsForApp(host->GetAppId());
92 for (extensions::ShellWindowRegistry::const_iterator it = windows.begin();
93 it != windows.end(); ++it) {
94 (*it)->GetBaseWindow()->Close();
95 }
96 }
97
83 bool ExtensionAppShimHandler::LaunchApp(Profile* profile, 98 bool ExtensionAppShimHandler::LaunchApp(Profile* profile,
84 const std::string& app_id) { 99 const std::string& app_id) {
85 extensions::ExtensionSystem* extension_system = 100 extensions::ExtensionSystem* extension_system =
86 extensions::ExtensionSystem::Get(profile); 101 extensions::ExtensionSystem::Get(profile);
87 ExtensionServiceInterface* extension_service = 102 ExtensionServiceInterface* extension_service =
88 extension_system->extension_service(); 103 extension_system->extension_service();
89 const extensions::Extension* extension = 104 const extensions::Extension* extension =
90 extension_service->GetExtensionById(app_id, false); 105 extension_service->GetExtensionById(app_id, false);
91 if (!extension) { 106 if (!extension) {
92 LOG(ERROR) << "Attempted to launch nonexistent app with id '" 107 LOG(ERROR) << "Attempted to launch nonexistent app with id '"
(...skipping 28 matching lines...) Expand all
121 } 136 }
122 137
123 void ExtensionAppShimHandler::CloseShim(Profile* profile, 138 void ExtensionAppShimHandler::CloseShim(Profile* profile,
124 const std::string& app_id) { 139 const std::string& app_id) {
125 HostMap::const_iterator it = hosts_.find(make_pair(profile, app_id)); 140 HostMap::const_iterator it = hosts_.find(make_pair(profile, app_id));
126 if (it != hosts_.end()) 141 if (it != hosts_.end())
127 it->second->OnAppClosed(); 142 it->second->OnAppClosed();
128 } 143 }
129 144
130 } // namespace apps 145 } // namespace apps
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698