OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include "ios/web/navigation/navigation_item_impl.h" | 5 #include "ios/web/navigation/navigation_item_impl.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "net/base/net_util.h" | 9 #include "components/url_formatter/url_formatter.h" |
10 #include "ui/base/page_transition_types.h" | 10 #include "ui/base/page_transition_types.h" |
11 #include "ui/gfx/text_elider.h" | 11 #include "ui/gfx/text_elider.h" |
12 | 12 |
13 namespace { | 13 namespace { |
14 | 14 |
15 // Returns a new unique ID for use in NavigationItem during construction. The | 15 // Returns a new unique ID for use in NavigationItem during construction. The |
16 // returned ID is guaranteed to be nonzero (which is the "no ID" indicator). | 16 // returned ID is guaranteed to be nonzero (which is the "no ID" indicator). |
17 static int GetUniqueIDInConstructor() { | 17 static int GetUniqueIDInConstructor() { |
18 static int unique_id_counter = 0; | 18 static int unique_id_counter = 0; |
19 return ++unique_id_counter; | 19 return ++unique_id_counter; |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 return title_; | 131 return title_; |
132 | 132 |
133 // More complicated cases will use the URLs as the title. This result we will | 133 // More complicated cases will use the URLs as the title. This result we will |
134 // cache since it's more complicated to compute. | 134 // cache since it's more complicated to compute. |
135 if (!cached_display_title_.empty()) | 135 if (!cached_display_title_.empty()) |
136 return cached_display_title_; | 136 return cached_display_title_; |
137 | 137 |
138 // Use the virtual URL first if any, and fall back on using the real URL. | 138 // Use the virtual URL first if any, and fall back on using the real URL. |
139 base::string16 title; | 139 base::string16 title; |
140 if (!virtual_url_.is_empty()) { | 140 if (!virtual_url_.is_empty()) { |
141 title = net::FormatUrl(virtual_url_, languages); | 141 title = url_formatter::FormatUrl(virtual_url_, languages); |
142 } else if (!url_.is_empty()) { | 142 } else if (!url_.is_empty()) { |
143 title = net::FormatUrl(url_, languages); | 143 title = url_formatter::FormatUrl(url_, languages); |
144 } | 144 } |
145 | 145 |
146 // For file:// URLs use the filename as the title, not the full path. | 146 // For file:// URLs use the filename as the title, not the full path. |
147 if (url_.SchemeIsFile()) { | 147 if (url_.SchemeIsFile()) { |
148 base::string16::size_type slashpos = title.rfind('/'); | 148 base::string16::size_type slashpos = title.rfind('/'); |
149 if (slashpos != base::string16::npos) | 149 if (slashpos != base::string16::npos) |
150 title = title.substr(slashpos + 1); | 150 title = title.substr(slashpos + 1); |
151 } | 151 } |
152 | 152 |
153 const int kMaxTitleChars = 4 * 1024; | 153 const int kMaxTitleChars = 4 * 1024; |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 http_request_headers_.reset(); | 267 http_request_headers_.reset(); |
268 } | 268 } |
269 | 269 |
270 void NavigationItemImpl::ResetForCommit() { | 270 void NavigationItemImpl::ResetForCommit() { |
271 // Any state that only matters when a navigation item is pending should be | 271 // Any state that only matters when a navigation item is pending should be |
272 // cleared here. | 272 // cleared here. |
273 set_is_renderer_initiated(false); | 273 set_is_renderer_initiated(false); |
274 } | 274 } |
275 | 275 |
276 } // namespace web | 276 } // namespace web |
OLD | NEW |