OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 "chrome/browser/ui/views/ash/chrome_browser_main_extra_parts_ash.h" | 5 #include "chrome/browser/ui/views/ash/chrome_browser_main_extra_parts_ash.h" |
6 | 6 |
7 #include "ash/root_window_controller.h" | 7 #include "ash/root_window_controller.h" |
8 #include "ash/session/session_state_delegate.h" | 8 #include "ash/session/session_state_delegate.h" |
9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/lazy_instance.h" | 11 #include "base/lazy_instance.h" |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "build/build_config.h" | 13 #include "build/build_config.h" |
14 #include "chrome/browser/chrome_browser_main.h" | 14 #include "chrome/browser/chrome_browser_main.h" |
15 #include "chrome/browser/ui/ash/ash_init.h" | 15 #include "chrome/browser/ui/ash/ash_init.h" |
16 #include "chrome/browser/ui/ash/ash_util.h" | 16 #include "chrome/browser/ui/ash/ash_util.h" |
17 #include "chrome/browser/ui/views/ash/tab_scrubber.h" | 17 #include "chrome/browser/ui/views/ash/tab_scrubber.h" |
18 #include "chrome/common/chrome_switches.h" | 18 #include "chrome/common/chrome_switches.h" |
19 #include "ui/aura/env.h" | 19 #include "ui/aura/env.h" |
20 #include "ui/gfx/screen.h" | 20 #include "ui/gfx/screen.h" |
21 #include "ui/gfx/screen_type_delegate.h" | |
22 #include "ui/keyboard/content/keyboard.h" | 21 #include "ui/keyboard/content/keyboard.h" |
23 #include "ui/keyboard/keyboard_controller.h" | 22 #include "ui/keyboard/keyboard_controller.h" |
24 | 23 |
25 #if defined(OS_CHROMEOS) | 24 #if defined(OS_CHROMEOS) |
26 #include "chrome/browser/ui/views/select_file_dialog_extension.h" | 25 #include "chrome/browser/ui/views/select_file_dialog_extension.h" |
27 #include "chrome/browser/ui/views/select_file_dialog_extension_factory.h" | 26 #include "chrome/browser/ui/views/select_file_dialog_extension_factory.h" |
28 #endif | 27 #endif |
29 | 28 |
30 #if !defined(OS_CHROMEOS) | 29 #if !defined(OS_CHROMEOS) |
31 #include "ui/shell_dialogs/select_file_dialog.h" | 30 #include "ui/shell_dialogs/select_file_dialog.h" |
32 #include "ui/shell_dialogs/shell_dialogs_delegate.h" | 31 #include "ui/shell_dialogs/shell_dialogs_delegate.h" |
33 #endif | 32 #endif |
34 | 33 |
35 #if defined(OS_WIN) | 34 #if defined(OS_WIN) |
36 #include "base/win/windows_version.h" | 35 #include "base/win/windows_version.h" |
37 #endif | 36 #endif |
38 | 37 |
39 #if !defined(OS_CHROMEOS) | 38 #if !defined(OS_CHROMEOS) |
40 class ScreenTypeDelegateWin : public gfx::ScreenTypeDelegate { | |
41 public: | |
42 ScreenTypeDelegateWin() {} | |
43 gfx::ScreenType GetScreenTypeForNativeView(gfx::NativeView view) override { | |
44 return chrome::IsNativeViewInAsh(view) ? | |
45 gfx::SCREEN_TYPE_ALTERNATE : | |
46 gfx::SCREEN_TYPE_NATIVE; | |
47 } | |
48 private: | |
49 DISALLOW_COPY_AND_ASSIGN(ScreenTypeDelegateWin); | |
50 }; | |
51 | 39 |
52 class ShellDialogsDelegateWin : public ui::ShellDialogsDelegate { | 40 class ShellDialogsDelegateWin : public ui::ShellDialogsDelegate { |
53 public: | 41 public: |
54 ShellDialogsDelegateWin() {} | 42 ShellDialogsDelegateWin() {} |
55 bool IsWindowInMetro(gfx::NativeWindow window) override { | 43 bool IsWindowInMetro(gfx::NativeWindow window) override { |
56 #if defined(OS_WIN) | 44 #if defined(OS_WIN) |
57 if (base::win::GetVersion() < base::win::VERSION_WIN8) | 45 if (base::win::GetVersion() < base::win::VERSION_WIN8) |
58 return false; | 46 return false; |
59 #endif | 47 #endif |
60 return chrome::IsNativeViewInAsh(window); | 48 return chrome::IsNativeViewInAsh(window); |
61 } | 49 } |
62 private: | 50 private: |
63 DISALLOW_COPY_AND_ASSIGN(ShellDialogsDelegateWin); | 51 DISALLOW_COPY_AND_ASSIGN(ShellDialogsDelegateWin); |
64 }; | 52 }; |
65 | 53 |
66 base::LazyInstance<ShellDialogsDelegateWin> g_shell_dialogs_delegate; | 54 base::LazyInstance<ShellDialogsDelegateWin> g_shell_dialogs_delegate; |
67 | 55 |
68 #endif | 56 #endif // !OS_CHROMEOS |
69 | 57 |
70 ChromeBrowserMainExtraPartsAsh::ChromeBrowserMainExtraPartsAsh() { | 58 ChromeBrowserMainExtraPartsAsh::ChromeBrowserMainExtraPartsAsh() { |
71 } | 59 } |
72 | 60 |
73 ChromeBrowserMainExtraPartsAsh::~ChromeBrowserMainExtraPartsAsh() { | 61 ChromeBrowserMainExtraPartsAsh::~ChromeBrowserMainExtraPartsAsh() { |
74 } | 62 } |
75 | 63 |
76 void ChromeBrowserMainExtraPartsAsh::PreProfileInit() { | 64 void ChromeBrowserMainExtraPartsAsh::PreProfileInit() { |
77 if (chrome::ShouldOpenAshOnStartup()) { | 65 if (chrome::ShouldOpenAshOnStartup()) { |
78 chrome::OpenAsh(gfx::kNullAcceleratedWidget); | 66 chrome::OpenAsh(gfx::kNullAcceleratedWidget); |
79 | 67 |
80 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | 68 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
81 ash::Shell::GetInstance()->CreateShelf(); | 69 ash::Shell::GetInstance()->CreateShelf(); |
82 ash::Shell::GetInstance()->ShowShelf(); | 70 ash::Shell::GetInstance()->ShowShelf(); |
83 #endif | 71 #endif |
84 } else { | 72 } else { |
85 #if !defined(OS_CHROMEOS) | 73 #if !defined(OS_CHROMEOS) |
86 gfx::Screen::SetScreenTypeDelegate(new ScreenTypeDelegateWin); | |
87 ui::SelectFileDialog::SetShellDialogsDelegate( | 74 ui::SelectFileDialog::SetShellDialogsDelegate( |
88 g_shell_dialogs_delegate.Pointer()); | 75 g_shell_dialogs_delegate.Pointer()); |
89 #endif | 76 #endif |
90 } | 77 } |
91 #if defined(OS_CHROMEOS) | 78 #if defined(OS_CHROMEOS) |
92 // For OS_CHROMEOS, virtual keyboard needs to be initialized before profile | 79 // For OS_CHROMEOS, virtual keyboard needs to be initialized before profile |
93 // initialized. Otherwise, virtual keyboard extension will not load at login | 80 // initialized. Otherwise, virtual keyboard extension will not load at login |
94 // screen. | 81 // screen. |
95 keyboard::InitializeKeyboard(); | 82 keyboard::InitializeKeyboard(); |
96 #endif | 83 #endif |
(...skipping 11 matching lines...) Expand all Loading... |
108 TabScrubber::GetInstance(); | 95 TabScrubber::GetInstance(); |
109 // Activate virtual keyboard after profile is initialized. It depends on the | 96 // Activate virtual keyboard after profile is initialized. It depends on the |
110 // default profile. | 97 // default profile. |
111 ash::Shell::GetPrimaryRootWindowController()->ActivateKeyboard( | 98 ash::Shell::GetPrimaryRootWindowController()->ActivateKeyboard( |
112 keyboard::KeyboardController::GetInstance()); | 99 keyboard::KeyboardController::GetInstance()); |
113 } | 100 } |
114 | 101 |
115 void ChromeBrowserMainExtraPartsAsh::PostMainMessageLoopRun() { | 102 void ChromeBrowserMainExtraPartsAsh::PostMainMessageLoopRun() { |
116 chrome::CloseAsh(); | 103 chrome::CloseAsh(); |
117 } | 104 } |
OLD | NEW |