summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authormgiuca@chromium.org <mgiuca@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-17 15:54:57 +0000
committermgiuca@chromium.org <mgiuca@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-17 15:54:57 +0000
commit497783ccdd4e96518a6c455b0ced0b9ed0e00cb4 (patch)
tree376b76dec812664c9a06a3b25d8030dc8a9a1be9 /chrome/browser
parent5b779a1aefd60fb6721422b5a0308554c45f641b (diff)
downloadchromium_src-497783ccdd4e96518a6c455b0ced0b9ed0e00cb4.zip
chromium_src-497783ccdd4e96518a6c455b0ced0b9ed0e00cb4.tar.gz
chromium_src-497783ccdd4e96518a6c455b0ced0b9ed0e00cb4.tar.bz2
Refactor code paths into the Create Shortcuts dialog.
Removed BrowserWindow::ShowCreateChromeAppShortcutsDialog -- this no longer makes sense because the dialog can also be launched from the App Launcher which does not use BrowserWindow. chrome::ShowCreateChromeAppShortcutsDialog is now available on all platforms (Views, Cocoa and GTK, not just Views). The New Tab Page now calls this function directly, instead of going through BrowserWindow. This is consistent with how the App Launcher opens this dialog. BUG=307837 Review URL: https://codereview.chromium.org/27490002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@229148 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/ui/browser_dialogs.h8
-rw-r--r--chrome/browser/ui/browser_window.h4
-rw-r--r--chrome/browser/ui/cocoa/browser_window_cocoa.h3
-rw-r--r--chrome/browser/ui/cocoa/browser_window_cocoa.mm16
-rw-r--r--chrome/browser/ui/gtk/browser_window_gtk.cc5
-rw-r--r--chrome/browser/ui/gtk/browser_window_gtk.h3
-rw-r--r--chrome/browser/ui/gtk/create_application_shortcuts_dialog_gtk.cc30
-rw-r--r--chrome/browser/ui/gtk/create_application_shortcuts_dialog_gtk.h17
-rw-r--r--chrome/browser/ui/views/app_list/win/app_list_controller_delegate_win.cc2
-rw-r--r--chrome/browser/ui/views/browser_dialogs.h10
-rw-r--r--chrome/browser/ui/views/frame/browser_view.cc7
-rw-r--r--chrome/browser/ui/views/frame/browser_view.h2
-rw-r--r--chrome/browser/ui/webui/ntp/app_launcher_handler.cc6
-rw-r--r--chrome/browser/web_applications/web_app_mac.mm28
14 files changed, 68 insertions, 73 deletions
diff --git a/chrome/browser/ui/browser_dialogs.h b/chrome/browser/ui/browser_dialogs.h
index c3ad400..72af390 100644
--- a/chrome/browser/ui/browser_dialogs.h
+++ b/chrome/browser/ui/browser_dialogs.h
@@ -77,6 +77,14 @@ void ShowCreateWebAppShortcutsDialog(gfx::NativeWindow parent_window,
content::WebContents* web_contents);
#endif
+// Shows the create chrome app shortcut dialog box.
+// On Mac, this creates a shortcut without prompting.
+// |close_callback| may be null.
+void ShowCreateChromeAppShortcutsDialog(gfx::NativeWindow parent_window,
+ Profile* profile,
+ const extensions::Extension* app,
+ const base::Closure& close_callback);
+
// Shows a color chooser that reports to the given WebContents.
content::ColorChooser* ShowColorChooser(content::WebContents* web_contents,
SkColor initial_color);
diff --git a/chrome/browser/ui/browser_window.h b/chrome/browser/ui/browser_window.h
index 2acfbf6..7811ace 100644
--- a/chrome/browser/ui/browser_window.h
+++ b/chrome/browser/ui/browser_window.h
@@ -296,10 +296,6 @@ class BrowserWindow : public ui::BaseWindow {
virtual void HandleKeyboardEvent(
const content::NativeWebKeyboardEvent& event) = 0;
- // Shows the create chrome app shortcut dialog box.
- virtual void ShowCreateChromeAppShortcutsDialog(Profile* profile,
- const extensions::Extension* app) = 0;
-
// Clipboard commands applied to the whole browser window.
virtual void Cut() = 0;
virtual void Copy() = 0;
diff --git a/chrome/browser/ui/cocoa/browser_window_cocoa.h b/chrome/browser/ui/cocoa/browser_window_cocoa.h
index db7c621..0370bc0 100644
--- a/chrome/browser/ui/cocoa/browser_window_cocoa.h
+++ b/chrome/browser/ui/cocoa/browser_window_cocoa.h
@@ -127,9 +127,6 @@ class BrowserWindowCocoa :
bool* is_keyboard_shortcut) OVERRIDE;
virtual void HandleKeyboardEvent(
const content::NativeWebKeyboardEvent& event) OVERRIDE;
- virtual void ShowCreateChromeAppShortcutsDialog(
- Profile* profile,
- const extensions::Extension* app) OVERRIDE;
virtual void Cut() OVERRIDE;
virtual void Copy() OVERRIDE;
virtual void Paste() OVERRIDE;
diff --git a/chrome/browser/ui/cocoa/browser_window_cocoa.mm b/chrome/browser/ui/cocoa/browser_window_cocoa.mm
index d3e9ac8..230ba44 100644
--- a/chrome/browser/ui/cocoa/browser_window_cocoa.mm
+++ b/chrome/browser/ui/cocoa/browser_window_cocoa.mm
@@ -44,7 +44,6 @@
#import "chrome/browser/ui/cocoa/website_settings_bubble_controller.h"
#include "chrome/browser/ui/search/search_model.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
-#include "chrome/browser/ui/web_applications/web_app_ui.h"
#include "chrome/browser/web_applications/web_app.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
@@ -104,13 +103,6 @@ NSPoint GetPointForBubble(content::WebContents* web_contents,
return point;
}
-void CreateShortcuts(const ShellIntegration::ShortcutInfo& shortcut_info) {
- // creation_locations will be ignored by CreatePlatformShortcuts on Mac.
- ShellIntegration::ShortcutLocations creation_locations;
- web_app::CreateShortcuts(shortcut_info, creation_locations,
- web_app::SHORTCUT_CREATION_BY_USER);
-}
-
} // namespace
BrowserWindowCocoa::BrowserWindowCocoa(Browser* browser,
@@ -598,14 +590,6 @@ void BrowserWindowCocoa::HandleKeyboardEvent(
[BrowserWindowUtils handleKeyboardEvent:event.os_event inWindow:window()];
}
-void BrowserWindowCocoa::ShowCreateChromeAppShortcutsDialog(
- Profile* profile, const extensions::Extension* app) {
- // Normally we would show a dialog, but since we always create the app
- // shortcut in /Applications there are no options for the user to choose.
- web_app::UpdateShortcutInfoAndIconForApp(*app, profile,
- base::Bind(&CreateShortcuts));
-}
-
void BrowserWindowCocoa::Cut() {
[NSApp sendAction:@selector(cut:) to:nil from:nil];
}
diff --git a/chrome/browser/ui/gtk/browser_window_gtk.cc b/chrome/browser/ui/gtk/browser_window_gtk.cc
index e108d45..e17c22b 100644
--- a/chrome/browser/ui/gtk/browser_window_gtk.cc
+++ b/chrome/browser/ui/gtk/browser_window_gtk.cc
@@ -1173,11 +1173,6 @@ void BrowserWindowGtk::HandleKeyboardEvent(
gtk_window_activate_key(window_, os_event);
}
-void BrowserWindowGtk::ShowCreateChromeAppShortcutsDialog(
- Profile* profile, const extensions::Extension* app) {
- CreateChromeApplicationShortcutsDialogGtk::Show(window_, profile, app);
-}
-
void BrowserWindowGtk::Cut() {
gtk_window_util::DoCut(
window_, browser_->tab_strip_model()->GetActiveWebContents());
diff --git a/chrome/browser/ui/gtk/browser_window_gtk.h b/chrome/browser/ui/gtk/browser_window_gtk.h
index 5ad7b58..9aeac84 100644
--- a/chrome/browser/ui/gtk/browser_window_gtk.h
+++ b/chrome/browser/ui/gtk/browser_window_gtk.h
@@ -162,9 +162,6 @@ class BrowserWindowGtk
bool* is_keyboard_shortcut) OVERRIDE;
virtual void HandleKeyboardEvent(
const content::NativeWebKeyboardEvent& event) OVERRIDE;
- virtual void ShowCreateChromeAppShortcutsDialog(
- Profile* profile,
- const extensions::Extension* app) OVERRIDE;
virtual void Cut() OVERRIDE;
virtual void Copy() OVERRIDE;
virtual void Paste() OVERRIDE;
diff --git a/chrome/browser/ui/gtk/create_application_shortcuts_dialog_gtk.cc b/chrome/browser/ui/gtk/create_application_shortcuts_dialog_gtk.cc
index c3035cf..b2e14a9 100644
--- a/chrome/browser/ui/gtk/create_application_shortcuts_dialog_gtk.cc
+++ b/chrome/browser/ui/gtk/create_application_shortcuts_dialog_gtk.cc
@@ -56,14 +56,16 @@ void ShowCreateWebAppShortcutsDialog(gfx::NativeWindow parent_window,
new CreateWebApplicationShortcutsDialogGtk(parent_window, web_contents);
}
-} // namespace chrome
-
-void CreateChromeApplicationShortcutsDialogGtk::Show(GtkWindow* parent,
- Profile* profile,
- const Extension* app) {
- new CreateChromeApplicationShortcutsDialogGtk(parent, profile, app);
+void ShowCreateChromeAppShortcutsDialog(
+ gfx::NativeWindow parent_window,
+ Profile* profile,
+ const extensions::Extension* app,
+ const base::Closure& close_callback) {
+ new CreateChromeApplicationShortcutsDialogGtk(parent_window, profile, app,
+ close_callback);
}
+} // namespace chrome
CreateApplicationShortcutsDialogGtk::CreateApplicationShortcutsDialogGtk(
GtkWindow* parent)
@@ -314,10 +316,12 @@ CreateChromeApplicationShortcutsDialogGtk::
CreateChromeApplicationShortcutsDialogGtk(
GtkWindow* parent,
Profile* profile,
- const Extension* app)
- : CreateApplicationShortcutsDialogGtk(parent),
- app_(app),
- profile_path_(profile->GetPath()) {
+ const Extension* app,
+ const base::Closure& close_callback)
+ : CreateApplicationShortcutsDialogGtk(parent),
+ app_(app),
+ profile_path_(profile->GetPath()),
+ close_callback_(close_callback) {
// Place Chrome app shortcuts in the "Chrome Apps" submenu.
shortcut_menu_subdir_ = web_app::GetAppShortcutsSubdirName();
@@ -330,6 +334,12 @@ CreateChromeApplicationShortcutsDialogGtk::
this));
}
+CreateChromeApplicationShortcutsDialogGtk::
+ ~CreateChromeApplicationShortcutsDialogGtk() {
+ if (!close_callback_.is_null())
+ close_callback_.Run();
+}
+
// Called when the app's ShortcutInfo (with icon) is loaded.
void CreateChromeApplicationShortcutsDialogGtk::OnShortcutInfoLoaded(
const ShellIntegration::ShortcutInfo& shortcut_info) {
diff --git a/chrome/browser/ui/gtk/create_application_shortcuts_dialog_gtk.h b/chrome/browser/ui/gtk/create_application_shortcuts_dialog_gtk.h
index 1491b09..434bdf3 100644
--- a/chrome/browser/ui/gtk/create_application_shortcuts_dialog_gtk.h
+++ b/chrome/browser/ui/gtk/create_application_shortcuts_dialog_gtk.h
@@ -112,17 +112,14 @@ class CreateWebApplicationShortcutsDialogGtk
class CreateChromeApplicationShortcutsDialogGtk
: public CreateApplicationShortcutsDialogGtk {
public:
- // Displays the dialog box to create application shortcuts for |app|.
- static void Show(GtkWindow* parent, Profile* profile,
- const extensions::Extension* app);
-
- CreateChromeApplicationShortcutsDialogGtk(GtkWindow* parent,
- Profile* profile,
- const extensions::Extension* app);
-
+ CreateChromeApplicationShortcutsDialogGtk(
+ GtkWindow* parent,
+ Profile* profile,
+ const extensions::Extension* app,
+ const base::Closure& close_callback);
protected:
- virtual ~CreateChromeApplicationShortcutsDialogGtk() {}
+ virtual ~CreateChromeApplicationShortcutsDialogGtk();
virtual void CreateDesktopShortcut(
const ShellIntegration::ShortcutInfo& shortcut_info,
@@ -132,9 +129,9 @@ class CreateChromeApplicationShortcutsDialogGtk
void OnShortcutInfoLoaded(
const ShellIntegration::ShortcutInfo& shortcut_info);
- private:
const extensions::Extension* app_;
base::FilePath profile_path_;
+ base::Closure close_callback_;
DISALLOW_COPY_AND_ASSIGN(CreateChromeApplicationShortcutsDialogGtk);
};
diff --git a/chrome/browser/ui/views/app_list/win/app_list_controller_delegate_win.cc b/chrome/browser/ui/views/app_list/win/app_list_controller_delegate_win.cc
index 74ebeca..be95736 100644
--- a/chrome/browser/ui/views/app_list/win/app_list_controller_delegate_win.cc
+++ b/chrome/browser/ui/views/app_list/win/app_list_controller_delegate_win.cc
@@ -8,9 +8,9 @@
#include "chrome/browser/extensions/extension_system.h"
#include "chrome/browser/ui/app_list/app_list_icon_win.h"
#include "chrome/browser/ui/browser_commands.h"
+#include "chrome/browser/ui/browser_dialogs.h"
#include "chrome/browser/ui/extensions/application_launch.h"
#include "chrome/browser/ui/views/app_list/win/app_list_service_win.h"
-#include "chrome/browser/ui/views/browser_dialogs.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/manifest_handlers/app_launch_info.h"
#include "net/base/url_util.h"
diff --git a/chrome/browser/ui/views/browser_dialogs.h b/chrome/browser/ui/views/browser_dialogs.h
index b7d684f..d1a941f 100644
--- a/chrome/browser/ui/views/browser_dialogs.h
+++ b/chrome/browser/ui/views/browser_dialogs.h
@@ -21,10 +21,6 @@ class FindBar;
class Profile;
class TemplateURL;
-namespace extensions {
-class Extension;
-}
-
namespace chrome {
// Creates and returns a find bar for the given browser window. See FindBarWin.
@@ -40,12 +36,6 @@ void EditSearchEngine(gfx::NativeWindow parent,
EditSearchEngineControllerDelegate* delegate,
Profile* profile);
-// Shows the create chrome app shortcut dialog box.
-void ShowCreateChromeAppShortcutsDialog(gfx::NativeWindow parent_window,
- Profile* profile,
- const extensions::Extension* app,
- const base::Closure& close_callback);
-
} // namespace chrome
#endif // CHROME_BROWSER_UI_VIEWS_BROWSER_DIALOGS_H_
diff --git a/chrome/browser/ui/views/frame/browser_view.cc b/chrome/browser/ui/views/frame/browser_view.cc
index a7dd621..4703151 100644
--- a/chrome/browser/ui/views/frame/browser_view.cc
+++ b/chrome/browser/ui/views/frame/browser_view.cc
@@ -1223,13 +1223,6 @@ void BrowserView::ConfirmBrowserCloseWithPendingDownloads(
GetNativeWindow(), download_count, dialog_type, app_modal, callback);
}
-void BrowserView::ShowCreateChromeAppShortcutsDialog(
- Profile* profile,
- const extensions::Extension* app) {
- chrome::ShowCreateChromeAppShortcutsDialog(
- GetNativeWindow(), profile, app, base::Closure());
-}
-
void BrowserView::UserChangedTheme() {
frame_->FrameTypeChanged();
}
diff --git a/chrome/browser/ui/views/frame/browser_view.h b/chrome/browser/ui/views/frame/browser_view.h
index 9991575..82bc6b3 100644
--- a/chrome/browser/ui/views/frame/browser_view.h
+++ b/chrome/browser/ui/views/frame/browser_view.h
@@ -354,8 +354,6 @@ class BrowserView : public BrowserWindow,
bool* is_keyboard_shortcut) OVERRIDE;
virtual void HandleKeyboardEvent(
const content::NativeWebKeyboardEvent& event) OVERRIDE;
- virtual void ShowCreateChromeAppShortcutsDialog(
- Profile*, const extensions::Extension* app) OVERRIDE;
virtual void Cut() OVERRIDE;
virtual void Copy() OVERRIDE;
virtual void Paste() OVERRIDE;
diff --git a/chrome/browser/ui/webui/ntp/app_launcher_handler.cc b/chrome/browser/ui/webui/ntp/app_launcher_handler.cc
index 2420bc5..022a1a5 100644
--- a/chrome/browser/ui/webui/ntp/app_launcher_handler.cc
+++ b/chrome/browser/ui/webui/ntp/app_launcher_handler.cc
@@ -27,6 +27,7 @@
#include "chrome/browser/favicon/favicon_service_factory.h"
#include "chrome/browser/prefs/scoped_user_pref_update.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/ui/browser_dialogs.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/browser_tabstrip.h"
#include "chrome/browser/ui/browser_window.h"
@@ -602,8 +603,9 @@ void AppLauncherHandler::HandleCreateAppShortcut(const ListValue* args) {
Browser* browser = chrome::FindBrowserWithWebContents(
web_ui()->GetWebContents());
- browser->window()->ShowCreateChromeAppShortcutsDialog(
- browser->profile(), extension);
+ chrome::ShowCreateChromeAppShortcutsDialog(
+ browser->window()->GetNativeWindow(), browser->profile(), extension,
+ base::Closure());
}
void AppLauncherHandler::HandleReorderApps(const ListValue* args) {
diff --git a/chrome/browser/web_applications/web_app_mac.mm b/chrome/browser/web_applications/web_app_mac.mm
index dad22c5..098b432 100644
--- a/chrome/browser/web_applications/web_app_mac.mm
+++ b/chrome/browser/web_applications/web_app_mac.mm
@@ -24,6 +24,8 @@
#include "base/strings/sys_string_conversions.h"
#include "base/strings/utf_string_conversions.h"
#import "chrome/browser/mac/dock.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/ui/web_applications/web_app_ui.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
@@ -338,8 +340,34 @@ ShellIntegration::ShortcutInfo BuildShortcutInfoFromBundle(
return shortcut_info;
}
+void CreateShortcutsAndRunCallback(
+ const base::Closure& close_callback,
+ const ShellIntegration::ShortcutInfo& shortcut_info) {
+ // creation_locations will be ignored by CreatePlatformShortcuts on Mac.
+ ShellIntegration::ShortcutLocations creation_locations;
+ web_app::CreateShortcuts(shortcut_info, creation_locations,
+ web_app::SHORTCUT_CREATION_BY_USER);
+ if (!close_callback.is_null())
+ close_callback.Run();
+}
+
} // namespace
+namespace chrome {
+
+void ShowCreateChromeAppShortcutsDialog(gfx::NativeWindow /*parent_window*/,
+ Profile* profile,
+ const extensions::Extension* app,
+ const base::Closure& close_callback) {
+ // Normally we would show a dialog, but since we always create the app
+ // shortcut in /Applications there are no options for the user to choose.
+ web_app::UpdateShortcutInfoAndIconForApp(
+ *app, profile,
+ base::Bind(&CreateShortcutsAndRunCallback, close_callback));
+}
+
+} // namespace chrome
+
namespace web_app {
WebAppShortcutCreator::WebAppShortcutCreator(