Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(483)

Unified Diff: chrome/browser/ui/views/bookmarks/bookmark_editor_view.cc

Issue 7310023: Pre-fill the 'Add Page' bookmark window with the current page (gtk and windows). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/views/bookmarks/bookmark_editor_view.cc
diff --git a/chrome/browser/ui/views/bookmarks/bookmark_editor_view.cc b/chrome/browser/ui/views/bookmarks/bookmark_editor_view.cc
index 04056babe7726dfe3f2c04ec328c8118570b1f69..eb14375193f37406d79ad7dc7e6aff213884d0da 100644
--- a/chrome/browser/ui/views/bookmarks/bookmark_editor_view.cc
+++ b/chrome/browser/ui/views/bookmarks/bookmark_editor_view.cc
@@ -14,7 +14,10 @@
#include "chrome/browser/net/url_fixer_upper.h"
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_list.h"
#include "chrome/common/pref_names.h"
+#include "content/browser/tab_contents/tab_contents.h"
#include "googleurl/src/gurl.h"
#include "grit/chromium_strings.h"
#include "grit/generated_resources.h"
@@ -267,11 +270,22 @@ void BookmarkEditorView::Init() {
title_tf_.set_parent_owned(false);
std::wstring title;
- if (details_.type == EditDetails::EXISTING_NODE)
+ GURL url;
+ if (details_.type == EditDetails::EXISTING_NODE) {
title = details_.existing_node->GetTitle();
- else if (details_.type == EditDetails::NEW_FOLDER)
+ url = details_.existing_node->GetURL();
+ } else if (details_.type == EditDetails::NEW_FOLDER) {
title = UTF16ToWide(
l10n_util::GetStringUTF16(IDS_BOOMARK_EDITOR_NEW_FOLDER_NAME));
+ } else if (details_.type == EditDetails::NEW_URL) {
+ Browser* browser = BrowserList::GetLastActiveWithProfile(profile_);
+ TabContents* tab_contents = browser ? browser->GetSelectedTabContents()
+ : NULL;
+ if (tab_contents) {
+ title = UTF16ToWide(tab_contents->GetTitle());
+ url = tab_contents->GetURL();
+ }
+ }
title_tf_.SetText(title);
title_tf_.SetController(this);
@@ -280,14 +294,14 @@ void BookmarkEditorView::Init() {
title_tf_.SetAccessibleName(WideToUTF16Hack(title_label_->GetText()));
string16 url_text;
- if (details_.type == EditDetails::EXISTING_NODE) {
+ if (details_.type != EditDetails::NEW_FOLDER) {
std::string languages = profile_
? profile_->GetPrefs()->GetString(prefs::kAcceptLanguages)
: std::string();
// Because this gets parsed by FixupURL(), it's safe to omit the scheme or
// trailing slash, and unescape most characters, but we need to not drop any
// username/password, or unescape anything that changes the meaning.
- url_text = net::FormatUrl(details_.existing_node->GetURL(), languages,
+ url_text = net::FormatUrl(url, languages,
net::kFormatUrlOmitAll & ~net::kFormatUrlOmitUsernamePassword,
UnescapeRule::SPACES, NULL, NULL, NULL);
}

Powered by Google App Engine
This is Rietveld 408576698