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

Side by Side Diff: chrome/browser/cocoa/preferences_window_controller.mm

Issue 2102019: Invalid URLs are no longer mangled when reopening the Options window (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 10 years, 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « AUTHORS ('k') | chrome/browser/gtk/options/general_page_gtk.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #import "chrome/browser/cocoa/preferences_window_controller.h" 5 #import "chrome/browser/cocoa/preferences_window_controller.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "app/l10n_util.h" 9 #include "app/l10n_util.h"
10 #include "app/l10n_util_mac.h" 10 #include "app/l10n_util_mac.h"
(...skipping 778 matching lines...) Expand 10 before | Expand all | Expand 10 after
789 launchAppWithBundleIdentifier:kKeychainBundleId 789 launchAppWithBundleIdentifier:kKeychainBundleId
790 options:0L 790 options:0L
791 additionalEventParamDescriptor:nil 791 additionalEventParamDescriptor:nil
792 launchIdentifier:nil]; 792 launchIdentifier:nil];
793 } 793 }
794 794
795 //------------------------------------------------------------------------- 795 //-------------------------------------------------------------------------
796 // Basics panel 796 // Basics panel
797 797
798 // Sets the home page preferences for kNewTabPageIsHomePage and kHomePage. If a 798 // Sets the home page preferences for kNewTabPageIsHomePage and kHomePage. If a
799 // blank string is passed in we revert to using NewTab page as the Home page. 799 // blank or null-host URL is passed in we revert to using NewTab page
800 // When setting the Home Page to NewTab page, we preserve the old value of 800 // as the Home page. Note: using SetValue() causes the observers not to fire,
801 // kHomePage (we don't overwrite it). Note: using SetValue() causes the 801 // which is actually a good thing as we could end up in a state where setting
802 // observers not to fire, which is actually a good thing as we could end up in a 802 // the homepage to an empty url would automatically reset the prefs back to
803 // state where setting the homepage to an empty url would automatically reset 803 // using the NTP, so we'd be never be able to change it.
804 // the prefs back to using the NTP, so we'd be never be able to change it. 804 - (void)setHomepage:(const GURL&)homepage {
805 - (void)setHomepage:(const std::string&)homepage { 805 if (!homepage.is_valid() || homepage.spec() == GetNewTabUIURLString()) {
806 if (homepage.empty() || homepage == GetNewTabUIURLString()) {
807 newTabPageIsHomePage_.SetValue(true); 806 newTabPageIsHomePage_.SetValue(true);
807 if (!homepage.has_host())
808 homepage_.SetValue(std::wstring());
808 } else { 809 } else {
809 newTabPageIsHomePage_.SetValue(false); 810 newTabPageIsHomePage_.SetValue(false);
810 homepage_.SetValue(UTF8ToWide(homepage)); 811 homepage_.SetValue(UTF8ToWide(homepage.spec()));
811 } 812 }
812 } 813 }
813 814
814 // Callback when preferences are changed by someone modifying the prefs backend 815 // Callback when preferences are changed by someone modifying the prefs backend
815 // externally. |prefName| is the name of the pref that has changed. Unlike on 816 // externally. |prefName| is the name of the pref that has changed. Unlike on
816 // Windows, we don't need to use this method for initializing, that's handled by 817 // Windows, we don't need to use this method for initializing, that's handled by
817 // Cocoa Bindings. 818 // Cocoa Bindings.
818 // Handles prefs for the "Basics" panel. 819 // Handles prefs for the "Basics" panel.
819 - (void)basicsPrefChanged:(std::wstring*)prefName { 820 - (void)basicsPrefChanged:(std::wstring*)prefName {
820 if (*prefName == prefs::kRestoreOnStartup) { 821 if (*prefName == prefs::kRestoreOnStartup) {
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
1006 return value; 1007 return value;
1007 } 1008 }
1008 1009
1009 // Sets the homepage URL to |urlString| with some fixing up. 1010 // Sets the homepage URL to |urlString| with some fixing up.
1010 - (void)setHomepageURL:(NSString*)urlString { 1011 - (void)setHomepageURL:(NSString*)urlString {
1011 // If the text field contains a valid URL, sync it to prefs. We run it 1012 // If the text field contains a valid URL, sync it to prefs. We run it
1012 // through the fixer upper to allow input like "google.com" to be converted 1013 // through the fixer upper to allow input like "google.com" to be converted
1013 // to something valid ("http://google.com"). 1014 // to something valid ("http://google.com").
1014 std::string unfixedURL = urlString ? base::SysNSStringToUTF8(urlString) : 1015 std::string unfixedURL = urlString ? base::SysNSStringToUTF8(urlString) :
1015 chrome::kChromeUINewTabURL; 1016 chrome::kChromeUINewTabURL;
1016 std::string fixedURL = URLFixerUpper::FixupURL(unfixedURL, std::string()); 1017 [self setHomepage:GURL(URLFixerUpper::FixupURL(unfixedURL, std::string()))];
1017 if (GURL(fixedURL).is_valid())
1018 [self setHomepage:fixedURL];
1019 } 1018 }
1020 1019
1021 // Returns whether the home button should be checked based on the preference. 1020 // Returns whether the home button should be checked based on the preference.
1022 - (BOOL)showHomeButton { 1021 - (BOOL)showHomeButton {
1023 return showHomeButton_.GetValue() ? YES : NO; 1022 return showHomeButton_.GetValue() ? YES : NO;
1024 } 1023 }
1025 1024
1026 // Sets the backend pref for whether or not the home button should be displayed 1025 // Sets the backend pref for whether or not the home button should be displayed
1027 // based on |value|. 1026 // based on |value|.
1028 - (void)setShowHomeButton:(BOOL)value { 1027 - (void)setShowHomeButton:(BOOL)value {
(...skipping 853 matching lines...) Expand 10 before | Expand all | Expand 10 after
1882 case OPTIONS_PAGE_ADVANCED: 1881 case OPTIONS_PAGE_ADVANCED:
1883 return underTheHoodView_; 1882 return underTheHoodView_;
1884 case OPTIONS_PAGE_DEFAULT: 1883 case OPTIONS_PAGE_DEFAULT:
1885 case OPTIONS_PAGE_COUNT: 1884 case OPTIONS_PAGE_COUNT:
1886 LOG(DFATAL) << "Invalid page value " << page; 1885 LOG(DFATAL) << "Invalid page value " << page;
1887 } 1886 }
1888 return basicsView_; 1887 return basicsView_;
1889 } 1888 }
1890 1889
1891 @end 1890 @end
OLDNEW
« no previous file with comments | « AUTHORS ('k') | chrome/browser/gtk/options/general_page_gtk.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698