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

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

Issue 67070: Merge 13131 - Make the throbber throb sooner after you navigate. This fixes t... (Closed) Base URL: svn://chrome-svn.corp.google.com/chrome/branches/172/src/
Patch Set: '' Created 11 years, 8 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
« no previous file with comments | « no previous file | chrome/browser/dom_ui/dom_ui_unittest.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 (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/browser.h" 5 #include "chrome/browser/browser.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/idle_timer.h" 8 #include "base/idle_timer.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 1636 matching lines...) Expand 10 before | Expand all | Expand 10 after
1647 // call to LoadURL (perhaps related to TabContents type switching), so we 1647 // call to LoadURL (perhaps related to TabContents type switching), so we
1648 // save the NavigationController here. 1648 // save the NavigationController here.
1649 NavigationController* controller = current_tab->controller(); 1649 NavigationController* controller = current_tab->controller();
1650 controller->LoadURL(url, referrer, transition); 1650 controller->LoadURL(url, referrer, transition);
1651 // If the TabContents type has been swapped, we need to point to the current 1651 // If the TabContents type has been swapped, we need to point to the current
1652 // active type otherwise there will be weirdness. 1652 // active type otherwise there will be weirdness.
1653 new_contents = controller->active_contents(); 1653 new_contents = controller->active_contents();
1654 if (GetStatusBubble()) 1654 if (GetStatusBubble())
1655 GetStatusBubble()->Hide(); 1655 GetStatusBubble()->Hide();
1656 1656
1657 // Synchronously update the location bar. This allows us to immediately 1657 // Update the location bar and load state. These are both synchronous
1658 // have the URL bar update when the user types something, rather than 1658 // updates inside of ScheduleUIUpdate.
1659 // going through the normal system of ScheduleUIUpdate which has a delay. 1659 ScheduleUIUpdate(source, TabContents::INVALIDATE_URL |
1660 TabContents::INVALIDATE_LOAD);
1660 UpdateToolbar(false); 1661 UpdateToolbar(false);
1661 } else if (disposition == OFF_THE_RECORD) { 1662 } else if (disposition == OFF_THE_RECORD) {
1662 OpenURLOffTheRecord(profile_, url); 1663 OpenURLOffTheRecord(profile_, url);
1663 return; 1664 return;
1664 } else if (disposition != SUPPRESS_OPEN) { 1665 } else if (disposition != SUPPRESS_OPEN) {
1665 new_contents = AddTabWithURL(url, referrer, transition, 1666 new_contents = AddTabWithURL(url, referrer, transition,
1666 disposition != NEW_BACKGROUND_TAB, instance); 1667 disposition != NEW_BACKGROUND_TAB, instance);
1667 } 1668 }
1668 1669
1669 if (disposition != NEW_BACKGROUND_TAB && source_tab_was_frontmost) { 1670 if (disposition != NEW_BACKGROUND_TAB && source_tab_was_frontmost) {
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
1858 1859
1859 tabstrip_model_.DetachTabContentsAt(index); 1860 tabstrip_model_.DetachTabContentsAt(index);
1860 Browser* browser = Browser::CreateForApp(app_name, profile_, false); 1861 Browser* browser = Browser::CreateForApp(app_name, profile_, false);
1861 browser->tabstrip_model()->AppendTabContents(contents, true); 1862 browser->tabstrip_model()->AppendTabContents(contents, true);
1862 browser->window()->Show(); 1863 browser->window()->Show();
1863 } 1864 }
1864 1865
1865 void Browser::ContentsStateChanged(TabContents* source) { 1866 void Browser::ContentsStateChanged(TabContents* source) {
1866 int index = tabstrip_model_.GetIndexOfTabContents(source); 1867 int index = tabstrip_model_.GetIndexOfTabContents(source);
1867 if (index != TabStripModel::kNoTab) 1868 if (index != TabStripModel::kNoTab)
1868 tabstrip_model_.UpdateTabContentsStateAt(index); 1869 tabstrip_model_.UpdateTabContentsStateAt(index, true);
1869 } 1870 }
1870 1871
1871 bool Browser::ShouldDisplayURLField() { 1872 bool Browser::ShouldDisplayURLField() {
1872 return !IsApplication(); 1873 return !IsApplication();
1873 } 1874 }
1874 1875
1875 void Browser::BeforeUnloadFired(TabContents* tab, 1876 void Browser::BeforeUnloadFired(TabContents* tab,
1876 bool proceed, 1877 bool proceed,
1877 bool* proceed_to_fire_unload) { 1878 bool* proceed_to_fire_unload) {
1878 if (!is_attempting_to_close_browser_) { 1879 if (!is_attempting_to_close_browser_) {
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
2189 2190
2190 /////////////////////////////////////////////////////////////////////////////// 2191 ///////////////////////////////////////////////////////////////////////////////
2191 // Browser, UI update coalescing and handling (private): 2192 // Browser, UI update coalescing and handling (private):
2192 2193
2193 void Browser::UpdateToolbar(bool should_restore_state) { 2194 void Browser::UpdateToolbar(bool should_restore_state) {
2194 window_->UpdateToolbar(GetSelectedTabContents(), should_restore_state); 2195 window_->UpdateToolbar(GetSelectedTabContents(), should_restore_state);
2195 } 2196 }
2196 2197
2197 void Browser::ScheduleUIUpdate(const TabContents* source, 2198 void Browser::ScheduleUIUpdate(const TabContents* source,
2198 unsigned changed_flags) { 2199 unsigned changed_flags) {
2199 // Synchronously update the URL. 2200 // Do some synchronous updates.
2200 if (changed_flags & TabContents::INVALIDATE_URL && 2201 if (changed_flags & TabContents::INVALIDATE_URL &&
2201 source == GetSelectedTabContents()) { 2202 source == GetSelectedTabContents()) {
2202 // Only update the URL for the current tab. Note that we do not update 2203 // Only update the URL for the current tab. Note that we do not update
2203 // the navigation commands since those would have already been updated 2204 // the navigation commands since those would have already been updated
2204 // synchronously by NavigationStateChanged. 2205 // synchronously by NavigationStateChanged.
2205 UpdateToolbar(false); 2206 UpdateToolbar(false);
2207 }
2208 if (changed_flags & TabContents::INVALIDATE_LOAD && source) {
2209 // Update the loading state synchronously. This is so the throbber will
2210 // immediately start/stop, which gives a more snappy feel. We want to do
2211 // this for any tab so they start & stop quickly, but the source can be
2212 // NULL, so we have to check for that.
2213 tabstrip_model_.UpdateTabContentsStateAt(
2214 tabstrip_model_.GetIndexOfController(source->controller()), true);
2215 }
2206 2216
2207 if (changed_flags == TabContents::INVALIDATE_URL) 2217 // If the only updates were synchronously handled above, we're done.
2208 return; // Just had an update URL and nothing else. 2218 if (changed_flags ==
2209 } 2219 (TabContents::INVALIDATE_URL | TabContents::INVALIDATE_LOAD))
2220 return;
2210 2221
2211 // Save the dirty bits. 2222 // Save the dirty bits.
2212 scheduled_updates_.push_back(UIUpdate(source, changed_flags)); 2223 scheduled_updates_.push_back(UIUpdate(source, changed_flags));
2213 2224
2214 if (chrome_updater_factory_.empty()) { 2225 if (chrome_updater_factory_.empty()) {
2215 // No task currently scheduled, start another. 2226 // No task currently scheduled, start another.
2216 MessageLoop::current()->PostDelayedTask(FROM_HERE, 2227 MessageLoop::current()->PostDelayedTask(FROM_HERE,
2217 chrome_updater_factory_.NewRunnableMethod( 2228 chrome_updater_factory_.NewRunnableMethod(
2218 &Browser::ProcessPendingUIUpdates), 2229 &Browser::ProcessPendingUIUpdates),
2219 kUIUpdateCoalescingTimeMS); 2230 kUIUpdateCoalescingTimeMS);
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
2279 if (flags & TabContents::INVALIDATE_FEEDLIST) 2290 if (flags & TabContents::INVALIDATE_FEEDLIST)
2280 window()->GetLocationBar()->UpdateFeedIcon(); 2291 window()->GetLocationBar()->UpdateFeedIcon();
2281 2292
2282 // Updating the URL happens synchronously in ScheduleUIUpdate. 2293 // Updating the URL happens synchronously in ScheduleUIUpdate.
2283 2294
2284 if (flags & TabContents::INVALIDATE_LOAD && GetStatusBubble()) 2295 if (flags & TabContents::INVALIDATE_LOAD && GetStatusBubble())
2285 GetStatusBubble()->SetStatus(GetSelectedTabContents()->GetStatusText()); 2296 GetStatusBubble()->SetStatus(GetSelectedTabContents()->GetStatusText());
2286 2297
2287 if (invalidate_tab) { // INVALIDATE_TITLE or INVALIDATE_FAVICON. 2298 if (invalidate_tab) { // INVALIDATE_TITLE or INVALIDATE_FAVICON.
2288 tabstrip_model_.UpdateTabContentsStateAt( 2299 tabstrip_model_.UpdateTabContentsStateAt(
2289 tabstrip_model_.GetIndexOfController(contents->controller())); 2300 tabstrip_model_.GetIndexOfController(contents->controller()), false);
2290 window_->UpdateTitleBar(); 2301 window_->UpdateTitleBar();
2291 2302
2292 if (contents == GetSelectedTabContents()) { 2303 if (contents == GetSelectedTabContents()) {
2293 TabContents* current_tab = GetSelectedTabContents(); 2304 TabContents* current_tab = GetSelectedTabContents();
2294 command_updater_.UpdateCommandEnabled(IDC_CREATE_SHORTCUTS, 2305 command_updater_.UpdateCommandEnabled(IDC_CREATE_SHORTCUTS,
2295 current_tab->type() == TAB_CONTENTS_WEB && 2306 current_tab->type() == TAB_CONTENTS_WEB &&
2296 !current_tab->GetFavIcon().isNull()); 2307 !current_tab->GetFavIcon().isNull());
2297 } 2308 }
2298 } 2309 }
2299 2310
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
2509 2520
2510 // We need to register the window position pref. 2521 // We need to register the window position pref.
2511 std::wstring window_pref(prefs::kBrowserWindowPlacement); 2522 std::wstring window_pref(prefs::kBrowserWindowPlacement);
2512 window_pref.append(L"_"); 2523 window_pref.append(L"_");
2513 window_pref.append(app_name); 2524 window_pref.append(app_name);
2514 PrefService* prefs = g_browser_process->local_state(); 2525 PrefService* prefs = g_browser_process->local_state();
2515 DCHECK(prefs); 2526 DCHECK(prefs);
2516 2527
2517 prefs->RegisterDictionaryPref(window_pref.c_str()); 2528 prefs->RegisterDictionaryPref(window_pref.c_str());
2518 } 2529 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/dom_ui/dom_ui_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698