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

Unified Diff: chrome/browser/protector/session_startup_change.cc

Issue 9968007: [protector] Support for collapsing multiple changes into a single one. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge Created 8 years, 8 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/protector/session_startup_change.cc
diff --git a/chrome/browser/protector/session_startup_change.cc b/chrome/browser/protector/session_startup_change.cc
index c1d6b191c8e5c4b1c1e7eb9264830b261f87464e..2c767709f5f309576f7d680289d43e511b78dbf5 100644
--- a/chrome/browser/protector/session_startup_change.cc
+++ b/chrome/browser/protector/session_startup_change.cc
@@ -43,10 +43,16 @@ class SessionStartupChange : public BasePrefsChange {
virtual string16 GetBubbleMessage() const OVERRIDE;
virtual string16 GetApplyButtonText() const OVERRIDE;
virtual string16 GetDiscardButtonText() const OVERRIDE;
+ virtual DisplayName GetApplyDisplayName() const OVERRIDE;
+ virtual GURL GetNewSettingURL() const OVERRIDE;
private:
virtual ~SessionStartupChange();
+ // Returns the first URL among new startup pages. Returns an empty URL if
+ // there are no new startup pages.
+ GURL GetFirstNewURL() const;
+
// Opens all tabs in |tabs| and makes them pinned.
void OpenPinnedTabs(Browser* browser, const PinnedTabCodec::Tabs& tabs);
@@ -139,26 +145,43 @@ string16 SessionStartupChange::GetApplyButtonText() const {
if (new_startup_pref_.type == SessionStartupPref::LAST)
return l10n_util::GetStringUTF16(IDS_CHANGE_STARTUP_SETTINGS_RESTORE);
- string16 first_url;
- if (new_startup_pref_.type == SessionStartupPref::URLS &&
- !new_startup_pref_.urls.empty()) {
- // Display the domain name of the first statrup URL.
- first_url = UTF8ToUTF16(new_startup_pref_.urls[0].host());
- } else if (!new_pinned_tabs_.empty()) {
- // Start with NTP or no URLs (basically the same): display the domain name
- // of the first pinned tab, if any.
- first_url = UTF8ToUTF16(new_pinned_tabs_[0].url.host());
- }
- return first_url.empty() ?
+ // Display the domain name of the first startup/pinned URL.
+ string16 first_domain = UTF8ToUTF16(GetFirstNewURL().host());
+ return first_domain.empty() ?
l10n_util::GetStringUTF16(IDS_CHANGE_STARTUP_SETTINGS_NTP) :
l10n_util::GetStringFUTF16(IDS_CHANGE_STARTUP_SETTINGS_URLS,
- first_url);
+ first_domain);
}
string16 SessionStartupChange::GetDiscardButtonText() const {
return l10n_util::GetStringUTF16(IDS_KEEP_SETTING);
}
+BaseSettingChange::DisplayName
+SessionStartupChange::GetApplyDisplayName() const {
+ string16 first_domain = UTF8ToUTF16(GetFirstNewURL().host());
+ return first_domain.empty() ?
+ BaseSettingChange::GetApplyDisplayName() :
+ DisplayName(kSessionStartupChangeNamePriority, first_domain);
+}
+
+GURL SessionStartupChange::GetNewSettingURL() const {
+ VLOG(1) << "HP URL: " << GetFirstNewURL().spec();
+ return GetFirstNewURL();
+}
+
+GURL SessionStartupChange::GetFirstNewURL() const {
+ // TODO(ivankr): this actually should return the first URL present in new
+ // startup prefs AND not in old.
+ if (new_startup_pref_.type == SessionStartupPref::URLS &&
+ !new_startup_pref_.urls.empty()) {
+ return new_startup_pref_.urls[0];
+ }
+ if (!new_pinned_tabs_.empty())
+ return new_pinned_tabs_[0].url;
+ return GURL();
+}
+
void SessionStartupChange::OpenPinnedTabs(
Browser* browser,
const PinnedTabCodec::Tabs& tabs) {
« no previous file with comments | « chrome/browser/protector/protector_service_browsertest.cc ('k') | chrome/browser/protector/session_startup_change_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698