summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-20 16:47:13 +0000
committerphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-20 16:47:13 +0000
commit0ba5c5e634c8e0282169fd94e119d9e4070b1e6d (patch)
treeacbc48190a9dc739c120f62e97d67a9be9beab4a /chrome
parent797cf0cc490f960fec4bfd3de5a19d23e42c6b84 (diff)
downloadchromium_src-0ba5c5e634c8e0282169fd94e119d9e4070b1e6d.zip
chromium_src-0ba5c5e634c8e0282169fd94e119d9e4070b1e6d.tar.gz
chromium_src-0ba5c5e634c8e0282169fd94e119d9e4070b1e6d.tar.bz2
Add (incomplete) UI for creating application shortcuts on Linux
TEST=none http://crbug.com/17251 Review URL: http://codereview.chromium.org/171082 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@23827 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/app/generated_resources.grd28
-rw-r--r--chrome/browser/gtk/create_application_shortcuts_dialog_gtk.cc69
-rw-r--r--chrome/browser/gtk/create_application_shortcuts_dialog_gtk.h46
-rw-r--r--chrome/browser/tab_contents/tab_contents.cc12
-rw-r--r--chrome/chrome.gyp2
5 files changed, 146 insertions, 11 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd
index 62860a8..9a767a5 100644
--- a/chrome/app/generated_resources.grd
+++ b/chrome/app/generated_resources.grd
@@ -407,7 +407,7 @@ each locale. -->
<message name="IDS_CONTENT_CONTEXT_UNMUTE" desc="The name of the Unmute command for audio and video playback in the content area context menu">
Un&amp;mute
</message>
-
+
<message name="IDS_CONTENT_CONTEXT_FULLSCREEN" desc="The name of the Fullscreen command for the video element in the content area context menu">
&amp;Fullscreen
</message>
@@ -433,7 +433,7 @@ each locale. -->
<message name="IDS_CONTENT_CONTEXT_OPENAUDIONEWTAB" desc="The name of the Open Audio in New Tab command in the content area context menu">
&amp;Open audio in new tab
</message>
-
+
<message name="IDS_CONTENT_CONTEXT_UNDO" desc="The name of the Undo command in the content area context menu">
&amp;Undo
</message>
@@ -1656,7 +1656,7 @@ each locale. -->
<ph name="DOWNLOAD_SIZE">$1<ex>54kB</ex></ph>, Complete
</message>
<message name="IDS_DOWNLOAD_STATUS_CANCELED" desc="Canceled text.">
- Canceled
+ Canceled
</message>
<message name="IDS_DOWNLOAD_BUTTON_OPEN"
desc="Button open text.">
@@ -1798,6 +1798,20 @@ each locale. -->
Create application &amp;shortcuts...
</message>
+ <!-- "Create application shortcuts" dialog (non-Gears) -->
+ <message name="IDS_CREATE_SHORTCUTS_TITLE" desc="Title of the dialog to create application shortcuts for current page.">
+ Create application shortcuts
+ </message>
+ <message name="IDS_CREATE_SHORTCUTS_LABEL" desc="Contents of the main label in the create application shortcuts dialog explaining the dialog.">
+ Create application shortcuts in the following places:
+ </message>
+ <message name="IDS_CREATE_SHORTCUTS_DESKTOP_CHKBOX" desc="Label of the checkbox to create an application shortcut on the desktop.">
+ Desktop
+ </message>
+ <message name="IDS_CREATE_SHORTCUTS_COMMIT" desc="Title of the button to actually create the shortcuts.">
+ Create
+ </message>
+
<!-- SSL error strings -->
<message name="IDS_SEVERAL_SSL_ERRORS" desc="Bubble info header text when there is more than 1 error">
There are several SSL errors on this page:
@@ -2421,7 +2435,7 @@ each locale. -->
<message name="IDS_CONFIRM_MESSAGEBOX_NO_BUTTON_LABEL" desc="Confirm MessageBox Dialog's 'No' button text">
No
</message>
-
+
<!-- Password Manager -->
<message name="IDS_PASSWORD_MANAGER_SAVE_BUTTON" desc="Save button text for password manager">
Save password
@@ -3852,8 +3866,8 @@ each locale. -->
<message name="IDS_NEW_TAB_THEMES_GALLERY_PAGE_TITLE"
desc="Title for the hard coded thumbnail that represents the Google Chrome Themes Gallery page. This is used on the NTP when there aren't enough thumbnails to show.">
Google Chrome Themes Gallery
- </message>
-
+ </message>
+
<!-- New tab page web clips. These are not in use yet -->
<message name="IDS_NEW_TAB_WEB_CLIPS_WEB_CLIPS"
desc="Web Clips module header">
@@ -4703,7 +4717,7 @@ each locale. -->
<!-- Privacy Blacklist -->
<message name="IDS_BLACKLIST_TITLE" desc="Title of the page displayed when a page is blocked.">
- Blocked Resource
+ Blocked Resource
</message>
<message name="IDS_BLACKLIST_MESSAGE" desc="Message shown instead of a blocked element.">
The following Privacy Blacklists prevented this content from showing:
diff --git a/chrome/browser/gtk/create_application_shortcuts_dialog_gtk.cc b/chrome/browser/gtk/create_application_shortcuts_dialog_gtk.cc
new file mode 100644
index 0000000..6997651
--- /dev/null
+++ b/chrome/browser/gtk/create_application_shortcuts_dialog_gtk.cc
@@ -0,0 +1,69 @@
+// 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.
+
+#include "chrome/browser/gtk/create_application_shortcuts_dialog_gtk.h"
+
+#include "app/l10n_util.h"
+#include "chrome/browser/shell_integration.h"
+#include "chrome/common/gtk_util.h"
+#include "grit/generated_resources.h"
+
+// static
+void CreateApplicationShortcutsDialogGtk::Show(GtkWindow* parent,
+ const GURL& url,
+ const string16& title) {
+ new CreateApplicationShortcutsDialogGtk(parent, url, title);
+}
+
+CreateApplicationShortcutsDialogGtk::CreateApplicationShortcutsDialogGtk(
+ GtkWindow* parent, const GURL& url, const string16& title)
+ : url_(url),
+ title_(title) {
+ // Build the dialog.
+ GtkWidget* dialog = gtk_dialog_new_with_buttons(
+ l10n_util::GetStringUTF8(IDS_CREATE_SHORTCUTS_TITLE).c_str(),
+ parent,
+ (GtkDialogFlags) (GTK_DIALOG_MODAL | GTK_DIALOG_NO_SEPARATOR),
+ GTK_STOCK_CANCEL,
+ GTK_RESPONSE_REJECT,
+ NULL);
+ gtk_util::AddButtonToDialog(dialog,
+ l10n_util::GetStringUTF8(IDS_CREATE_SHORTCUTS_COMMIT).c_str(),
+ GTK_STOCK_APPLY, GTK_RESPONSE_ACCEPT);
+
+ GtkWidget* content_area = GTK_DIALOG(dialog)->vbox;
+ gtk_box_set_spacing(GTK_BOX(content_area), gtk_util::kContentAreaSpacing);
+
+ GtkWidget* vbox = gtk_vbox_new(FALSE, gtk_util::kControlSpacing);
+ gtk_container_add(GTK_CONTAINER(content_area), vbox);
+
+ // Label on top of the checkboxes.
+ GtkWidget* description = gtk_label_new(
+ l10n_util::GetStringUTF8(IDS_CREATE_SHORTCUTS_LABEL).c_str());
+ gtk_misc_set_alignment(GTK_MISC(description), 0, 0);
+ gtk_box_pack_start(GTK_BOX(vbox), description, FALSE, FALSE, 0);
+
+ // Desktop checkbox.
+ desktop_checkbox_ = gtk_check_button_new_with_label(
+ l10n_util::GetStringUTF8(IDS_CREATE_SHORTCUTS_DESKTOP_CHKBOX).c_str());
+ gtk_box_pack_start(GTK_BOX(vbox), desktop_checkbox_, FALSE, FALSE, 0);
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(desktop_checkbox_), true);
+
+ g_signal_connect(dialog, "response",
+ G_CALLBACK(HandleOnResponseDialog), this);
+ gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE);
+ gtk_widget_show_all(dialog);
+}
+
+void CreateApplicationShortcutsDialogGtk::OnDialogResponse(GtkWidget* widget,
+ int response) {
+ if (response == GTK_RESPONSE_ACCEPT) {
+ if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(desktop_checkbox_)))
+ ShellIntegration::CreateDesktopShortcut(url_, title_);
+ }
+
+ delete this;
+ gtk_widget_destroy(GTK_WIDGET(widget));
+}
+
diff --git a/chrome/browser/gtk/create_application_shortcuts_dialog_gtk.h b/chrome/browser/gtk/create_application_shortcuts_dialog_gtk.h
new file mode 100644
index 0000000..79b54306
--- /dev/null
+++ b/chrome/browser/gtk/create_application_shortcuts_dialog_gtk.h
@@ -0,0 +1,46 @@
+// 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/string16.h"
+#include "googleurl/src/gurl.h"
+
+typedef struct _GtkWidget GtkWidget;
+typedef struct _GtkWindow GtkWindow;
+
+class CreateApplicationShortcutsDialogGtk {
+ public:
+ // Displays the dialog box to create application shortcuts for |url| with
+ // |title|.
+ static void Show(GtkWindow* parent, const GURL& url, const string16& title);
+
+ private:
+ CreateApplicationShortcutsDialogGtk(GtkWindow* parent, const GURL& url,
+ const string16& title);
+ ~CreateApplicationShortcutsDialogGtk() { }
+
+ // Handler to respond to Ok and Cancel responses from the dialog.
+ static void HandleOnResponseDialog(GtkWidget* widget,
+ int response, CreateApplicationShortcutsDialogGtk* user_data) {
+ user_data->OnDialogResponse(widget, response);
+ }
+
+ void OnDialogResponse(GtkWidget* widget, int response);
+
+ // UI elements.
+ GtkWidget* desktop_checkbox_;
+
+ // Target URL of the shortcut.
+ GURL url_;
+
+ // Visible title of the shortcut.
+ string16 title_;
+
+ DISALLOW_COPY_AND_ASSIGN(CreateApplicationShortcutsDialogGtk);
+};
+
+#endif // CHROME_BROWSER_GTK_CREATE_APPLICATION_SHORTCUTS_DIALOG_GTK_H_
diff --git a/chrome/browser/tab_contents/tab_contents.cc b/chrome/browser/tab_contents/tab_contents.cc
index 5b630cd..9e00de5 100644
--- a/chrome/browser/tab_contents/tab_contents.cc
+++ b/chrome/browser/tab_contents/tab_contents.cc
@@ -45,7 +45,6 @@
#include "chrome/browser/thumbnail_store.h"
#include "chrome/browser/search_engines/template_url_fetcher.h"
#include "chrome/browser/search_engines/template_url_model.h"
-#include "chrome/browser/shell_integration.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/notification_service.h"
#include "chrome/common/page_action.h"
@@ -76,7 +75,12 @@
#if defined(OS_CHROMEOS)
// For GdkScreen
#include <gdk/gdk.h>
-#endif
+#endif // defined(OS_CHROMEOS)
+
+#if defined(OS_LINUX)
+#include "chrome/browser/gtk/create_application_shortcuts_dialog_gtk.h"
+#endif // defined(OS_LINUX)
+
// Cross-Site Navigations
//
// If a TabContents is told to navigate to a different web site (as determined
@@ -756,8 +760,8 @@ void TabContents::CreateShortcut() {
return;
#if defined(OS_LINUX)
- // TODO(phajdan.jr): Finish creating shortcuts (UI etc).
- ShellIntegration::CreateDesktopShortcut(GetURL(), GetTitle());
+ CreateApplicationShortcutsDialogGtk::Show(view()->GetTopLevelNativeWindow(),
+ GetURL(), GetTitle());
#else
// We only allow one pending install request. By resetting the page id we
// effectively cancel the pending install request.
diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp
index 1d39eca..f699624 100644
--- a/chrome/chrome.gyp
+++ b/chrome/chrome.gyp
@@ -1157,6 +1157,8 @@
'browser/gtk/clear_browsing_data_dialog_gtk.h',
'browser/gtk/constrained_window_gtk.cc',
'browser/gtk/constrained_window_gtk.h',
+ 'browser/gtk/create_application_shortcuts_dialog_gtk.cc',
+ 'browser/gtk/create_application_shortcuts_dialog_gtk.h',
'browser/gtk/custom_button.cc',
'browser/gtk/custom_button.h',
'browser/gtk/dialogs_gtk.cc',