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

Side by Side Diff: chrome/browser/ui/browser_instant_controller.cc

Issue 15041004: Replace PruneAllButActive with PruneAllButVisible. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Change to CHECK. Created 7 years, 6 months 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 | « chrome/browser/ui/browser_commands.cc ('k') | chrome/browser/ui/search/instant_controller.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/prefs/pref_service.h" 8 #include "base/prefs/pref_service.h"
9 #include "chrome/browser/extensions/extension_service.h" 9 #include "chrome/browser/extensions/extension_service.h"
10 #include "chrome/browser/extensions/extension_web_ui.h" 10 #include "chrome/browser/extensions/extension_web_ui.h"
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 // If there is an extension overriding the NTP do not use the Instant NTP. 93 // If there is an extension overriding the NTP do not use the Instant NTP.
94 return false; 94 return false;
95 } 95 }
96 96
97 scoped_ptr<content::WebContents> instant_ntp = instant_.ReleaseNTPContents(); 97 scoped_ptr<content::WebContents> instant_ntp = instant_.ReleaseNTPContents();
98 if (!instant_ntp) 98 if (!instant_ntp)
99 return false; 99 return false;
100 100
101 *target_contents = instant_ntp.get(); 101 *target_contents = instant_ntp.get();
102 if (source_contents) { 102 if (source_contents) {
103 instant_ntp->GetController().CopyStateFromAndPrune( 103 // If the Instant NTP hasn't yet committed an entry, we can't call
104 &source_contents->GetController()); 104 // CopyStateFromAndPrune. Instead, load the Local NTP URL directly in the
105 ReplaceWebContentsAt( 105 // source contents.
106 browser_->tab_strip_model()->GetIndexOfWebContents(source_contents), 106 // TODO(sreeram): Always using the local URL is wrong in the case of the
107 instant_ntp.Pass()); 107 // first tab in a window where we might want to use the remote URL. Fix.
108 if (!instant_ntp->GetController().CanPruneAllButVisible()) {
109 source_contents->GetController().LoadURL(chrome::GetLocalInstantURL(
110 profile()), content::Referrer(), content::PAGE_TRANSITION_GENERATED,
111 std::string());
112 *target_contents = source_contents;
113 } else {
114 instant_ntp->GetController().CopyStateFromAndPrune(
115 &source_contents->GetController());
116 ReplaceWebContentsAt(
117 browser_->tab_strip_model()->GetIndexOfWebContents(source_contents),
118 instant_ntp.Pass());
119 }
108 } else { 120 } else {
109 instant_ntp->GetController().PruneAllButActive(); 121 // If the Instant NTP hasn't yet committed an entry, we can't call
122 // PruneAllButVisible. In that case, there shouldn't be any entries to
123 // prune anyway.
124 if (instant_ntp->GetController().CanPruneAllButVisible())
125 instant_ntp->GetController().PruneAllButVisible();
126 else
127 CHECK(!instant_ntp->GetController().GetLastCommittedEntry());
128
110 // If |source_contents| is NULL, then the caller is responsible for 129 // If |source_contents| is NULL, then the caller is responsible for
111 // inserting instant_ntp into the tabstrip and will take ownership. 130 // inserting instant_ntp into the tabstrip and will take ownership.
112 ignore_result(instant_ntp.release()); 131 ignore_result(instant_ntp.release());
113 } 132 }
114 return true; 133 return true;
115 } 134 }
116 135
117 bool BrowserInstantController::OpenInstant(WindowOpenDisposition disposition) { 136 bool BrowserInstantController::OpenInstant(WindowOpenDisposition disposition) {
118 // Unsupported dispositions. 137 // Unsupported dispositions.
119 if (disposition == NEW_BACKGROUND_TAB || disposition == NEW_WINDOW) 138 if (disposition == NEW_BACKGROUND_TAB || disposition == NEW_WINDOW)
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 if (!instant_service->IsInstantProcess( 415 if (!instant_service->IsInstantProcess(
397 contents->GetRenderProcessHost()->GetID())) 416 contents->GetRenderProcessHost()->GetID()))
398 continue; 417 continue;
399 418
400 // Reload the contents to ensure that it gets assigned to a non-priviledged 419 // Reload the contents to ensure that it gets assigned to a non-priviledged
401 // renderer. 420 // renderer.
402 contents->GetController().Reload(false); 421 contents->GetController().Reload(false);
403 } 422 }
404 instant_.OnDefaultSearchProviderChanged(); 423 instant_.OnDefaultSearchProviderChanged();
405 } 424 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/browser_commands.cc ('k') | chrome/browser/ui/search/instant_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698