| 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.h" | 5 #include "chrome/browser/ui/browser.h" |
| 6 | 6 |
| 7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
| 8 #include <windows.h> | 8 #include <windows.h> |
| 9 #include <shellapi.h> | 9 #include <shellapi.h> |
| 10 #endif // defined(OS_WIN) | 10 #endif // defined(OS_WIN) |
| 11 | 11 |
| 12 #include <algorithm> | 12 #include <algorithm> |
| 13 #include <string> | 13 #include <string> |
| 14 | 14 |
| 15 #include "base/base_paths.h" | 15 #include "base/base_paths.h" |
| 16 #include "base/bind.h" | 16 #include "base/bind.h" |
| 17 #include "base/command_line.h" | 17 #include "base/command_line.h" |
| 18 #include "base/logging.h" | 18 #include "base/logging.h" |
| 19 #include "base/metrics/histogram.h" | 19 #include "base/metrics/histogram.h" |
| 20 #include "base/prefs/pref_service.h" | 20 #include "base/prefs/pref_service.h" |
| 21 #include "base/process/process_info.h" | 21 #include "base/process/process_info.h" |
| 22 #include "base/profiler/scoped_tracker.h" |
| 22 #include "base/strings/string_number_conversions.h" | 23 #include "base/strings/string_number_conversions.h" |
| 23 #include "base/strings/string_util.h" | 24 #include "base/strings/string_util.h" |
| 24 #include "base/strings/stringprintf.h" | 25 #include "base/strings/stringprintf.h" |
| 25 #include "base/strings/utf_string_conversions.h" | 26 #include "base/strings/utf_string_conversions.h" |
| 26 #include "base/threading/thread.h" | 27 #include "base/threading/thread.h" |
| 27 #include "base/threading/thread_restrictions.h" | 28 #include "base/threading/thread_restrictions.h" |
| 28 #include "base/time/time.h" | 29 #include "base/time/time.h" |
| 29 #include "chrome/app/chrome_command_ids.h" | 30 #include "chrome/app/chrome_command_ids.h" |
| 30 #include "chrome/browser/app_mode/app_mode_utils.h" | 31 #include "chrome/browser/app_mode/app_mode_utils.h" |
| 31 #include "chrome/browser/autofill/personal_data_manager_factory.h" | 32 #include "chrome/browser/autofill/personal_data_manager_factory.h" |
| (...skipping 1349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1381 } | 1382 } |
| 1382 } | 1383 } |
| 1383 | 1384 |
| 1384 chrome::Navigate(&nav_params); | 1385 chrome::Navigate(&nav_params); |
| 1385 | 1386 |
| 1386 return nav_params.target_contents; | 1387 return nav_params.target_contents; |
| 1387 } | 1388 } |
| 1388 | 1389 |
| 1389 void Browser::NavigationStateChanged(WebContents* source, | 1390 void Browser::NavigationStateChanged(WebContents* source, |
| 1390 content::InvalidateTypes changed_flags) { | 1391 content::InvalidateTypes changed_flags) { |
| 1392 // TODO(erikchen): Remove ScopedTracker below once http://crbug.com/466285 |
| 1393 // is fixed. |
| 1394 tracked_objects::ScopedTracker tracking_profile1( |
| 1395 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 1396 "466285 Browser::NavigationStateChanged::ScheduleUIUpdate")); |
| 1391 // Only update the UI when something visible has changed. | 1397 // Only update the UI when something visible has changed. |
| 1392 if (changed_flags) | 1398 if (changed_flags) |
| 1393 ScheduleUIUpdate(source, changed_flags); | 1399 ScheduleUIUpdate(source, changed_flags); |
| 1394 | 1400 |
| 1401 // TODO(erikchen): Remove ScopedTracker below once http://crbug.com/466285 |
| 1402 // is fixed. |
| 1403 tracked_objects::ScopedTracker tracking_profile2( |
| 1404 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 1405 "466285 Browser::NavigationStateChanged::TabStateChanged")); |
| 1395 // We can synchronously update commands since they will only change once per | 1406 // We can synchronously update commands since they will only change once per |
| 1396 // navigation, so we don't have to worry about flickering. We do, however, | 1407 // navigation, so we don't have to worry about flickering. We do, however, |
| 1397 // need to update the command state early on load to always present usable | 1408 // need to update the command state early on load to always present usable |
| 1398 // actions in the face of slow-to-commit pages. | 1409 // actions in the face of slow-to-commit pages. |
| 1399 if (changed_flags & (content::INVALIDATE_TYPE_URL | | 1410 if (changed_flags & (content::INVALIDATE_TYPE_URL | |
| 1400 content::INVALIDATE_TYPE_LOAD)) | 1411 content::INVALIDATE_TYPE_LOAD)) |
| 1401 command_controller_->TabStateChanged(); | 1412 command_controller_->TabStateChanged(); |
| 1402 } | 1413 } |
| 1403 | 1414 |
| 1404 void Browser::VisibleSSLStateChanged(const WebContents* source) { | 1415 void Browser::VisibleSSLStateChanged(const WebContents* source) { |
| (...skipping 695 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2100 window_->UpdateToolbar(should_restore_state ? | 2111 window_->UpdateToolbar(should_restore_state ? |
| 2101 tab_strip_model_->GetActiveWebContents() : NULL); | 2112 tab_strip_model_->GetActiveWebContents() : NULL); |
| 2102 } | 2113 } |
| 2103 | 2114 |
| 2104 void Browser::ScheduleUIUpdate(WebContents* source, | 2115 void Browser::ScheduleUIUpdate(WebContents* source, |
| 2105 unsigned changed_flags) { | 2116 unsigned changed_flags) { |
| 2106 DCHECK(source); | 2117 DCHECK(source); |
| 2107 int index = tab_strip_model_->GetIndexOfWebContents(source); | 2118 int index = tab_strip_model_->GetIndexOfWebContents(source); |
| 2108 DCHECK_NE(TabStripModel::kNoTab, index); | 2119 DCHECK_NE(TabStripModel::kNoTab, index); |
| 2109 | 2120 |
| 2121 // TODO(erikchen): Remove ScopedTracker below once http://crbug.com/466285 |
| 2122 // is fixed. |
| 2123 tracked_objects::ScopedTracker tracking_profile1( |
| 2124 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 2125 "466285 Browser::ScheduleUIUpdate::Toolbar")); |
| 2110 // Do some synchronous updates. | 2126 // Do some synchronous updates. |
| 2111 if (changed_flags & content::INVALIDATE_TYPE_URL) { | 2127 if (changed_flags & content::INVALIDATE_TYPE_URL) { |
| 2112 if (source == tab_strip_model_->GetActiveWebContents()) { | 2128 if (source == tab_strip_model_->GetActiveWebContents()) { |
| 2113 // Only update the URL for the current tab. Note that we do not update | 2129 // Only update the URL for the current tab. Note that we do not update |
| 2114 // the navigation commands since those would have already been updated | 2130 // the navigation commands since those would have already been updated |
| 2115 // synchronously by NavigationStateChanged. | 2131 // synchronously by NavigationStateChanged. |
| 2116 UpdateToolbar(false); | 2132 UpdateToolbar(false); |
| 2117 } else { | 2133 } else { |
| 2118 // Clear the saved tab state for the tab that navigated, so that we don't | 2134 // Clear the saved tab state for the tab that navigated, so that we don't |
| 2119 // restore any user text after the old URL has been invalidated (e.g., | 2135 // restore any user text after the old URL has been invalidated (e.g., |
| 2120 // after a new navigation commits in that tab while unfocused). | 2136 // after a new navigation commits in that tab while unfocused). |
| 2121 window_->ResetToolbarTabState(source); | 2137 window_->ResetToolbarTabState(source); |
| 2122 } | 2138 } |
| 2123 changed_flags &= ~content::INVALIDATE_TYPE_URL; | 2139 changed_flags &= ~content::INVALIDATE_TYPE_URL; |
| 2124 } | 2140 } |
| 2141 |
| 2142 // TODO(erikchen): Remove ScopedTracker below once http://crbug.com/466285 |
| 2143 // is fixed. |
| 2144 tracked_objects::ScopedTracker tracking_profile2( |
| 2145 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 2146 "466285 Browser::ScheduleUIUpdate::TabStripModel")); |
| 2125 if (changed_flags & content::INVALIDATE_TYPE_LOAD) { | 2147 if (changed_flags & content::INVALIDATE_TYPE_LOAD) { |
| 2126 // Update the loading state synchronously. This is so the throbber will | 2148 // Update the loading state synchronously. This is so the throbber will |
| 2127 // immediately start/stop, which gives a more snappy feel. We want to do | 2149 // immediately start/stop, which gives a more snappy feel. We want to do |
| 2128 // this for any tab so they start & stop quickly. | 2150 // this for any tab so they start & stop quickly. |
| 2129 tab_strip_model_->UpdateWebContentsStateAt( | 2151 tab_strip_model_->UpdateWebContentsStateAt( |
| 2130 tab_strip_model_->GetIndexOfWebContents(source), | 2152 tab_strip_model_->GetIndexOfWebContents(source), |
| 2131 TabStripModelObserver::LOADING_ONLY); | 2153 TabStripModelObserver::LOADING_ONLY); |
| 2132 // The status bubble needs to be updated during INVALIDATE_TYPE_LOAD too, | 2154 // The status bubble needs to be updated during INVALIDATE_TYPE_LOAD too, |
| 2133 // but we do that asynchronously by not stripping INVALIDATE_TYPE_LOAD from | 2155 // but we do that asynchronously by not stripping INVALIDATE_TYPE_LOAD from |
| 2134 // changed_flags. | 2156 // changed_flags. |
| (...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2544 if (contents && !allow_js_access) { | 2566 if (contents && !allow_js_access) { |
| 2545 contents->web_contents()->GetController().LoadURL( | 2567 contents->web_contents()->GetController().LoadURL( |
| 2546 target_url, | 2568 target_url, |
| 2547 content::Referrer(), | 2569 content::Referrer(), |
| 2548 ui::PAGE_TRANSITION_LINK, | 2570 ui::PAGE_TRANSITION_LINK, |
| 2549 std::string()); // No extra headers. | 2571 std::string()); // No extra headers. |
| 2550 } | 2572 } |
| 2551 | 2573 |
| 2552 return contents != NULL; | 2574 return contents != NULL; |
| 2553 } | 2575 } |
| OLD | NEW |