| OLD | NEW |
| 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 "chrome/browser/tabs/tab_strip_model.h" | 5 #include "chrome/browser/tabs/tab_strip_model.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 #include "chrome/common/url_constants.h" | 27 #include "chrome/common/url_constants.h" |
| 28 #include "content/browser/tab_contents/navigation_controller.h" | 28 #include "content/browser/tab_contents/navigation_controller.h" |
| 29 #include "content/browser/tab_contents/tab_contents.h" | 29 #include "content/browser/tab_contents/tab_contents.h" |
| 30 #include "content/browser/tab_contents/tab_contents_view.h" | 30 #include "content/browser/tab_contents/tab_contents_view.h" |
| 31 #include "content/public/browser/navigation_entry.h" | 31 #include "content/public/browser/navigation_entry.h" |
| 32 #include "content/public/browser/notification_service.h" | 32 #include "content/public/browser/notification_service.h" |
| 33 #include "content/public/browser/render_process_host.h" | 33 #include "content/public/browser/render_process_host.h" |
| 34 #include "content/public/browser/user_metrics.h" | 34 #include "content/public/browser/user_metrics.h" |
| 35 #include "content/public/browser/web_contents_delegate.h" | 35 #include "content/public/browser/web_contents_delegate.h" |
| 36 | 36 |
| 37 using content::NavigationEntry; |
| 37 using content::UserMetricsAction; | 38 using content::UserMetricsAction; |
| 38 using content::WebContents; | 39 using content::WebContents; |
| 39 | 40 |
| 40 namespace { | 41 namespace { |
| 41 | 42 |
| 42 // Returns true if the specified transition is one of the types that cause the | 43 // Returns true if the specified transition is one of the types that cause the |
| 43 // opener relationships for the tab in which the transition occured to be | 44 // opener relationships for the tab in which the transition occured to be |
| 44 // forgotten. This is generally any navigation that isn't a link click (i.e. | 45 // forgotten. This is generally any navigation that isn't a link click (i.e. |
| 45 // any navigation that can be considered to be the start of a new task distinct | 46 // any navigation that can be considered to be the start of a new task distinct |
| 46 // from what had previously occurred in that tab). | 47 // from what had previously occurred in that tab). |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 TabContentsWrapper* TabStripModel::DiscardTabContentsAt(int index) { | 210 TabContentsWrapper* TabStripModel::DiscardTabContentsAt(int index) { |
| 210 DCHECK(ContainsIndex(index)); | 211 DCHECK(ContainsIndex(index)); |
| 211 TabContentsWrapper* null_contents = | 212 TabContentsWrapper* null_contents = |
| 212 new TabContentsWrapper( | 213 new TabContentsWrapper( |
| 213 new TabContents(profile(), | 214 new TabContents(profile(), |
| 214 NULL /* site_instance */, | 215 NULL /* site_instance */, |
| 215 MSG_ROUTING_NONE, | 216 MSG_ROUTING_NONE, |
| 216 NULL /* base_tab_contents */, | 217 NULL /* base_tab_contents */, |
| 217 NULL /* session_storage_namespace */)); | 218 NULL /* session_storage_namespace */)); |
| 218 TabContentsWrapper* old_contents = GetContentsAt(index); | 219 TabContentsWrapper* old_contents = GetContentsAt(index); |
| 219 content::NavigationEntry* old_nav_entry = | 220 NavigationEntry* old_nav_entry = |
| 220 old_contents->tab_contents()->GetController().GetActiveEntry(); | 221 old_contents->tab_contents()->GetController().GetActiveEntry(); |
| 221 if (old_nav_entry) { | 222 if (old_nav_entry) { |
| 222 // Set the new tab contents to reload this URL when clicked. | 223 // Set the new tab contents to reload this URL when clicked. |
| 223 // This also allows the tab to keep drawing the favicon and page title. | 224 // This also allows the tab to keep drawing the favicon and page title. |
| 224 content::NavigationEntry* new_nav_entry = | 225 NavigationEntry* new_nav_entry = NavigationEntry::Create(*old_nav_entry); |
| 225 content::NavigationEntry::Create(*old_nav_entry); | 226 std::vector<NavigationEntry*> entries; |
| 226 std::vector<content::NavigationEntry*> entries; | |
| 227 entries.push_back(new_nav_entry); | 227 entries.push_back(new_nav_entry); |
| 228 null_contents->tab_contents()->GetController().Restore(0, false, &entries); | 228 null_contents->tab_contents()->GetController().Restore(0, false, &entries); |
| 229 } | 229 } |
| 230 ReplaceTabContentsAt(index, null_contents); | 230 ReplaceTabContentsAt(index, null_contents); |
| 231 // Mark the tab so it will reload when we click. | 231 // Mark the tab so it will reload when we click. |
| 232 contents_data_[index]->discarded = true; | 232 contents_data_[index]->discarded = true; |
| 233 delete old_contents; | 233 delete old_contents; |
| 234 return null_contents; | 234 return null_contents; |
| 235 } | 235 } |
| 236 | 236 |
| (...skipping 1089 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1326 void TabStripModel::ForgetOpenersAndGroupsReferencing( | 1326 void TabStripModel::ForgetOpenersAndGroupsReferencing( |
| 1327 const NavigationController* tab) { | 1327 const NavigationController* tab) { |
| 1328 for (TabContentsDataVector::const_iterator i = contents_data_.begin(); | 1328 for (TabContentsDataVector::const_iterator i = contents_data_.begin(); |
| 1329 i != contents_data_.end(); ++i) { | 1329 i != contents_data_.end(); ++i) { |
| 1330 if ((*i)->group == tab) | 1330 if ((*i)->group == tab) |
| 1331 (*i)->group = NULL; | 1331 (*i)->group = NULL; |
| 1332 if ((*i)->opener == tab) | 1332 if ((*i)->opener == tab) |
| 1333 (*i)->opener = NULL; | 1333 (*i)->opener = NULL; |
| 1334 } | 1334 } |
| 1335 } | 1335 } |
| OLD | NEW |