1a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// Copyright 2013 The Chromium Authors. All rights reserved. 2a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 3a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// found in the LICENSE file. 4a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 5a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "content/shell/browser/shell.h" 6a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 7a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "content/public/browser/web_contents.h" 8a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "content/shell/browser/shell_platform_data_aura.h" 9a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "ui/aura/env.h" 10a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "ui/aura/test/test_screen.h" 11a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "ui/aura/window.h" 12a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "ui/aura/window_event_dispatcher.h" 13a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 14a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)namespace content { 15a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 16a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// static 17a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void Shell::PlatformInitialize(const gfx::Size& default_window_size) { 18a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) CHECK(!platform_); 19a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) aura::TestScreen* screen = aura::TestScreen::Create(gfx::Size()); 20a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, screen); 21a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) platform_ = new ShellPlatformDataAura(default_window_size); 22a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)} 23a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 24a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void Shell::PlatformExit() { 25a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) CHECK(platform_); 26a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) delete platform_; 27a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) platform_ = NULL; 28a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) aura::Env::DeleteInstance(); 29a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)} 30a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 31a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void Shell::PlatformCleanUp() { 32a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)} 33a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 34a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void Shell::PlatformEnableUIControl(UIControl control, bool is_enabled) { 35a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)} 36a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 37a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void Shell::PlatformSetAddressBarURL(const GURL& url) { 38a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)} 39a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 40a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void Shell::PlatformSetIsLoading(bool loading) { 41a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)} 42a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 43a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void Shell::PlatformCreateWindow(int width, int height) { 44a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) CHECK(platform_); 45a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) if (!headless_) 46a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) platform_->ShowWindow(); 47a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) platform_->ResizeWindow(gfx::Size(width, height)); 48a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)} 49a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 50a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void Shell::PlatformSetContents() { 51a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) CHECK(platform_); 52a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) aura::Window* content = web_contents_->GetNativeView(); 53a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) aura::Window* parent = platform_->host()->window(); 54a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) if (!parent->Contains(content)) 55a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) parent->AddChild(content); 56a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 57a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) content->Show(); 58a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)} 59a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 60a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void Shell::PlatformResizeSubViews() { 616e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)} 626e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 63a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void Shell::Close() { 64a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) delete this; 65a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)} 66a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 67a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void Shell::PlatformSetTitle(const base::string16& title) { 68a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)} 69a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 70a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)bool Shell::PlatformHandleContextMenu( 71a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) const content::ContextMenuParams& params) { 72a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) return false; 73a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)} 74a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 75a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)} // namespace content 76a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)