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

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

Issue 335003003: Introduces AppActivity and handler of chrome.shell API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 6 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/shell/browser/shell_desktop_controller.h ('k') | apps/shell/test/shell_test.cc » ('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 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 "apps/shell/browser/shell_desktop_controller.h" 5 #include "apps/shell/browser/shell_desktop_controller.h"
6 6
7 #include "apps/shell/browser/shell_app_window.h" 7 #include "apps/shell/browser/shell_app_window_controller.h"
8 #include "content/public/browser/context_factory.h" 8 #include "content/public/browser/context_factory.h"
9 #include "ui/aura/client/cursor_client.h" 9 #include "ui/aura/client/cursor_client.h"
10 #include "ui/aura/client/default_capture_client.h" 10 #include "ui/aura/client/default_capture_client.h"
11 #include "ui/aura/env.h" 11 #include "ui/aura/env.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"
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 display_configurator_->ForceInitialConfigure(0); 166 display_configurator_->ForceInitialConfigure(0);
167 display_configurator_->AddObserver(this); 167 display_configurator_->AddObserver(this);
168 #endif 168 #endif
169 aura::Env::CreateInstance(true); 169 aura::Env::CreateInstance(true);
170 aura::Env::GetInstance()->set_context_factory(content::GetContextFactory()); 170 aura::Env::GetInstance()->set_context_factory(content::GetContextFactory());
171 171
172 g_instance = this; 172 g_instance = this;
173 } 173 }
174 174
175 ShellDesktopController::~ShellDesktopController() { 175 ShellDesktopController::~ShellDesktopController() {
176 // The app window must be explicitly closed before desktop teardown. 176 app_window_controller_.reset();
177 DCHECK(!app_window_);
178 g_instance = NULL; 177 g_instance = NULL;
179 DestroyRootWindow(); 178 DestroyRootWindow();
180 aura::Env::DeleteInstance(); 179 aura::Env::DeleteInstance();
181 } 180 }
182 181
183 // static 182 // static
184 ShellDesktopController* ShellDesktopController::instance() { 183 ShellDesktopController* ShellDesktopController::instance() {
185 return g_instance; 184 return g_instance;
186 } 185 }
187 186
187 void ShellDesktopController::SetAppWindowController(
188 ShellAppWindowController* app_window_controller) {
189 app_window_controller_.reset(app_window_controller);
190 }
191
188 ShellAppWindow* ShellDesktopController::CreateAppWindow( 192 ShellAppWindow* ShellDesktopController::CreateAppWindow(
189 content::BrowserContext* context) { 193 content::BrowserContext* context) {
190 aura::Window* root_window = host_->window(); 194 return app_window_controller_->CreateAppWindow(context);
191
192 app_window_.reset(new ShellAppWindow);
193 app_window_->Init(context, root_window->bounds().size());
194
195 // Attach the web contents view to our window hierarchy.
196 aura::Window* content = app_window_->GetNativeWindow();
197 root_window->AddChild(content);
198 content->Show();
199
200 return app_window_.get();
201 } 195 }
202 196
203 void ShellDesktopController::CloseAppWindow() { app_window_.reset(); } 197 void ShellDesktopController::CloseAppWindows() {
198 if (app_window_controller_)
199 app_window_controller_->CloseAppWindows();
200 }
204 201
205 aura::Window* ShellDesktopController::GetDefaultParent( 202 aura::Window* ShellDesktopController::GetDefaultParent(
206 aura::Window* context, 203 aura::Window* context,
207 aura::Window* window, 204 aura::Window* window,
208 const gfx::Rect& bounds) { 205 const gfx::Rect& bounds) {
209 return host_->window(); 206 return host_->window();
210 } 207 }
211 208
212 #if defined(OS_CHROMEOS) 209 #if defined(OS_CHROMEOS)
213 void ShellDesktopController::OnDisplayModeChanged( 210 void ShellDesktopController::OnDisplayModeChanged(
214 const std::vector<ui::DisplayConfigurator::DisplayState>& displays) { 211 const std::vector<ui::DisplayConfigurator::DisplayState>& displays) {
215 gfx::Size size = GetPrimaryDisplaySize(); 212 gfx::Size size = GetPrimaryDisplaySize();
216 if (!size.IsEmpty()) 213 if (!size.IsEmpty())
217 host_->UpdateRootWindowSize(size); 214 host_->UpdateRootWindowSize(size);
218 } 215 }
219 #endif 216 #endif
220 217
221 void ShellDesktopController::OnHostCloseRequested( 218 void ShellDesktopController::OnHostCloseRequested(
222 const aura::WindowTreeHost* host) { 219 const aura::WindowTreeHost* host) {
223 DCHECK_EQ(host_.get(), host); 220 DCHECK_EQ(host_.get(), host);
224 CloseAppWindow(); 221 CloseAppWindows();
225 base::MessageLoop::current()->PostTask(FROM_HERE, 222 base::MessageLoop::current()->PostTask(FROM_HERE,
226 base::MessageLoop::QuitClosure()); 223 base::MessageLoop::QuitClosure());
227 } 224 }
228 225
229 void ShellDesktopController::CreateRootWindow() { 226 void ShellDesktopController::CreateRootWindow() {
230 test_screen_.reset(aura::TestScreen::Create()); 227 test_screen_.reset(aura::TestScreen::Create());
231 // TODO(jamescook): Replace this with a real Screen implementation. 228 // TODO(jamescook): Replace this with a real Screen implementation.
232 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, test_screen_.get()); 229 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, test_screen_.get());
233 // TODO(mukai): Set up input method. 230 // TODO(mukai): Set up input method.
234 231
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 if (displays.empty()) 316 if (displays.empty())
320 return gfx::Size(); 317 return gfx::Size();
321 const ui::DisplayMode* mode = displays[0].display->current_mode(); 318 const ui::DisplayMode* mode = displays[0].display->current_mode();
322 return mode ? mode->size() : gfx::Size(); 319 return mode ? mode->size() : gfx::Size();
323 #else 320 #else
324 return gfx::Size(); 321 return gfx::Size();
325 #endif 322 #endif
326 } 323 }
327 324
328 } // namespace apps 325 } // namespace apps
OLDNEW
« no previous file with comments | « apps/shell/browser/shell_desktop_controller.h ('k') | apps/shell/test/shell_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698