| 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/keyboard_codes.h" | 10 #include "base/keyboard_codes.h" |
| (...skipping 1061 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1072 } | 1072 } |
| 1073 | 1073 |
| 1074 void Browser::FocusSearch() { | 1074 void Browser::FocusSearch() { |
| 1075 // TODO(beng): replace this with FocusLocationBar | 1075 // TODO(beng): replace this with FocusLocationBar |
| 1076 UserMetrics::RecordAction(L"FocusSearch", profile_); | 1076 UserMetrics::RecordAction(L"FocusSearch", profile_); |
| 1077 window_->GetLocationBar()->FocusSearch(); | 1077 window_->GetLocationBar()->FocusSearch(); |
| 1078 } | 1078 } |
| 1079 | 1079 |
| 1080 void Browser::OpenFile() { | 1080 void Browser::OpenFile() { |
| 1081 UserMetrics::RecordAction(L"OpenFile", profile_); | 1081 UserMetrics::RecordAction(L"OpenFile", profile_); |
| 1082 |
| 1083 TabContents* contents = GetSelectedTabContents(); |
| 1084 if (!contents) { // Avoid crashing in release. |
| 1085 NOTREACHED(); |
| 1086 return; |
| 1087 } |
| 1088 |
| 1089 // TODO(beng): figure out how to juggle this. |
| 1090 #if defined(OS_MACOSX) |
| 1091 // TODO(viettrungluu@gmail.com): If there's a constrained dialog in the |
| 1092 // current tab, we should probably just create a new tab and go do the open |
| 1093 // there. (Why not just close the current dialog, esp. if it's not important? |
| 1094 // If we did that, then the previous one should come back with its original |
| 1095 // state on cancel.) |
| 1096 if (!contents->CanCreateConstrainedDialog()) { |
| 1097 if (type() == TYPE_NORMAL) { |
| 1098 contents = AddBlankTab(true); |
| 1099 if (!contents) { // Avoid crashing in release. |
| 1100 NOTREACHED(); |
| 1101 return; |
| 1102 } |
| 1103 } else { |
| 1104 // TODO(viettrungluu@gmail.com): the other cases. |
| 1105 NOTIMPLEMENTED(); |
| 1106 return; |
| 1107 } |
| 1108 } |
| 1109 |
| 1110 if (!contents->CanCreateConstrainedDialog()) { // Avoid crashing in release. |
| 1111 NOTREACHED(); |
| 1112 return; |
| 1113 } |
| 1114 |
| 1082 if (!select_file_dialog_.get()) | 1115 if (!select_file_dialog_.get()) |
| 1083 select_file_dialog_ = SelectFileDialog::Create(this); | 1116 select_file_dialog_ = SelectFileDialog::Create(this); |
| 1084 | 1117 select_file_dialog_->SelectFileInTab(SelectFileDialog::SELECT_OPEN_FILE, |
| 1085 // TODO(beng): figure out how to juggle this. | 1118 string16(), FilePath(), |
| 1119 NULL, 0, FILE_PATH_LITERAL(""), |
| 1120 contents, NULL); |
| 1121 #else |
| 1122 if (!select_file_dialog_.get()) |
| 1123 select_file_dialog_ = SelectFileDialog::Create(this); |
| 1086 gfx::NativeWindow parent_window = window_->GetNativeHandle(); | 1124 gfx::NativeWindow parent_window = window_->GetNativeHandle(); |
| 1087 select_file_dialog_->SelectFile(SelectFileDialog::SELECT_OPEN_FILE, | 1125 select_file_dialog_->SelectFile(SelectFileDialog::SELECT_OPEN_FILE, |
| 1088 string16(), FilePath(), | 1126 string16(), FilePath(), |
| 1089 NULL, 0, FILE_PATH_LITERAL(""), | 1127 NULL, 0, FILE_PATH_LITERAL(""), |
| 1090 parent_window, NULL); | 1128 parent_window, NULL); |
| 1129 #endif |
| 1091 } | 1130 } |
| 1092 | 1131 |
| 1093 void Browser::OpenCreateShortcutsDialog() { | 1132 void Browser::OpenCreateShortcutsDialog() { |
| 1094 UserMetrics::RecordAction(L"CreateShortcut", profile_); | 1133 UserMetrics::RecordAction(L"CreateShortcut", profile_); |
| 1095 #if defined(OS_WIN) || defined(OS_LINUX) | 1134 #if defined(OS_WIN) || defined(OS_LINUX) |
| 1096 GetSelectedTabContents()->CreateShortcut(); | 1135 GetSelectedTabContents()->CreateShortcut(); |
| 1097 #else | 1136 #else |
| 1098 NOTIMPLEMENTED(); | 1137 NOTIMPLEMENTED(); |
| 1099 #endif | 1138 #endif |
| 1100 } | 1139 } |
| (...skipping 873 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1974 void Browser::UpdateTargetURL(TabContents* source, const GURL& url) { | 2013 void Browser::UpdateTargetURL(TabContents* source, const GURL& url) { |
| 1975 if (!GetStatusBubble()) | 2014 if (!GetStatusBubble()) |
| 1976 return; | 2015 return; |
| 1977 | 2016 |
| 1978 if (source == GetSelectedTabContents()) { | 2017 if (source == GetSelectedTabContents()) { |
| 1979 PrefService* prefs = profile_->GetPrefs(); | 2018 PrefService* prefs = profile_->GetPrefs(); |
| 1980 GetStatusBubble()->SetURL(url, prefs->GetString(prefs::kAcceptLanguages)); | 2019 GetStatusBubble()->SetURL(url, prefs->GetString(prefs::kAcceptLanguages)); |
| 1981 } | 2020 } |
| 1982 } | 2021 } |
| 1983 | 2022 |
| 2023 void Browser::ChildWindowsChanged(TabContents* source) { |
| 2024 if (source == GetSelectedTabContents()) |
| 2025 UpdateCommandsForTabState(); |
| 2026 } |
| 2027 |
| 1984 void Browser::UpdateDownloadShelfVisibility(bool visible) { | 2028 void Browser::UpdateDownloadShelfVisibility(bool visible) { |
| 1985 if (GetStatusBubble()) | 2029 if (GetStatusBubble()) |
| 1986 GetStatusBubble()->UpdateDownloadShelfVisibility(visible); | 2030 GetStatusBubble()->UpdateDownloadShelfVisibility(visible); |
| 1987 } | 2031 } |
| 1988 | 2032 |
| 1989 void Browser::ContentsZoomChange(bool zoom_in) { | 2033 void Browser::ContentsZoomChange(bool zoom_in) { |
| 1990 ExecuteCommand(zoom_in ? IDC_ZOOM_PLUS : IDC_ZOOM_MINUS); | 2034 ExecuteCommand(zoom_in ? IDC_ZOOM_PLUS : IDC_ZOOM_MINUS); |
| 1991 } | 2035 } |
| 1992 | 2036 |
| 1993 void Browser::TabContentsFocused(TabContents* tab_content) { | 2037 void Browser::TabContentsFocused(TabContents* tab_content) { |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2331 command_updater_.UpdateCommandEnabled(IDC_ENCODING_ISO885914, true); | 2375 command_updater_.UpdateCommandEnabled(IDC_ENCODING_ISO885914, true); |
| 2332 command_updater_.UpdateCommandEnabled(IDC_ENCODING_ISO885916, true); | 2376 command_updater_.UpdateCommandEnabled(IDC_ENCODING_ISO885916, true); |
| 2333 command_updater_.UpdateCommandEnabled(IDC_ENCODING_WINDOWS1254, true); | 2377 command_updater_.UpdateCommandEnabled(IDC_ENCODING_WINDOWS1254, true); |
| 2334 command_updater_.UpdateCommandEnabled(IDC_ENCODING_ISO88596, true); | 2378 command_updater_.UpdateCommandEnabled(IDC_ENCODING_ISO88596, true); |
| 2335 command_updater_.UpdateCommandEnabled(IDC_ENCODING_WINDOWS1256, true); | 2379 command_updater_.UpdateCommandEnabled(IDC_ENCODING_WINDOWS1256, true); |
| 2336 command_updater_.UpdateCommandEnabled(IDC_ENCODING_ISO88598, true); | 2380 command_updater_.UpdateCommandEnabled(IDC_ENCODING_ISO88598, true); |
| 2337 command_updater_.UpdateCommandEnabled(IDC_ENCODING_ISO88598I, true); | 2381 command_updater_.UpdateCommandEnabled(IDC_ENCODING_ISO88598I, true); |
| 2338 command_updater_.UpdateCommandEnabled(IDC_ENCODING_WINDOWS1255, true); | 2382 command_updater_.UpdateCommandEnabled(IDC_ENCODING_WINDOWS1255, true); |
| 2339 command_updater_.UpdateCommandEnabled(IDC_ENCODING_WINDOWS1258, true); | 2383 command_updater_.UpdateCommandEnabled(IDC_ENCODING_WINDOWS1258, true); |
| 2340 | 2384 |
| 2385 #if defined(OS_MACOSX) |
| 2386 // On Mac, we do not disable the Encoding menu, but rather the individual menu |
| 2387 // items (like other Mac apps). The Encoding menu's contents start out |
| 2388 // disabled by default. |
| 2389 command_updater_.UpdateCommandEnabled(IDC_ENCODING_MENU, true); |
| 2390 #endif |
| 2391 |
| 2341 // Clipboard commands | 2392 // Clipboard commands |
| 2342 command_updater_.UpdateCommandEnabled(IDC_CUT, true); | 2393 command_updater_.UpdateCommandEnabled(IDC_CUT, true); |
| 2343 command_updater_.UpdateCommandEnabled(IDC_COPY, true); | 2394 command_updater_.UpdateCommandEnabled(IDC_COPY, true); |
| 2344 command_updater_.UpdateCommandEnabled(IDC_PASTE, true); | 2395 command_updater_.UpdateCommandEnabled(IDC_PASTE, true); |
| 2345 command_updater_.UpdateCommandEnabled(IDC_COPY_URL, true); | 2396 command_updater_.UpdateCommandEnabled(IDC_COPY_URL, true); |
| 2346 | 2397 |
| 2347 // Find-in-page | 2398 // Find-in-page |
| 2348 command_updater_.UpdateCommandEnabled(IDC_FIND, true); | 2399 command_updater_.UpdateCommandEnabled(IDC_FIND, true); |
| 2349 command_updater_.UpdateCommandEnabled(IDC_FIND_NEXT, true); | 2400 command_updater_.UpdateCommandEnabled(IDC_FIND_NEXT, true); |
| 2350 command_updater_.UpdateCommandEnabled(IDC_FIND_PREVIOUS, true); | 2401 command_updater_.UpdateCommandEnabled(IDC_FIND_PREVIOUS, true); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2412 | 2463 |
| 2413 // Show various bits of UI | 2464 // Show various bits of UI |
| 2414 command_updater_.UpdateCommandEnabled(IDC_CLEAR_BROWSING_DATA, | 2465 command_updater_.UpdateCommandEnabled(IDC_CLEAR_BROWSING_DATA, |
| 2415 normal_window); | 2466 normal_window); |
| 2416 } | 2467 } |
| 2417 | 2468 |
| 2418 // Initialize other commands whose state changes based on fullscreen mode. | 2469 // Initialize other commands whose state changes based on fullscreen mode. |
| 2419 UpdateCommandsForFullscreenMode(false); | 2470 UpdateCommandsForFullscreenMode(false); |
| 2420 } | 2471 } |
| 2421 | 2472 |
| 2473 #if defined(OS_MACOSX) |
| 2474 // TODO(viettrungluu@gmail.com): Merge with non-Mac implementation. The main |
| 2475 // differences are: (1) on Mac, we have full-tab-modals; (2) on Mac, we have a |
| 2476 // global application menu. |
| 2477 void Browser::UpdateCommandsForTabState() { |
| 2478 struct cmd_disabled_at { |
| 2479 int cmd_id; |
| 2480 ConstrainedWindow::ModalityLevel level; |
| 2481 }; |
| 2482 // Notes: |
| 2483 // - IDC_GO should be tied to IDC_OPEN_CURRENT_URL (i.e., the latter disables |
| 2484 // the former) |
| 2485 // - is IDC_STOP tied to IDC_GO? at least the button should be, right? |
| 2486 // - unknown: IDC_CLOSE_POPUPS |
| 2487 // - this is designed to handle additional entries (e.g., for |
| 2488 // |kModalForWindow|, or a hypothetical |kModalForApp|) |
| 2489 // TODO(viettrungluu@gmail.com): move the modality stuff to somewhere where we |
| 2490 // can use it during window modals |
| 2491 // TODO(viettrungluu@gmail.com): IDC_OPEN_RECENT_MENU_CONTENTS isn't actually |
| 2492 // picked up by anything (actually, it doesn't do anything either) |
| 2493 // FIXME(viettrungluu@gmail.com): IDC_PRINT is still really wonky (presumably |
| 2494 // because it determines whether it's active by sending up the responder |
| 2495 // chain) |
| 2496 const cmd_disabled_at k_cmd_levels[] = { |
| 2497 { IDC_OPEN_FILE, ConstrainedWindow::kModalForTab }, |
| 2498 { IDC_SAVE_PAGE, ConstrainedWindow::kModalForContent }, |
| 2499 { IDC_FOCUS_LOCATION, ConstrainedWindow::kModalForTab }, |
| 2500 // FIXME(viettrungluU@gmail.com): I think page setup will app-modal or modeless |
| 2501 // { IDC_PRINT_PAGE_SETUP, ConstrainedWindow::kModalForContent }, |
| 2502 { IDC_PRINT, ConstrainedWindow::kModalForContent }, |
| 2503 { IDC_SHOW_BOOKMARK_BAR, ConstrainedWindow::kModalForTab }, |
| 2504 { IDC_STOP, ConstrainedWindow::kModalForTab }, |
| 2505 { IDC_RELOAD, ConstrainedWindow::kModalForTab }, |
| 2506 { IDC_ZOOM_PLUS, ConstrainedWindow::kModalForTab }, |
| 2507 { IDC_ZOOM_NORMAL, ConstrainedWindow::kModalForTab }, |
| 2508 { IDC_ZOOM_MINUS, ConstrainedWindow::kModalForTab }, |
| 2509 { IDC_VIEW_SOURCE, ConstrainedWindow::kModalForTab }, |
| 2510 { IDC_DEV_TOOLS, ConstrainedWindow::kModalForTab }, |
| 2511 { IDC_STAR, ConstrainedWindow::kModalForTab }, |
| 2512 { IDC_BACK, ConstrainedWindow::kModalForTab }, |
| 2513 { IDC_FORWARD, ConstrainedWindow::kModalForTab }, |
| 2514 { IDC_HOME, ConstrainedWindow::kModalForTab }, |
| 2515 { IDC_OPEN_CURRENT_URL, ConstrainedWindow::kModalForTab }, |
| 2516 { IDC_FIND, ConstrainedWindow::kModalForContent }, |
| 2517 { IDC_FIND_NEXT, ConstrainedWindow::kModalForContent }, |
| 2518 { IDC_FIND_PREVIOUS, ConstrainedWindow::kModalForContent }, |
| 2519 { IDC_PAGE_MENU_BUTTON, ConstrainedWindow::kModalForTab }, |
| 2520 { IDC_WRENCH_MENU_BUTTON, ConstrainedWindow::kModalForTab }, |
| 2521 { IDC_OPEN_RECENT_MENU_CONTENTS, ConstrainedWindow::kModalForTab }, |
| 2522 { IDC_HISTORY_MENU_CONTENTS, ConstrainedWindow::kModalForTab }, |
| 2523 { IDC_BOOKMARK_MENU_CONTENTS, ConstrainedWindow::kModalForTab }, |
| 2524 // On Mac, we disable the Encoding menu's contents |
| 2525 // (IDC_ENCODING_MENU_CONTENTS) rather than the menu (IDC_ENCODING_MENU). |
| 2526 { IDC_ENCODING_MENU_CONTENTS, ConstrainedWindow::kModalForTab }, |
| 2527 }; |
| 2528 const size_t k_num_cmd_levels = ARRAYSIZE_UNSAFE(k_cmd_levels); |
| 2529 |
| 2530 TabContents* current_tab = GetSelectedTabContents(); |
| 2531 if (!current_tab) // May be NULL during tab restore. |
| 2532 return; |
| 2533 |
| 2534 // We make a map out of the above, and "calculate" enable/disable states on |
| 2535 // the map. We store *disabled* status (i.e., true if disabled), since STL |
| 2536 // will initialize bool's to false by default (and we want default enabled). |
| 2537 // See below for how to (possibly) modify the state. |
| 2538 std::map<int,bool> disable_cmd; |
| 2539 ConstrainedWindow::ModalityLevel cur_lev = current_tab->GetTabModalityLevel(); |
| 2540 for (size_t i = 0; i < k_num_cmd_levels; ++i) |
| 2541 disable_cmd[k_cmd_levels[i].cmd_id] = (cur_lev >= k_cmd_levels[i].level); |
| 2542 |
| 2543 // === Keep in sync with non-Mac implementation (below) |
| 2544 |
| 2545 // Navigation commands |
| 2546 NavigationController& nc = current_tab->controller(); |
| 2547 disable_cmd[IDC_BACK] |= !nc.CanGoBack(); |
| 2548 disable_cmd[IDC_FORWARD] |= !nc.CanGoForward(); |
| 2549 |
| 2550 // Window management commands |
| 2551 disable_cmd[IDC_DUPLICATE_TAB] |= !(!(type() & TYPE_APP) && |
| 2552 CanDuplicateContentsAt(selected_index())); |
| 2553 |
| 2554 // Current navigation entry, may be NULL. |
| 2555 NavigationEntry* active_entry = current_tab->controller().GetActiveEntry(); |
| 2556 bool is_source_viewable = net::IsSupportedNonImageMimeType( |
| 2557 current_tab->contents_mime_type().c_str()); |
| 2558 |
| 2559 // Page-related commands |
| 2560 window_->SetStarredState(current_tab->is_starred()); |
| 2561 // View-source should not be enabled if already in view-source mode or |
| 2562 // the source is not viewable. |
| 2563 disable_cmd[IDC_VIEW_SOURCE] |= !(active_entry && |
| 2564 !active_entry->IsViewSourceMode() && |
| 2565 is_source_viewable); |
| 2566 disable_cmd[IDC_SAVE_PAGE] |= |
| 2567 !(SavePackage::IsSavableURL(current_tab->GetURL())); |
| 2568 |
| 2569 // We don't enable/disable the Encoding menu on Mac, but its contents (see |
| 2570 // note above). |
| 2571 disable_cmd[IDC_ENCODING_MENU_CONTENTS] |= |
| 2572 !(SavePackage::IsSavableContents(current_tab->contents_mime_type()) && |
| 2573 SavePackage::IsSavableURL(current_tab->GetURL())); |
| 2574 |
| 2575 // Show various bits of UI |
| 2576 disable_cmd[IDC_CREATE_SHORTCUTS] |= current_tab->GetFavIcon().isNull(); |
| 2577 |
| 2578 // === end sync |
| 2579 |
| 2580 // TODO(viettrungluu@gmail.com): not complete; should other implementation |
| 2581 // have this? |
| 2582 disable_cmd[IDC_PRINT] |= !active_entry; |
| 2583 |
| 2584 // Now we update commands. |
| 2585 std::map<int,bool>::iterator it, end; |
| 2586 for (it = disable_cmd.begin(), end = disable_cmd.end(); it != end; ++it) |
| 2587 command_updater_.UpdateCommandEnabled(it->first, !(it->second)); |
| 2588 } |
| 2589 #else |
| 2422 void Browser::UpdateCommandsForTabState() { | 2590 void Browser::UpdateCommandsForTabState() { |
| 2423 TabContents* current_tab = GetSelectedTabContents(); | 2591 TabContents* current_tab = GetSelectedTabContents(); |
| 2424 if (!current_tab) // May be NULL during tab restore. | 2592 if (!current_tab) // May be NULL during tab restore. |
| 2425 return; | 2593 return; |
| 2426 | 2594 |
| 2427 // Navigation commands | 2595 // Navigation commands |
| 2428 NavigationController& nc = current_tab->controller(); | 2596 NavigationController& nc = current_tab->controller(); |
| 2429 command_updater_.UpdateCommandEnabled(IDC_BACK, nc.CanGoBack()); | 2597 command_updater_.UpdateCommandEnabled(IDC_BACK, nc.CanGoBack()); |
| 2430 command_updater_.UpdateCommandEnabled(IDC_FORWARD, nc.CanGoForward()); | 2598 command_updater_.UpdateCommandEnabled(IDC_FORWARD, nc.CanGoForward()); |
| 2431 | 2599 |
| 2432 // Window management commands | 2600 // Window management commands |
| 2433 command_updater_.UpdateCommandEnabled(IDC_DUPLICATE_TAB, | 2601 command_updater_.UpdateCommandEnabled(IDC_DUPLICATE_TAB, |
| 2434 !(type() & TYPE_APP) && CanDuplicateContentsAt(selected_index())); | 2602 !(type() & TYPE_APP) && CanDuplicateContentsAt(selected_index())); |
| 2435 | 2603 |
| 2436 // Current navigation entry, may be NULL. | 2604 // Current navigation entry, may be NULL. |
| 2437 NavigationEntry* active_entry = current_tab->controller().GetActiveEntry(); | 2605 NavigationEntry* active_entry = current_tab->controller().GetActiveEntry(); |
| 2438 bool is_source_viewable = | 2606 bool is_source_viewable = |
| 2439 net::IsSupportedNonImageMimeType( | 2607 net::IsSupportedNonImageMimeType( |
| 2440 current_tab->contents_mime_type().c_str()); | 2608 current_tab->contents_mime_type().c_str()); |
| 2441 | 2609 |
| 2442 // Page-related commands | 2610 // Page-related commands |
| 2443 window_->SetStarredState(current_tab->is_starred()); | 2611 window_->SetStarredState(current_tab->is_starred()); |
| 2444 // View-source should not be enabled if already in view-source mode or | 2612 // View-source should not be enabled if already in view-source mode or |
| 2445 // the source is not viewable. | 2613 // the source is not viewable. |
| 2446 command_updater_.UpdateCommandEnabled(IDC_VIEW_SOURCE, | 2614 command_updater_.UpdateCommandEnabled(IDC_VIEW_SOURCE, |
| 2447 active_entry && !active_entry->IsViewSourceMode() && | 2615 active_entry && !active_entry->IsViewSourceMode() && |
| 2448 is_source_viewable); | 2616 is_source_viewable); |
| 2449 | 2617 |
| 2450 // Instead of using GetURL here, we use url() (which is the "real" url of the | 2618 // Instead of using GetURL here, we use url() (which is the "real" url of the |
| 2451 // page) from the NavigationEntry because its reflects their origin rather | 2619 // page) from the NavigationEntry because its reflects their origin rather |
| 2452 // than the display one (returned by GetURL) which may be different (like | 2620 // than the display one (returned by GetURL) which may be different (like |
| 2453 // having "view-source:" on the front). | 2621 // having "view-source:" on the front). |
| 2454 GURL savable_url = (active_entry) ? active_entry->url() : GURL::EmptyGURL(); | 2622 GURL savable_url = (active_entry) ? active_entry->url() : GURL::EmptyGURL(); |
| 2455 | 2623 |
| 2456 command_updater_.UpdateCommandEnabled(IDC_SAVE_PAGE, | 2624 command_updater_.UpdateCommandEnabled(IDC_SAVE_PAGE, |
| 2457 SavePackage::IsSavableURL(savable_url)); | 2625 SavePackage::IsSavableURL(savable_url)); |
| 2458 command_updater_.UpdateCommandEnabled(IDC_ENCODING_MENU, | 2626 command_updater_.UpdateCommandEnabled(IDC_ENCODING_MENU, |
| 2459 SavePackage::IsSavableContents(current_tab->contents_mime_type()) && | 2627 SavePackage::IsSavableContents(current_tab->contents_mime_type()) && |
| 2460 SavePackage::IsSavableURL(savable_url)); | 2628 SavePackage::IsSavableURL(savable_url)); |
| 2461 | 2629 |
| 2462 // Show various bits of UI | 2630 // Show various bits of UI |
| 2463 command_updater_.UpdateCommandEnabled(IDC_CREATE_SHORTCUTS, | 2631 command_updater_.UpdateCommandEnabled(IDC_CREATE_SHORTCUTS, |
| 2464 !current_tab->GetFavIcon().isNull()); | 2632 !current_tab->GetFavIcon().isNull()); |
| 2465 } | 2633 } |
| 2634 #endif |
| 2466 | 2635 |
| 2467 void Browser::UpdateStopGoState(bool is_loading, bool force) { | 2636 void Browser::UpdateStopGoState(bool is_loading, bool force) { |
| 2468 window_->UpdateStopGoState(is_loading, force); | 2637 window_->UpdateStopGoState(is_loading, force); |
| 2469 command_updater_.UpdateCommandEnabled(IDC_GO, !is_loading); | 2638 command_updater_.UpdateCommandEnabled(IDC_GO, !is_loading); |
| 2470 command_updater_.UpdateCommandEnabled(IDC_STOP, is_loading); | 2639 command_updater_.UpdateCommandEnabled(IDC_STOP, is_loading); |
| 2471 } | 2640 } |
| 2472 | 2641 |
| 2473 | 2642 |
| 2474 /////////////////////////////////////////////////////////////////////////////// | 2643 /////////////////////////////////////////////////////////////////////////////// |
| 2475 // Browser, UI update coalescing and handling (private): | 2644 // Browser, UI update coalescing and handling (private): |
| (...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2966 /////////////////////////////////////////////////////////////////////////////// | 3135 /////////////////////////////////////////////////////////////////////////////// |
| 2967 // BrowserToolbarModel (private): | 3136 // BrowserToolbarModel (private): |
| 2968 | 3137 |
| 2969 NavigationController* Browser::BrowserToolbarModel::GetNavigationController() { | 3138 NavigationController* Browser::BrowserToolbarModel::GetNavigationController() { |
| 2970 // This |current_tab| can be NULL during the initialization of the | 3139 // This |current_tab| can be NULL during the initialization of the |
| 2971 // toolbar during window creation (i.e. before any tabs have been added | 3140 // toolbar during window creation (i.e. before any tabs have been added |
| 2972 // to the window). | 3141 // to the window). |
| 2973 TabContents* current_tab = browser_->GetSelectedTabContents(); | 3142 TabContents* current_tab = browser_->GetSelectedTabContents(); |
| 2974 return current_tab ? ¤t_tab->controller() : NULL; | 3143 return current_tab ? ¤t_tab->controller() : NULL; |
| 2975 } | 3144 } |
| OLD | NEW |