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

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

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

Powered by Google App Engine
This is Rietveld 408576698