OLD | NEW |
(Empty) | |
| 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 "ui/app_list/views/views_demo_app.h" |
| 6 |
| 7 #include "ui/aura/env.h" |
| 8 #include "ui/aura/window.h" |
| 9 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" |
| 10 #include "ui/views/widget/desktop_aura/desktop_screen.h" |
| 11 #include "ui/wm/core/wm_state.h" |
| 12 |
| 13 namespace { |
| 14 |
| 15 // ViewsDelegate implementation to mimic ChromeViewsDelegate, without Chrome. |
| 16 class DemoViewsDelegate : public views::ViewsDelegate { |
| 17 public: |
| 18 DemoViewsDelegate() {} |
| 19 virtual ~DemoViewsDelegate() {} |
| 20 |
| 21 protected: |
| 22 // Overridden from views::ViewsDelegate: |
| 23 virtual void SaveWindowPlacement(const views::Widget* window, |
| 24 const std::string& window_name, |
| 25 const gfx::Rect& bounds, |
| 26 ui::WindowShowState show_state) OVERRIDE {} |
| 27 virtual bool GetSavedWindowPlacement( |
| 28 const views::Widget* widget, |
| 29 const std::string& window_name, |
| 30 gfx::Rect* bounds, |
| 31 ui::WindowShowState* show_state) const OVERRIDE { |
| 32 return false; |
| 33 } |
| 34 virtual void NotifyAccessibilityEvent(views::View* view, |
| 35 ui::AXEvent event_type) OVERRIDE {} |
| 36 virtual void NotifyMenuItemFocused(const base::string16& menu_name, |
| 37 const base::string16& menu_item_name, |
| 38 int item_index, |
| 39 int item_count, |
| 40 bool has_submenu) OVERRIDE {} |
| 41 |
| 42 virtual views::NonClientFrameView* CreateDefaultNonClientFrameView( |
| 43 views::Widget* widget) OVERRIDE { |
| 44 return NULL; |
| 45 } |
| 46 virtual void AddRef() OVERRIDE {} |
| 47 virtual void ReleaseRef() OVERRIDE {} |
| 48 virtual content::WebContents* CreateWebContents( |
| 49 content::BrowserContext* browser_context, |
| 50 content::SiteInstance* site_instance) OVERRIDE { |
| 51 return NULL; |
| 52 } |
| 53 virtual void OnBeforeWidgetInit( |
| 54 views::Widget::InitParams* params, |
| 55 views::internal::NativeWidgetDelegate* delegate) OVERRIDE { |
| 56 if (params->parent == NULL && params->context == NULL && params->top_level) |
| 57 params->native_widget = new views::DesktopNativeWidgetAura(delegate); |
| 58 } |
| 59 virtual base::TimeDelta GetDefaultTextfieldObscuredRevealDuration() OVERRIDE { |
| 60 return base::TimeDelta(); |
| 61 } |
| 62 virtual bool WindowManagerProvidesTitleBar(bool maximized) OVERRIDE { |
| 63 return true; |
| 64 } |
| 65 |
| 66 private: |
| 67 DISALLOW_COPY_AND_ASSIGN(DemoViewsDelegate); |
| 68 }; |
| 69 |
| 70 class ViewsDemoAppAura : public ViewsDemoApp { |
| 71 public: |
| 72 ViewsDemoAppAura(scoped_ptr<ViewsDemoAppDelegate> delegate) |
| 73 delegate_(delegate) { |
| 74 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, |
| 75 views::CreateDesktopScreen()); |
| 76 views::ViewsDelegate::views_delegate = new DemoViewsDelegate; |
| 77 aura::Env::CreateInstance(); |
| 78 } |
| 79 |
| 80 virtual void Run() OVERRIDE { |
| 81 base::MessageLoopForUI message_loop; |
| 82 delegate_->Run(); |
| 83 } |
| 84 |
| 85 private: |
| 86 wm::WMState wm_state; |
| 87 base::scoped_nsobject<CocoaDemoAppImpl> impl_; |
| 88 scoped_ptr<ViewsDemoAppDelegate> delegate_; |
| 89 |
| 90 DISALLOW_COPY_AND_ASSIGN(ViewsDemoAppAura); |
| 91 }; |
| 92 } |
| 93 |
| 94 // static |
| 95 scoped_ptr<ViewsDemoApp> ViewsDemoApp::Create( |
| 96 scoped_ptr<ViewsDemoAppDelegate> delegate) { |
| 97 return scoped_ptr<ViewsDemoApp>(new ViewsDemoAppAura(delegate.Pass())); |
| 98 } |
OLD | NEW |