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

Side by Side Diff: extensions/shell/browser/shell_desktop_controller.cc

Issue 480353006: Separate athena's startup process from AppShell's (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: reformat Created 6 years, 4 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "extensions/shell/browser/shell_desktop_controller.h" 5 #include "extensions/shell/browser/shell_desktop_controller.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "extensions/shell/browser/shell_app_window_controller.h" 8 #include "extensions/shell/browser/shell_app_window.h"
9 #include "extensions/shell/common/switches.h" 9 #include "extensions/shell/common/switches.h"
10 #include "ui/aura/client/cursor_client.h" 10 #include "ui/aura/client/cursor_client.h"
11 #include "ui/aura/client/default_capture_client.h" 11 #include "ui/aura/client/default_capture_client.h"
12 #include "ui/aura/layout_manager.h" 12 #include "ui/aura/layout_manager.h"
13 #include "ui/aura/test/test_screen.h" 13 #include "ui/aura/test/test_screen.h"
14 #include "ui/aura/window.h" 14 #include "ui/aura/window.h"
15 #include "ui/aura/window_event_dispatcher.h" 15 #include "ui/aura/window_event_dispatcher.h"
16 #include "ui/aura/window_tree_host.h" 16 #include "ui/aura/window_tree_host.h"
17 #include "ui/base/cursor/cursor.h" 17 #include "ui/base/cursor/cursor.h"
18 #include "ui/base/cursor/image_cursors.h" 18 #include "ui/base/cursor/image_cursors.h"
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 virtual ~AppsFocusRules() {} 144 virtual ~AppsFocusRules() {}
145 145
146 virtual bool SupportsChildActivation(aura::Window* window) const OVERRIDE { 146 virtual bool SupportsChildActivation(aura::Window* window) const OVERRIDE {
147 return true; 147 return true;
148 } 148 }
149 149
150 private: 150 private:
151 DISALLOW_COPY_AND_ASSIGN(AppsFocusRules); 151 DISALLOW_COPY_AND_ASSIGN(AppsFocusRules);
152 }; 152 };
153 153
154 ShellDesktopController* g_instance = NULL;
155
156 } // namespace 154 } // namespace
157 155
158 ShellDesktopController::ShellDesktopController() { 156 ShellDesktopController::ShellDesktopController() {
159 CHECK(!g_instance) << "ShellDesktopController already exists";
160
161 #if defined(OS_CHROMEOS) 157 #if defined(OS_CHROMEOS)
162 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()-> 158 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->
163 AddObserver(this); 159 AddObserver(this);
164 display_configurator_.reset(new ui::DisplayConfigurator); 160 display_configurator_.reset(new ui::DisplayConfigurator);
165 display_configurator_->Init(false); 161 display_configurator_->Init(false);
166 display_configurator_->ForceInitialConfigure(0); 162 display_configurator_->ForceInitialConfigure(0);
167 display_configurator_->AddObserver(this); 163 display_configurator_->AddObserver(this);
168 #endif 164 #endif
169 165
170 CreateRootWindow(); 166 CreateRootWindow();
171
172 g_instance = this;
173 } 167 }
174 168
175 ShellDesktopController::~ShellDesktopController() { 169 ShellDesktopController::~ShellDesktopController() {
176 app_window_controller_.reset();
177 g_instance = NULL;
178 DestroyRootWindow(); 170 DestroyRootWindow();
James Cook 2014/08/25 16:56:14 I think you should either app_window_.reset() befo
oshima 2014/08/25 17:29:32 Done.
179 #if defined(OS_CHROMEOS) 171 #if defined(OS_CHROMEOS)
180 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()-> 172 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->
181 RemoveObserver(this); 173 RemoveObserver(this);
182 #endif 174 #endif
183 } 175 }
184 176
185 // static 177 aura::WindowTreeHost* ShellDesktopController::GetHost() {
186 ShellDesktopController* ShellDesktopController::instance() { 178 return host_.get();
187 return g_instance;
188 }
189
190 void ShellDesktopController::SetAppWindowController(
191 ShellAppWindowController* app_window_controller) {
192 app_window_controller_.reset(app_window_controller);
193 } 179 }
194 180
195 ShellAppWindow* ShellDesktopController::CreateAppWindow( 181 ShellAppWindow* ShellDesktopController::CreateAppWindow(
196 content::BrowserContext* context, 182 content::BrowserContext* context,
197 const Extension* extension) { 183 const Extension* extension) {
198 return app_window_controller_->CreateAppWindow(context, extension); 184 aura::Window* root_window = GetHost()->window();
185
186 app_window_.reset(new ShellAppWindow);
187 app_window_->Init(context, extension, root_window->bounds().size());
188
189 // Attach the web contents view to our window hierarchy.
190 aura::Window* content = app_window_->GetNativeWindow();
191 root_window->AddChild(content);
192 content->Show();
193
194 return app_window_.get();
199 } 195 }
200 196
201 void ShellDesktopController::CloseAppWindows() { 197 void ShellDesktopController::CloseAppWindows() {
202 if (app_window_controller_) 198 app_window_.reset();
203 app_window_controller_->CloseAppWindows();
204 }
205
206 void ShellDesktopController::SetDisplayWorkAreaInsets(
207 const gfx::Insets& insets) {
208 test_screen_->SetWorkAreaInsets(insets);
209 } 199 }
210 200
211 aura::Window* ShellDesktopController::GetDefaultParent( 201 aura::Window* ShellDesktopController::GetDefaultParent(
212 aura::Window* context, 202 aura::Window* context,
213 aura::Window* window, 203 aura::Window* window,
214 const gfx::Rect& bounds) { 204 const gfx::Rect& bounds) {
215 return host_->window(); 205 return host_->window();
216 } 206 }
217 207
218 #if defined(OS_CHROMEOS) 208 #if defined(OS_CHROMEOS)
(...skipping 17 matching lines...) Expand all
236 void ShellDesktopController::OnHostCloseRequested( 226 void ShellDesktopController::OnHostCloseRequested(
237 const aura::WindowTreeHost* host) { 227 const aura::WindowTreeHost* host) {
238 DCHECK_EQ(host_.get(), host); 228 DCHECK_EQ(host_.get(), host);
239 CloseAppWindows(); 229 CloseAppWindows();
240 base::MessageLoop::current()->PostTask(FROM_HERE, 230 base::MessageLoop::current()->PostTask(FROM_HERE,
241 base::MessageLoop::QuitClosure()); 231 base::MessageLoop::QuitClosure());
242 } 232 }
243 233
244 void ShellDesktopController::InitWindowManager() { 234 void ShellDesktopController::InitWindowManager() {
245 wm::FocusController* focus_controller = 235 wm::FocusController* focus_controller =
246 new wm::FocusController(CreateFocusRules()); 236 new wm::FocusController(new AppsFocusRules());
247 aura::client::SetFocusClient(host_->window(), focus_controller); 237 aura::client::SetFocusClient(host_->window(), focus_controller);
248 host_->window()->AddPreTargetHandler(focus_controller); 238 host_->window()->AddPreTargetHandler(focus_controller);
249 aura::client::SetActivationClient(host_->window(), focus_controller); 239 aura::client::SetActivationClient(host_->window(), focus_controller);
250 focus_client_.reset(focus_controller); 240 focus_client_.reset(focus_controller);
251 241
252 input_method_filter_.reset( 242 input_method_filter_.reset(
253 new wm::InputMethodEventFilter(host_->GetAcceleratedWidget())); 243 new wm::InputMethodEventFilter(host_->GetAcceleratedWidget()));
254 input_method_filter_->SetInputMethodPropertyInRootWindow(host_->window()); 244 input_method_filter_->SetInputMethodPropertyInRootWindow(host_->window());
255 root_window_event_filter_->AddHandler(input_method_filter_.get()); 245 root_window_event_filter_->AddHandler(input_method_filter_.get());
256 246
(...skipping 13 matching lines...) Expand all
270 260
271 user_activity_detector_.reset(new wm::UserActivityDetector); 261 user_activity_detector_.reset(new wm::UserActivityDetector);
272 host_->event_processor()->GetRootTarget()->AddPreTargetHandler( 262 host_->event_processor()->GetRootTarget()->AddPreTargetHandler(
273 user_activity_detector_.get()); 263 user_activity_detector_.get());
274 #if defined(OS_CHROMEOS) 264 #if defined(OS_CHROMEOS)
275 user_activity_notifier_.reset( 265 user_activity_notifier_.reset(
276 new ui::UserActivityPowerManagerNotifier(user_activity_detector_.get())); 266 new ui::UserActivityPowerManagerNotifier(user_activity_detector_.get()));
277 #endif 267 #endif
278 } 268 }
279 269
280 wm::FocusRules* ShellDesktopController::CreateFocusRules() {
281 return new AppsFocusRules();
282 }
283
284 void ShellDesktopController::CreateRootWindow() { 270 void ShellDesktopController::CreateRootWindow() {
285 // Set up basic pieces of ui::wm. 271 // Set up basic pieces of ui::wm.
286 gfx::Size size; 272 gfx::Size size;
287 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); 273 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
288 if (command_line->HasSwitch(switches::kAppShellHostWindowBounds)) { 274 if (command_line->HasSwitch(switches::kAppShellHostWindowBounds)) {
289 const std::string size_str = 275 const std::string size_str =
290 command_line->GetSwitchValueASCII(switches::kAppShellHostWindowBounds); 276 command_line->GetSwitchValueASCII(switches::kAppShellHostWindowBounds);
291 int width, height; 277 int width, height;
292 CHECK_EQ(2, sscanf(size_str.c_str(), "%dx%d", &width, &height)); 278 CHECK_EQ(2, sscanf(size_str.c_str(), "%dx%d", &width, &height));
293 size = gfx::Size(width, height); 279 size = gfx::Size(width, height);
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 if (displays.empty()) 334 if (displays.empty())
349 return gfx::Size(); 335 return gfx::Size();
350 const ui::DisplayMode* mode = displays[0].display->current_mode(); 336 const ui::DisplayMode* mode = displays[0].display->current_mode();
351 return mode ? mode->size() : gfx::Size(); 337 return mode ? mode->size() : gfx::Size();
352 #else 338 #else
353 return gfx::Size(); 339 return gfx::Size();
354 #endif 340 #endif
355 } 341 }
356 342
357 } // namespace extensions 343 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698