summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui/webui/chrome_web_ui.cc
blob: 9efe48262dae5fdc9dcb1d120aca9dabc603744f (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
61
62
63
64
// 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/ui/webui/chrome_web_ui.h"

#include "base/command_line.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/chrome_switches.h"
#include "content/browser/renderer_host/render_view_host.h"
#include "content/public/browser/web_contents.h"

#if defined(TOOLKIT_VIEWS)
#include "ui/views/widget/widget.h"
#endif

using content::WebContents;

namespace {

// If true, overrides IsMoreWebUI flag.
bool override_more_webui_ = false;

}  // namespace

ChromeWebUI::ChromeWebUI(WebContents* contents)
    : WebUI(contents) {
}

ChromeWebUI::~ChromeWebUI() {
}

Profile* ChromeWebUI::GetProfile() const {
  return Profile::FromBrowserContext(web_contents()->GetBrowserContext());
}

bool ChromeWebUI::CanShowBookmarkBar() const {
  return false;
}

void ChromeWebUI::RenderViewCreated(RenderViewHost* render_view_host) {
  WebUI::RenderViewCreated(render_view_host);

  // Let the WebUI know that we're looking for UI that's optimized for touch
  // input.
  // TODO(rbyers) Figure out the right model for enabling touch-optimized UI
  // (http://crbug.com/105380).
  if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kTouchOptimizedUI))
    render_view_host->SetWebUIProperty("touchOptimized", "true");
}

// static
bool ChromeWebUI::IsMoreWebUI() {
  bool more_webui = CommandLine::ForCurrentProcess()->HasSwitch(
      switches::kUseMoreWebUI) || override_more_webui_;
#if defined(TOOLKIT_VIEWS)
  more_webui |= views::Widget::IsPureViews();
#endif
  return more_webui;
}

void ChromeWebUI::OverrideMoreWebUI(bool use_more_webui) {
  override_more_webui_ = use_more_webui;
}