summaryrefslogtreecommitdiffstats
path: root/chrome/browser/bookmarks/bookmark_utils.cc
diff options
context:
space:
mode:
authorpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-08 23:20:20 +0000
committerpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-08 23:20:20 +0000
commita206b446481a9d522958a98e03912aba8c02bb4b (patch)
treeef94c7d31020aaa871117fa1d23b352db34f0940 /chrome/browser/bookmarks/bookmark_utils.cc
parent96a41a0ec6889b5923a92454eafaf39fd63277cf (diff)
downloadchromium_src-a206b446481a9d522958a98e03912aba8c02bb4b.zip
chromium_src-a206b446481a9d522958a98e03912aba8c02bb4b.tar.gz
chromium_src-a206b446481a9d522958a98e03912aba8c02bb4b.tar.bz2
* Add ctrl-shift-d to bookmark all tabs.
* Enable or disable bookmark commands based on whether we're actually going to be able to bookmark anything. * Rename IDC_STAR to IDC_BOOKMARK_PAGE, which is more obvious. BUG=2935 TEST=Hit ctrl-shift-d, make sure it bookmarks all tabs Review URL: http://codereview.chromium.org/266029 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@28480 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/bookmarks/bookmark_utils.cc')
-rw-r--r--chrome/browser/bookmarks/bookmark_utils.cc18
1 files changed, 9 insertions, 9 deletions
diff --git a/chrome/browser/bookmarks/bookmark_utils.cc b/chrome/browser/bookmarks/bookmark_utils.cc
index 95cfe64..edc3a46 100644
--- a/chrome/browser/bookmarks/bookmark_utils.cc
+++ b/chrome/browser/bookmarks/bookmark_utils.cc
@@ -614,20 +614,21 @@ void RegisterUserPrefs(PrefService* prefs) {
bool GetURLAndTitleToBookmark(TabContents* tab_contents,
GURL* url,
std::wstring* title) {
- if (!tab_contents->ShouldDisplayURL())
+ if (!tab_contents || !tab_contents->ShouldDisplayURL())
return false;
- *url = tab_contents->GetURL();
- if (url->is_empty() || !url->is_valid())
+ GURL tab_url = tab_contents->GetURL();
+ if (!tab_url.is_valid())
return false;
- *title = UTF16ToWideHack(tab_contents->GetTitle());
+ if (url != NULL)
+ *url = tab_url;
+ if (title != NULL)
+ *title = UTF16ToWideHack(tab_contents->GetTitle());
return true;
}
const BookmarkNode* CreateBookmarkForAllTabs(Browser* browser) {
BookmarkModel* model = browser->profile()->GetBookmarkModel();
- if (!model || !model->IsLoaded())
- return NULL;
-
+ DCHECK(model && model->IsLoaded());
const BookmarkNode* parent = model->GetParentForNewNodes();
const BookmarkNode* folder = model->AddGroup(
parent, parent->GetChildCount(),
@@ -635,9 +636,8 @@ const BookmarkNode* CreateBookmarkForAllTabs(Browser* browser) {
for (int i = 0; i < browser->tab_count(); ++i) {
GURL url;
std::wstring title;
- if (GetURLAndTitleToBookmark(browser->GetTabContentsAt(i), &url, &title)) {
+ if (GetURLAndTitleToBookmark(browser->GetTabContentsAt(i), &url, &title))
model->AddURL(folder, folder->GetChildCount(), title, url);
- }
}
return folder;
}