Home | History | Annotate | Download | only in views_content_client
      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
      3 // found in the LICENSE file.
      4 
      5 #include "content/shell/browser/shell_browser_context.h"
      6 #include "ui/aura/env.h"
      7 #include "ui/gfx/screen.h"
      8 #include "ui/views/widget/desktop_aura/desktop_screen.h"
      9 #include "ui/views_content_client/views_content_client.h"
     10 #include "ui/views_content_client/views_content_client_main_parts_aura.h"
     11 
     12 namespace ui {
     13 
     14 namespace {
     15 
     16 class ViewsContentClientMainPartsDesktopAura
     17     : public ViewsContentClientMainPartsAura {
     18  public:
     19   ViewsContentClientMainPartsDesktopAura(
     20       const content::MainFunctionParams& content_params,
     21       ViewsContentClient* views_content_client);
     22   virtual ~ViewsContentClientMainPartsDesktopAura() {}
     23 
     24   // content::BrowserMainParts:
     25   virtual void PreMainMessageLoopRun() OVERRIDE;
     26 
     27  private:
     28   DISALLOW_COPY_AND_ASSIGN(ViewsContentClientMainPartsDesktopAura);
     29 };
     30 
     31 ViewsContentClientMainPartsDesktopAura::ViewsContentClientMainPartsDesktopAura(
     32     const content::MainFunctionParams& content_params,
     33     ViewsContentClient* views_content_client)
     34     : ViewsContentClientMainPartsAura(content_params, views_content_client) {
     35 }
     36 
     37 void ViewsContentClientMainPartsDesktopAura::PreMainMessageLoopRun() {
     38   ViewsContentClientMainPartsAura::PreMainMessageLoopRun();
     39 
     40   aura::Env::CreateInstance(true);
     41   gfx::Screen::SetScreenInstance(
     42       gfx::SCREEN_TYPE_NATIVE, views::CreateDesktopScreen());
     43 
     44   views_content_client()->task().Run(browser_context(), NULL);
     45 }
     46 
     47 }  // namespace
     48 
     49 // static
     50 ViewsContentClientMainParts* ViewsContentClientMainParts::Create(
     51     const content::MainFunctionParams& content_params,
     52     ViewsContentClient* views_content_client) {
     53   return new ViewsContentClientMainPartsDesktopAura(
     54       content_params, views_content_client);
     55 }
     56 
     57 }  // namespace ui
     58