diff options
author | xiyuan@chromium.org <xiyuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-17 08:39:51 +0000 |
---|---|---|
committer | xiyuan@chromium.org <xiyuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-17 08:39:51 +0000 |
commit | ed54318708245efdfcf7454d3aaebfd419f4448c (patch) | |
tree | 8e233da9e3ca2c2cb8b57f04d75dde3d1cf1f704 /chrome/browser/browser.cc | |
parent | 80cf356e08919b18f502f20864d6f6b72b48eb60 (diff) | |
download | chromium_src-ed54318708245efdfcf7454d3aaebfd419f4448c.zip chromium_src-ed54318708245efdfcf7454d3aaebfd419f4448c.tar.gz chromium_src-ed54318708245efdfcf7454d3aaebfd419f4448c.tar.bz2 |
Implement web app shortcuts natively per issue 25528
- Implement a CreateApplicationShortcutView similar to the current Gears-based one;
- Add a few profile prefs to persist user's last checked shortcut locations
- Implement a web_app::CreateShortcut that stores icon under "<profile>/Web Applications"
in a similar layout as gears (i.e. <host>/<scheme_port>/<web_app_title>.ico) and calls
file_util code to creates shortcut on Windows;
- Add Win7 taskbar pin/unpin support function to file_util;
- Update TabContents to replace gears with new code;
Note:
- Gears dialog is modaless but this one is a modal dialog.
- Gear's icon store is not migrated because gears icons
could still be used by shortcuts created by gears and
thus we could not delete them even after migration. And we
are not using the local ico files in the dialog even if
they exists.
- New CreateApplicationShortcutView is included when
TOOLKIT_VIEW is defined. However on platforms other
than Windows, the actual CreateShortCut code is not
implemented. Right now it calls ShellIntegration's
CreateDesktopShort if OS_LINUX is defined and
NOTREACHED() for other platforms.
BUG=25528
TEST=Verify the new UI provides the same functionality as gears under XP/Vista and support pinning on Win 7.
Review URL: http://codereview.chromium.org/372012
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@32165 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/browser.cc')
-rw-r--r-- | chrome/browser/browser.cc | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc index 6728e5d..900a121 100644 --- a/chrome/browser/browser.cc +++ b/chrome/browser/browser.cc @@ -1148,7 +1148,17 @@ void Browser::OpenFile() { void Browser::OpenCreateShortcutsDialog() { UserMetrics::RecordAction(L"CreateShortcut", profile_); #if defined(OS_WIN) || defined(OS_LINUX) - GetSelectedTabContents()->CreateShortcut(); + TabContents* current_tab = GetSelectedTabContents(); + DCHECK(current_tab && current_tab->FavIconIsValid()) << + "Menu item should be disabled."; + + NavigationEntry* entry = current_tab->controller().GetLastCommittedEntry(); + if (!entry) + return; + + // Start fetching web app info for CreateApplicatoinShortcut dialog and + // show the dialog when the data is available in OnDidGetApplicationInfo. + current_tab->render_view_host()->GetApplicationInfo(entry->page_id()); #else NOTIMPLEMENTED(); #endif @@ -1348,6 +1358,9 @@ void Browser::RegisterUserPrefs(PrefService* prefs) { prefs->RegisterBooleanPref(prefs::kShowOmniboxSearchHint, true); prefs->RegisterIntegerPref(prefs::kNTPPromoRemaining, 5); prefs->RegisterBooleanPref(prefs::kShowExtensionShelf, true); + prefs->RegisterBooleanPref(prefs::kWebAppCreateOnDesktop, true); + prefs->RegisterBooleanPref(prefs::kWebAppCreateInAppsMenu, true); + prefs->RegisterBooleanPref(prefs::kWebAppCreateInQuickLaunchBar, true); } // static @@ -2204,6 +2217,19 @@ bool Browser::ShouldAddNavigationsToHistory() const { return !IsApplication(); } +void Browser::OnDidGetApplicationInfo(TabContents* tab_contents, + int32 page_id) { + TabContents* current_tab = GetSelectedTabContents(); + if (current_tab != tab_contents) + return; + + NavigationEntry* entry = current_tab->controller().GetLastCommittedEntry(); + if (!entry || (entry->page_id() != page_id)) + return; + + window()->ShowCreateShortcutsDialog(current_tab); +} + /////////////////////////////////////////////////////////////////////////////// // Browser, SelectFileDialog::Listener implementation: |