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

Side by Side Diff: chrome/browser/tab_contents/render_view_context_menu.cc

Issue 8253002: Move PageTransition into content namespace. While I'm touching all these files, I've also updated... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 2 months 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 <algorithm> 5 #include <algorithm>
6 #include <set> 6 #include <set>
7 7
8 #include "chrome/browser/tab_contents/render_view_context_menu.h" 8 #include "chrome/browser/tab_contents/render_view_context_menu.h"
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 791 matching lines...) Expand 10 before | Expand all | Expand 10 after
802 selection_navigation_url_ = match.destination_url; 802 selection_navigation_url_ = match.destination_url;
803 if (!selection_navigation_url_.is_valid()) 803 if (!selection_navigation_url_.is_valid())
804 return; 804 return;
805 805
806 string16 printable_selection_text = PrintableSelectionText(); 806 string16 printable_selection_text = PrintableSelectionText();
807 // Escape "&" as "&&". 807 // Escape "&" as "&&".
808 for (size_t i = printable_selection_text.find('&'); i != string16::npos; 808 for (size_t i = printable_selection_text.find('&'); i != string16::npos;
809 i = printable_selection_text.find('&', i + 2)) 809 i = printable_selection_text.find('&', i + 2))
810 printable_selection_text.insert(i, 1, '&'); 810 printable_selection_text.insert(i, 1, '&');
811 811
812 if (match.transition == PageTransition::TYPED) { 812 if (match.transition == content::PAGE_TRANSITION_TYPED) {
813 if (ChildProcessSecurityPolicy::GetInstance()->IsWebSafeScheme( 813 if (ChildProcessSecurityPolicy::GetInstance()->IsWebSafeScheme(
814 selection_navigation_url_.scheme())) { 814 selection_navigation_url_.scheme())) {
815 menu_model_.AddItem( 815 menu_model_.AddItem(
816 IDC_CONTENT_CONTEXT_GOTOURL, 816 IDC_CONTENT_CONTEXT_GOTOURL,
817 l10n_util::GetStringFUTF16(IDS_CONTENT_CONTEXT_GOTOURL, 817 l10n_util::GetStringFUTF16(IDS_CONTENT_CONTEXT_GOTOURL,
818 printable_selection_text)); 818 printable_selection_text));
819 } 819 }
820 } else { 820 } else {
821 const TemplateURL* const default_provider = 821 const TemplateURL* const default_provider =
822 TemplateURLServiceFactory::GetForProfile(profile_)-> 822 TemplateURLServiceFactory::GetForProfile(profile_)->
(...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after
1458 UserMetrics::RecordAction( 1458 UserMetrics::RecordAction(
1459 UserMetricsAction("RegisterProtocolHandler.ContextMenu_Open")); 1459 UserMetricsAction("RegisterProtocolHandler.ContextMenu_Open"));
1460 int handlerIndex = id - IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_FIRST; 1460 int handlerIndex = id - IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_FIRST;
1461 WindowOpenDisposition disposition = 1461 WindowOpenDisposition disposition =
1462 ForceNewTabDispositionFromEventFlags(event_flags); 1462 ForceNewTabDispositionFromEventFlags(event_flags);
1463 OpenURL( 1463 OpenURL(
1464 handlers[handlerIndex].TranslateUrl(params_.link_url), 1464 handlers[handlerIndex].TranslateUrl(params_.link_url),
1465 params_.frame_url.is_empty() ? params_.page_url : params_.frame_url, 1465 params_.frame_url.is_empty() ? params_.page_url : params_.frame_url,
1466 params_.frame_id, 1466 params_.frame_id,
1467 disposition, 1467 disposition,
1468 PageTransition::LINK); 1468 content::PAGE_TRANSITION_LINK);
1469 return; 1469 return;
1470 } 1470 }
1471 1471
1472 switch (id) { 1472 switch (id) {
1473 case IDC_CONTENT_CONTEXT_OPENLINKNEWTAB: 1473 case IDC_CONTENT_CONTEXT_OPENLINKNEWTAB:
1474 OpenURL( 1474 OpenURL(
1475 params_.link_url, 1475 params_.link_url,
1476 params_.frame_url.is_empty() ? params_.page_url : params_.frame_url, 1476 params_.frame_url.is_empty() ? params_.page_url : params_.frame_url,
1477 params_.frame_id, 1477 params_.frame_id,
1478 source_tab_contents_->delegate() && 1478 source_tab_contents_->delegate() &&
1479 source_tab_contents_->delegate()->IsApplication() ? 1479 source_tab_contents_->delegate()->IsApplication() ?
1480 NEW_FOREGROUND_TAB : NEW_BACKGROUND_TAB, 1480 NEW_FOREGROUND_TAB : NEW_BACKGROUND_TAB,
1481 PageTransition::LINK); 1481 content::PAGE_TRANSITION_LINK);
1482 break; 1482 break;
1483 1483
1484 case IDC_CONTENT_CONTEXT_OPENLINKNEWWINDOW: 1484 case IDC_CONTENT_CONTEXT_OPENLINKNEWWINDOW:
1485 OpenURL( 1485 OpenURL(
1486 params_.link_url, 1486 params_.link_url,
1487 params_.frame_url.is_empty() ? params_.page_url : params_.frame_url, 1487 params_.frame_url.is_empty() ? params_.page_url : params_.frame_url,
1488 params_.frame_id, 1488 params_.frame_id,
1489 NEW_WINDOW, PageTransition::LINK); 1489 NEW_WINDOW, content::PAGE_TRANSITION_LINK);
1490 break; 1490 break;
1491 1491
1492 case IDC_CONTENT_CONTEXT_OPENLINKOFFTHERECORD: 1492 case IDC_CONTENT_CONTEXT_OPENLINKOFFTHERECORD:
1493 OpenURL(params_.link_url, 1493 OpenURL(params_.link_url,
1494 GURL(), 1494 GURL(),
1495 params_.frame_id, 1495 params_.frame_id,
1496 OFF_THE_RECORD, 1496 OFF_THE_RECORD,
1497 PageTransition::LINK); 1497 content::PAGE_TRANSITION_LINK);
1498 break; 1498 break;
1499 1499
1500 case IDC_CONTENT_CONTEXT_SAVEAVAS: 1500 case IDC_CONTENT_CONTEXT_SAVEAVAS:
1501 case IDC_CONTENT_CONTEXT_SAVEIMAGEAS: 1501 case IDC_CONTENT_CONTEXT_SAVEIMAGEAS:
1502 case IDC_CONTENT_CONTEXT_SAVELINKAS: { 1502 case IDC_CONTENT_CONTEXT_SAVELINKAS: {
1503 download_stats::RecordDownloadCount( 1503 download_stats::RecordDownloadCount(
1504 download_stats::INITIATED_BY_CONTEXT_MENU_COUNT); 1504 download_stats::INITIATED_BY_CONTEXT_MENU_COUNT);
1505 const GURL& referrer = 1505 const GURL& referrer =
1506 params_.frame_url.is_empty() ? params_.page_url : params_.frame_url; 1506 params_.frame_url.is_empty() ? params_.page_url : params_.frame_url;
1507 const GURL& url = 1507 const GURL& url =
(...skipping 18 matching lines...) Expand all
1526 case IDC_CONTENT_CONTEXT_COPYIMAGE: 1526 case IDC_CONTENT_CONTEXT_COPYIMAGE:
1527 CopyImageAt(params_.x, params_.y); 1527 CopyImageAt(params_.x, params_.y);
1528 break; 1528 break;
1529 1529
1530 case IDC_CONTENT_CONTEXT_OPENIMAGENEWTAB: 1530 case IDC_CONTENT_CONTEXT_OPENIMAGENEWTAB:
1531 case IDC_CONTENT_CONTEXT_OPENAVNEWTAB: 1531 case IDC_CONTENT_CONTEXT_OPENAVNEWTAB:
1532 OpenURL( 1532 OpenURL(
1533 params_.src_url, 1533 params_.src_url,
1534 params_.frame_url.is_empty() ? params_.page_url : params_.frame_url, 1534 params_.frame_url.is_empty() ? params_.page_url : params_.frame_url,
1535 params_.frame_id, 1535 params_.frame_id,
1536 NEW_BACKGROUND_TAB, PageTransition::LINK); 1536 NEW_BACKGROUND_TAB, content::PAGE_TRANSITION_LINK);
1537 break; 1537 break;
1538 1538
1539 case IDC_CONTENT_CONTEXT_PLAYPAUSE: { 1539 case IDC_CONTENT_CONTEXT_PLAYPAUSE: {
1540 bool play = !!(params_.media_flags & WebContextMenuData::MediaPaused); 1540 bool play = !!(params_.media_flags & WebContextMenuData::MediaPaused);
1541 if (play) { 1541 if (play) {
1542 UserMetrics::RecordAction(UserMetricsAction("MediaContextMenu_Play")); 1542 UserMetrics::RecordAction(UserMetricsAction("MediaContextMenu_Play"));
1543 } else { 1543 } else {
1544 UserMetrics::RecordAction(UserMetricsAction("MediaContextMenu_Pause")); 1544 UserMetrics::RecordAction(UserMetricsAction("MediaContextMenu_Pause"));
1545 } 1545 }
1546 MediaPlayerActionAt(gfx::Point(params_.x, params_.y), 1546 MediaPlayerActionAt(gfx::Point(params_.x, params_.y),
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
1723 break; 1723 break;
1724 1724
1725 case IDC_CONTENT_CONTEXT_SEARCHWEBFOR: 1725 case IDC_CONTENT_CONTEXT_SEARCHWEBFOR:
1726 case IDC_CONTENT_CONTEXT_GOTOURL: { 1726 case IDC_CONTENT_CONTEXT_GOTOURL: {
1727 WindowOpenDisposition disposition = 1727 WindowOpenDisposition disposition =
1728 ForceNewTabDispositionFromEventFlags(event_flags); 1728 ForceNewTabDispositionFromEventFlags(event_flags);
1729 OpenURL(selection_navigation_url_, 1729 OpenURL(selection_navigation_url_,
1730 GURL(), 1730 GURL(),
1731 params_.frame_id, 1731 params_.frame_id,
1732 disposition, 1732 disposition,
1733 PageTransition::LINK); 1733 content::PAGE_TRANSITION_LINK);
1734 break; 1734 break;
1735 } 1735 }
1736 1736
1737 case IDC_SPELLCHECK_SUGGESTION_0: 1737 case IDC_SPELLCHECK_SUGGESTION_0:
1738 case IDC_SPELLCHECK_SUGGESTION_1: 1738 case IDC_SPELLCHECK_SUGGESTION_1:
1739 case IDC_SPELLCHECK_SUGGESTION_2: 1739 case IDC_SPELLCHECK_SUGGESTION_2:
1740 case IDC_SPELLCHECK_SUGGESTION_3: 1740 case IDC_SPELLCHECK_SUGGESTION_3:
1741 case IDC_SPELLCHECK_SUGGESTION_4: { 1741 case IDC_SPELLCHECK_SUGGESTION_4: {
1742 rvh->Replace( 1742 rvh->Replace(
1743 params_.dictionary_suggestions[id - IDC_SPELLCHECK_SUGGESTION_0]); 1743 params_.dictionary_suggestions[id - IDC_SPELLCHECK_SUGGESTION_0]);
(...skipping 16 matching lines...) Expand all
1760 UTF16ToUTF8(params_.misspelled_word)); 1760 UTF16ToUTF8(params_.misspelled_word));
1761 SpellCheckerPlatform::AddWord(params_.misspelled_word); 1761 SpellCheckerPlatform::AddWord(params_.misspelled_word);
1762 break; 1762 break;
1763 } 1763 }
1764 1764
1765 case IDC_CONTENT_CONTEXT_LANGUAGE_SETTINGS: { 1765 case IDC_CONTENT_CONTEXT_LANGUAGE_SETTINGS: {
1766 WindowOpenDisposition disposition = 1766 WindowOpenDisposition disposition =
1767 ForceNewTabDispositionFromEventFlags(event_flags); 1767 ForceNewTabDispositionFromEventFlags(event_flags);
1768 std::string url = std::string(chrome::kChromeUISettingsURL) + 1768 std::string url = std::string(chrome::kChromeUISettingsURL) +
1769 chrome::kLanguageOptionsSubPage; 1769 chrome::kLanguageOptionsSubPage;
1770 OpenURL(GURL(url), GURL(), 0, disposition, PageTransition::LINK); 1770 OpenURL(GURL(url), GURL(), 0, disposition, content::PAGE_TRANSITION_LINK);
1771 break; 1771 break;
1772 } 1772 }
1773 1773
1774 case IDC_SPELLPANEL_TOGGLE: { 1774 case IDC_SPELLPANEL_TOGGLE: {
1775 rvh->Send(new SpellCheckMsg_ToggleSpellPanel( 1775 rvh->Send(new SpellCheckMsg_ToggleSpellPanel(
1776 rvh->routing_id(), SpellCheckerPlatform::SpellingPanelVisible())); 1776 rvh->routing_id(), SpellCheckerPlatform::SpellingPanelVisible()));
1777 break; 1777 break;
1778 } 1778 }
1779 1779
1780 #if defined(OS_MACOSX) 1780 #if defined(OS_MACOSX)
(...skipping 14 matching lines...) Expand all
1795 LookUpInDictionary(); 1795 LookUpInDictionary();
1796 break; 1796 break;
1797 #endif // OS_MACOSX 1797 #endif // OS_MACOSX
1798 case IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_SETTINGS: { 1798 case IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_SETTINGS: {
1799 UserMetrics::RecordAction( 1799 UserMetrics::RecordAction(
1800 UserMetricsAction("RegisterProtocolHandler.ContextMenu_Settings")); 1800 UserMetricsAction("RegisterProtocolHandler.ContextMenu_Settings"));
1801 WindowOpenDisposition disposition = 1801 WindowOpenDisposition disposition =
1802 ForceNewTabDispositionFromEventFlags(event_flags); 1802 ForceNewTabDispositionFromEventFlags(event_flags);
1803 std::string url = std::string(chrome::kChromeUISettingsURL) + 1803 std::string url = std::string(chrome::kChromeUISettingsURL) +
1804 chrome::kHandlerSettingsSubPage; 1804 chrome::kHandlerSettingsSubPage;
1805 OpenURL(GURL(url), GURL(), 0, disposition, PageTransition::LINK); 1805 OpenURL(GURL(url), GURL(), 0, disposition, content::PAGE_TRANSITION_LINK);
1806 break; 1806 break;
1807 } 1807 }
1808 1808
1809 case IDC_CONTENT_CONTEXT_ADDSEARCHENGINE: { 1809 case IDC_CONTENT_CONTEXT_ADDSEARCHENGINE: {
1810 // Make sure the model is loaded. 1810 // Make sure the model is loaded.
1811 TemplateURLService* model = 1811 TemplateURLService* model =
1812 TemplateURLServiceFactory::GetForProfile(profile_); 1812 TemplateURLServiceFactory::GetForProfile(profile_);
1813 if (!model) 1813 if (!model)
1814 return; 1814 return;
1815 model->Load(); 1815 model->Load();
(...skipping 27 matching lines...) Expand all
1843 prefs->SetBoolean(prefs::kSpeechInputFilterProfanities, filter); 1843 prefs->SetBoolean(prefs::kSpeechInputFilterProfanities, filter);
1844 profile_->GetSpeechInputPreferences()->set_filter_profanities(filter); 1844 profile_->GetSpeechInputPreferences()->set_filter_profanities(filter);
1845 break; 1845 break;
1846 } 1846 }
1847 1847
1848 case IDC_CONTENT_CONTEXT_SPEECH_INPUT_ABOUT: { 1848 case IDC_CONTENT_CONTEXT_SPEECH_INPUT_ABOUT: {
1849 GURL url(chrome::kSpeechInputAboutURL); 1849 GURL url(chrome::kSpeechInputAboutURL);
1850 GURL localized_url = google_util::AppendGoogleLocaleParam(url); 1850 GURL localized_url = google_util::AppendGoogleLocaleParam(url);
1851 // Open URL with no referrer field (because user clicked on menu item). 1851 // Open URL with no referrer field (because user clicked on menu item).
1852 OpenURL(localized_url, GURL(), 0, NEW_FOREGROUND_TAB, 1852 OpenURL(localized_url, GURL(), 0, NEW_FOREGROUND_TAB,
1853 PageTransition::LINK); 1853 content::PAGE_TRANSITION_LINK);
1854 break; 1854 break;
1855 } 1855 }
1856 1856
1857 default: 1857 default:
1858 NOTREACHED(); 1858 NOTREACHED();
1859 break; 1859 break;
1860 } 1860 }
1861 } 1861 }
1862 1862
1863 ProtocolHandlerRegistry::ProtocolHandlerList 1863 ProtocolHandlerRegistry::ProtocolHandlerList
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1911 string16 RenderViewContextMenu::PrintableSelectionText() { 1911 string16 RenderViewContextMenu::PrintableSelectionText() {
1912 return ui::TruncateString(params_.selection_text, 1912 return ui::TruncateString(params_.selection_text,
1913 kMaxSelectionTextLength); 1913 kMaxSelectionTextLength);
1914 } 1914 }
1915 1915
1916 // Controller functions -------------------------------------------------------- 1916 // Controller functions --------------------------------------------------------
1917 1917
1918 void RenderViewContextMenu::OpenURL( 1918 void RenderViewContextMenu::OpenURL(
1919 const GURL& url, const GURL& referrer, int64 frame_id, 1919 const GURL& url, const GURL& referrer, int64 frame_id,
1920 WindowOpenDisposition disposition, 1920 WindowOpenDisposition disposition,
1921 PageTransition::Type transition) { 1921 content::PageTransition transition) {
1922 TabContents* new_contents = 1922 TabContents* new_contents =
1923 source_tab_contents_->OpenURL(url, referrer, disposition, transition); 1923 source_tab_contents_->OpenURL(url, referrer, disposition, transition);
1924 1924
1925 if (new_contents) { 1925 if (new_contents) {
1926 content::RetargetingDetails details; 1926 content::RetargetingDetails details;
1927 details.source_tab_contents = source_tab_contents_; 1927 details.source_tab_contents = source_tab_contents_;
1928 details.source_frame_id = frame_id; 1928 details.source_frame_id = frame_id;
1929 details.target_url = url; 1929 details.target_url = url;
1930 details.target_tab_contents = new_contents; 1930 details.target_tab_contents = new_contents;
1931 NotificationService::current()->Notify( 1931 NotificationService::current()->Notify(
(...skipping 20 matching lines...) Expand all
1952 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages), 1952 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages),
1953 g_browser_process->clipboard()); 1953 g_browser_process->clipboard());
1954 } 1954 }
1955 1955
1956 void RenderViewContextMenu::MediaPlayerActionAt( 1956 void RenderViewContextMenu::MediaPlayerActionAt(
1957 const gfx::Point& location, 1957 const gfx::Point& location,
1958 const WebMediaPlayerAction& action) { 1958 const WebMediaPlayerAction& action) {
1959 source_tab_contents_->render_view_host()-> 1959 source_tab_contents_->render_view_host()->
1960 ExecuteMediaPlayerActionAtLocation(location, action); 1960 ExecuteMediaPlayerActionAtLocation(location, action);
1961 } 1961 }
OLDNEW
« no previous file with comments | « chrome/browser/tab_contents/render_view_context_menu.h ('k') | chrome/browser/tab_contents/web_contents_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698