1// Copyright 2014 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 "chrome/browser/chromeos/set_time_dialog.h"
6
7#include "chrome/browser/profiles/profile_manager.h"
8#include "chrome/browser/ui/browser_dialogs.h"
9#include "chrome/common/url_constants.h"
10#include "content/public/browser/user_metrics.h"
11#include "grit/generated_resources.h"
12#include "ui/base/l10n/l10n_util.h"
13#include "ui/gfx/size.h"
14
15using content::WebContents;
16using content::WebUIMessageHandler;
17
18namespace chromeos {
19
20namespace {
21
22const int kDefaultWidth = 490;
23const int kDefaultHeight = 235;
24
25}  // namespace
26
27// static
28void SetTimeDialog::ShowDialog(gfx::NativeWindow owning_window) {
29  content::RecordAction(base::UserMetricsAction("Options_SetTimeDialog_Show"));
30  chrome::ShowWebDialog(owning_window,
31                        ProfileManager::GetActiveUserProfile(),
32                        new SetTimeDialog());
33}
34
35SetTimeDialog::SetTimeDialog() {
36}
37
38SetTimeDialog::~SetTimeDialog() {
39}
40
41ui::ModalType SetTimeDialog::GetDialogModalType() const {
42  return ui::MODAL_TYPE_SYSTEM;
43}
44
45base::string16 SetTimeDialog::GetDialogTitle() const {
46  return base::string16();
47}
48
49GURL SetTimeDialog::GetDialogContentURL() const {
50  return GURL(chrome::kChromeUISetTimeURL);
51}
52
53void SetTimeDialog::GetWebUIMessageHandlers(
54    std::vector<WebUIMessageHandler*>* handlers) const {
55}
56
57void SetTimeDialog::GetDialogSize(gfx::Size* size) const {
58  size->SetSize(kDefaultWidth, kDefaultHeight);
59}
60
61std::string SetTimeDialog::GetDialogArgs() const {
62  return std::string();
63}
64
65void SetTimeDialog::OnDialogClosed(const std::string& json_retval) {
66  delete this;
67}
68
69void SetTimeDialog::OnCloseContents(WebContents* source,
70                                    bool* out_close_dialog) {
71  if (out_close_dialog)
72    *out_close_dialog = true;
73}
74
75bool SetTimeDialog::ShouldShowDialogTitle() const {
76  return false;
77}
78
79bool SetTimeDialog::HandleContextMenu(
80    const content::ContextMenuParams& params) {
81  // Disable context menu.
82  return true;
83}
84
85}  // namespace chromeos
86