summaryrefslogtreecommitdiffstats
path: root/chrome/browser/gtk/create_application_shortcuts_dialog_gtk.h
blob: 2e42437e1a48078e95be1ed8952d3e65f2930726 (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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
// Copyright (c) 2009 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.

#ifndef CHROME_BROWSER_GTK_CREATE_APPLICATION_SHORTCUTS_DIALOG_GTK_H_
#define CHROME_BROWSER_GTK_CREATE_APPLICATION_SHORTCUTS_DIALOG_GTK_H_

#include "base/basictypes.h"
#include "base/ref_counted.h"
#include "base/string16.h"
#include "chrome/browser/chrome_thread.h"
#include "chrome/browser/shell_integration.h"
#include "googleurl/src/gurl.h"
#include "third_party/skia/include/core/SkBitmap.h"

typedef struct _GtkWidget GtkWidget;
typedef struct _GtkWindow GtkWindow;

class CreateApplicationShortcutsDialogGtk
    : public base::RefCountedThreadSafe<CreateApplicationShortcutsDialogGtk,
                                        ChromeThread::DeleteOnUIThread> {
 public:
  // Displays the dialog box to create application shortcuts for |url| with
  // |title|.
  static void Show(GtkWindow* parent,
                   const GURL& url,
                   const string16& title,
                   const SkBitmap& favicon);

 private:
  friend class ChromeThread;
  friend class DeleteTask<CreateApplicationShortcutsDialogGtk>;

  CreateApplicationShortcutsDialogGtk(GtkWindow* parent,
                                      const GURL& url,
                                      const string16& title,
                                      const SkBitmap& favicon);
  ~CreateApplicationShortcutsDialogGtk();

  static void HandleOnResponseCreateDialog(GtkWidget* widget,
      int response, CreateApplicationShortcutsDialogGtk* user_data) {
    user_data->OnCreateDialogResponse(widget, response);
  }
  static void HandleOnResponseErrorDialog(GtkWidget* widget,
      int response, CreateApplicationShortcutsDialogGtk* user_data) {
    user_data->OnErrorDialogResponse(widget, response);
  }

  void OnCreateDialogResponse(GtkWidget* widget, int response);
  void OnErrorDialogResponse(GtkWidget* widget, int response);

  void CreateDesktopShortcut(
      const ShellIntegration::ShortcutInfo& shortcut_info);
  void ShowErrorDialog();

  // UI elements.
  GtkWidget* desktop_checkbox_;
  GtkWidget* menu_checkbox_;

  // Target URL of the shortcut.
  GURL url_;

  // Visible title of the shortcut.
  string16 title_;

  // The favicon of the tab contents, used to set the icon on the desktop.
  SkBitmap favicon_;

  // Dialog box that allows the user to create an application shortcut.
  GtkWidget* create_dialog_;

  // Dialog box that shows the error message.
  GtkWidget* error_dialog_;

  DISALLOW_COPY_AND_ASSIGN(CreateApplicationShortcutsDialogGtk);
};

#endif  // CHROME_BROWSER_GTK_CREATE_APPLICATION_SHORTCUTS_DIALOG_GTK_H_