OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2012 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 "ash/shell/content_client/shell_browser_main_parts.h" |
| 6 |
| 7 #include "ash/shell/shell_delegate_impl.h" |
| 8 #include "ash/shell/window_watcher.h" |
| 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" |
| 11 #include "base/i18n/icu_util.h" |
| 12 #include "base/message_loop.h" |
| 13 #include "base/string_number_conversions.h" |
| 14 #include "base/threading/thread.h" |
| 15 #include "base/threading/thread_restrictions.h" |
| 16 #include "content/public/common/content_switches.h" |
| 17 #include "content/shell/shell.h" |
| 18 #include "content/shell/shell_browser_context.h" |
| 19 #include "content/shell/shell_devtools_delegate.h" |
| 20 #include "content/shell/shell_switches.h" |
| 21 #include "googleurl/src/gurl.h" |
| 22 #include "net/base/net_module.h" |
| 23 #include "ui/aura/client/stacking_client.h" |
| 24 #include "ui/aura/env.h" |
| 25 #include "ui/aura/root_window.h" |
| 26 #include "ui/aura/window.h" |
| 27 #include "ui/base/clipboard/clipboard.h" |
| 28 #include "ui/base/resource/resource_bundle.h" |
| 29 #include "ui/base/ui_base_paths.h" |
| 30 #include "ui/gfx/compositor/compositor.h" |
| 31 #include "ui/gfx/compositor/test/compositor_test_support.h" |
| 32 #include "ui/views/test/test_views_delegate.h" |
| 33 #include "ui/views/focus/accelerator_handler.h" |
| 34 |
| 35 namespace ash { |
| 36 namespace shell { |
| 37 void InitWindowTypeLauncher(); |
| 38 |
| 39 namespace { |
| 40 class ShellViewsDelegate : public views::TestViewsDelegate { |
| 41 public: |
| 42 ShellViewsDelegate() {} |
| 43 virtual ~ShellViewsDelegate() {} |
| 44 |
| 45 // Overridden from views::TestViewsDelegate: |
| 46 virtual views::NonClientFrameView* CreateDefaultNonClientFrameView( |
| 47 views::Widget* widget) OVERRIDE { |
| 48 return ash::Shell::GetInstance()->CreateDefaultNonClientFrameView(widget); |
| 49 } |
| 50 bool UseTransparentWindows() const OVERRIDE { |
| 51 // Ash uses transparent window frames. |
| 52 return true; |
| 53 } |
| 54 |
| 55 private: |
| 56 DISALLOW_COPY_AND_ASSIGN(ShellViewsDelegate); |
| 57 }; |
| 58 |
| 59 } // namespace |
| 60 |
| 61 ShellBrowserMainParts::ShellBrowserMainParts( |
| 62 const content::MainFunctionParams& parameters) |
| 63 : BrowserMainParts(), |
| 64 devtools_delegate_(NULL) { |
| 65 } |
| 66 |
| 67 ShellBrowserMainParts::~ShellBrowserMainParts() { |
| 68 } |
| 69 |
| 70 #if !defined(OS_MACOSX) |
| 71 void ShellBrowserMainParts::PreMainMessageLoopStart() { |
| 72 } |
| 73 #endif |
| 74 |
| 75 int ShellBrowserMainParts::PreCreateThreads() { |
| 76 return 0; |
| 77 } |
| 78 |
| 79 void ShellBrowserMainParts::PreMainMessageLoopRun() { |
| 80 browser_context_.reset(new content::ShellBrowserContext); |
| 81 |
| 82 // A ViewsDelegate is required. |
| 83 if (!views::ViewsDelegate::views_delegate) |
| 84 views::ViewsDelegate::views_delegate = new ShellViewsDelegate; |
| 85 |
| 86 ash::shell::ShellDelegateImpl* delegate = new ash::shell::ShellDelegateImpl; |
| 87 ash::Shell::CreateInstance(delegate); |
| 88 ash::Shell::GetInstance()->set_browser_context(browser_context_.get()); |
| 89 |
| 90 window_watcher_.reset(new ash::shell::WindowWatcher); |
| 91 delegate->SetWatcher(window_watcher_.get()); |
| 92 |
| 93 ash::shell::InitWindowTypeLauncher(); |
| 94 |
| 95 ash::Shell::GetRootWindow()->ShowRootWindow(); |
| 96 } |
| 97 |
| 98 void ShellBrowserMainParts::PostMainMessageLoopRun() { |
| 99 if (devtools_delegate_) |
| 100 devtools_delegate_->Stop(); |
| 101 browser_context_.reset(); |
| 102 |
| 103 window_watcher_.reset(); |
| 104 ash::Shell::DeleteInstance(); |
| 105 aura::Env::DeleteInstance(); |
| 106 } |
| 107 |
| 108 bool ShellBrowserMainParts::MainMessageLoopRun(int* result_code) { |
| 109 MessageLoopForUI::current()->Run(); |
| 110 return true; |
| 111 } |
| 112 |
| 113 ui::Clipboard* ShellBrowserMainParts::GetClipboard() { |
| 114 if (!clipboard_.get()) |
| 115 clipboard_.reset(new ui::Clipboard()); |
| 116 return clipboard_.get(); |
| 117 } |
| 118 |
| 119 } // namespace shell |
| 120 } // namespace ash |
OLD | NEW |