OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/ui/browser_instant_controller.h" | 5 #include "chrome/browser/ui/browser_instant_controller.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "chrome/browser/extensions/extension_service.h" | 8 #include "chrome/browser/extensions/extension_service.h" |
9 #include "chrome/browser/extensions/extension_web_ui.h" | 9 #include "chrome/browser/extensions/extension_web_ui.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 if (!instant_ntp) | 73 if (!instant_ntp) |
74 return false; | 74 return false; |
75 | 75 |
76 *target_contents = instant_ntp.get(); | 76 *target_contents = instant_ntp.get(); |
77 if (source_contents) { | 77 if (source_contents) { |
78 // If the Instant NTP hasn't yet committed an entry, we can't call | 78 // If the Instant NTP hasn't yet committed an entry, we can't call |
79 // CopyStateFromAndPrune. Instead, load the Local NTP URL directly in the | 79 // CopyStateFromAndPrune. Instead, load the Local NTP URL directly in the |
80 // source contents. | 80 // source contents. |
81 // TODO(sreeram): Always using the local URL is wrong in the case of the | 81 // TODO(sreeram): Always using the local URL is wrong in the case of the |
82 // first tab in a window where we might want to use the remote URL. Fix. | 82 // first tab in a window where we might want to use the remote URL. Fix. |
83 if (!instant_ntp->GetController().CanPruneAllButVisible()) { | 83 if (!instant_ntp->GetController().CanPruneAllButLastCommitted()) { |
84 source_contents->GetController().LoadURL(chrome::GetLocalInstantURL( | 84 source_contents->GetController().LoadURL(chrome::GetLocalInstantURL( |
85 profile()), content::Referrer(), content::PAGE_TRANSITION_GENERATED, | 85 profile()), content::Referrer(), content::PAGE_TRANSITION_GENERATED, |
86 std::string()); | 86 std::string()); |
87 *target_contents = source_contents; | 87 *target_contents = source_contents; |
88 } else { | 88 } else { |
89 instant_ntp->GetController().CopyStateFromAndPrune( | 89 instant_ntp->GetController().CopyStateFromAndPrune( |
90 &source_contents->GetController()); | 90 &source_contents->GetController()); |
91 ReplaceWebContentsAt( | 91 ReplaceWebContentsAt( |
92 browser_->tab_strip_model()->GetIndexOfWebContents(source_contents), | 92 browser_->tab_strip_model()->GetIndexOfWebContents(source_contents), |
93 instant_ntp.Pass()); | 93 instant_ntp.Pass()); |
94 } | 94 } |
95 } else { | 95 } else { |
96 // If the Instant NTP hasn't yet committed an entry, we can't call | 96 // If the Instant NTP hasn't yet committed an entry, we can't call |
97 // PruneAllButVisible. In that case, there shouldn't be any entries to | 97 // PruneAllButLastCommitted. In that case, there shouldn't be any entries |
98 // prune anyway. | 98 // to prune anyway. |
99 if (instant_ntp->GetController().CanPruneAllButVisible()) | 99 if (instant_ntp->GetController().CanPruneAllButLastCommitted()) |
100 instant_ntp->GetController().PruneAllButVisible(); | 100 instant_ntp->GetController().PruneAllButLastCommitted(); |
101 else | 101 else |
102 CHECK(!instant_ntp->GetController().GetLastCommittedEntry()); | 102 CHECK(!instant_ntp->GetController().GetLastCommittedEntry()); |
103 | 103 |
104 // If |source_contents| is NULL, then the caller is responsible for | 104 // If |source_contents| is NULL, then the caller is responsible for |
105 // inserting instant_ntp into the tabstrip and will take ownership. | 105 // inserting instant_ntp into the tabstrip and will take ownership. |
106 ignore_result(instant_ntp.release()); | 106 ignore_result(instant_ntp.release()); |
107 } | 107 } |
108 return true; | 108 return true; |
109 } | 109 } |
110 | 110 |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 content::RenderProcessHost* rph = contents->GetRenderProcessHost(); | 216 content::RenderProcessHost* rph = contents->GetRenderProcessHost(); |
217 instant_service->SendSearchURLsToRenderer(rph); | 217 instant_service->SendSearchURLsToRenderer(rph); |
218 | 218 |
219 // Reload the contents to ensure that it gets assigned to a non-priviledged | 219 // Reload the contents to ensure that it gets assigned to a non-priviledged |
220 // renderer. | 220 // renderer. |
221 if (!instant_service->IsInstantProcess(rph->GetID())) | 221 if (!instant_service->IsInstantProcess(rph->GetID())) |
222 continue; | 222 continue; |
223 contents->GetController().Reload(false); | 223 contents->GetController().Reload(false); |
224 } | 224 } |
225 } | 225 } |
OLD | NEW |