| 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/strings/string16.h" | 7 #include "base/strings/string16.h" |
| 8 #include "base/strings/sys_string_conversions.h" | 8 #include "base/strings/sys_string_conversions.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/ui/bookmarks/bookmark_utils.h" | 10 #include "chrome/browser/ui/bookmarks/bookmark_utils.h" |
| 11 #include "components/bookmarks/browser/bookmark_expanded_state_tracker.h" | 11 #include "components/bookmarks/browser/bookmark_expanded_state_tracker.h" |
| 12 #include "components/bookmarks/browser/bookmark_model.h" | 12 #include "components/bookmarks/browser/bookmark_model.h" |
| 13 #include "components/prefs/pref_service.h" | |
| 14 #include "components/url_formatter/url_fixer.h" | 13 #include "components/url_formatter/url_fixer.h" |
| 15 #include "components/user_prefs/user_prefs.h" | 14 #include "components/user_prefs/user_prefs.h" |
| 16 | 15 |
| 17 using bookmarks::BookmarkExpandedStateTracker; | 16 using bookmarks::BookmarkExpandedStateTracker; |
| 18 using bookmarks::BookmarkModel; | 17 using bookmarks::BookmarkModel; |
| 19 using bookmarks::BookmarkNode; | 18 using bookmarks::BookmarkNode; |
| 20 | 19 |
| 21 @interface BookmarkEditorController (Private) | 20 @interface BookmarkEditorController (Private) |
| 22 | 21 |
| 23 // Grab the url from the text field and convert. | 22 // Grab the url from the text field and convert. |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 } | 58 } |
| 60 | 59 |
| 61 - (void)awakeFromNib { | 60 - (void)awakeFromNib { |
| 62 NSTextFieldCell* nameFieldCell_ = [nameTextField_ cell]; | 61 NSTextFieldCell* nameFieldCell_ = [nameTextField_ cell]; |
| 63 [nameFieldCell_ setUsesSingleLineMode:YES]; | 62 [nameFieldCell_ setUsesSingleLineMode:YES]; |
| 64 | 63 |
| 65 // Set text fields to match our bookmark. If the node is NULL we arrived here | 64 // Set text fields to match our bookmark. If the node is NULL we arrived here |
| 66 // from an "Add Page..." item in a context menu. | 65 // from an "Add Page..." item in a context menu. |
| 67 if (node_) { | 66 if (node_) { |
| 68 [self setInitialName:base::SysUTF16ToNSString(node_->GetTitle())]; | 67 [self setInitialName:base::SysUTF16ToNSString(node_->GetTitle())]; |
| 69 PrefService* prefs = [self profile] ? | |
| 70 user_prefs::UserPrefs::Get([self profile]) : | |
| 71 NULL; | |
| 72 base::string16 urlString = | 68 base::string16 urlString = |
| 73 chrome::FormatBookmarkURLForDisplay(node_->url(), prefs); | 69 chrome::FormatBookmarkURLForDisplay(node_->url()); |
| 74 initialUrl_.reset([base::SysUTF16ToNSString(urlString) retain]); | 70 initialUrl_.reset([base::SysUTF16ToNSString(urlString) retain]); |
| 75 } else { | 71 } else { |
| 76 GURL url = [self url]; | 72 GURL url = [self url]; |
| 77 [self setInitialName:base::SysUTF16ToNSString([self title])]; | 73 [self setInitialName:base::SysUTF16ToNSString([self title])]; |
| 78 if (url.is_valid()) | 74 if (url.is_valid()) |
| 79 initialUrl_.reset([[NSString stringWithUTF8String:url.spec().c_str()] | 75 initialUrl_.reset([[NSString stringWithUTF8String:url.spec().c_str()] |
| 80 retain]); | 76 retain]); |
| 81 } | 77 } |
| 82 [self setDisplayURL:initialUrl_]; | 78 [self setDisplayURL:initialUrl_]; |
| 83 [super awakeFromNib]; | 79 [super awakeFromNib]; |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 SetExpandedNodes(expanded_nodes); | 155 SetExpandedNodes(expanded_nodes); |
| 160 return [NSNumber numberWithBool:YES]; | 156 return [NSNumber numberWithBool:YES]; |
| 161 } | 157 } |
| 162 | 158 |
| 163 - (NSColor *)urlFieldColor { | 159 - (NSColor *)urlFieldColor { |
| 164 return [urlField_ backgroundColor]; | 160 return [urlField_ backgroundColor]; |
| 165 } | 161 } |
| 166 | 162 |
| 167 @end // BookmarkEditorController | 163 @end // BookmarkEditorController |
| 168 | 164 |
| OLD | NEW |