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

Side by Side Diff: chrome/browser/ui/extensions/shell_window.cc

Issue 10409022: Move application lifetime functionality off BrowserList. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 7 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/ui/extensions/shell_window.h" 5 #include "chrome/browser/ui/extensions/shell_window.h"
6 6
7 #include "chrome/browser/ui/browser_list.h"
8 #include "chrome/browser/extensions/extension_process_manager.h" 7 #include "chrome/browser/extensions/extension_process_manager.h"
9 #include "chrome/browser/extensions/extension_tabs_module_constants.h" 8 #include "chrome/browser/extensions/extension_tabs_module_constants.h"
10 #include "chrome/browser/extensions/extension_window_controller.h" 9 #include "chrome/browser/extensions/extension_window_controller.h"
11 #include "chrome/browser/extensions/shell_window_registry.h" 10 #include "chrome/browser/extensions/shell_window_registry.h"
12 #include "chrome/browser/intents/web_intents_util.h" 11 #include "chrome/browser/intents/web_intents_util.h"
12 #include "chrome/browser/lifetime/application_lifetime.h"
13 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
14 #include "chrome/browser/sessions/session_id.h" 14 #include "chrome/browser/sessions/session_id.h"
15 #include "chrome/browser/ui/browser.h" 15 #include "chrome/browser/ui/browser.h"
16 #include "chrome/browser/ui/intents/web_intent_picker_controller.h" 16 #include "chrome/browser/ui/intents/web_intent_picker_controller.h"
17 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 17 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
18 #include "chrome/common/chrome_notification_types.h" 18 #include "chrome/common/chrome_notification_types.h"
19 #include "chrome/common/chrome_view_type.h" 19 #include "chrome/common/chrome_view_type.h"
20 #include "chrome/common/extensions/extension.h" 20 #include "chrome/common/extensions/extension.h"
21 #include "chrome/common/extensions/extension_messages.h" 21 #include "chrome/common/extensions/extension_messages.h"
22 #include "content/public/browser/notification_details.h" 22 #include "content/public/browser/notification_details.h"
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 std::string()); 113 std::string());
114 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, 114 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED,
115 content::Source<Profile>(profile_)); 115 content::Source<Profile>(profile_));
116 // Close when the browser is exiting. 116 // Close when the browser is exiting.
117 // TODO(mihaip): we probably don't want this in the long run (when platform 117 // TODO(mihaip): we probably don't want this in the long run (when platform
118 // apps are no longer tied to the browser process). 118 // apps are no longer tied to the browser process).
119 registrar_.Add(this, content::NOTIFICATION_APP_TERMINATING, 119 registrar_.Add(this, content::NOTIFICATION_APP_TERMINATING,
120 content::NotificationService::AllSources()); 120 content::NotificationService::AllSources());
121 121
122 // Prevent the browser process from shutting down while this window is open. 122 // Prevent the browser process from shutting down while this window is open.
123 BrowserList::StartKeepAlive(); 123 browser::StartKeepAlive();
124 124
125 // Make this window available to the extension API. 125 // Make this window available to the extension API.
126 extension_window_controller_.reset( 126 extension_window_controller_.reset(
127 new internal::ShellWindowController(this, profile_)); 127 new internal::ShellWindowController(this, profile_));
128 128
129 ShellWindowRegistry::Get(profile_)->AddShellWindow(this); 129 ShellWindowRegistry::Get(profile_)->AddShellWindow(this);
130 } 130 }
131 131
132 ShellWindow::~ShellWindow() { 132 ShellWindow::~ShellWindow() {
133 // Unregister now to prevent getting NOTIFICATION_APP_TERMINATING if we're the 133 // Unregister now to prevent getting NOTIFICATION_APP_TERMINATING if we're the
134 // last window open. 134 // last window open.
135 registrar_.RemoveAll(); 135 registrar_.RemoveAll();
136 136
137 ShellWindowRegistry::Get(profile_)->RemoveShellWindow(this); 137 ShellWindowRegistry::Get(profile_)->RemoveShellWindow(this);
138 138
139 // Remove shutdown prevention. 139 // Remove shutdown prevention.
140 BrowserList::EndKeepAlive(); 140 browser::EndKeepAlive();
141 } 141 }
142 142
143 bool ShellWindow::OnMessageReceived(const IPC::Message& message) { 143 bool ShellWindow::OnMessageReceived(const IPC::Message& message) {
144 bool handled = true; 144 bool handled = true;
145 IPC_BEGIN_MESSAGE_MAP(ShellWindow, message) 145 IPC_BEGIN_MESSAGE_MAP(ShellWindow, message)
146 IPC_MESSAGE_HANDLER(ExtensionHostMsg_Request, OnRequest) 146 IPC_MESSAGE_HANDLER(ExtensionHostMsg_Request, OnRequest)
147 IPC_MESSAGE_UNHANDLED(handled = false) 147 IPC_MESSAGE_UNHANDLED(handled = false)
148 IPC_END_MESSAGE_MAP() 148 IPC_END_MESSAGE_MAP()
149 return handled; 149 return handled;
150 } 150 }
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 } 195 }
196 196
197 ExtensionWindowController* ShellWindow::GetExtensionWindowController() const { 197 ExtensionWindowController* ShellWindow::GetExtensionWindowController() const {
198 return extension_window_controller_.get(); 198 return extension_window_controller_.get();
199 } 199 }
200 200
201 void ShellWindow::OnRequest(const ExtensionHostMsg_Request_Params& params) { 201 void ShellWindow::OnRequest(const ExtensionHostMsg_Request_Params& params) {
202 extension_function_dispatcher_.Dispatch(params, 202 extension_function_dispatcher_.Dispatch(params,
203 web_contents_->GetRenderViewHost()); 203 web_contents_->GetRenderViewHost());
204 } 204 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/restart_browser.mm ('k') | chrome/browser/ui/gtk/update_recommended_dialog.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698