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

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: 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(); 170 app_window_.reset();
177 g_instance = NULL;
178 DestroyRootWindow(); 171 DestroyRootWindow();
179 #if defined(OS_CHROMEOS) 172 #if defined(OS_CHROMEOS)
180 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()-> 173 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->
181 RemoveObserver(this); 174 RemoveObserver(this);
182 #endif 175 #endif
183 } 176 }
184 177
185 // static 178 aura::WindowTreeHost* ShellDesktopController::GetHost() {
186 ShellDesktopController* ShellDesktopController::instance() { 179 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 } 180 }
194 181
195 ShellAppWindow* ShellDesktopController::CreateAppWindow( 182 ShellAppWindow* ShellDesktopController::CreateAppWindow(
196 content::BrowserContext* context, 183 content::BrowserContext* context,
197 const Extension* extension) { 184 const Extension* extension) {
198 return app_window_controller_->CreateAppWindow(context, extension); 185 aura::Window* root_window = GetHost()->window();
186
187 app_window_.reset(new ShellAppWindow);
188 app_window_->Init(context, extension, root_window->bounds().size());
189
190 // Attach the web contents view to our window hierarchy.
191 aura::Window* content = app_window_->GetNativeWindow();
192 root_window->AddChild(content);
193 content->Show();
194
195 return app_window_.get();
199 } 196 }
200 197
201 void ShellDesktopController::CloseAppWindows() { 198 void ShellDesktopController::CloseAppWindows() {
202 if (app_window_controller_) 199 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 } 200 }
210 201
211 aura::Window* ShellDesktopController::GetDefaultParent( 202 aura::Window* ShellDesktopController::GetDefaultParent(
212 aura::Window* context, 203 aura::Window* context,
213 aura::Window* window, 204 aura::Window* window,
214 const gfx::Rect& bounds) { 205 const gfx::Rect& bounds) {
215 return host_->window(); 206 return host_->window();
216 } 207 }
217 208
218 #if defined(OS_CHROMEOS) 209 #if defined(OS_CHROMEOS)
(...skipping 17 matching lines...) Expand all
236 void ShellDesktopController::OnHostCloseRequested( 227 void ShellDesktopController::OnHostCloseRequested(
237 const aura::WindowTreeHost* host) { 228 const aura::WindowTreeHost* host) {
238 DCHECK_EQ(host_.get(), host); 229 DCHECK_EQ(host_.get(), host);
239 CloseAppWindows(); 230 CloseAppWindows();
240 base::MessageLoop::current()->PostTask(FROM_HERE, 231 base::MessageLoop::current()->PostTask(FROM_HERE,
241 base::MessageLoop::QuitClosure()); 232 base::MessageLoop::QuitClosure());
242 } 233 }
243 234
244 void ShellDesktopController::InitWindowManager() { 235 void ShellDesktopController::InitWindowManager() {
245 wm::FocusController* focus_controller = 236 wm::FocusController* focus_controller =
246 new wm::FocusController(CreateFocusRules()); 237 new wm::FocusController(new AppsFocusRules());
247 aura::client::SetFocusClient(host_->window(), focus_controller); 238 aura::client::SetFocusClient(host_->window(), focus_controller);
248 host_->window()->AddPreTargetHandler(focus_controller); 239 host_->window()->AddPreTargetHandler(focus_controller);
249 aura::client::SetActivationClient(host_->window(), focus_controller); 240 aura::client::SetActivationClient(host_->window(), focus_controller);
250 focus_client_.reset(focus_controller); 241 focus_client_.reset(focus_controller);
251 242
252 input_method_filter_.reset( 243 input_method_filter_.reset(
253 new wm::InputMethodEventFilter(host_->GetAcceleratedWidget())); 244 new wm::InputMethodEventFilter(host_->GetAcceleratedWidget()));
254 input_method_filter_->SetInputMethodPropertyInRootWindow(host_->window()); 245 input_method_filter_->SetInputMethodPropertyInRootWindow(host_->window());
255 root_window_event_filter_->AddHandler(input_method_filter_.get()); 246 root_window_event_filter_->AddHandler(input_method_filter_.get());
256 247
(...skipping 13 matching lines...) Expand all
270 261
271 user_activity_detector_.reset(new wm::UserActivityDetector); 262 user_activity_detector_.reset(new wm::UserActivityDetector);
272 host_->event_processor()->GetRootTarget()->AddPreTargetHandler( 263 host_->event_processor()->GetRootTarget()->AddPreTargetHandler(
273 user_activity_detector_.get()); 264 user_activity_detector_.get());
274 #if defined(OS_CHROMEOS) 265 #if defined(OS_CHROMEOS)
275 user_activity_notifier_.reset( 266 user_activity_notifier_.reset(
276 new ui::UserActivityPowerManagerNotifier(user_activity_detector_.get())); 267 new ui::UserActivityPowerManagerNotifier(user_activity_detector_.get()));
277 #endif 268 #endif
278 } 269 }
279 270
280 wm::FocusRules* ShellDesktopController::CreateFocusRules() {
281 return new AppsFocusRules();
282 }
283
284 void ShellDesktopController::CreateRootWindow() { 271 void ShellDesktopController::CreateRootWindow() {
285 // Set up basic pieces of ui::wm. 272 // Set up basic pieces of ui::wm.
286 gfx::Size size; 273 gfx::Size size;
287 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); 274 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
288 if (command_line->HasSwitch(switches::kAppShellHostWindowBounds)) { 275 if (command_line->HasSwitch(switches::kAppShellHostWindowBounds)) {
289 const std::string size_str = 276 const std::string size_str =
290 command_line->GetSwitchValueASCII(switches::kAppShellHostWindowBounds); 277 command_line->GetSwitchValueASCII(switches::kAppShellHostWindowBounds);
291 int width, height; 278 int width, height;
292 CHECK_EQ(2, sscanf(size_str.c_str(), "%dx%d", &width, &height)); 279 CHECK_EQ(2, sscanf(size_str.c_str(), "%dx%d", &width, &height));
293 size = gfx::Size(width, height); 280 size = gfx::Size(width, height);
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 if (displays.empty()) 335 if (displays.empty())
349 return gfx::Size(); 336 return gfx::Size();
350 const ui::DisplayMode* mode = displays[0].display->current_mode(); 337 const ui::DisplayMode* mode = displays[0].display->current_mode();
351 return mode ? mode->size() : gfx::Size(); 338 return mode ? mode->size() : gfx::Size();
352 #else 339 #else
353 return gfx::Size(); 340 return gfx::Size();
354 #endif 341 #endif
355 } 342 }
356 343
357 } // namespace extensions 344 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698