OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 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 | 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 "chrome/browser/tab_contents.h" | 5 #include "chrome/browser/tab_contents.h" |
6 | 6 |
7 #include "chrome/browser/cert_store.h" | 7 #include "chrome/browser/cert_store.h" |
8 #include "chrome/browser/navigation_entry.h" | 8 #include "chrome/browser/navigation_entry.h" |
9 #include "chrome/browser/views/download_shelf_view.h" | 9 #include "chrome/browser/views/download_shelf_view.h" |
10 #include "chrome/browser/views/download_started_animation.h" | 10 #include "chrome/browser/views/download_started_animation.h" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 // Reset the parent to NULL to ensure hidden tabs don't receive messages. | 53 // Reset the parent to NULL to ensure hidden tabs don't receive messages. |
54 SetParent(GetContainerHWND(), NULL); | 54 SetParent(GetContainerHWND(), NULL); |
55 | 55 |
56 // Remove any focus manager related information. | 56 // Remove any focus manager related information. |
57 ChromeViews::FocusManager::UninstallFocusSubclass(GetContainerHWND()); | 57 ChromeViews::FocusManager::UninstallFocusSubclass(GetContainerHWND()); |
58 | 58 |
59 WasHidden(); | 59 WasHidden(); |
60 } | 60 } |
61 | 61 |
62 int32 TabContents::GetMaxPageID() { | 62 int32 TabContents::GetMaxPageID() { |
63 if (AsWebContents()) | 63 if (GetSiteInstance()) |
64 return AsWebContents()->site_instance()->max_page_id(); | 64 return GetSiteInstance()->max_page_id(); |
65 else | 65 else |
66 return max_page_id_; | 66 return max_page_id_; |
67 } | 67 } |
68 | 68 |
69 void TabContents::UpdateMaxPageID(int32 page_id) { | 69 void TabContents::UpdateMaxPageID(int32 page_id) { |
70 if (AsWebContents()) { | 70 // Ensure both the SiteInstance and RenderProcessHost update their max page |
71 // Ensure both the SiteInstance and RenderProcessHost update their max page | 71 // IDs in sync. Only WebContents will also have site instances, except during |
72 // IDs in sync. | 72 // testing. |
73 AsWebContents()->site_instance()->UpdateMaxPageID(page_id); | 73 if (GetSiteInstance()) |
| 74 GetSiteInstance()->UpdateMaxPageID(page_id); |
| 75 |
| 76 if (AsWebContents()) |
74 AsWebContents()->process()->UpdateMaxPageID(page_id); | 77 AsWebContents()->process()->UpdateMaxPageID(page_id); |
75 } else { | 78 else |
76 max_page_id_ = std::max(max_page_id_, page_id); | 79 max_page_id_ = std::max(max_page_id_, page_id); |
77 } | |
78 } | 80 } |
79 | 81 |
80 const std::wstring TabContents::GetDefaultTitle() const { | 82 const std::wstring TabContents::GetDefaultTitle() const { |
81 return l10n_util::GetString(IDS_DEFAULT_TAB_TITLE); | 83 return l10n_util::GetString(IDS_DEFAULT_TAB_TITLE); |
82 } | 84 } |
83 | 85 |
84 void TabContents::SetupController(Profile* profile) { | 86 void TabContents::SetupController(Profile* profile) { |
85 DCHECK(!controller_); | 87 DCHECK(!controller_); |
86 controller_ = new NavigationController(this, profile); | 88 controller_ = new NavigationController(this, profile); |
87 } | 89 } |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 if (delegate_) | 251 if (delegate_) |
250 delegate_->LoadingStateChanged(this); | 252 delegate_->LoadingStateChanged(this); |
251 | 253 |
252 NotificationService::current()-> | 254 NotificationService::current()-> |
253 Notify((is_loading ? NOTIFY_LOAD_START : NOTIFY_LOAD_STOP), | 255 Notify((is_loading ? NOTIFY_LOAD_START : NOTIFY_LOAD_STOP), |
254 Source<NavigationController>(this->controller()), | 256 Source<NavigationController>(this->controller()), |
255 details ? Details<LoadNotificationDetails>(details) : | 257 details ? Details<LoadNotificationDetails>(details) : |
256 NotificationService::NoDetails()); | 258 NotificationService::NoDetails()); |
257 } | 259 } |
258 | 260 |
259 void TabContents::DidNavigateToEntry( | 261 bool TabContents::NavigateToPendingEntry(bool reload) { |
260 NavigationEntry* entry, | 262 // Our benavior is just to report that the entry was committed. |
261 NavigationController::LoadCommittedDetails* details) { | 263 controller()->GetPendingEntry()->set_title(GetDefaultTitle()); |
262 // The entry may be deleted by DidNavigateToEntry... | 264 controller()->CommitPendingEntry(); |
263 int new_page_id = entry->page_id(); | |
264 | |
265 controller_->DidNavigateToEntry(entry, details); | |
266 | |
267 // update after informing the navigation controller so it can check the | |
268 // previous value of the max page id. | |
269 UpdateMaxPageID(new_page_id); | |
270 } | |
271 | |
272 bool TabContents::Navigate(const NavigationEntry& entry, bool reload) { | |
273 NavigationEntry* new_entry = new NavigationEntry(entry); | |
274 if (new_entry->page_id() == -1) { | |
275 // This is a new navigation. Our behavior is to always navigate to the | |
276 // same page (page 0) in response to a navigation. | |
277 new_entry->set_page_id(0); | |
278 new_entry->set_title(GetDefaultTitle()); | |
279 } | |
280 | |
281 // When we're commanded to navigate like this, it's always a new main frame | |
282 // navigation (which is the default for the details). | |
283 NavigationController::LoadCommittedDetails details; | |
284 if (controller()->GetLastCommittedEntry()) | |
285 details.previous_url = controller()->GetLastCommittedEntry()->url(); | |
286 | |
287 DidNavigateToEntry(new_entry, &details); | |
288 return true; | 265 return true; |
289 } | 266 } |
290 | 267 |
291 void TabContents::NotifyNavigationStateChanged(unsigned changed_flags) { | 268 void TabContents::NotifyNavigationStateChanged(unsigned changed_flags) { |
292 if (delegate_) | 269 if (delegate_) |
293 delegate_->NavigationStateChanged(this, changed_flags); | 270 delegate_->NavigationStateChanged(this, changed_flags); |
294 } | 271 } |
295 | 272 |
296 void TabContents::NotifyDidNavigate(NavigationType nav_type, | 273 void TabContents::NotifyDidNavigate(NavigationType nav_type, |
297 int relative_navigation_offset) { | 274 int relative_navigation_offset) { |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
586 if (was_shelf_visible) | 563 if (was_shelf_visible) |
587 to->MigrateShelfViewFrom(from); | 564 to->MigrateShelfViewFrom(from); |
588 to->SetDownloadShelfVisible(was_shelf_visible); | 565 to->SetDownloadShelfVisible(was_shelf_visible); |
589 } | 566 } |
590 | 567 |
591 // static | 568 // static |
592 void TabContents::RegisterUserPrefs(PrefService* prefs) { | 569 void TabContents::RegisterUserPrefs(PrefService* prefs) { |
593 prefs->RegisterBooleanPref(prefs::kBlockPopups, false); | 570 prefs->RegisterBooleanPref(prefs::kBlockPopups, false); |
594 } | 571 } |
595 | 572 |
OLD | NEW |