blob: e243f8a0aaed1f4719772e062f6cd0a43febcd34 [file] [log] [blame]
license.botbf09a502008-08-24 00:55:551// 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.commit09911bf2008-07-26 23:55:294
[email protected]f3ec7742009-01-15 00:59:165#include "chrome/browser/tab_contents/navigation_entry.h"
initial.commit09911bf2008-07-26 23:55:296
[email protected]6de74452009-02-25 18:04:597#include "chrome/common/url_constants.h"
initial.commit09911bf2008-07-26 23:55:298#include "chrome/common/resource_bundle.h"
9
[email protected]1e5645ff2008-08-27 18:09:0710// 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).
12static int GetUniqueID() {
13 static int unique_id_counter = 0;
14 return ++unique_id_counter;
15}
initial.commit09911bf2008-07-26 23:55:2916
[email protected]eb34392b2008-08-19 15:42:2017NavigationEntry::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]1e5645ff2008-08-27 18:09:0725NavigationEntry::FaviconStatus::FaviconStatus() : valid_(false) {
26 ResourceBundle &rb = ResourceBundle::GetSharedInstance();
27 bitmap_ = *rb.GetBitmapNamed(IDR_DEFAULT_FAVICON);
28}
29
initial.commit09911bf2008-07-26 23:55:2930NavigationEntry::NavigationEntry(TabContentsType type)
[email protected]1e5645ff2008-08-27 18:09:0731 : unique_id_(GetUniqueID()),
32 tab_type_(type),
initial.commit09911bf2008-07-26 23:55:2933 site_instance_(NULL),
[email protected]1e5645ff2008-08-27 18:09:0734 page_type_(NORMAL_PAGE),
initial.commit09911bf2008-07-26 23:55:2935 page_id_(-1),
initial.commit09911bf2008-07-26 23:55:2936 transition_type_(PageTransition::LINK),
initial.commit09911bf2008-07-26 23:55:2937 has_post_data_(false),
38 restored_(false) {
initial.commit09911bf2008-07-26 23:55:2939}
40
41NavigationEntry::NavigationEntry(TabContentsType type,
42 SiteInstance* instance,
43 int page_id,
44 const GURL& url,
[email protected]c0588052008-10-27 23:01:5045 const GURL& referrer,
initial.commit09911bf2008-07-26 23:55:2946 const std::wstring& title,
47 PageTransition::Type transition_type)
[email protected]1e5645ff2008-08-27 18:09:0748 : unique_id_(GetUniqueID()),
49 tab_type_(type),
initial.commit09911bf2008-07-26 23:55:2950 site_instance_(instance),
[email protected]1e5645ff2008-08-27 18:09:0751 page_type_(NORMAL_PAGE),
initial.commit09911bf2008-07-26 23:55:2952 url_(url),
[email protected]c0588052008-10-27 23:01:5053 referrer_(referrer),
initial.commit09911bf2008-07-26 23:55:2954 title_(title),
[email protected]1e5645ff2008-08-27 18:09:0755 page_id_(page_id),
initial.commit09911bf2008-07-26 23:55:2956 transition_type_(transition_type),
initial.commit09911bf2008-07-26 23:55:2957 has_post_data_(false),
58 restored_(false) {
initial.commit09911bf2008-07-26 23:55:2959}
[email protected]3d627bbc2008-10-23 20:49:0760
61const std::wstring& NavigationEntry::GetTitleForDisplay() {
[email protected]8654b682008-11-01 23:36:1762 if (title_.empty())
[email protected]97f756b2008-12-16 04:06:2463 return display_url_as_string_;
[email protected]3d627bbc2008-10-23 20:49:0764 return title_;
[email protected]97f756b2008-12-16 04:06:2465}
[email protected]6de74452009-02-25 18:04:5966
67bool NavigationEntry::IsViewSourceMode() const {
68 return display_url_.SchemeIs(chrome::kViewSourceScheme);
69}