| 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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 return title_; | 141 return title_; |
| 142 | 142 |
| 143 // More complicated cases will use the URLs as the title. This result we will | 143 // More complicated cases will use the URLs as the title. This result we will |
| 144 // cache since it's more complicated to compute. | 144 // cache since it's more complicated to compute. |
| 145 if (!cached_display_title_.empty()) | 145 if (!cached_display_title_.empty()) |
| 146 return cached_display_title_; | 146 return cached_display_title_; |
| 147 | 147 |
| 148 // Use the virtual URL first if any, and fall back on using the real URL. | 148 // Use the virtual URL first if any, and fall back on using the real URL. |
| 149 base::string16 title; | 149 base::string16 title; |
| 150 if (!virtual_url_.is_empty()) { | 150 if (!virtual_url_.is_empty()) { |
| 151 title = net::FormatUrl(virtual_url_, languages); | 151 title = url_formatter::FormatUrl(virtual_url_, languages); |
| 152 } else if (!url_.is_empty()) { | 152 } else if (!url_.is_empty()) { |
| 153 title = net::FormatUrl(url_, languages); | 153 title = url_formatter::FormatUrl(url_, languages); |
| 154 } | 154 } |
| 155 | 155 |
| 156 // For file:// URLs use the filename as the title, not the full path. | 156 // For file:// URLs use the filename as the title, not the full path. |
| 157 if (url_.SchemeIsFile()) { | 157 if (url_.SchemeIsFile()) { |
| 158 base::string16::size_type slashpos = title.rfind('/'); | 158 base::string16::size_type slashpos = title.rfind('/'); |
| 159 if (slashpos != base::string16::npos) | 159 if (slashpos != base::string16::npos) |
| 160 title = title.substr(slashpos + 1); | 160 title = title.substr(slashpos + 1); |
| 161 } | 161 } |
| 162 | 162 |
| 163 const int kMaxTitleChars = 4 * 1024; | 163 const int kMaxTitleChars = 4 * 1024; |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 http_request_headers_.reset(); | 277 http_request_headers_.reset(); |
| 278 } | 278 } |
| 279 | 279 |
| 280 void NavigationItemImpl::ResetForCommit() { | 280 void NavigationItemImpl::ResetForCommit() { |
| 281 // Any state that only matters when a navigation item is pending should be | 281 // Any state that only matters when a navigation item is pending should be |
| 282 // cleared here. | 282 // cleared here. |
| 283 set_is_renderer_initiated(false); | 283 set_is_renderer_initiated(false); |
| 284 } | 284 } |
| 285 | 285 |
| 286 } // namespace web | 286 } // namespace web |
| OLD | NEW |