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

Side by Side Diff: chrome/browser/ui/cocoa/bookmarks/bookmark_editor_controller.mm

Issue 12340111: Introduce //components/user_prefs, use to eliminate c/b/prefs dependency in Autofill. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Pure merge of LKGR Created 7 years, 9 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
OLDNEW
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/string16.h" 8 #include "base/string16.h"
9 #include "base/sys_string_conversions.h" 9 #include "base/sys_string_conversions.h"
10 #include "chrome/browser/bookmarks/bookmark_expanded_state_tracker.h" 10 #include "chrome/browser/bookmarks/bookmark_expanded_state_tracker.h"
11 #include "chrome/browser/bookmarks/bookmark_model.h" 11 #include "chrome/browser/bookmarks/bookmark_model.h"
12 #include "chrome/browser/net/url_fixer_upper.h" 12 #include "chrome/browser/net/url_fixer_upper.h"
13 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
14 #include "chrome/browser/ui/bookmarks/bookmark_utils.h" 14 #include "chrome/browser/ui/bookmarks/bookmark_utils.h"
15 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_cell_single_line.h" 15 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_cell_single_line.h"
16 #include "components/user_prefs/user_prefs.h"
16 #include "ui/base/l10n/l10n_util.h" 17 #include "ui/base/l10n/l10n_util.h"
17 18
18 @interface BookmarkEditorController (Private) 19 @interface BookmarkEditorController (Private)
19 20
20 // Grab the url from the text field and convert. 21 // Grab the url from the text field and convert.
21 - (GURL)GURLFromUrlField; 22 - (GURL)GURLFromUrlField;
22 23
23 @end 24 @end
24 25
25 @implementation BookmarkEditorController 26 @implementation BookmarkEditorController
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 if ([nameFieldCell_ 64 if ([nameFieldCell_
64 respondsToSelector:@selector(setUsesSingleLineMode:)]) { 65 respondsToSelector:@selector(setUsesSingleLineMode:)]) {
65 [nameFieldCell_ setUsesSingleLineMode:YES]; 66 [nameFieldCell_ setUsesSingleLineMode:YES];
66 } 67 }
67 68
68 // Set text fields to match our bookmark. If the node is NULL we 69 // Set text fields to match our bookmark. If the node is NULL we
69 // arrived here from an "Add Page..." item in a context menu. 70 // arrived here from an "Add Page..." item in a context menu.
70 if (node_) { 71 if (node_) {
71 [self setInitialName:base::SysUTF16ToNSString(node_->GetTitle())]; 72 [self setInitialName:base::SysUTF16ToNSString(node_->GetTitle())];
72 PrefService* prefs = [self profile] ? 73 PrefService* prefs = [self profile] ?
73 PrefServiceFromBrowserContext([self profile]) : 74 components::UserPrefs::Get([self profile]) :
74 NULL; 75 NULL;
75 string16 urlString = 76 string16 urlString =
76 chrome::FormatBookmarkURLForDisplay(node_->url(), prefs); 77 chrome::FormatBookmarkURLForDisplay(node_->url(), prefs);
77 initialUrl_.reset([base::SysUTF16ToNSString(urlString) retain]); 78 initialUrl_.reset([base::SysUTF16ToNSString(urlString) retain]);
78 } else { 79 } else {
79 GURL url = [self url]; 80 GURL url = [self url];
80 [self setInitialName:base::SysUTF16ToNSString([self title])]; 81 [self setInitialName:base::SysUTF16ToNSString([self title])];
81 if (url.is_valid()) 82 if (url.is_valid())
82 initialUrl_.reset([[NSString stringWithUTF8String:url.spec().c_str()] 83 initialUrl_.reset([[NSString stringWithUTF8String:url.spec().c_str()]
83 retain]); 84 retain]);
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 SetExpandedNodes(expanded_nodes); 163 SetExpandedNodes(expanded_nodes);
163 return [NSNumber numberWithBool:YES]; 164 return [NSNumber numberWithBool:YES];
164 } 165 }
165 166
166 - (NSColor *)urlFieldColor { 167 - (NSColor *)urlFieldColor {
167 return [urlField_ backgroundColor]; 168 return [urlField_ backgroundColor];
168 } 169 }
169 170
170 @end // BookmarkEditorController 171 @end // BookmarkEditorController
171 172
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698