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

Side by Side Diff: content/browser/tab_contents/navigation_controller.cc

Issue 8895010: Remove static initialization from navigation_controller.cc (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years 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
« no previous file with comments | « content/browser/tab_contents/navigation_controller.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "content/browser/tab_contents/navigation_controller.h" 5 #include "content/browser/tab_contents/navigation_controller.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/string_number_conversions.h" // Temporary 9 #include "base/string_number_conversions.h" // Temporary
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 url_canon::Replacements<char> replacements; 96 url_canon::Replacements<char> replacements;
97 replacements.ClearRef(); 97 replacements.ClearRef();
98 return existing_url.ReplaceComponents(replacements) == 98 return existing_url.ReplaceComponents(replacements) ==
99 new_url.ReplaceComponents(replacements); 99 new_url.ReplaceComponents(replacements);
100 } 100 }
101 101
102 } // namespace 102 } // namespace
103 103
104 // NavigationController --------------------------------------------------- 104 // NavigationController ---------------------------------------------------
105 105
106 const size_t kMaxEntryCountForTestingNotSet = -1;
107
106 // static 108 // static
107 size_t NavigationController::max_entry_count_ = 109 size_t NavigationController::max_entry_count_for_testing_ =
108 content::kMaxSessionHistoryEntries; 110 kMaxEntryCountForTestingNotSet;
109 111
110 // static 112 // static
111 bool NavigationController::check_for_repost_ = true; 113 bool NavigationController::check_for_repost_ = true;
112 114
113 NavigationController::NavigationController( 115 NavigationController::NavigationController(
114 TabContents* contents, 116 TabContents* contents,
115 content::BrowserContext* browser_context, 117 content::BrowserContext* browser_context,
116 SessionStorageNamespace* session_storage_namespace) 118 SessionStorageNamespace* session_storage_namespace)
117 : browser_context_(browser_context), 119 : browser_context_(browser_context),
118 pending_entry_(NULL), 120 pending_entry_(NULL),
(...skipping 999 matching lines...) Expand 10 before | Expand all | Expand 10 after
1118 int num_pruned = 0; 1120 int num_pruned = 0;
1119 while (last_committed_entry_index_ < (current_size - 1)) { 1121 while (last_committed_entry_index_ < (current_size - 1)) {
1120 num_pruned++; 1122 num_pruned++;
1121 entries_.pop_back(); 1123 entries_.pop_back();
1122 current_size--; 1124 current_size--;
1123 } 1125 }
1124 if (num_pruned > 0) // Only notify if we did prune something. 1126 if (num_pruned > 0) // Only notify if we did prune something.
1125 NotifyPrunedEntries(this, false, num_pruned); 1127 NotifyPrunedEntries(this, false, num_pruned);
1126 } 1128 }
1127 1129
1128 if (entries_.size() >= max_entry_count_) { 1130 if (entries_.size() >= max_entry_count()) {
1129 RemoveEntryAtIndex(0, GURL()); 1131 RemoveEntryAtIndex(0, GURL());
1130 NotifyPrunedEntries(this, true, 1); 1132 NotifyPrunedEntries(this, true, 1);
1131 } 1133 }
1132 1134
1133 entries_.push_back(linked_ptr<NavigationEntry>(entry)); 1135 entries_.push_back(linked_ptr<NavigationEntry>(entry));
1134 last_committed_entry_index_ = static_cast<int>(entries_.size()) - 1; 1136 last_committed_entry_index_ = static_cast<int>(entries_.size()) - 1;
1135 1137
1136 // This is a new page ID, so we need everybody to know about it. 1138 // This is a new page ID, so we need everybody to know about it.
1137 tab_contents_->UpdateMaxPageID(entry->page_id()); 1139 tab_contents_->UpdateMaxPageID(entry->page_id());
1138 } 1140 }
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
1197 content::NOTIFICATION_NAV_ENTRY_COMMITTED, 1199 content::NOTIFICATION_NAV_ENTRY_COMMITTED,
1198 content::Source<NavigationController>(this), 1200 content::Source<NavigationController>(this),
1199 notification_details); 1201 notification_details);
1200 } 1202 }
1201 1203
1202 // static 1204 // static
1203 void NavigationController::DisablePromptOnRepost() { 1205 void NavigationController::DisablePromptOnRepost() {
1204 check_for_repost_ = false; 1206 check_for_repost_ = false;
1205 } 1207 }
1206 1208
1209 // static
1210 size_t NavigationController::max_entry_count() {
1211 if (max_entry_count_for_testing_ != kMaxEntryCountForTestingNotSet)
1212 return max_entry_count_for_testing_;
1213 return content::kMaxSessionHistoryEntries;
1214 }
1215
1207 void NavigationController::SetActive(bool is_active) { 1216 void NavigationController::SetActive(bool is_active) {
1208 if (is_active && needs_reload_) 1217 if (is_active && needs_reload_)
1209 LoadIfNecessary(); 1218 LoadIfNecessary();
1210 } 1219 }
1211 1220
1212 void NavigationController::LoadIfNecessary() { 1221 void NavigationController::LoadIfNecessary() {
1213 if (!needs_reload_) 1222 if (!needs_reload_)
1214 return; 1223 return;
1215 1224
1216 // Calling Reload() results in ignoring state, and not loading. 1225 // Calling Reload() results in ignoring state, and not loading.
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
1283 for (int i = 0; i < max_index; i++) { 1292 for (int i = 0; i < max_index; i++) {
1284 // When cloning a tab, copy all entries except interstitial pages 1293 // When cloning a tab, copy all entries except interstitial pages
1285 if (source.entries_[i].get()->page_type() != 1294 if (source.entries_[i].get()->page_type() !=
1286 content::PAGE_TYPE_INTERSTITIAL) { 1295 content::PAGE_TYPE_INTERSTITIAL) {
1287 entries_.insert(entries_.begin() + insert_index++, 1296 entries_.insert(entries_.begin() + insert_index++,
1288 linked_ptr<NavigationEntry>( 1297 linked_ptr<NavigationEntry>(
1289 new NavigationEntry(*source.entries_[i]))); 1298 new NavigationEntry(*source.entries_[i])));
1290 } 1299 }
1291 } 1300 }
1292 } 1301 }
OLDNEW
« no previous file with comments | « content/browser/tab_contents/navigation_controller.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698