license.bot | bf09a50 | 2008-08-24 00:55:55 | [diff] [blame] | 1 | // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 4 | |
[email protected] | f3ec774 | 2009-01-15 00:59:16 | [diff] [blame] | 5 | #include "chrome/browser/tab_contents/navigation_entry.h" |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 6 | |
[email protected] | 6de7445 | 2009-02-25 18:04:59 | [diff] [blame^] | 7 | #include "chrome/common/url_constants.h" |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 8 | #include "chrome/common/resource_bundle.h" |
| 9 | |
[email protected] | 1e5645ff | 2008-08-27 18:09:07 | [diff] [blame] | 10 | // Use this to get a new unique ID for a NavigationEntry during construction. |
| 11 | // The returned ID is guaranteed to be nonzero (which is the "no ID" indicator). |
| 12 | static int GetUniqueID() { |
| 13 | static int unique_id_counter = 0; |
| 14 | return ++unique_id_counter; |
| 15 | } |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 16 | |
[email protected] | eb34392b | 2008-08-19 15:42:20 | [diff] [blame] | 17 | NavigationEntry::SSLStatus::SSLStatus() |
| 18 | : security_style_(SECURITY_STYLE_UNKNOWN), |
| 19 | cert_id_(0), |
| 20 | cert_status_(0), |
| 21 | security_bits_(-1), |
| 22 | content_status_(NORMAL_CONTENT) { |
| 23 | } |
| 24 | |
[email protected] | 1e5645ff | 2008-08-27 18:09:07 | [diff] [blame] | 25 | NavigationEntry::FaviconStatus::FaviconStatus() : valid_(false) { |
| 26 | ResourceBundle &rb = ResourceBundle::GetSharedInstance(); |
| 27 | bitmap_ = *rb.GetBitmapNamed(IDR_DEFAULT_FAVICON); |
| 28 | } |
| 29 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 30 | NavigationEntry::NavigationEntry(TabContentsType type) |
[email protected] | 1e5645ff | 2008-08-27 18:09:07 | [diff] [blame] | 31 | : unique_id_(GetUniqueID()), |
| 32 | tab_type_(type), |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 33 | site_instance_(NULL), |
[email protected] | 1e5645ff | 2008-08-27 18:09:07 | [diff] [blame] | 34 | page_type_(NORMAL_PAGE), |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 35 | page_id_(-1), |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 36 | transition_type_(PageTransition::LINK), |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 37 | has_post_data_(false), |
| 38 | restored_(false) { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 39 | } |
| 40 | |
| 41 | NavigationEntry::NavigationEntry(TabContentsType type, |
| 42 | SiteInstance* instance, |
| 43 | int page_id, |
| 44 | const GURL& url, |
[email protected] | c058805 | 2008-10-27 23:01:50 | [diff] [blame] | 45 | const GURL& referrer, |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 46 | const std::wstring& title, |
| 47 | PageTransition::Type transition_type) |
[email protected] | 1e5645ff | 2008-08-27 18:09:07 | [diff] [blame] | 48 | : unique_id_(GetUniqueID()), |
| 49 | tab_type_(type), |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 50 | site_instance_(instance), |
[email protected] | 1e5645ff | 2008-08-27 18:09:07 | [diff] [blame] | 51 | page_type_(NORMAL_PAGE), |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 52 | url_(url), |
[email protected] | c058805 | 2008-10-27 23:01:50 | [diff] [blame] | 53 | referrer_(referrer), |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 54 | title_(title), |
[email protected] | 1e5645ff | 2008-08-27 18:09:07 | [diff] [blame] | 55 | page_id_(page_id), |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 56 | transition_type_(transition_type), |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 57 | has_post_data_(false), |
| 58 | restored_(false) { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 59 | } |
[email protected] | 3d627bbc | 2008-10-23 20:49:07 | [diff] [blame] | 60 | |
| 61 | const std::wstring& NavigationEntry::GetTitleForDisplay() { |
[email protected] | 8654b68 | 2008-11-01 23:36:17 | [diff] [blame] | 62 | if (title_.empty()) |
[email protected] | 97f756b | 2008-12-16 04:06:24 | [diff] [blame] | 63 | return display_url_as_string_; |
[email protected] | 3d627bbc | 2008-10-23 20:49:07 | [diff] [blame] | 64 | return title_; |
[email protected] | 97f756b | 2008-12-16 04:06:24 | [diff] [blame] | 65 | } |
[email protected] | 6de7445 | 2009-02-25 18:04:59 | [diff] [blame^] | 66 | |
| 67 | bool NavigationEntry::IsViewSourceMode() const { |
| 68 | return display_url_.SchemeIs(chrome::kViewSourceScheme); |
| 69 | } |