summaryrefslogtreecommitdiffstats
path: root/chrome/browser/chrome_browser_parts_views.cc
blob: 31911082602f37635f19b1814e7cbd79885d8e8b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/chrome_browser_parts_views.h"

#include <string>

#include "base/command_line.h"
#include "chrome/browser/ui/views/chrome_views_delegate.h"
#include "chrome/common/chrome_switches.h"
#include "ui/views/desktop/desktop_window_view.h"
#include "views/widget/widget.h"

ChromeBrowserPartsViews::ChromeBrowserPartsViews()
    : content::BrowserMainParts() {
}

void ChromeBrowserPartsViews::ToolkitInitialized() {
  // The delegate needs to be set before any UI is created so that windows
  // display the correct icon.
  if (!views::ViewsDelegate::views_delegate)
    views::ViewsDelegate::views_delegate = new ChromeViewsDelegate;

  // TODO(beng): Move to WidgetImpl and implement on Windows too!
  if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDebugViewsPaint))
    views::Widget::SetDebugPaintEnabled(true);
}

void ChromeBrowserPartsViews::PreMainMessageLoopRun() {
#if !defined(USE_AURA)
  views::Widget::SetPureViews(
      CommandLine::ForCurrentProcess()->HasSwitch(switches::kUsePureViews));
  // Launch the views desktop shell window and register it as the default parent
  // for all unparented views widgets.
  const CommandLine& command_line = *CommandLine::ForCurrentProcess();
  if (command_line.HasSwitch(switches::kViewsDesktop)) {
    std::string desktop_type_cmd =
        command_line.GetSwitchValueASCII(switches::kViewsDesktop);
    if (desktop_type_cmd != "disabled") {
      views::desktop::DesktopWindowView::DesktopType desktop_type;
      if (desktop_type_cmd == "netbook")
        desktop_type = views::desktop::DesktopWindowView::DESKTOP_NETBOOK;
      else if (desktop_type_cmd == "other")
        desktop_type = views::desktop::DesktopWindowView::DESKTOP_OTHER;
      else
        desktop_type = views::desktop::DesktopWindowView::DESKTOP_DEFAULT;
      views::desktop::DesktopWindowView::CreateDesktopWindow(desktop_type);
      ChromeViewsDelegate* chrome_views_delegate = static_cast
          <ChromeViewsDelegate*>(views::ViewsDelegate::views_delegate);
      chrome_views_delegate->default_parent_view =
        views::desktop::DesktopWindowView::desktop_window_view;
    }
  }
#endif
}

bool ChromeBrowserPartsViews::MainMessageLoopRun(int* result_code) {
  return false;
}