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

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

Issue 9845003: Pass command line arguments onto platform apps which provide the right intent. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Include files Created 8 years, 9 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
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"
10 #include "chrome/browser/extensions/platform_app_intent_dispatcher.h"
11 #include "chrome/browser/profiles/profile.h" 11 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/browser/ui/browser_list.h"
12 #include "chrome/common/chrome_notification_types.h" 13 #include "chrome/common/chrome_notification_types.h"
13 #include "chrome/common/extensions/extension.h" 14 #include "chrome/common/extensions/extension.h"
14 #include "content/public/browser/notification_details.h" 15 #include "content/public/browser/notification_details.h"
15 #include "content/public/browser/notification_service.h" 16 #include "content/public/browser/notification_service.h"
16 #include "content/public/browser/notification_source.h" 17 #include "content/public/browser/notification_source.h"
17 #include "content/public/browser/notification_types.h" 18 #include "content/public/browser/notification_types.h"
18 19
19 namespace internal { 20 namespace internal {
20 21
21 class ShellWindowController : public ExtensionWindowController { 22 class ShellWindowController : public ExtensionWindowController {
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 break; 112 break;
112 } 113 }
113 case content::NOTIFICATION_APP_TERMINATING: 114 case content::NOTIFICATION_APP_TERMINATING:
114 Close(); 115 Close();
115 break; 116 break;
116 default: 117 default:
117 NOTREACHED() << "Received unexpected notification"; 118 NOTREACHED() << "Received unexpected notification";
118 } 119 }
119 } 120 }
120 121
122 void ShellWindow::RenderViewCreated(content::RenderViewHost* render_view_host) {
123 extensions::DispatchPlatformAppIntentData(host_.get());
124 }
125
121 ShellWindow::ShellWindow(ExtensionHost* host) 126 ShellWindow::ShellWindow(ExtensionHost* host)
122 : host_(host) { 127 : host_(host) {
123 // Close the window in response to window.close() and the like. 128 // Close the window in response to window.close() and the like.
124 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE, 129 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE,
125 content::Source<Profile>(host->profile())); 130 content::Source<Profile>(host->profile()));
126 // Also close if the window if the extension has been unloaded (parallels 131 // Also close if the window if the extension has been unloaded (parallels
127 // NOTIFICATION_EXTENSION_UNLOADED closing the app's tabs in TabStripModel). 132 // NOTIFICATION_EXTENSION_UNLOADED closing the app's tabs in TabStripModel).
128 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, 133 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED,
129 content::Source<Profile>(host->profile())); 134 content::Source<Profile>(host->profile()));
130 // Close when the browser is exiting. 135 // Close when the browser is exiting.
131 // TODO(mihaip): we probably don't want this in the long run (when platform 136 // TODO(mihaip): we probably don't want this in the long run (when platform
132 // apps are no longer tied to the browser process). 137 // apps are no longer tied to the browser process).
133 registrar_.Add(this, content::NOTIFICATION_APP_TERMINATING, 138 registrar_.Add(this, content::NOTIFICATION_APP_TERMINATING,
134 content::NotificationService::AllSources()); 139 content::NotificationService::AllSources());
135 140
136 // Prevent the browser process from shutting down while this window is open. 141 // Prevent the browser process from shutting down while this window is open.
137 BrowserList::StartKeepAlive(); 142 BrowserList::StartKeepAlive();
138 143
139 // Make this window available to the extension API. 144 // Make this window available to the extension API.
140 extension_window_controller_.reset( 145 extension_window_controller_.reset(
141 new internal::ShellWindowController(this, host->profile())); 146 new internal::ShellWindowController(this, host->profile()));
147
148 content::WebContentsObserver::Observe(web_contents());
142 } 149 }
143 150
144 ShellWindow::~ShellWindow() { 151 ShellWindow::~ShellWindow() {
145 // Unregister now to prevent getting NOTIFICATION_APP_TERMINATING if we're the 152 // Unregister now to prevent getting NOTIFICATION_APP_TERMINATING if we're the
146 // last window open. 153 // last window open.
147 registrar_.RemoveAll(); 154 registrar_.RemoveAll();
148 155
149 // Remove shutdown prevention. 156 // Remove shutdown prevention.
150 BrowserList::EndKeepAlive(); 157 BrowserList::EndKeepAlive();
151 } 158 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698