| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // OS_WIN | 10 #endif // OS_WIN |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 #include "content/browser/download/save_package.h" | 144 #include "content/browser/download/save_package.h" |
| 145 #include "content/browser/host_zoom_map.h" | 145 #include "content/browser/host_zoom_map.h" |
| 146 #include "content/browser/plugin_service.h" | 146 #include "content/browser/plugin_service.h" |
| 147 #include "content/browser/renderer_host/render_view_host.h" | 147 #include "content/browser/renderer_host/render_view_host.h" |
| 148 #include "content/browser/site_instance.h" | 148 #include "content/browser/site_instance.h" |
| 149 #include "content/browser/tab_contents/interstitial_page.h" | 149 #include "content/browser/tab_contents/interstitial_page.h" |
| 150 #include "content/browser/tab_contents/navigation_controller.h" | 150 #include "content/browser/tab_contents/navigation_controller.h" |
| 151 #include "content/browser/tab_contents/navigation_entry.h" | 151 #include "content/browser/tab_contents/navigation_entry.h" |
| 152 #include "content/browser/tab_contents/tab_contents.h" | 152 #include "content/browser/tab_contents/tab_contents.h" |
| 153 #include "content/browser/tab_contents/tab_contents_view.h" | 153 #include "content/browser/tab_contents/tab_contents_view.h" |
| 154 #include "content/browser/user_metrics.h" | |
| 155 #include "content/public/browser/devtools_manager.h" | 154 #include "content/public/browser/devtools_manager.h" |
| 155 #include "content/public/browser/intents_host.h" |
| 156 #include "content/public/browser/notification_details.h" |
| 156 #include "content/public/browser/notification_service.h" | 157 #include "content/public/browser/notification_service.h" |
| 157 #include "content/public/browser/notification_details.h" | 158 #include "content/public/browser/user_metrics.h" |
| 158 #include "content/public/browser/intents_host.h" | |
| 159 #include "content/public/common/content_restriction.h" | 159 #include "content/public/common/content_restriction.h" |
| 160 #include "content/public/common/content_switches.h" | 160 #include "content/public/common/content_switches.h" |
| 161 #include "content/public/common/page_zoom.h" | 161 #include "content/public/common/page_zoom.h" |
| 162 #include "grit/chromium_strings.h" | 162 #include "grit/chromium_strings.h" |
| 163 #include "grit/generated_resources.h" | 163 #include "grit/generated_resources.h" |
| 164 #include "grit/locale_settings.h" | 164 #include "grit/locale_settings.h" |
| 165 #include "grit/theme_resources_standard.h" | 165 #include "grit/theme_resources_standard.h" |
| 166 #include "net/base/cookie_monster.h" | 166 #include "net/base/cookie_monster.h" |
| 167 #include "net/base/net_util.h" | 167 #include "net/base/net_util.h" |
| 168 #include "net/base/registry_controlled_domain.h" | 168 #include "net/base/registry_controlled_domain.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 199 | 199 |
| 200 #if !defined(OS_CHROMEOS) || defined(USE_AURA) | 200 #if !defined(OS_CHROMEOS) || defined(USE_AURA) |
| 201 #include "chrome/browser/download/download_shelf.h" | 201 #include "chrome/browser/download/download_shelf.h" |
| 202 #endif | 202 #endif |
| 203 | 203 |
| 204 #if defined(FILE_MANAGER_EXTENSION) | 204 #if defined(FILE_MANAGER_EXTENSION) |
| 205 #include "chrome/browser/extensions/file_manager_util.h" | 205 #include "chrome/browser/extensions/file_manager_util.h" |
| 206 #endif | 206 #endif |
| 207 | 207 |
| 208 using base::TimeDelta; | 208 using base::TimeDelta; |
| 209 using content::UserMetricsAction; |
| 209 | 210 |
| 210 /////////////////////////////////////////////////////////////////////////////// | 211 /////////////////////////////////////////////////////////////////////////////// |
| 211 | 212 |
| 212 namespace { | 213 namespace { |
| 213 | 214 |
| 214 // The URL to be loaded to display Help. | 215 // The URL to be loaded to display Help. |
| 215 const char kHelpContentUrl[] = | 216 const char kHelpContentUrl[] = |
| 216 #if defined(OS_CHROMEOS) | 217 #if defined(OS_CHROMEOS) |
| 217 #if defined(OFFICIAL_BUILD) | 218 #if defined(OFFICIAL_BUILD) |
| 218 "chrome-extension://honijodknafkokifofgiaalefdiedpko/main.html"; | 219 "chrome-extension://honijodknafkokifofgiaalefdiedpko/main.html"; |
| (...skipping 1269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1488 CancelWindowClose(); | 1489 CancelWindowClose(); |
| 1489 return can_close; | 1490 return can_close; |
| 1490 } | 1491 } |
| 1491 | 1492 |
| 1492 bool Browser::CanGoBack() const { | 1493 bool Browser::CanGoBack() const { |
| 1493 return GetSelectedTabContentsWrapper()-> | 1494 return GetSelectedTabContentsWrapper()-> |
| 1494 tab_contents()->controller().CanGoBack(); | 1495 tab_contents()->controller().CanGoBack(); |
| 1495 } | 1496 } |
| 1496 | 1497 |
| 1497 void Browser::GoBack(WindowOpenDisposition disposition) { | 1498 void Browser::GoBack(WindowOpenDisposition disposition) { |
| 1498 UserMetrics::RecordAction(UserMetricsAction("Back")); | 1499 content::RecordAction(UserMetricsAction("Back")); |
| 1499 | 1500 |
| 1500 TabContentsWrapper* current_tab = GetSelectedTabContentsWrapper(); | 1501 TabContentsWrapper* current_tab = GetSelectedTabContentsWrapper(); |
| 1501 if (CanGoBack()) { | 1502 if (CanGoBack()) { |
| 1502 TabContents* new_tab = GetOrCloneTabForDisposition(disposition); | 1503 TabContents* new_tab = GetOrCloneTabForDisposition(disposition); |
| 1503 // If we are on an interstitial page and clone the tab, it won't be copied | 1504 // If we are on an interstitial page and clone the tab, it won't be copied |
| 1504 // to the new tab, so we don't need to go back. | 1505 // to the new tab, so we don't need to go back. |
| 1505 if (current_tab->tab_contents()->showing_interstitial_page() && | 1506 if (current_tab->tab_contents()->showing_interstitial_page() && |
| 1506 (new_tab != current_tab->tab_contents())) | 1507 (new_tab != current_tab->tab_contents())) |
| 1507 return; | 1508 return; |
| 1508 new_tab->controller().GoBack(); | 1509 new_tab->controller().GoBack(); |
| 1509 } | 1510 } |
| 1510 } | 1511 } |
| 1511 | 1512 |
| 1512 bool Browser::CanGoForward() const { | 1513 bool Browser::CanGoForward() const { |
| 1513 return GetSelectedTabContentsWrapper()-> | 1514 return GetSelectedTabContentsWrapper()-> |
| 1514 tab_contents()->controller().CanGoForward(); | 1515 tab_contents()->controller().CanGoForward(); |
| 1515 } | 1516 } |
| 1516 | 1517 |
| 1517 void Browser::GoForward(WindowOpenDisposition disposition) { | 1518 void Browser::GoForward(WindowOpenDisposition disposition) { |
| 1518 UserMetrics::RecordAction(UserMetricsAction("Forward")); | 1519 content::RecordAction(UserMetricsAction("Forward")); |
| 1519 if (CanGoForward()) | 1520 if (CanGoForward()) |
| 1520 GetOrCloneTabForDisposition(disposition)->controller().GoForward(); | 1521 GetOrCloneTabForDisposition(disposition)->controller().GoForward(); |
| 1521 } | 1522 } |
| 1522 | 1523 |
| 1523 void Browser::Reload(WindowOpenDisposition disposition) { | 1524 void Browser::Reload(WindowOpenDisposition disposition) { |
| 1524 UserMetrics::RecordAction(UserMetricsAction("Reload")); | 1525 content::RecordAction(UserMetricsAction("Reload")); |
| 1525 ReloadInternal(disposition, false); | 1526 ReloadInternal(disposition, false); |
| 1526 } | 1527 } |
| 1527 | 1528 |
| 1528 void Browser::ReloadIgnoringCache(WindowOpenDisposition disposition) { | 1529 void Browser::ReloadIgnoringCache(WindowOpenDisposition disposition) { |
| 1529 UserMetrics::RecordAction(UserMetricsAction("ReloadIgnoringCache")); | 1530 content::RecordAction(UserMetricsAction("ReloadIgnoringCache")); |
| 1530 ReloadInternal(disposition, true); | 1531 ReloadInternal(disposition, true); |
| 1531 } | 1532 } |
| 1532 | 1533 |
| 1533 void Browser::ReloadInternal(WindowOpenDisposition disposition, | 1534 void Browser::ReloadInternal(WindowOpenDisposition disposition, |
| 1534 bool ignore_cache) { | 1535 bool ignore_cache) { |
| 1535 // If we are showing an interstitial, treat this as an OpenURL. | 1536 // If we are showing an interstitial, treat this as an OpenURL. |
| 1536 TabContents* current_tab = GetSelectedTabContents(); | 1537 TabContents* current_tab = GetSelectedTabContents(); |
| 1537 if (current_tab && current_tab->showing_interstitial_page()) { | 1538 if (current_tab && current_tab->showing_interstitial_page()) { |
| 1538 NavigationEntry* entry = current_tab->controller().GetActiveEntry(); | 1539 NavigationEntry* entry = current_tab->controller().GetActiveEntry(); |
| 1539 DCHECK(entry); // Should exist if interstitial is showing. | 1540 DCHECK(entry); // Should exist if interstitial is showing. |
| 1540 OpenURL(entry->url(), GURL(), disposition, content::PAGE_TRANSITION_RELOAD); | 1541 OpenURL(entry->url(), GURL(), disposition, content::PAGE_TRANSITION_RELOAD); |
| 1541 return; | 1542 return; |
| 1542 } | 1543 } |
| 1543 | 1544 |
| 1544 // As this is caused by a user action, give the focus to the page. | 1545 // As this is caused by a user action, give the focus to the page. |
| 1545 TabContents* tab = GetOrCloneTabForDisposition(disposition); | 1546 TabContents* tab = GetOrCloneTabForDisposition(disposition); |
| 1546 if (!tab->FocusLocationBarByDefault()) | 1547 if (!tab->FocusLocationBarByDefault()) |
| 1547 tab->Focus(); | 1548 tab->Focus(); |
| 1548 if (ignore_cache) | 1549 if (ignore_cache) |
| 1549 tab->controller().ReloadIgnoringCache(true); | 1550 tab->controller().ReloadIgnoringCache(true); |
| 1550 else | 1551 else |
| 1551 tab->controller().Reload(true); | 1552 tab->controller().Reload(true); |
| 1552 } | 1553 } |
| 1553 | 1554 |
| 1554 void Browser::Home(WindowOpenDisposition disposition) { | 1555 void Browser::Home(WindowOpenDisposition disposition) { |
| 1555 UserMetrics::RecordAction(UserMetricsAction("Home")); | 1556 content::RecordAction(UserMetricsAction("Home")); |
| 1556 OpenURL( | 1557 OpenURL( |
| 1557 profile_->GetHomePage(), GURL(), disposition, | 1558 profile_->GetHomePage(), GURL(), disposition, |
| 1558 content::PageTransitionFromInt( | 1559 content::PageTransitionFromInt( |
| 1559 content::PAGE_TRANSITION_AUTO_BOOKMARK | | 1560 content::PAGE_TRANSITION_AUTO_BOOKMARK | |
| 1560 content::PAGE_TRANSITION_HOME_PAGE)); | 1561 content::PAGE_TRANSITION_HOME_PAGE)); |
| 1561 } | 1562 } |
| 1562 | 1563 |
| 1563 void Browser::OpenCurrentURL() { | 1564 void Browser::OpenCurrentURL() { |
| 1564 UserMetrics::RecordAction(UserMetricsAction("LoadURL")); | 1565 content::RecordAction(UserMetricsAction("LoadURL")); |
| 1565 LocationBar* location_bar = window_->GetLocationBar(); | 1566 LocationBar* location_bar = window_->GetLocationBar(); |
| 1566 if (!location_bar) | 1567 if (!location_bar) |
| 1567 return; | 1568 return; |
| 1568 | 1569 |
| 1569 WindowOpenDisposition open_disposition = | 1570 WindowOpenDisposition open_disposition = |
| 1570 location_bar->GetWindowOpenDisposition(); | 1571 location_bar->GetWindowOpenDisposition(); |
| 1571 if (OpenInstant(open_disposition)) | 1572 if (OpenInstant(open_disposition)) |
| 1572 return; | 1573 return; |
| 1573 | 1574 |
| 1574 GURL url(location_bar->GetInputString()); | 1575 GURL url(location_bar->GetInputString()); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1595 | 1596 |
| 1596 DCHECK(profile_->GetExtensionService()); | 1597 DCHECK(profile_->GetExtensionService()); |
| 1597 if (profile_->GetExtensionService()->IsInstalledApp(url)) { | 1598 if (profile_->GetExtensionService()->IsInstalledApp(url)) { |
| 1598 UMA_HISTOGRAM_ENUMERATION(extension_misc::kAppLaunchHistogram, | 1599 UMA_HISTOGRAM_ENUMERATION(extension_misc::kAppLaunchHistogram, |
| 1599 extension_misc::APP_LAUNCH_OMNIBOX_LOCATION, | 1600 extension_misc::APP_LAUNCH_OMNIBOX_LOCATION, |
| 1600 extension_misc::APP_LAUNCH_BUCKET_BOUNDARY); | 1601 extension_misc::APP_LAUNCH_BUCKET_BOUNDARY); |
| 1601 } | 1602 } |
| 1602 } | 1603 } |
| 1603 | 1604 |
| 1604 void Browser::Stop() { | 1605 void Browser::Stop() { |
| 1605 UserMetrics::RecordAction(UserMetricsAction("Stop")); | 1606 content::RecordAction(UserMetricsAction("Stop")); |
| 1606 GetSelectedTabContentsWrapper()->tab_contents()->Stop(); | 1607 GetSelectedTabContentsWrapper()->tab_contents()->Stop(); |
| 1607 } | 1608 } |
| 1608 | 1609 |
| 1609 void Browser::NewWindow() { | 1610 void Browser::NewWindow() { |
| 1610 IncognitoModePrefs::Availability incognito_avail = | 1611 IncognitoModePrefs::Availability incognito_avail = |
| 1611 IncognitoModePrefs::GetAvailability(profile_->GetPrefs()); | 1612 IncognitoModePrefs::GetAvailability(profile_->GetPrefs()); |
| 1612 if (browser_defaults::kAlwaysOpenIncognitoWindow && | 1613 if (browser_defaults::kAlwaysOpenIncognitoWindow && |
| 1613 incognito_avail != IncognitoModePrefs::DISABLED && | 1614 incognito_avail != IncognitoModePrefs::DISABLED && |
| 1614 (CommandLine::ForCurrentProcess()->HasSwitch(switches::kIncognito) || | 1615 (CommandLine::ForCurrentProcess()->HasSwitch(switches::kIncognito) || |
| 1615 incognito_avail == IncognitoModePrefs::FORCED)) { | 1616 incognito_avail == IncognitoModePrefs::FORCED)) { |
| 1616 NewIncognitoWindow(); | 1617 NewIncognitoWindow(); |
| 1617 return; | 1618 return; |
| 1618 } | 1619 } |
| 1619 UserMetrics::RecordAction(UserMetricsAction("NewWindow")); | 1620 content::RecordAction(UserMetricsAction("NewWindow")); |
| 1620 SessionService* session_service = | 1621 SessionService* session_service = |
| 1621 SessionServiceFactory::GetForProfile(profile_->GetOriginalProfile()); | 1622 SessionServiceFactory::GetForProfile(profile_->GetOriginalProfile()); |
| 1622 if (!session_service || | 1623 if (!session_service || |
| 1623 !session_service->RestoreIfNecessary(std::vector<GURL>())) { | 1624 !session_service->RestoreIfNecessary(std::vector<GURL>())) { |
| 1624 Browser::OpenEmptyWindow(profile_->GetOriginalProfile()); | 1625 Browser::OpenEmptyWindow(profile_->GetOriginalProfile()); |
| 1625 } | 1626 } |
| 1626 } | 1627 } |
| 1627 | 1628 |
| 1628 void Browser::NewIncognitoWindow() { | 1629 void Browser::NewIncognitoWindow() { |
| 1629 if (IncognitoModePrefs::GetAvailability(profile_->GetPrefs()) == | 1630 if (IncognitoModePrefs::GetAvailability(profile_->GetPrefs()) == |
| 1630 IncognitoModePrefs::DISABLED) { | 1631 IncognitoModePrefs::DISABLED) { |
| 1631 NewWindow(); | 1632 NewWindow(); |
| 1632 return; | 1633 return; |
| 1633 } | 1634 } |
| 1634 | 1635 |
| 1635 UserMetrics::RecordAction(UserMetricsAction("NewIncognitoWindow")); | 1636 content::RecordAction(UserMetricsAction("NewIncognitoWindow")); |
| 1636 Browser::OpenEmptyWindow(profile_->GetOffTheRecordProfile()); | 1637 Browser::OpenEmptyWindow(profile_->GetOffTheRecordProfile()); |
| 1637 } | 1638 } |
| 1638 | 1639 |
| 1639 void Browser::CloseWindow() { | 1640 void Browser::CloseWindow() { |
| 1640 UserMetrics::RecordAction(UserMetricsAction("CloseWindow")); | 1641 content::RecordAction(UserMetricsAction("CloseWindow")); |
| 1641 window_->Close(); | 1642 window_->Close(); |
| 1642 } | 1643 } |
| 1643 | 1644 |
| 1644 void Browser::NewTab() { | 1645 void Browser::NewTab() { |
| 1645 UserMetrics::RecordAction(UserMetricsAction("NewTab")); | 1646 content::RecordAction(UserMetricsAction("NewTab")); |
| 1646 | 1647 |
| 1647 if (is_type_tabbed()) { | 1648 if (is_type_tabbed()) { |
| 1648 AddBlankTab(true); | 1649 AddBlankTab(true); |
| 1649 GetSelectedTabContentsWrapper()->tab_contents()->view()->RestoreFocus(); | 1650 GetSelectedTabContentsWrapper()->tab_contents()->view()->RestoreFocus(); |
| 1650 } else { | 1651 } else { |
| 1651 Browser* b = GetOrCreateTabbedBrowser(profile_); | 1652 Browser* b = GetOrCreateTabbedBrowser(profile_); |
| 1652 b->AddBlankTab(true); | 1653 b->AddBlankTab(true); |
| 1653 b->window()->Show(); | 1654 b->window()->Show(); |
| 1654 // The call to AddBlankTab above did not set the focus to the tab as its | 1655 // The call to AddBlankTab above did not set the focus to the tab as its |
| 1655 // window was not active, so we have to do it explicitly. | 1656 // window was not active, so we have to do it explicitly. |
| 1656 // See http://crbug.com/6380. | 1657 // See http://crbug.com/6380. |
| 1657 b->GetSelectedTabContentsWrapper()->tab_contents()->view()->RestoreFocus(); | 1658 b->GetSelectedTabContentsWrapper()->tab_contents()->view()->RestoreFocus(); |
| 1658 } | 1659 } |
| 1659 } | 1660 } |
| 1660 | 1661 |
| 1661 void Browser::CloseTab() { | 1662 void Browser::CloseTab() { |
| 1662 UserMetrics::RecordAction(UserMetricsAction("CloseTab_Accelerator")); | 1663 content::RecordAction(UserMetricsAction("CloseTab_Accelerator")); |
| 1663 if (CanCloseTab()) | 1664 if (CanCloseTab()) |
| 1664 tab_handler_->GetTabStripModel()->CloseSelectedTabs(); | 1665 tab_handler_->GetTabStripModel()->CloseSelectedTabs(); |
| 1665 } | 1666 } |
| 1666 | 1667 |
| 1667 void Browser::SelectNextTab() { | 1668 void Browser::SelectNextTab() { |
| 1668 UserMetrics::RecordAction(UserMetricsAction("SelectNextTab")); | 1669 content::RecordAction(UserMetricsAction("SelectNextTab")); |
| 1669 tab_handler_->GetTabStripModel()->SelectNextTab(); | 1670 tab_handler_->GetTabStripModel()->SelectNextTab(); |
| 1670 } | 1671 } |
| 1671 | 1672 |
| 1672 void Browser::SelectPreviousTab() { | 1673 void Browser::SelectPreviousTab() { |
| 1673 UserMetrics::RecordAction(UserMetricsAction("SelectPrevTab")); | 1674 content::RecordAction(UserMetricsAction("SelectPrevTab")); |
| 1674 tab_handler_->GetTabStripModel()->SelectPreviousTab(); | 1675 tab_handler_->GetTabStripModel()->SelectPreviousTab(); |
| 1675 } | 1676 } |
| 1676 | 1677 |
| 1677 void Browser::OpenTabpose() { | 1678 void Browser::OpenTabpose() { |
| 1678 #if defined(OS_MACOSX) | 1679 #if defined(OS_MACOSX) |
| 1679 if (!CommandLine::ForCurrentProcess()->HasSwitch( | 1680 if (!CommandLine::ForCurrentProcess()->HasSwitch( |
| 1680 switches::kEnableExposeForTabs)) { | 1681 switches::kEnableExposeForTabs)) { |
| 1681 return; | 1682 return; |
| 1682 } | 1683 } |
| 1683 | 1684 |
| 1684 UserMetrics::RecordAction(UserMetricsAction("OpenTabpose")); | 1685 content::RecordAction(UserMetricsAction("OpenTabpose")); |
| 1685 window()->OpenTabpose(); | 1686 window()->OpenTabpose(); |
| 1686 #else | 1687 #else |
| 1687 NOTREACHED(); | 1688 NOTREACHED(); |
| 1688 #endif | 1689 #endif |
| 1689 } | 1690 } |
| 1690 | 1691 |
| 1691 void Browser::MoveTabNext() { | 1692 void Browser::MoveTabNext() { |
| 1692 UserMetrics::RecordAction(UserMetricsAction("MoveTabNext")); | 1693 content::RecordAction(UserMetricsAction("MoveTabNext")); |
| 1693 tab_handler_->GetTabStripModel()->MoveTabNext(); | 1694 tab_handler_->GetTabStripModel()->MoveTabNext(); |
| 1694 } | 1695 } |
| 1695 | 1696 |
| 1696 void Browser::MoveTabPrevious() { | 1697 void Browser::MoveTabPrevious() { |
| 1697 UserMetrics::RecordAction(UserMetricsAction("MoveTabPrevious")); | 1698 content::RecordAction(UserMetricsAction("MoveTabPrevious")); |
| 1698 tab_handler_->GetTabStripModel()->MoveTabPrevious(); | 1699 tab_handler_->GetTabStripModel()->MoveTabPrevious(); |
| 1699 } | 1700 } |
| 1700 | 1701 |
| 1701 void Browser::SelectNumberedTab(int index) { | 1702 void Browser::SelectNumberedTab(int index) { |
| 1702 if (index < tab_count()) { | 1703 if (index < tab_count()) { |
| 1703 UserMetrics::RecordAction(UserMetricsAction("SelectNumberedTab")); | 1704 content::RecordAction(UserMetricsAction("SelectNumberedTab")); |
| 1704 tab_handler_->GetTabStripModel()->ActivateTabAt(index, true); | 1705 tab_handler_->GetTabStripModel()->ActivateTabAt(index, true); |
| 1705 } | 1706 } |
| 1706 } | 1707 } |
| 1707 | 1708 |
| 1708 void Browser::SelectLastTab() { | 1709 void Browser::SelectLastTab() { |
| 1709 UserMetrics::RecordAction(UserMetricsAction("SelectLastTab")); | 1710 content::RecordAction(UserMetricsAction("SelectLastTab")); |
| 1710 tab_handler_->GetTabStripModel()->SelectLastTab(); | 1711 tab_handler_->GetTabStripModel()->SelectLastTab(); |
| 1711 } | 1712 } |
| 1712 | 1713 |
| 1713 void Browser::DuplicateTab() { | 1714 void Browser::DuplicateTab() { |
| 1714 UserMetrics::RecordAction(UserMetricsAction("Duplicate")); | 1715 content::RecordAction(UserMetricsAction("Duplicate")); |
| 1715 DuplicateContentsAt(active_index()); | 1716 DuplicateContentsAt(active_index()); |
| 1716 } | 1717 } |
| 1717 | 1718 |
| 1718 void Browser::RestoreTab() { | 1719 void Browser::RestoreTab() { |
| 1719 UserMetrics::RecordAction(UserMetricsAction("RestoreTab")); | 1720 content::RecordAction(UserMetricsAction("RestoreTab")); |
| 1720 TabRestoreService* service = | 1721 TabRestoreService* service = |
| 1721 TabRestoreServiceFactory::GetForProfile(profile_); | 1722 TabRestoreServiceFactory::GetForProfile(profile_); |
| 1722 if (!service) | 1723 if (!service) |
| 1723 return; | 1724 return; |
| 1724 | 1725 |
| 1725 service->RestoreMostRecentEntry(tab_restore_service_delegate()); | 1726 service->RestoreMostRecentEntry(tab_restore_service_delegate()); |
| 1726 } | 1727 } |
| 1727 | 1728 |
| 1728 void Browser::WriteCurrentURLToClipboard() { | 1729 void Browser::WriteCurrentURLToClipboard() { |
| 1729 // TODO(ericu): There isn't currently a metric for this. Should there be? | 1730 // TODO(ericu): There isn't currently a metric for this. Should there be? |
| 1730 // We don't appear to track the action when it comes from the | 1731 // We don't appear to track the action when it comes from the |
| 1731 // RenderContextViewMenu. | 1732 // RenderContextViewMenu. |
| 1732 | 1733 |
| 1733 TabContents* contents = GetSelectedTabContents(); | 1734 TabContents* contents = GetSelectedTabContents(); |
| 1734 if (!toolbar_model_.ShouldDisplayURL()) | 1735 if (!toolbar_model_.ShouldDisplayURL()) |
| 1735 return; | 1736 return; |
| 1736 | 1737 |
| 1737 chrome_browser_net::WriteURLToClipboard( | 1738 chrome_browser_net::WriteURLToClipboard( |
| 1738 contents->GetURL(), | 1739 contents->GetURL(), |
| 1739 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages), | 1740 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages), |
| 1740 g_browser_process->clipboard()); | 1741 g_browser_process->clipboard()); |
| 1741 } | 1742 } |
| 1742 | 1743 |
| 1743 void Browser::ConvertPopupToTabbedBrowser() { | 1744 void Browser::ConvertPopupToTabbedBrowser() { |
| 1744 UserMetrics::RecordAction(UserMetricsAction("ShowAsTab")); | 1745 content::RecordAction(UserMetricsAction("ShowAsTab")); |
| 1745 int tab_strip_index = tab_handler_->GetTabStripModel()->active_index(); | 1746 int tab_strip_index = tab_handler_->GetTabStripModel()->active_index(); |
| 1746 TabContentsWrapper* contents = | 1747 TabContentsWrapper* contents = |
| 1747 tab_handler_->GetTabStripModel()->DetachTabContentsAt(tab_strip_index); | 1748 tab_handler_->GetTabStripModel()->DetachTabContentsAt(tab_strip_index); |
| 1748 Browser* browser = Browser::Create(profile_); | 1749 Browser* browser = Browser::Create(profile_); |
| 1749 browser->tabstrip_model()->AppendTabContents(contents, true); | 1750 browser->tabstrip_model()->AppendTabContents(contents, true); |
| 1750 browser->window()->Show(); | 1751 browser->window()->Show(); |
| 1751 } | 1752 } |
| 1752 | 1753 |
| 1753 // TODO(koz): Change |for_tab| to an enum. | 1754 // TODO(koz): Change |for_tab| to an enum. |
| 1754 void Browser::ToggleFullscreenMode(bool for_tab) { | 1755 void Browser::ToggleFullscreenMode(bool for_tab) { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 1784 NewTab(); | 1785 NewTab(); |
| 1785 } | 1786 } |
| 1786 } | 1787 } |
| 1787 | 1788 |
| 1788 void Browser::ShowKeyboardOverlay() { | 1789 void Browser::ShowKeyboardOverlay() { |
| 1789 window_->ShowKeyboardOverlay(window_->GetNativeHandle()); | 1790 window_->ShowKeyboardOverlay(window_->GetNativeHandle()); |
| 1790 } | 1791 } |
| 1791 #endif | 1792 #endif |
| 1792 | 1793 |
| 1793 void Browser::Exit() { | 1794 void Browser::Exit() { |
| 1794 UserMetrics::RecordAction(UserMetricsAction("Exit")); | 1795 content::RecordAction(UserMetricsAction("Exit")); |
| 1795 BrowserList::AttemptUserExit(); | 1796 BrowserList::AttemptUserExit(); |
| 1796 } | 1797 } |
| 1797 | 1798 |
| 1798 void Browser::BookmarkCurrentPage() { | 1799 void Browser::BookmarkCurrentPage() { |
| 1799 UserMetrics::RecordAction(UserMetricsAction("Star")); | 1800 content::RecordAction(UserMetricsAction("Star")); |
| 1800 | 1801 |
| 1801 BookmarkModel* model = profile()->GetBookmarkModel(); | 1802 BookmarkModel* model = profile()->GetBookmarkModel(); |
| 1802 if (!model || !model->IsLoaded()) | 1803 if (!model || !model->IsLoaded()) |
| 1803 return; // Ignore requests until bookmarks are loaded. | 1804 return; // Ignore requests until bookmarks are loaded. |
| 1804 | 1805 |
| 1805 GURL url; | 1806 GURL url; |
| 1806 string16 title; | 1807 string16 title; |
| 1807 TabContentsWrapper* tab = GetSelectedTabContentsWrapper(); | 1808 TabContentsWrapper* tab = GetSelectedTabContentsWrapper(); |
| 1808 bookmark_utils::GetURLAndTitleToBookmark(tab->tab_contents(), &url, &title); | 1809 bookmark_utils::GetURLAndTitleToBookmark(tab->tab_contents(), &url, &title); |
| 1809 bool was_bookmarked = model->IsBookmarked(url); | 1810 bool was_bookmarked = model->IsBookmarked(url); |
| 1810 if (!was_bookmarked && profile_->IsOffTheRecord()) { | 1811 if (!was_bookmarked && profile_->IsOffTheRecord()) { |
| 1811 // If we're incognito the favicon may not have been saved. Save it now | 1812 // If we're incognito the favicon may not have been saved. Save it now |
| 1812 // so that bookmarks have an icon for the page. | 1813 // so that bookmarks have an icon for the page. |
| 1813 tab->favicon_tab_helper()->SaveFavicon(); | 1814 tab->favicon_tab_helper()->SaveFavicon(); |
| 1814 } | 1815 } |
| 1815 bookmark_utils::AddIfNotBookmarked(model, url, title); | 1816 bookmark_utils::AddIfNotBookmarked(model, url, title); |
| 1816 // Make sure the model actually added a bookmark before showing the star. A | 1817 // Make sure the model actually added a bookmark before showing the star. A |
| 1817 // bookmark isn't created if the url is invalid. | 1818 // bookmark isn't created if the url is invalid. |
| 1818 if (window_->IsActive() && model->IsBookmarked(url)) { | 1819 if (window_->IsActive() && model->IsBookmarked(url)) { |
| 1819 // Only show the bubble if the window is active, otherwise we may get into | 1820 // Only show the bubble if the window is active, otherwise we may get into |
| 1820 // weird situations were the bubble is deleted as soon as it is shown. | 1821 // weird situations were the bubble is deleted as soon as it is shown. |
| 1821 window_->ShowBookmarkBubble(url, was_bookmarked); | 1822 window_->ShowBookmarkBubble(url, was_bookmarked); |
| 1822 } | 1823 } |
| 1823 } | 1824 } |
| 1824 | 1825 |
| 1825 void Browser::SavePage() { | 1826 void Browser::SavePage() { |
| 1826 UserMetrics::RecordAction(UserMetricsAction("SavePage")); | 1827 content::RecordAction(UserMetricsAction("SavePage")); |
| 1827 TabContents* current_tab = GetSelectedTabContents(); | 1828 TabContents* current_tab = GetSelectedTabContents(); |
| 1828 if (current_tab && current_tab->contents_mime_type() == "application/pdf") | 1829 if (current_tab && current_tab->contents_mime_type() == "application/pdf") |
| 1829 UserMetrics::RecordAction(UserMetricsAction("PDF.SavePage")); | 1830 content::RecordAction(UserMetricsAction("PDF.SavePage")); |
| 1830 GetSelectedTabContents()->OnSavePage(); | 1831 GetSelectedTabContents()->OnSavePage(); |
| 1831 } | 1832 } |
| 1832 | 1833 |
| 1833 void Browser::ViewSelectedSource() { | 1834 void Browser::ViewSelectedSource() { |
| 1834 ViewSource(GetSelectedTabContentsWrapper()); | 1835 ViewSource(GetSelectedTabContentsWrapper()); |
| 1835 } | 1836 } |
| 1836 | 1837 |
| 1837 void Browser::ShowFindBar() { | 1838 void Browser::ShowFindBar() { |
| 1838 GetFindBarController()->Show(); | 1839 GetFindBarController()->Show(); |
| 1839 } | 1840 } |
| 1840 | 1841 |
| 1841 bool Browser::SupportsWindowFeature(WindowFeature feature) const { | 1842 bool Browser::SupportsWindowFeature(WindowFeature feature) const { |
| 1842 return SupportsWindowFeatureImpl(feature, true); | 1843 return SupportsWindowFeatureImpl(feature, true); |
| 1843 } | 1844 } |
| 1844 | 1845 |
| 1845 bool Browser::CanSupportWindowFeature(WindowFeature feature) const { | 1846 bool Browser::CanSupportWindowFeature(WindowFeature feature) const { |
| 1846 return SupportsWindowFeatureImpl(feature, false); | 1847 return SupportsWindowFeatureImpl(feature, false); |
| 1847 } | 1848 } |
| 1848 | 1849 |
| 1849 void Browser::EmailPageLocation() { | 1850 void Browser::EmailPageLocation() { |
| 1850 UserMetrics::RecordAction(UserMetricsAction("EmailPageLocation")); | 1851 content::RecordAction(UserMetricsAction("EmailPageLocation")); |
| 1851 TabContents* tc = GetSelectedTabContents(); | 1852 TabContents* tc = GetSelectedTabContents(); |
| 1852 DCHECK(tc); | 1853 DCHECK(tc); |
| 1853 | 1854 |
| 1854 std::string title = net::EscapeQueryParamValue( | 1855 std::string title = net::EscapeQueryParamValue( |
| 1855 UTF16ToUTF8(tc->GetTitle()), false); | 1856 UTF16ToUTF8(tc->GetTitle()), false); |
| 1856 std::string page_url = net::EscapeQueryParamValue(tc->GetURL().spec(), false); | 1857 std::string page_url = net::EscapeQueryParamValue(tc->GetURL().spec(), false); |
| 1857 std::string mailto = std::string("mailto:?subject=Fwd:%20") + | 1858 std::string mailto = std::string("mailto:?subject=Fwd:%20") + |
| 1858 title + "&body=%0A%0A" + page_url; | 1859 title + "&body=%0A%0A" + page_url; |
| 1859 platform_util::OpenExternal(GURL(mailto)); | 1860 platform_util::OpenExternal(GURL(mailto)); |
| 1860 } | 1861 } |
| 1861 | 1862 |
| 1862 void Browser::Print() { | 1863 void Browser::Print() { |
| 1863 if (switches::IsPrintPreviewEnabled()) | 1864 if (switches::IsPrintPreviewEnabled()) |
| 1864 GetSelectedTabContentsWrapper()->print_view_manager()->PrintPreviewNow(); | 1865 GetSelectedTabContentsWrapper()->print_view_manager()->PrintPreviewNow(); |
| 1865 else | 1866 else |
| 1866 GetSelectedTabContentsWrapper()->print_view_manager()->PrintNow(); | 1867 GetSelectedTabContentsWrapper()->print_view_manager()->PrintNow(); |
| 1867 } | 1868 } |
| 1868 | 1869 |
| 1869 void Browser::AdvancedPrint() { | 1870 void Browser::AdvancedPrint() { |
| 1870 GetSelectedTabContentsWrapper()->print_view_manager()->AdvancedPrintNow(); | 1871 GetSelectedTabContentsWrapper()->print_view_manager()->AdvancedPrintNow(); |
| 1871 } | 1872 } |
| 1872 | 1873 |
| 1873 void Browser::ToggleEncodingAutoDetect() { | 1874 void Browser::ToggleEncodingAutoDetect() { |
| 1874 UserMetrics::RecordAction(UserMetricsAction("AutoDetectChange")); | 1875 content::RecordAction(UserMetricsAction("AutoDetectChange")); |
| 1875 encoding_auto_detect_.SetValue(!encoding_auto_detect_.GetValue()); | 1876 encoding_auto_detect_.SetValue(!encoding_auto_detect_.GetValue()); |
| 1876 // If "auto detect" is turned on, then any current override encoding | 1877 // If "auto detect" is turned on, then any current override encoding |
| 1877 // is cleared. This also implicitly performs a reload. | 1878 // is cleared. This also implicitly performs a reload. |
| 1878 // OTOH, if "auto detect" is turned off, we don't change the currently | 1879 // OTOH, if "auto detect" is turned off, we don't change the currently |
| 1879 // active encoding. | 1880 // active encoding. |
| 1880 if (encoding_auto_detect_.GetValue()) { | 1881 if (encoding_auto_detect_.GetValue()) { |
| 1881 TabContents* contents = GetSelectedTabContents(); | 1882 TabContents* contents = GetSelectedTabContents(); |
| 1882 if (contents) | 1883 if (contents) |
| 1883 contents->ResetOverrideEncoding(); | 1884 contents->ResetOverrideEncoding(); |
| 1884 } | 1885 } |
| 1885 } | 1886 } |
| 1886 | 1887 |
| 1887 void Browser::OverrideEncoding(int encoding_id) { | 1888 void Browser::OverrideEncoding(int encoding_id) { |
| 1888 UserMetrics::RecordAction(UserMetricsAction("OverrideEncoding")); | 1889 content::RecordAction(UserMetricsAction("OverrideEncoding")); |
| 1889 const std::string selected_encoding = | 1890 const std::string selected_encoding = |
| 1890 CharacterEncoding::GetCanonicalEncodingNameByCommandId(encoding_id); | 1891 CharacterEncoding::GetCanonicalEncodingNameByCommandId(encoding_id); |
| 1891 TabContents* contents = GetSelectedTabContents(); | 1892 TabContents* contents = GetSelectedTabContents(); |
| 1892 if (!selected_encoding.empty() && contents) | 1893 if (!selected_encoding.empty() && contents) |
| 1893 contents->SetOverrideEncoding(selected_encoding); | 1894 contents->SetOverrideEncoding(selected_encoding); |
| 1894 // Update the list of recently selected encodings. | 1895 // Update the list of recently selected encodings. |
| 1895 std::string new_selected_encoding_list; | 1896 std::string new_selected_encoding_list; |
| 1896 if (CharacterEncoding::UpdateRecentlySelectedEncoding( | 1897 if (CharacterEncoding::UpdateRecentlySelectedEncoding( |
| 1897 profile_->GetPrefs()->GetString(prefs::kRecentlySelectedEncoding), | 1898 profile_->GetPrefs()->GetString(prefs::kRecentlySelectedEncoding), |
| 1898 encoding_id, | 1899 encoding_id, |
| 1899 &new_selected_encoding_list)) { | 1900 &new_selected_encoding_list)) { |
| 1900 profile_->GetPrefs()->SetString(prefs::kRecentlySelectedEncoding, | 1901 profile_->GetPrefs()->SetString(prefs::kRecentlySelectedEncoding, |
| 1901 new_selected_encoding_list); | 1902 new_selected_encoding_list); |
| 1902 } | 1903 } |
| 1903 } | 1904 } |
| 1904 | 1905 |
| 1905 void Browser::Cut() { | 1906 void Browser::Cut() { |
| 1906 UserMetrics::RecordAction(UserMetricsAction("Cut")); | 1907 content::RecordAction(UserMetricsAction("Cut")); |
| 1907 window()->Cut(); | 1908 window()->Cut(); |
| 1908 } | 1909 } |
| 1909 | 1910 |
| 1910 void Browser::Copy() { | 1911 void Browser::Copy() { |
| 1911 UserMetrics::RecordAction(UserMetricsAction("Copy")); | 1912 content::RecordAction(UserMetricsAction("Copy")); |
| 1912 window()->Copy(); | 1913 window()->Copy(); |
| 1913 } | 1914 } |
| 1914 | 1915 |
| 1915 void Browser::Paste() { | 1916 void Browser::Paste() { |
| 1916 UserMetrics::RecordAction(UserMetricsAction("Paste")); | 1917 content::RecordAction(UserMetricsAction("Paste")); |
| 1917 window()->Paste(); | 1918 window()->Paste(); |
| 1918 } | 1919 } |
| 1919 | 1920 |
| 1920 void Browser::Find() { | 1921 void Browser::Find() { |
| 1921 UserMetrics::RecordAction(UserMetricsAction("Find")); | 1922 content::RecordAction(UserMetricsAction("Find")); |
| 1922 FindInPage(false, false); | 1923 FindInPage(false, false); |
| 1923 } | 1924 } |
| 1924 | 1925 |
| 1925 void Browser::FindNext() { | 1926 void Browser::FindNext() { |
| 1926 UserMetrics::RecordAction(UserMetricsAction("FindNext")); | 1927 content::RecordAction(UserMetricsAction("FindNext")); |
| 1927 FindInPage(true, true); | 1928 FindInPage(true, true); |
| 1928 } | 1929 } |
| 1929 | 1930 |
| 1930 void Browser::FindPrevious() { | 1931 void Browser::FindPrevious() { |
| 1931 UserMetrics::RecordAction(UserMetricsAction("FindPrevious")); | 1932 content::RecordAction(UserMetricsAction("FindPrevious")); |
| 1932 FindInPage(true, false); | 1933 FindInPage(true, false); |
| 1933 } | 1934 } |
| 1934 | 1935 |
| 1935 void Browser::Zoom(content::PageZoom zoom) { | 1936 void Browser::Zoom(content::PageZoom zoom) { |
| 1936 if (is_devtools()) | 1937 if (is_devtools()) |
| 1937 return; | 1938 return; |
| 1938 | 1939 |
| 1939 RenderViewHost* host = | 1940 RenderViewHost* host = |
| 1940 GetSelectedTabContentsWrapper()->tab_contents()->render_view_host(); | 1941 GetSelectedTabContentsWrapper()->tab_contents()->render_view_host(); |
| 1941 if (zoom == content::PAGE_ZOOM_RESET) { | 1942 if (zoom == content::PAGE_ZOOM_RESET) { |
| 1942 host->SetZoomLevel(0); | 1943 host->SetZoomLevel(0); |
| 1943 UserMetrics::RecordAction(UserMetricsAction("ZoomNormal")); | 1944 content::RecordAction(UserMetricsAction("ZoomNormal")); |
| 1944 return; | 1945 return; |
| 1945 } | 1946 } |
| 1946 | 1947 |
| 1947 double current_zoom_level = GetSelectedTabContents()->GetZoomLevel(); | 1948 double current_zoom_level = GetSelectedTabContents()->GetZoomLevel(); |
| 1948 double default_zoom_level = | 1949 double default_zoom_level = |
| 1949 profile_->GetPrefs()->GetDouble(prefs::kDefaultZoomLevel); | 1950 profile_->GetPrefs()->GetDouble(prefs::kDefaultZoomLevel); |
| 1950 | 1951 |
| 1951 // Generate a vector of zoom levels from an array of known presets along with | 1952 // Generate a vector of zoom levels from an array of known presets along with |
| 1952 // the default level added if necessary. | 1953 // the default level added if necessary. |
| 1953 std::vector<double> zoom_levels = | 1954 std::vector<double> zoom_levels = |
| 1954 chrome_page_zoom::PresetZoomLevels(default_zoom_level); | 1955 chrome_page_zoom::PresetZoomLevels(default_zoom_level); |
| 1955 | 1956 |
| 1956 if (zoom == content::PAGE_ZOOM_OUT) { | 1957 if (zoom == content::PAGE_ZOOM_OUT) { |
| 1957 // Iterate through the zoom levels in reverse order to find the next | 1958 // Iterate through the zoom levels in reverse order to find the next |
| 1958 // lower level based on the current zoom level for this page. | 1959 // lower level based on the current zoom level for this page. |
| 1959 for (std::vector<double>::reverse_iterator i = zoom_levels.rbegin(); | 1960 for (std::vector<double>::reverse_iterator i = zoom_levels.rbegin(); |
| 1960 i != zoom_levels.rend(); ++i) { | 1961 i != zoom_levels.rend(); ++i) { |
| 1961 double zoom_level = *i; | 1962 double zoom_level = *i; |
| 1962 if (content::ZoomValuesEqual(zoom_level, current_zoom_level)) | 1963 if (content::ZoomValuesEqual(zoom_level, current_zoom_level)) |
| 1963 continue; | 1964 continue; |
| 1964 if (zoom_level < current_zoom_level) { | 1965 if (zoom_level < current_zoom_level) { |
| 1965 host->SetZoomLevel(zoom_level); | 1966 host->SetZoomLevel(zoom_level); |
| 1966 UserMetrics::RecordAction(UserMetricsAction("ZoomMinus")); | 1967 content::RecordAction(UserMetricsAction("ZoomMinus")); |
| 1967 return; | 1968 return; |
| 1968 } | 1969 } |
| 1969 UserMetrics::RecordAction(UserMetricsAction("ZoomMinus_AtMinimum")); | 1970 content::RecordAction(UserMetricsAction("ZoomMinus_AtMinimum")); |
| 1970 } | 1971 } |
| 1971 } else { | 1972 } else { |
| 1972 // Iterate through the zoom levels in normal order to find the next | 1973 // Iterate through the zoom levels in normal order to find the next |
| 1973 // higher level based on the current zoom level for this page. | 1974 // higher level based on the current zoom level for this page. |
| 1974 for (std::vector<double>::const_iterator i = zoom_levels.begin(); | 1975 for (std::vector<double>::const_iterator i = zoom_levels.begin(); |
| 1975 i != zoom_levels.end(); ++i) { | 1976 i != zoom_levels.end(); ++i) { |
| 1976 double zoom_level = *i; | 1977 double zoom_level = *i; |
| 1977 if (content::ZoomValuesEqual(zoom_level, current_zoom_level)) | 1978 if (content::ZoomValuesEqual(zoom_level, current_zoom_level)) |
| 1978 continue; | 1979 continue; |
| 1979 if (zoom_level > current_zoom_level) { | 1980 if (zoom_level > current_zoom_level) { |
| 1980 host->SetZoomLevel(zoom_level); | 1981 host->SetZoomLevel(zoom_level); |
| 1981 UserMetrics::RecordAction(UserMetricsAction("ZoomPlus")); | 1982 content::RecordAction(UserMetricsAction("ZoomPlus")); |
| 1982 return; | 1983 return; |
| 1983 } | 1984 } |
| 1984 } | 1985 } |
| 1985 UserMetrics::RecordAction(UserMetricsAction("ZoomPlus_AtMaximum")); | 1986 content::RecordAction(UserMetricsAction("ZoomPlus_AtMaximum")); |
| 1986 } | 1987 } |
| 1987 } | 1988 } |
| 1988 | 1989 |
| 1989 void Browser::FocusToolbar() { | 1990 void Browser::FocusToolbar() { |
| 1990 UserMetrics::RecordAction(UserMetricsAction("FocusToolbar")); | 1991 content::RecordAction(UserMetricsAction("FocusToolbar")); |
| 1991 window_->FocusToolbar(); | 1992 window_->FocusToolbar(); |
| 1992 } | 1993 } |
| 1993 | 1994 |
| 1994 void Browser::FocusAppMenu() { | 1995 void Browser::FocusAppMenu() { |
| 1995 UserMetrics::RecordAction(UserMetricsAction("FocusAppMenu")); | 1996 content::RecordAction(UserMetricsAction("FocusAppMenu")); |
| 1996 window_->FocusAppMenu(); | 1997 window_->FocusAppMenu(); |
| 1997 } | 1998 } |
| 1998 | 1999 |
| 1999 void Browser::FocusLocationBar() { | 2000 void Browser::FocusLocationBar() { |
| 2000 UserMetrics::RecordAction(UserMetricsAction("FocusLocation")); | 2001 content::RecordAction(UserMetricsAction("FocusLocation")); |
| 2001 window_->SetFocusToLocationBar(true); | 2002 window_->SetFocusToLocationBar(true); |
| 2002 } | 2003 } |
| 2003 | 2004 |
| 2004 void Browser::FocusBookmarksToolbar() { | 2005 void Browser::FocusBookmarksToolbar() { |
| 2005 UserMetrics::RecordAction(UserMetricsAction("FocusBookmarksToolbar")); | 2006 content::RecordAction(UserMetricsAction("FocusBookmarksToolbar")); |
| 2006 window_->FocusBookmarksToolbar(); | 2007 window_->FocusBookmarksToolbar(); |
| 2007 } | 2008 } |
| 2008 | 2009 |
| 2009 void Browser::FocusChromeOSStatus() { | 2010 void Browser::FocusChromeOSStatus() { |
| 2010 UserMetrics::RecordAction(UserMetricsAction("FocusChromeOSStatus")); | 2011 content::RecordAction(UserMetricsAction("FocusChromeOSStatus")); |
| 2011 window_->FocusChromeOSStatus(); | 2012 window_->FocusChromeOSStatus(); |
| 2012 } | 2013 } |
| 2013 | 2014 |
| 2014 void Browser::FocusNextPane() { | 2015 void Browser::FocusNextPane() { |
| 2015 UserMetrics::RecordAction(UserMetricsAction("FocusNextPane")); | 2016 content::RecordAction(UserMetricsAction("FocusNextPane")); |
| 2016 window_->RotatePaneFocus(true); | 2017 window_->RotatePaneFocus(true); |
| 2017 } | 2018 } |
| 2018 | 2019 |
| 2019 void Browser::FocusPreviousPane() { | 2020 void Browser::FocusPreviousPane() { |
| 2020 UserMetrics::RecordAction(UserMetricsAction("FocusPreviousPane")); | 2021 content::RecordAction(UserMetricsAction("FocusPreviousPane")); |
| 2021 window_->RotatePaneFocus(false); | 2022 window_->RotatePaneFocus(false); |
| 2022 } | 2023 } |
| 2023 | 2024 |
| 2024 void Browser::FocusSearch() { | 2025 void Browser::FocusSearch() { |
| 2025 // TODO(beng): replace this with FocusLocationBar | 2026 // TODO(beng): replace this with FocusLocationBar |
| 2026 UserMetrics::RecordAction(UserMetricsAction("FocusSearch")); | 2027 content::RecordAction(UserMetricsAction("FocusSearch")); |
| 2027 window_->GetLocationBar()->FocusSearch(); | 2028 window_->GetLocationBar()->FocusSearch(); |
| 2028 } | 2029 } |
| 2029 | 2030 |
| 2030 void Browser::OpenFile() { | 2031 void Browser::OpenFile() { |
| 2031 UserMetrics::RecordAction(UserMetricsAction("OpenFile")); | 2032 content::RecordAction(UserMetricsAction("OpenFile")); |
| 2032 if (!select_file_dialog_.get()) | 2033 if (!select_file_dialog_.get()) |
| 2033 select_file_dialog_ = SelectFileDialog::Create(this); | 2034 select_file_dialog_ = SelectFileDialog::Create(this); |
| 2034 | 2035 |
| 2035 const FilePath directory = profile_->last_selected_directory(); | 2036 const FilePath directory = profile_->last_selected_directory(); |
| 2036 | 2037 |
| 2037 // TODO(beng): figure out how to juggle this. | 2038 // TODO(beng): figure out how to juggle this. |
| 2038 gfx::NativeWindow parent_window = window_->GetNativeHandle(); | 2039 gfx::NativeWindow parent_window = window_->GetNativeHandle(); |
| 2039 select_file_dialog_->SelectFile(SelectFileDialog::SELECT_OPEN_FILE, | 2040 select_file_dialog_->SelectFile(SelectFileDialog::SELECT_OPEN_FILE, |
| 2040 string16(), directory, | 2041 string16(), directory, |
| 2041 NULL, 0, FILE_PATH_LITERAL(""), | 2042 NULL, 0, FILE_PATH_LITERAL(""), |
| 2042 GetSelectedTabContents(), | 2043 GetSelectedTabContents(), |
| 2043 parent_window, NULL); | 2044 parent_window, NULL); |
| 2044 } | 2045 } |
| 2045 | 2046 |
| 2046 void Browser::OpenCreateShortcutsDialog() { | 2047 void Browser::OpenCreateShortcutsDialog() { |
| 2047 UserMetrics::RecordAction(UserMetricsAction("CreateShortcut")); | 2048 content::RecordAction(UserMetricsAction("CreateShortcut")); |
| 2048 #if !defined(OS_MACOSX) | 2049 #if !defined(OS_MACOSX) |
| 2049 TabContentsWrapper* current_tab = GetSelectedTabContentsWrapper(); | 2050 TabContentsWrapper* current_tab = GetSelectedTabContentsWrapper(); |
| 2050 DCHECK(current_tab && | 2051 DCHECK(current_tab && |
| 2051 web_app::IsValidUrl(current_tab->tab_contents()->GetURL())) << | 2052 web_app::IsValidUrl(current_tab->tab_contents()->GetURL())) << |
| 2052 "Menu item should be disabled."; | 2053 "Menu item should be disabled."; |
| 2053 | 2054 |
| 2054 NavigationEntry* entry = | 2055 NavigationEntry* entry = |
| 2055 current_tab->tab_contents()->controller().GetLastCommittedEntry(); | 2056 current_tab->tab_contents()->controller().GetLastCommittedEntry(); |
| 2056 if (!entry) | 2057 if (!entry) |
| 2057 return; | 2058 return; |
| 2058 | 2059 |
| 2059 // RVH's GetApplicationInfo should not be called before it returns. | 2060 // RVH's GetApplicationInfo should not be called before it returns. |
| 2060 DCHECK(pending_web_app_action_ == NONE); | 2061 DCHECK(pending_web_app_action_ == NONE); |
| 2061 pending_web_app_action_ = CREATE_SHORTCUT; | 2062 pending_web_app_action_ = CREATE_SHORTCUT; |
| 2062 | 2063 |
| 2063 // Start fetching web app info for CreateApplicationShortcut dialog and show | 2064 // Start fetching web app info for CreateApplicationShortcut dialog and show |
| 2064 // the dialog when the data is available in OnDidGetApplicationInfo. | 2065 // the dialog when the data is available in OnDidGetApplicationInfo. |
| 2065 current_tab->extension_tab_helper()->GetApplicationInfo(entry->page_id()); | 2066 current_tab->extension_tab_helper()->GetApplicationInfo(entry->page_id()); |
| 2066 #else | 2067 #else |
| 2067 NOTIMPLEMENTED(); | 2068 NOTIMPLEMENTED(); |
| 2068 #endif | 2069 #endif |
| 2069 } | 2070 } |
| 2070 | 2071 |
| 2071 void Browser::ToggleDevToolsWindow(DevToolsToggleAction action) { | 2072 void Browser::ToggleDevToolsWindow(DevToolsToggleAction action) { |
| 2072 if (action == DEVTOOLS_TOGGLE_ACTION_SHOW_CONSOLE) | 2073 if (action == DEVTOOLS_TOGGLE_ACTION_SHOW_CONSOLE) |
| 2073 UserMetrics::RecordAction(UserMetricsAction("DevTools_ToggleConsole")); | 2074 content::RecordAction(UserMetricsAction("DevTools_ToggleConsole")); |
| 2074 else | 2075 else |
| 2075 UserMetrics::RecordAction(UserMetricsAction("DevTools_ToggleWindow")); | 2076 content::RecordAction(UserMetricsAction("DevTools_ToggleWindow")); |
| 2076 | 2077 |
| 2077 DevToolsWindow::ToggleDevToolsWindow( | 2078 DevToolsWindow::ToggleDevToolsWindow( |
| 2078 GetSelectedTabContentsWrapper()->tab_contents()->render_view_host(), | 2079 GetSelectedTabContentsWrapper()->tab_contents()->render_view_host(), |
| 2079 action); | 2080 action); |
| 2080 } | 2081 } |
| 2081 | 2082 |
| 2082 void Browser::OpenTaskManager(bool highlight_background_resources) { | 2083 void Browser::OpenTaskManager(bool highlight_background_resources) { |
| 2083 UserMetrics::RecordAction(UserMetricsAction("TaskManager")); | 2084 content::RecordAction(UserMetricsAction("TaskManager")); |
| 2084 if (highlight_background_resources) | 2085 if (highlight_background_resources) |
| 2085 window_->ShowBackgroundPages(); | 2086 window_->ShowBackgroundPages(); |
| 2086 else | 2087 else |
| 2087 window_->ShowTaskManager(); | 2088 window_->ShowTaskManager(); |
| 2088 } | 2089 } |
| 2089 | 2090 |
| 2090 void Browser::OpenBugReportDialog() { | 2091 void Browser::OpenBugReportDialog() { |
| 2091 UserMetrics::RecordAction(UserMetricsAction("ReportBug")); | 2092 content::RecordAction(UserMetricsAction("ReportBug")); |
| 2092 browser::ShowHtmlBugReportView(this, std::string(), 0); | 2093 browser::ShowHtmlBugReportView(this, std::string(), 0); |
| 2093 } | 2094 } |
| 2094 | 2095 |
| 2095 void Browser::ToggleBookmarkBar() { | 2096 void Browser::ToggleBookmarkBar() { |
| 2096 UserMetrics::RecordAction(UserMetricsAction("ShowBookmarksBar")); | 2097 content::RecordAction(UserMetricsAction("ShowBookmarksBar")); |
| 2097 window_->ToggleBookmarkBar(); | 2098 window_->ToggleBookmarkBar(); |
| 2098 } | 2099 } |
| 2099 | 2100 |
| 2100 void Browser::OpenBookmarkManager() { | 2101 void Browser::OpenBookmarkManager() { |
| 2101 UserMetrics::RecordAction(UserMetricsAction("ShowBookmarkManager")); | 2102 content::RecordAction(UserMetricsAction("ShowBookmarkManager")); |
| 2102 UserMetrics::RecordAction(UserMetricsAction("ShowBookmarks")); | 2103 content::RecordAction(UserMetricsAction("ShowBookmarks")); |
| 2103 ShowSingletonTabOverwritingNTP( | 2104 ShowSingletonTabOverwritingNTP( |
| 2104 GetSingletonTabNavigateParams(GURL(chrome::kChromeUIBookmarksURL))); | 2105 GetSingletonTabNavigateParams(GURL(chrome::kChromeUIBookmarksURL))); |
| 2105 } | 2106 } |
| 2106 | 2107 |
| 2107 void Browser::OpenBookmarkManagerWithHash(const std::string& action, | 2108 void Browser::OpenBookmarkManagerWithHash(const std::string& action, |
| 2108 int64 node_id) { | 2109 int64 node_id) { |
| 2109 UserMetrics::RecordAction(UserMetricsAction("ShowBookmarkManager")); | 2110 content::RecordAction(UserMetricsAction("ShowBookmarkManager")); |
| 2110 UserMetrics::RecordAction(UserMetricsAction("ShowBookmarks")); | 2111 content::RecordAction(UserMetricsAction("ShowBookmarks")); |
| 2111 browser::NavigateParams params(GetSingletonTabNavigateParams( | 2112 browser::NavigateParams params(GetSingletonTabNavigateParams( |
| 2112 GURL(chrome::kChromeUIBookmarksURL).Resolve( | 2113 GURL(chrome::kChromeUIBookmarksURL).Resolve( |
| 2113 StringPrintf("/#%s%s", action.c_str(), | 2114 StringPrintf("/#%s%s", action.c_str(), |
| 2114 base::Int64ToString(node_id).c_str())))); | 2115 base::Int64ToString(node_id).c_str())))); |
| 2115 params.path_behavior = browser::NavigateParams::IGNORE_AND_NAVIGATE; | 2116 params.path_behavior = browser::NavigateParams::IGNORE_AND_NAVIGATE; |
| 2116 ShowSingletonTabOverwritingNTP(params); | 2117 ShowSingletonTabOverwritingNTP(params); |
| 2117 } | 2118 } |
| 2118 | 2119 |
| 2119 void Browser::OpenBookmarkManagerForNode(int64 node_id) { | 2120 void Browser::OpenBookmarkManagerForNode(int64 node_id) { |
| 2120 OpenBookmarkManagerWithHash("", node_id); | 2121 OpenBookmarkManagerWithHash("", node_id); |
| 2121 } | 2122 } |
| 2122 | 2123 |
| 2123 void Browser::OpenBookmarkManagerEditNode(int64 node_id) { | 2124 void Browser::OpenBookmarkManagerEditNode(int64 node_id) { |
| 2124 OpenBookmarkManagerWithHash("e=", node_id); | 2125 OpenBookmarkManagerWithHash("e=", node_id); |
| 2125 } | 2126 } |
| 2126 | 2127 |
| 2127 void Browser::ShowAppMenu() { | 2128 void Browser::ShowAppMenu() { |
| 2128 // We record the user metric for this event in WrenchMenu::RunMenu. | 2129 // We record the user metric for this event in WrenchMenu::RunMenu. |
| 2129 window_->ShowAppMenu(); | 2130 window_->ShowAppMenu(); |
| 2130 } | 2131 } |
| 2131 | 2132 |
| 2132 void Browser::ShowAvatarMenu() { | 2133 void Browser::ShowAvatarMenu() { |
| 2133 window_->ShowAvatarBubbleFromAvatarButton(); | 2134 window_->ShowAvatarBubbleFromAvatarButton(); |
| 2134 } | 2135 } |
| 2135 | 2136 |
| 2136 void Browser::ShowHistoryTab() { | 2137 void Browser::ShowHistoryTab() { |
| 2137 UserMetrics::RecordAction(UserMetricsAction("ShowHistory")); | 2138 content::RecordAction(UserMetricsAction("ShowHistory")); |
| 2138 ShowSingletonTabOverwritingNTP( | 2139 ShowSingletonTabOverwritingNTP( |
| 2139 GetSingletonTabNavigateParams(GURL(chrome::kChromeUIHistoryURL))); | 2140 GetSingletonTabNavigateParams(GURL(chrome::kChromeUIHistoryURL))); |
| 2140 } | 2141 } |
| 2141 | 2142 |
| 2142 void Browser::ShowDownloadsTab() { | 2143 void Browser::ShowDownloadsTab() { |
| 2143 UserMetrics::RecordAction(UserMetricsAction("ShowDownloads")); | 2144 content::RecordAction(UserMetricsAction("ShowDownloads")); |
| 2144 #if !defined(OS_CHROMEOS) | 2145 #if !defined(OS_CHROMEOS) |
| 2145 // ChromiumOS uses ActiveDownloadsUI instead of of DownloadShelf. | 2146 // ChromiumOS uses ActiveDownloadsUI instead of of DownloadShelf. |
| 2146 if (window()) { | 2147 if (window()) { |
| 2147 DownloadShelf* shelf = window()->GetDownloadShelf(); | 2148 DownloadShelf* shelf = window()->GetDownloadShelf(); |
| 2148 if (shelf->IsShowing()) | 2149 if (shelf->IsShowing()) |
| 2149 shelf->Close(); | 2150 shelf->Close(); |
| 2150 } | 2151 } |
| 2151 #endif | 2152 #endif |
| 2152 ShowSingletonTabOverwritingNTP( | 2153 ShowSingletonTabOverwritingNTP( |
| 2153 GetSingletonTabNavigateParams(GURL(chrome::kChromeUIDownloadsURL))); | 2154 GetSingletonTabNavigateParams(GURL(chrome::kChromeUIDownloadsURL))); |
| 2154 } | 2155 } |
| 2155 | 2156 |
| 2156 void Browser::ShowExtensionsTab() { | 2157 void Browser::ShowExtensionsTab() { |
| 2157 UserMetrics::RecordAction(UserMetricsAction("ShowExtensions")); | 2158 content::RecordAction(UserMetricsAction("ShowExtensions")); |
| 2158 ShowOptionsTab(chrome::kExtensionsSubPage); | 2159 ShowOptionsTab(chrome::kExtensionsSubPage); |
| 2159 } | 2160 } |
| 2160 | 2161 |
| 2161 void Browser::ShowAboutConflictsTab() { | 2162 void Browser::ShowAboutConflictsTab() { |
| 2162 UserMetrics::RecordAction(UserMetricsAction("AboutConflicts")); | 2163 content::RecordAction(UserMetricsAction("AboutConflicts")); |
| 2163 ShowSingletonTab(GURL(chrome::kChromeUIConflictsURL)); | 2164 ShowSingletonTab(GURL(chrome::kChromeUIConflictsURL)); |
| 2164 } | 2165 } |
| 2165 | 2166 |
| 2166 void Browser::ShowBrokenPageTab(TabContents* contents) { | 2167 void Browser::ShowBrokenPageTab(TabContents* contents) { |
| 2167 UserMetrics::RecordAction(UserMetricsAction("ReportBug")); | 2168 content::RecordAction(UserMetricsAction("ReportBug")); |
| 2168 string16 page_title = contents->GetTitle(); | 2169 string16 page_title = contents->GetTitle(); |
| 2169 NavigationEntry* entry = contents->controller().GetActiveEntry(); | 2170 NavigationEntry* entry = contents->controller().GetActiveEntry(); |
| 2170 if (!entry) | 2171 if (!entry) |
| 2171 return; | 2172 return; |
| 2172 std::string page_url = entry->url().spec(); | 2173 std::string page_url = entry->url().spec(); |
| 2173 std::vector<std::string> subst; | 2174 std::vector<std::string> subst; |
| 2174 subst.push_back(UTF16ToASCII(page_title)); | 2175 subst.push_back(UTF16ToASCII(page_title)); |
| 2175 subst.push_back(page_url); | 2176 subst.push_back(page_url); |
| 2176 std::string report_page_url = | 2177 std::string report_page_url = |
| 2177 ReplaceStringPlaceholders(kBrokenPageUrl, subst, NULL); | 2178 ReplaceStringPlaceholders(kBrokenPageUrl, subst, NULL); |
| 2178 ShowSingletonTab(GURL(report_page_url)); | 2179 ShowSingletonTab(GURL(report_page_url)); |
| 2179 } | 2180 } |
| 2180 | 2181 |
| 2181 void Browser::ShowOptionsTab(const std::string& sub_page) { | 2182 void Browser::ShowOptionsTab(const std::string& sub_page) { |
| 2182 browser::NavigateParams params(GetSingletonTabNavigateParams( | 2183 browser::NavigateParams params(GetSingletonTabNavigateParams( |
| 2183 GURL(chrome::kChromeUISettingsURL + sub_page))); | 2184 GURL(chrome::kChromeUISettingsURL + sub_page))); |
| 2184 params.path_behavior = browser::NavigateParams::IGNORE_AND_NAVIGATE; | 2185 params.path_behavior = browser::NavigateParams::IGNORE_AND_NAVIGATE; |
| 2185 | 2186 |
| 2186 ShowSingletonTabOverwritingNTP(params); | 2187 ShowSingletonTabOverwritingNTP(params); |
| 2187 } | 2188 } |
| 2188 | 2189 |
| 2189 void Browser::OpenClearBrowsingDataDialog() { | 2190 void Browser::OpenClearBrowsingDataDialog() { |
| 2190 UserMetrics::RecordAction(UserMetricsAction("ClearBrowsingData_ShowDlg")); | 2191 content::RecordAction(UserMetricsAction("ClearBrowsingData_ShowDlg")); |
| 2191 ShowOptionsTab(chrome::kClearBrowserDataSubPage); | 2192 ShowOptionsTab(chrome::kClearBrowserDataSubPage); |
| 2192 } | 2193 } |
| 2193 | 2194 |
| 2194 void Browser::OpenOptionsDialog() { | 2195 void Browser::OpenOptionsDialog() { |
| 2195 UserMetrics::RecordAction(UserMetricsAction("ShowOptions")); | 2196 content::RecordAction(UserMetricsAction("ShowOptions")); |
| 2196 ShowOptionsTab(""); | 2197 ShowOptionsTab(""); |
| 2197 } | 2198 } |
| 2198 | 2199 |
| 2199 void Browser::OpenPasswordManager() { | 2200 void Browser::OpenPasswordManager() { |
| 2200 UserMetrics::RecordAction(UserMetricsAction("Options_ShowPasswordManager")); | 2201 content::RecordAction(UserMetricsAction("Options_ShowPasswordManager")); |
| 2201 ShowOptionsTab(chrome::kPasswordManagerSubPage); | 2202 ShowOptionsTab(chrome::kPasswordManagerSubPage); |
| 2202 } | 2203 } |
| 2203 | 2204 |
| 2204 void Browser::OpenImportSettingsDialog() { | 2205 void Browser::OpenImportSettingsDialog() { |
| 2205 UserMetrics::RecordAction(UserMetricsAction("Import_ShowDlg")); | 2206 content::RecordAction(UserMetricsAction("Import_ShowDlg")); |
| 2206 ShowOptionsTab(chrome::kImportDataSubPage); | 2207 ShowOptionsTab(chrome::kImportDataSubPage); |
| 2207 } | 2208 } |
| 2208 | 2209 |
| 2209 void Browser::OpenInstantConfirmDialog() { | 2210 void Browser::OpenInstantConfirmDialog() { |
| 2210 ShowOptionsTab(chrome::kInstantConfirmPage); | 2211 ShowOptionsTab(chrome::kInstantConfirmPage); |
| 2211 } | 2212 } |
| 2212 | 2213 |
| 2213 void Browser::OpenSyncMyBookmarksDialog() { | 2214 void Browser::OpenSyncMyBookmarksDialog() { |
| 2214 sync_ui_util::OpenSyncMyBookmarksDialog( | 2215 sync_ui_util::OpenSyncMyBookmarksDialog( |
| 2215 profile_, this, ProfileSyncService::START_FROM_WRENCH); | 2216 profile_, this, ProfileSyncService::START_FROM_WRENCH); |
| 2216 } | 2217 } |
| 2217 | 2218 |
| 2218 void Browser::OpenAboutChromeDialog() { | 2219 void Browser::OpenAboutChromeDialog() { |
| 2219 UserMetrics::RecordAction(UserMetricsAction("AboutChrome")); | 2220 content::RecordAction(UserMetricsAction("AboutChrome")); |
| 2220 #if defined(OS_CHROMEOS) | 2221 #if defined(OS_CHROMEOS) |
| 2221 std::string chrome_settings(chrome::kChromeUISettingsURL); | 2222 std::string chrome_settings(chrome::kChromeUISettingsURL); |
| 2222 ShowSingletonTab(GURL(chrome_settings.append(chrome::kAboutOptionsSubPage))); | 2223 ShowSingletonTab(GURL(chrome_settings.append(chrome::kAboutOptionsSubPage))); |
| 2223 #else | 2224 #else |
| 2224 window_->ShowAboutChromeDialog(); | 2225 window_->ShowAboutChromeDialog(); |
| 2225 #endif | 2226 #endif |
| 2226 } | 2227 } |
| 2227 | 2228 |
| 2228 void Browser::OpenUpdateChromeDialog() { | 2229 void Browser::OpenUpdateChromeDialog() { |
| 2229 UserMetrics::RecordAction(UserMetricsAction("UpdateChrome")); | 2230 content::RecordAction(UserMetricsAction("UpdateChrome")); |
| 2230 window_->ShowUpdateChromeDialog(); | 2231 window_->ShowUpdateChromeDialog(); |
| 2231 } | 2232 } |
| 2232 | 2233 |
| 2233 void Browser::ShowHelpTab() { | 2234 void Browser::ShowHelpTab() { |
| 2234 UserMetrics::RecordAction(UserMetricsAction("ShowHelpTab")); | 2235 content::RecordAction(UserMetricsAction("ShowHelpTab")); |
| 2235 GURL help_url(kHelpContentUrl); | 2236 GURL help_url(kHelpContentUrl); |
| 2236 GURL localized_help_url = google_util::AppendGoogleLocaleParam(help_url); | 2237 GURL localized_help_url = google_util::AppendGoogleLocaleParam(help_url); |
| 2237 ShowSingletonTab(localized_help_url); | 2238 ShowSingletonTab(localized_help_url); |
| 2238 } | 2239 } |
| 2239 | 2240 |
| 2240 void Browser::OpenPrivacyDashboardTabAndActivate() { | 2241 void Browser::OpenPrivacyDashboardTabAndActivate() { |
| 2241 OpenURL(GURL(kPrivacyDashboardUrl), GURL(), | 2242 OpenURL(GURL(kPrivacyDashboardUrl), GURL(), |
| 2242 NEW_FOREGROUND_TAB, content::PAGE_TRANSITION_LINK); | 2243 NEW_FOREGROUND_TAB, content::PAGE_TRANSITION_LINK); |
| 2243 window_->Activate(); | 2244 window_->Activate(); |
| 2244 } | 2245 } |
| 2245 | 2246 |
| 2246 void Browser::OpenAutofillHelpTabAndActivate() { | 2247 void Browser::OpenAutofillHelpTabAndActivate() { |
| 2247 GURL help_url = google_util::AppendGoogleLocaleParam(GURL(kAutofillHelpUrl)); | 2248 GURL help_url = google_util::AppendGoogleLocaleParam(GURL(kAutofillHelpUrl)); |
| 2248 AddSelectedTabWithURL(help_url, content::PAGE_TRANSITION_LINK); | 2249 AddSelectedTabWithURL(help_url, content::PAGE_TRANSITION_LINK); |
| 2249 } | 2250 } |
| 2250 | 2251 |
| 2251 void Browser::OpenSearchEngineOptionsDialog() { | 2252 void Browser::OpenSearchEngineOptionsDialog() { |
| 2252 UserMetrics::RecordAction(UserMetricsAction("EditSearchEngines")); | 2253 content::RecordAction(UserMetricsAction("EditSearchEngines")); |
| 2253 ShowOptionsTab(chrome::kSearchEnginesSubPage); | 2254 ShowOptionsTab(chrome::kSearchEnginesSubPage); |
| 2254 } | 2255 } |
| 2255 | 2256 |
| 2256 #if defined(FILE_MANAGER_EXTENSION) | 2257 #if defined(FILE_MANAGER_EXTENSION) |
| 2257 void Browser::OpenFileManager() { | 2258 void Browser::OpenFileManager() { |
| 2258 UserMetrics::RecordAction(UserMetricsAction("OpenFileManager")); | 2259 content::RecordAction(UserMetricsAction("OpenFileManager")); |
| 2259 ShowSingletonTabRespectRef(GURL(chrome::kChromeUIFileManagerURL)); | 2260 ShowSingletonTabRespectRef(GURL(chrome::kChromeUIFileManagerURL)); |
| 2260 } | 2261 } |
| 2261 #endif | 2262 #endif |
| 2262 | 2263 |
| 2263 #if defined(OS_CHROMEOS) | 2264 #if defined(OS_CHROMEOS) |
| 2264 void Browser::LockScreen() { | 2265 void Browser::LockScreen() { |
| 2265 UserMetrics::RecordAction(UserMetricsAction("LockScreen")); | 2266 content::RecordAction(UserMetricsAction("LockScreen")); |
| 2266 chromeos::CrosLibrary::Get()->GetScreenLockLibrary()-> | 2267 chromeos::CrosLibrary::Get()->GetScreenLockLibrary()-> |
| 2267 NotifyScreenLockRequested(); | 2268 NotifyScreenLockRequested(); |
| 2268 } | 2269 } |
| 2269 | 2270 |
| 2270 void Browser::Shutdown() { | 2271 void Browser::Shutdown() { |
| 2271 UserMetrics::RecordAction(UserMetricsAction("Shutdown")); | 2272 content::RecordAction(UserMetricsAction("Shutdown")); |
| 2272 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()-> | 2273 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()-> |
| 2273 RequestShutdown(); | 2274 RequestShutdown(); |
| 2274 } | 2275 } |
| 2275 | 2276 |
| 2276 void Browser::OpenSystemOptionsDialog() { | 2277 void Browser::OpenSystemOptionsDialog() { |
| 2277 UserMetrics::RecordAction(UserMetricsAction("OpenSystemOptionsDialog")); | 2278 content::RecordAction(UserMetricsAction("OpenSystemOptionsDialog")); |
| 2278 ShowOptionsTab(chrome::kSystemOptionsSubPage); | 2279 ShowOptionsTab(chrome::kSystemOptionsSubPage); |
| 2279 } | 2280 } |
| 2280 | 2281 |
| 2281 void Browser::OpenInternetOptionsDialog() { | 2282 void Browser::OpenInternetOptionsDialog() { |
| 2282 UserMetrics::RecordAction(UserMetricsAction("OpenInternetOptionsDialog")); | 2283 content::RecordAction(UserMetricsAction("OpenInternetOptionsDialog")); |
| 2283 ShowOptionsTab(chrome::kInternetOptionsSubPage); | 2284 ShowOptionsTab(chrome::kInternetOptionsSubPage); |
| 2284 } | 2285 } |
| 2285 | 2286 |
| 2286 void Browser::OpenLanguageOptionsDialog() { | 2287 void Browser::OpenLanguageOptionsDialog() { |
| 2287 UserMetrics::RecordAction(UserMetricsAction("OpenLanguageOptionsDialog")); | 2288 content::RecordAction(UserMetricsAction("OpenLanguageOptionsDialog")); |
| 2288 ShowOptionsTab(chrome::kLanguageOptionsSubPage); | 2289 ShowOptionsTab(chrome::kLanguageOptionsSubPage); |
| 2289 } | 2290 } |
| 2290 | 2291 |
| 2291 void Browser::OpenSystemTabAndActivate() { | 2292 void Browser::OpenSystemTabAndActivate() { |
| 2292 OpenURL(GURL(chrome::kChromeUISystemInfoURL), GURL(), | 2293 OpenURL(GURL(chrome::kChromeUISystemInfoURL), GURL(), |
| 2293 NEW_FOREGROUND_TAB, content::PAGE_TRANSITION_LINK); | 2294 NEW_FOREGROUND_TAB, content::PAGE_TRANSITION_LINK); |
| 2294 window_->Activate(); | 2295 window_->Activate(); |
| 2295 } | 2296 } |
| 2296 | 2297 |
| 2297 void Browser::OpenMobilePlanTabAndActivate() { | 2298 void Browser::OpenMobilePlanTabAndActivate() { |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2581 if (policy->IsPseudoScheme(protocol) || policy->IsDisabledScheme(protocol)) | 2582 if (policy->IsPseudoScheme(protocol) || policy->IsDisabledScheme(protocol)) |
| 2582 return; | 2583 return; |
| 2583 | 2584 |
| 2584 ProtocolHandler handler = | 2585 ProtocolHandler handler = |
| 2585 ProtocolHandler::CreateProtocolHandler(protocol, url, title); | 2586 ProtocolHandler::CreateProtocolHandler(protocol, url, title); |
| 2586 | 2587 |
| 2587 ProtocolHandlerRegistry* registry = | 2588 ProtocolHandlerRegistry* registry = |
| 2588 tcw->profile()->GetProtocolHandlerRegistry(); | 2589 tcw->profile()->GetProtocolHandlerRegistry(); |
| 2589 | 2590 |
| 2590 if (!registry->SilentlyHandleRegisterHandlerRequest(handler)) { | 2591 if (!registry->SilentlyHandleRegisterHandlerRequest(handler)) { |
| 2591 UserMetrics::RecordAction( | 2592 content::RecordAction( |
| 2592 UserMetricsAction("RegisterProtocolHandler.InfoBar_Shown")); | 2593 UserMetricsAction("RegisterProtocolHandler.InfoBar_Shown")); |
| 2593 InfoBarTabHelper* infobar_helper = tcw->infobar_tab_helper(); | 2594 InfoBarTabHelper* infobar_helper = tcw->infobar_tab_helper(); |
| 2594 infobar_helper->AddInfoBar( | 2595 infobar_helper->AddInfoBar( |
| 2595 new RegisterProtocolHandlerInfoBarDelegate(infobar_helper, | 2596 new RegisterProtocolHandlerInfoBarDelegate(infobar_helper, |
| 2596 registry, | 2597 registry, |
| 2597 handler)); | 2598 handler)); |
| 2598 } | 2599 } |
| 2599 } | 2600 } |
| 2600 | 2601 |
| 2601 // static | 2602 // static |
| (...skipping 2591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5193 contents->tab_contents()->controller().GetActiveEntry(); | 5194 contents->tab_contents()->controller().GetActiveEntry(); |
| 5194 if (!active_entry) | 5195 if (!active_entry) |
| 5195 return; | 5196 return; |
| 5196 | 5197 |
| 5197 ViewSource(contents, active_entry->url(), active_entry->content_state()); | 5198 ViewSource(contents, active_entry->url(), active_entry->content_state()); |
| 5198 } | 5199 } |
| 5199 | 5200 |
| 5200 void Browser::ViewSource(TabContentsWrapper* contents, | 5201 void Browser::ViewSource(TabContentsWrapper* contents, |
| 5201 const GURL& url, | 5202 const GURL& url, |
| 5202 const std::string& content_state) { | 5203 const std::string& content_state) { |
| 5203 UserMetrics::RecordAction(UserMetricsAction("ViewSource")); | 5204 content::RecordAction(UserMetricsAction("ViewSource")); |
| 5204 DCHECK(contents); | 5205 DCHECK(contents); |
| 5205 | 5206 |
| 5206 TabContentsWrapper* view_source_contents = contents->Clone(); | 5207 TabContentsWrapper* view_source_contents = contents->Clone(); |
| 5207 view_source_contents->tab_contents()->controller().PruneAllButActive(); | 5208 view_source_contents->tab_contents()->controller().PruneAllButActive(); |
| 5208 NavigationEntry* active_entry = | 5209 NavigationEntry* active_entry = |
| 5209 view_source_contents->tab_contents()->controller().GetActiveEntry(); | 5210 view_source_contents->tab_contents()->controller().GetActiveEntry(); |
| 5210 if (!active_entry) | 5211 if (!active_entry) |
| 5211 return; | 5212 return; |
| 5212 | 5213 |
| 5213 GURL view_source_url = GURL(chrome::kViewSourceScheme + std::string(":") + | 5214 GURL view_source_url = GURL(chrome::kViewSourceScheme + std::string(":") + |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5353 window_->GetLocationBar()->ShowFirstRunBubble(bubble_type); | 5354 window_->GetLocationBar()->ShowFirstRunBubble(bubble_type); |
| 5354 } else { | 5355 } else { |
| 5355 GlobalErrorService* service = | 5356 GlobalErrorService* service = |
| 5356 GlobalErrorServiceFactory::GetForProfile(profile()); | 5357 GlobalErrorServiceFactory::GetForProfile(profile()); |
| 5357 GlobalError* error = service->GetFirstGlobalErrorWithBubbleView(); | 5358 GlobalError* error = service->GetFirstGlobalErrorWithBubbleView(); |
| 5358 if (error) { | 5359 if (error) { |
| 5359 error->ShowBubbleView(this); | 5360 error->ShowBubbleView(this); |
| 5360 } | 5361 } |
| 5361 } | 5362 } |
| 5362 } | 5363 } |
| OLD | NEW |