| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/ui/cocoa/bookmarks/bookmark_editor_controller.h" | 5 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_editor_controller.h" |
| 6 | 6 |
| 7 #include "base/prefs/pref_service.h" | 7 #include "base/prefs/pref_service.h" |
| 8 #include "base/strings/string16.h" | 8 #include "base/strings/string16.h" |
| 9 #include "base/strings/sys_string_conversions.h" | 9 #include "base/strings/sys_string_conversions.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| 11 #include "chrome/browser/ui/bookmarks/bookmark_utils.h" | 11 #include "chrome/browser/ui/bookmarks/bookmark_utils.h" |
| 12 #include "components/bookmarks/browser/bookmark_expanded_state_tracker.h" | 12 #include "components/bookmarks/browser/bookmark_expanded_state_tracker.h" |
| 13 #include "components/bookmarks/browser/bookmark_model.h" | 13 #include "components/bookmarks/browser/bookmark_model.h" |
| 14 #include "components/url_fixer/url_fixer.h" | 14 #include "components/url_formatter/url_fixer.h" |
| 15 #include "components/user_prefs/user_prefs.h" | 15 #include "components/user_prefs/user_prefs.h" |
| 16 | 16 |
| 17 using bookmarks::BookmarkExpandedStateTracker; | 17 using bookmarks::BookmarkExpandedStateTracker; |
| 18 using bookmarks::BookmarkModel; | 18 using bookmarks::BookmarkModel; |
| 19 using bookmarks::BookmarkNode; | 19 using bookmarks::BookmarkNode; |
| 20 | 20 |
| 21 @interface BookmarkEditorController (Private) | 21 @interface BookmarkEditorController (Private) |
| 22 | 22 |
| 23 // Grab the url from the text field and convert. | 23 // Grab the url from the text field and convert. |
| 24 - (GURL)GURLFromUrlField; | 24 - (GURL)GURLFromUrlField; |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 // Be conservative; it is needed (e.g. "Add Page...") | 97 // Be conservative; it is needed (e.g. "Add Page...") |
| 98 node_ = NULL; | 98 node_ = NULL; |
| 99 [self cancel:self]; | 99 [self cancel:self]; |
| 100 } | 100 } |
| 101 | 101 |
| 102 #pragma mark Bookmark Editing | 102 #pragma mark Bookmark Editing |
| 103 | 103 |
| 104 // If possible, return a valid GURL from the URL text field. | 104 // If possible, return a valid GURL from the URL text field. |
| 105 - (GURL)GURLFromUrlField { | 105 - (GURL)GURLFromUrlField { |
| 106 NSString* url = [self displayURL]; | 106 NSString* url = [self displayURL]; |
| 107 return url_fixer::FixupURL([url UTF8String], std::string()); | 107 return url_formatter::FixupURL([url UTF8String], std::string()); |
| 108 } | 108 } |
| 109 | 109 |
| 110 // Enable the OK button if there is a valid URL. | 110 // Enable the OK button if there is a valid URL. |
| 111 - (BOOL)okEnabled { | 111 - (BOOL)okEnabled { |
| 112 BOOL okEnabled = NO; | 112 BOOL okEnabled = NO; |
| 113 if ([[self displayURL] length]) { | 113 if ([[self displayURL] length]) { |
| 114 GURL newURL = [self GURLFromUrlField]; | 114 GURL newURL = [self GURLFromUrlField]; |
| 115 okEnabled = (newURL.is_valid()) ? YES : NO; | 115 okEnabled = (newURL.is_valid()) ? YES : NO; |
| 116 } | 116 } |
| 117 if (okEnabled) | 117 if (okEnabled) |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 SetExpandedNodes(expanded_nodes); | 165 SetExpandedNodes(expanded_nodes); |
| 166 return [NSNumber numberWithBool:YES]; | 166 return [NSNumber numberWithBool:YES]; |
| 167 } | 167 } |
| 168 | 168 |
| 169 - (NSColor *)urlFieldColor { | 169 - (NSColor *)urlFieldColor { |
| 170 return [urlField_ backgroundColor]; | 170 return [urlField_ backgroundColor]; |
| 171 } | 171 } |
| 172 | 172 |
| 173 @end // BookmarkEditorController | 173 @end // BookmarkEditorController |
| 174 | 174 |
| OLD | NEW |