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

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

Issue 166573005: Rename apps::ShellWindow to apps::AppWindow (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase, nits (rename) Created 6 years, 10 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_restore_service.cc ('k') | apps/app_shim/extension_app_shim_handler_mac.h » ('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/app_shim_handler_mac.h" 5 #include "apps/app_shim/app_shim_handler_mac.h"
6 6
7 #include <map> 7 #include <map>
8 8
9 #include "apps/shell_window_registry.h" 9 #include "apps/app_window_registry.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/memory/singleton.h" 12 #include "base/memory/singleton.h"
13 #include "base/message_loop/message_loop.h" 13 #include "base/message_loop/message_loop.h"
14 #include "chrome/browser/chrome_notification_types.h" 14 #include "chrome/browser/chrome_notification_types.h"
15 #include "chrome/browser/lifetime/application_lifetime.h" 15 #include "chrome/browser/lifetime/application_lifetime.h"
16 #include "chrome/browser/ui/app_list/app_list_service.h" 16 #include "chrome/browser/ui/app_list/app_list_service.h"
17 #include "content/public/browser/notification_observer.h" 17 #include "content/public/browser/notification_observer.h"
18 #include "content/public/browser/notification_registrar.h" 18 #include "content/public/browser/notification_registrar.h"
19 #include "content/public/browser/notification_service.h" 19 #include "content/public/browser/notification_service.h"
20 20
21 namespace apps { 21 namespace apps {
22 22
23 namespace { 23 namespace {
24 24
25 void TerminateIfNoShellWindows() { 25 void TerminateIfNoAppWindows() {
26 bool shell_windows_left = 26 bool app_windows_left =
27 apps::ShellWindowRegistry::IsShellWindowRegisteredInAnyProfile(0); 27 apps::AppWindowRegistry::IsAppWindowRegisteredInAnyProfile(0);
28 if (!shell_windows_left && !AppListService::Get( 28 if (!app_windows_left &&
29 chrome::HOST_DESKTOP_TYPE_NATIVE)->IsAppListVisible()) { 29 !AppListService::Get(chrome::HOST_DESKTOP_TYPE_NATIVE)
30 ->IsAppListVisible()) {
30 chrome::AttemptExit(); 31 chrome::AttemptExit();
31 } 32 }
32 } 33 }
33 34
34 class AppShimHandlerRegistry : public content::NotificationObserver { 35 class AppShimHandlerRegistry : public content::NotificationObserver {
35 public: 36 public:
36 static AppShimHandlerRegistry* GetInstance() { 37 static AppShimHandlerRegistry* GetInstance() {
37 return Singleton<AppShimHandlerRegistry, 38 return Singleton<AppShimHandlerRegistry,
38 LeakySingletonTraits<AppShimHandlerRegistry> >::get(); 39 LeakySingletonTraits<AppShimHandlerRegistry> >::get();
39 } 40 }
(...skipping 14 matching lines...) Expand all
54 return inserted_or_removed; 55 return inserted_or_removed;
55 } 56 }
56 57
57 void SetDefaultHandler(AppShimHandler* handler) { 58 void SetDefaultHandler(AppShimHandler* handler) {
58 DCHECK_NE(default_handler_ == NULL, handler == NULL); 59 DCHECK_NE(default_handler_ == NULL, handler == NULL);
59 default_handler_ = handler; 60 default_handler_ = handler;
60 } 61 }
61 62
62 void MaybeTerminate() { 63 void MaybeTerminate() {
63 if (!browser_opened_ever_) { 64 if (!browser_opened_ever_) {
64 // Post this to give ShellWindows a chance to remove themselves from the 65 // Post this to give AppWindows a chance to remove themselves from the
65 // registry. 66 // registry.
66 base::MessageLoop::current()->PostTask( 67 base::MessageLoop::current()->PostTask(
67 FROM_HERE, 68 FROM_HERE, base::Bind(&TerminateIfNoAppWindows));
68 base::Bind(&TerminateIfNoShellWindows));
69 } 69 }
70 } 70 }
71 71
72 private: 72 private:
73 friend struct DefaultSingletonTraits<AppShimHandlerRegistry>; 73 friend struct DefaultSingletonTraits<AppShimHandlerRegistry>;
74 typedef std::map<std::string, AppShimHandler*> HandlerMap; 74 typedef std::map<std::string, AppShimHandler*> HandlerMap;
75 75
76 AppShimHandlerRegistry() 76 AppShimHandlerRegistry()
77 : default_handler_(NULL), 77 : default_handler_(NULL),
78 browser_opened_ever_(false) { 78 browser_opened_ever_(false) {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 void AppShimHandler::SetDefaultHandler(AppShimHandler* handler) { 126 void AppShimHandler::SetDefaultHandler(AppShimHandler* handler) {
127 AppShimHandlerRegistry::GetInstance()->SetDefaultHandler(handler); 127 AppShimHandlerRegistry::GetInstance()->SetDefaultHandler(handler);
128 } 128 }
129 129
130 // static 130 // static
131 void AppShimHandler::MaybeTerminate() { 131 void AppShimHandler::MaybeTerminate() {
132 AppShimHandlerRegistry::GetInstance()->MaybeTerminate(); 132 AppShimHandlerRegistry::GetInstance()->MaybeTerminate();
133 } 133 }
134 134
135 } // namespace apps 135 } // namespace apps
OLDNEW
« no previous file with comments | « apps/app_restore_service.cc ('k') | apps/app_shim/extension_app_shim_handler_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698