Add new certificateProvider extension API.
[chromium-blink-merge.git] / chrome / browser / ui / views / ash / chrome_browser_main_extra_parts_ash.cc
blob1f8020c991ca8e0f4c347c10546c8f7c446a9041
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.
5 #include "chrome/browser/ui/views/ash/chrome_browser_main_extra_parts_ash.h"
7 #include "ash/root_window_controller.h"
8 #include "ash/session/session_state_delegate.h"
9 #include "ash/shell.h"
10 #include "base/command_line.h"
11 #include "base/lazy_instance.h"
12 #include "chrome/browser/chrome_browser_main.h"
13 #include "chrome/browser/ui/ash/ash_init.h"
14 #include "chrome/browser/ui/ash/ash_util.h"
15 #include "chrome/browser/ui/views/ash/tab_scrubber.h"
16 #include "chrome/common/chrome_switches.h"
17 #include "ui/aura/env.h"
18 #include "ui/gfx/screen.h"
19 #include "ui/gfx/screen_type_delegate.h"
20 #include "ui/keyboard/keyboard.h"
21 #include "ui/keyboard/keyboard_controller.h"
23 #if defined(OS_CHROMEOS)
24 #include "chrome/browser/ui/views/select_file_dialog_extension.h"
25 #include "chrome/browser/ui/views/select_file_dialog_extension_factory.h"
26 #endif
28 #if !defined(OS_CHROMEOS)
29 #include "ui/shell_dialogs/select_file_dialog.h"
30 #include "ui/shell_dialogs/shell_dialogs_delegate.h"
31 #endif
33 #if defined(OS_WIN)
34 #include "base/win/windows_version.h"
35 #endif
37 #if !defined(OS_CHROMEOS)
38 class ScreenTypeDelegateWin : public gfx::ScreenTypeDelegate {
39 public:
40 ScreenTypeDelegateWin() {}
41 gfx::ScreenType GetScreenTypeForNativeView(gfx::NativeView view) override {
42 return chrome::IsNativeViewInAsh(view) ?
43 gfx::SCREEN_TYPE_ALTERNATE :
44 gfx::SCREEN_TYPE_NATIVE;
46 private:
47 DISALLOW_COPY_AND_ASSIGN(ScreenTypeDelegateWin);
50 class ShellDialogsDelegateWin : public ui::ShellDialogsDelegate {
51 public:
52 ShellDialogsDelegateWin() {}
53 bool IsWindowInMetro(gfx::NativeWindow window) override {
54 #if defined(OS_WIN)
55 if (base::win::GetVersion() < base::win::VERSION_WIN8)
56 return false;
57 #endif
58 return chrome::IsNativeViewInAsh(window);
60 private:
61 DISALLOW_COPY_AND_ASSIGN(ShellDialogsDelegateWin);
64 base::LazyInstance<ShellDialogsDelegateWin> g_shell_dialogs_delegate;
66 #endif
68 ChromeBrowserMainExtraPartsAsh::ChromeBrowserMainExtraPartsAsh() {
71 ChromeBrowserMainExtraPartsAsh::~ChromeBrowserMainExtraPartsAsh() {
74 void ChromeBrowserMainExtraPartsAsh::PreProfileInit() {
75 if (chrome::ShouldOpenAshOnStartup()) {
76 chrome::OpenAsh(gfx::kNullAcceleratedWidget);
78 #if defined(OS_LINUX) && !defined(OS_CHROMEOS)
79 ash::Shell::GetInstance()->CreateShelf();
80 ash::Shell::GetInstance()->ShowShelf();
81 #endif
82 } else {
83 #if !defined(OS_CHROMEOS)
84 gfx::Screen::SetScreenTypeDelegate(new ScreenTypeDelegateWin);
85 ui::SelectFileDialog::SetShellDialogsDelegate(
86 g_shell_dialogs_delegate.Pointer());
87 #endif
89 #if defined(OS_CHROMEOS)
90 // For OS_CHROMEOS, virtual keyboard needs to be initialized before profile
91 // initialized. Otherwise, virtual keyboard extension will not load at login
92 // screen.
93 keyboard::InitializeKeyboard();
94 #endif
96 #if defined(OS_CHROMEOS)
97 ui::SelectFileDialog::SetFactory(new SelectFileDialogExtensionFactory);
98 #endif
101 void ChromeBrowserMainExtraPartsAsh::PostProfileInit() {
102 if (!ash::Shell::HasInstance())
103 return;
105 // Initialize TabScrubber after the Ash Shell has been initialized.
106 TabScrubber::GetInstance();
107 // Activate virtual keyboard after profile is initialized. It depends on the
108 // default profile.
109 ash::Shell::GetPrimaryRootWindowController()->ActivateKeyboard(
110 keyboard::KeyboardController::GetInstance());
113 void ChromeBrowserMainExtraPartsAsh::PostMainMessageLoopRun() {
114 chrome::CloseAsh();