| OLD | NEW |
| 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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 "app/animation.h" | 7 #include "app/animation.h" |
| 8 #include "app/l10n_util.h" | 8 #include "app/l10n_util.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/idle_timer.h" | 10 #include "base/idle_timer.h" |
| (...skipping 2256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2267 net::IsSupportedNonImageMimeType( | 2267 net::IsSupportedNonImageMimeType( |
| 2268 current_tab->contents_mime_type().c_str()); | 2268 current_tab->contents_mime_type().c_str()); |
| 2269 | 2269 |
| 2270 // Page-related commands | 2270 // Page-related commands |
| 2271 window_->SetStarredState(current_tab->is_starred()); | 2271 window_->SetStarredState(current_tab->is_starred()); |
| 2272 // View-source should not be enabled if already in view-source mode or | 2272 // View-source should not be enabled if already in view-source mode or |
| 2273 // the source is not viewable. | 2273 // the source is not viewable. |
| 2274 command_updater_.UpdateCommandEnabled(IDC_VIEW_SOURCE, | 2274 command_updater_.UpdateCommandEnabled(IDC_VIEW_SOURCE, |
| 2275 active_entry && !active_entry->IsViewSourceMode() && | 2275 active_entry && !active_entry->IsViewSourceMode() && |
| 2276 is_source_viewable); | 2276 is_source_viewable); |
| 2277 |
| 2278 // Instead of using GetURL here, we use url() (which is the "real" url of the |
| 2279 // page) from the NavigationEntry because its reflects their origin rather |
| 2280 // than the display one (returned by GetURL) which may be different (like |
| 2281 // having "view-source:" on the front). |
| 2282 GURL savable_url = (active_entry) ? active_entry->url() : GURL::EmptyGURL(); |
| 2283 |
| 2277 command_updater_.UpdateCommandEnabled(IDC_SAVE_PAGE, | 2284 command_updater_.UpdateCommandEnabled(IDC_SAVE_PAGE, |
| 2278 SavePackage::IsSavableURL(current_tab->GetURL())); | 2285 SavePackage::IsSavableURL(savable_url)); |
| 2279 command_updater_.UpdateCommandEnabled(IDC_ENCODING_MENU, | 2286 command_updater_.UpdateCommandEnabled(IDC_ENCODING_MENU, |
| 2280 SavePackage::IsSavableContents(current_tab->contents_mime_type()) && | 2287 SavePackage::IsSavableContents(current_tab->contents_mime_type()) && |
| 2281 SavePackage::IsSavableURL(current_tab->GetURL())); | 2288 SavePackage::IsSavableURL(savable_url)); |
| 2282 | 2289 |
| 2283 // Show various bits of UI | 2290 // Show various bits of UI |
| 2284 command_updater_.UpdateCommandEnabled(IDC_CREATE_SHORTCUTS, | 2291 command_updater_.UpdateCommandEnabled(IDC_CREATE_SHORTCUTS, |
| 2285 !current_tab->GetFavIcon().isNull()); | 2292 !current_tab->GetFavIcon().isNull()); |
| 2286 } | 2293 } |
| 2287 | 2294 |
| 2288 void Browser::UpdateStopGoState(bool is_loading, bool force) { | 2295 void Browser::UpdateStopGoState(bool is_loading, bool force) { |
| 2289 window_->UpdateStopGoState(is_loading, force); | 2296 window_->UpdateStopGoState(is_loading, force); |
| 2290 command_updater_.UpdateCommandEnabled(IDC_GO, !is_loading); | 2297 command_updater_.UpdateCommandEnabled(IDC_GO, !is_loading); |
| 2291 command_updater_.UpdateCommandEnabled(IDC_STOP, is_loading); | 2298 command_updater_.UpdateCommandEnabled(IDC_STOP, is_loading); |
| (...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2791 /////////////////////////////////////////////////////////////////////////////// | 2798 /////////////////////////////////////////////////////////////////////////////// |
| 2792 // BrowserToolbarModel (private): | 2799 // BrowserToolbarModel (private): |
| 2793 | 2800 |
| 2794 NavigationController* Browser::BrowserToolbarModel::GetNavigationController() { | 2801 NavigationController* Browser::BrowserToolbarModel::GetNavigationController() { |
| 2795 // This |current_tab| can be NULL during the initialization of the | 2802 // This |current_tab| can be NULL during the initialization of the |
| 2796 // toolbar during window creation (i.e. before any tabs have been added | 2803 // toolbar during window creation (i.e. before any tabs have been added |
| 2797 // to the window). | 2804 // to the window). |
| 2798 TabContents* current_tab = browser_->GetSelectedTabContents(); | 2805 TabContents* current_tab = browser_->GetSelectedTabContents(); |
| 2799 return current_tab ? ¤t_tab->controller() : NULL; | 2806 return current_tab ? ¤t_tab->controller() : NULL; |
| 2800 } | 2807 } |
| OLD | NEW |