Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/renderer_context_menu/render_view_context_menu.h" | 5 #include "chrome/browser/renderer_context_menu/render_view_context_menu.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 45 #include "chrome/browser/spellchecker/spellcheck_host_metrics.h" | 45 #include "chrome/browser/spellchecker/spellcheck_host_metrics.h" |
| 46 #include "chrome/browser/spellchecker/spellcheck_service.h" | 46 #include "chrome/browser/spellchecker/spellcheck_service.h" |
| 47 #include "chrome/browser/ssl/security_state_model.h" | 47 #include "chrome/browser/ssl/security_state_model.h" |
| 48 #include "chrome/browser/tab_contents/retargeting_details.h" | 48 #include "chrome/browser/tab_contents/retargeting_details.h" |
| 49 #include "chrome/browser/translate/chrome_translate_client.h" | 49 #include "chrome/browser/translate/chrome_translate_client.h" |
| 50 #include "chrome/browser/translate/translate_service.h" | 50 #include "chrome/browser/translate/translate_service.h" |
| 51 #include "chrome/browser/ui/browser.h" | 51 #include "chrome/browser/ui/browser.h" |
| 52 #include "chrome/browser/ui/browser_commands.h" | 52 #include "chrome/browser/ui/browser_commands.h" |
| 53 #include "chrome/browser/ui/browser_finder.h" | 53 #include "chrome/browser/ui/browser_finder.h" |
| 54 #include "chrome/browser/ui/chrome_pages.h" | 54 #include "chrome/browser/ui/chrome_pages.h" |
| 55 #include "chrome/browser/ui/search_engines/search_engine_tab_helper.h" | 55 #include "chrome/browser/ui/search_engines/search_engine_tab_helper.h" |
|
Avi (use Gerrit)
2015/10/01 00:41:35
You can probably remove this include, too.
Evan Stade
2015/10/01 17:48:00
Done.
| |
| 56 #include "chrome/browser/ui/tab_contents/core_tab_helper.h" | 56 #include "chrome/browser/ui/tab_contents/core_tab_helper.h" |
| 57 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 57 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 58 #include "chrome/common/chrome_constants.h" | 58 #include "chrome/common/chrome_constants.h" |
| 59 #include "chrome/common/chrome_switches.h" | 59 #include "chrome/common/chrome_switches.h" |
| 60 #include "chrome/common/content_restriction.h" | 60 #include "chrome/common/content_restriction.h" |
| 61 #include "chrome/common/pref_names.h" | 61 #include "chrome/common/pref_names.h" |
| 62 #include "chrome/common/render_messages.h" | 62 #include "chrome/common/render_messages.h" |
| 63 #include "chrome/common/spellcheck_common.h" | 63 #include "chrome/common/spellcheck_common.h" |
| 64 #include "chrome/common/url_constants.h" | 64 #include "chrome/common/url_constants.h" |
| 65 #include "chrome/grit/generated_resources.h" | 65 #include "chrome/grit/generated_resources.h" |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 218 {38, -1, IDC_CONTENT_CONTEXT_CUT}, | 218 {38, -1, IDC_CONTENT_CONTEXT_CUT}, |
| 219 {39, 4, IDC_CONTENT_CONTEXT_COPY}, | 219 {39, 4, IDC_CONTENT_CONTEXT_COPY}, |
| 220 {40, -1, IDC_CONTENT_CONTEXT_PASTE}, | 220 {40, -1, IDC_CONTENT_CONTEXT_PASTE}, |
| 221 {41, -1, IDC_CONTENT_CONTEXT_PASTE_AND_MATCH_STYLE}, | 221 {41, -1, IDC_CONTENT_CONTEXT_PASTE_AND_MATCH_STYLE}, |
| 222 {42, -1, IDC_CONTENT_CONTEXT_DELETE}, | 222 {42, -1, IDC_CONTENT_CONTEXT_DELETE}, |
| 223 {43, -1, IDC_CONTENT_CONTEXT_SELECTALL}, | 223 {43, -1, IDC_CONTENT_CONTEXT_SELECTALL}, |
| 224 {44, 17, IDC_CONTENT_CONTEXT_SEARCHWEBFOR}, | 224 {44, 17, IDC_CONTENT_CONTEXT_SEARCHWEBFOR}, |
| 225 {45, -1, IDC_CONTENT_CONTEXT_GOTOURL}, | 225 {45, -1, IDC_CONTENT_CONTEXT_GOTOURL}, |
| 226 {46, -1, IDC_CONTENT_CONTEXT_LANGUAGE_SETTINGS}, | 226 {46, -1, IDC_CONTENT_CONTEXT_LANGUAGE_SETTINGS}, |
| 227 {47, -1, IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_SETTINGS}, | 227 {47, -1, IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_SETTINGS}, |
| 228 {48, -1, IDC_CONTENT_CONTEXT_ADDSEARCHENGINE}, | |
| 229 {52, -1, IDC_CONTENT_CONTEXT_OPENLINKWITH}, | 228 {52, -1, IDC_CONTENT_CONTEXT_OPENLINKWITH}, |
| 230 {53, -1, IDC_CHECK_SPELLING_WHILE_TYPING}, | 229 {53, -1, IDC_CHECK_SPELLING_WHILE_TYPING}, |
| 231 {54, -1, IDC_SPELLCHECK_MENU}, | 230 {54, -1, IDC_SPELLCHECK_MENU}, |
| 232 {55, -1, IDC_CONTENT_CONTEXT_SPELLING_TOGGLE}, | 231 {55, -1, IDC_CONTENT_CONTEXT_SPELLING_TOGGLE}, |
| 233 {56, -1, IDC_SPELLCHECK_LANGUAGES_FIRST}, | 232 {56, -1, IDC_SPELLCHECK_LANGUAGES_FIRST}, |
| 234 {57, 11, IDC_CONTENT_CONTEXT_SEARCHWEBFORIMAGE}, | 233 {57, 11, IDC_CONTENT_CONTEXT_SEARCHWEBFORIMAGE}, |
| 235 {58, -1, IDC_SPELLCHECK_SUGGESTION_0}, | 234 {58, -1, IDC_SPELLCHECK_SUGGESTION_0}, |
| 236 {59, -1, IDC_SPELLCHECK_ADD_TO_DICTIONARY}, | 235 {59, -1, IDC_SPELLCHECK_ADD_TO_DICTIONARY}, |
| 237 {60, -1, IDC_SPELLPANEL_TOGGLE}, | 236 {60, -1, IDC_SPELLPANEL_TOGGLE}, |
| 238 {61, -1, IDC_CONTENT_CONTEXT_OPEN_ORIGINAL_IMAGE_NEW_TAB}, | 237 {61, -1, IDC_CONTENT_CONTEXT_OPEN_ORIGINAL_IMAGE_NEW_TAB}, |
| (...skipping 1139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1378 | 1377 |
| 1379 case IDC_CHECK_SPELLING_WHILE_TYPING: | 1378 case IDC_CHECK_SPELLING_WHILE_TYPING: |
| 1380 return prefs->GetBoolean(prefs::kEnableContinuousSpellcheck); | 1379 return prefs->GetBoolean(prefs::kEnableContinuousSpellcheck); |
| 1381 | 1380 |
| 1382 #if !defined(OS_MACOSX) && defined(OS_POSIX) | 1381 #if !defined(OS_MACOSX) && defined(OS_POSIX) |
| 1383 // TODO(suzhe): this should not be enabled for password fields. | 1382 // TODO(suzhe): this should not be enabled for password fields. |
| 1384 case IDC_INPUT_METHODS_MENU: | 1383 case IDC_INPUT_METHODS_MENU: |
| 1385 return true; | 1384 return true; |
| 1386 #endif | 1385 #endif |
| 1387 | 1386 |
| 1388 case IDC_CONTENT_CONTEXT_ADDSEARCHENGINE: | |
| 1389 return !params_.keyword_url.is_empty(); | |
| 1390 | |
| 1391 case IDC_SPELLCHECK_MENU: | 1387 case IDC_SPELLCHECK_MENU: |
| 1392 return true; | 1388 return true; |
| 1393 | 1389 |
| 1394 case IDC_CONTENT_CONTEXT_OPENLINKWITH: | 1390 case IDC_CONTENT_CONTEXT_OPENLINKWITH: |
| 1395 return true; | 1391 return true; |
| 1396 | 1392 |
| 1397 case IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_SETTINGS: | 1393 case IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_SETTINGS: |
| 1398 return true; | 1394 return true; |
| 1399 | 1395 |
| 1400 case IDC_CONTENT_CONTEXT_FORCESAVEPASSWORD: | 1396 case IDC_CONTENT_CONTEXT_FORCESAVEPASSWORD: |
| (...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1855 case IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_SETTINGS: { | 1851 case IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_SETTINGS: { |
| 1856 content::RecordAction( | 1852 content::RecordAction( |
| 1857 UserMetricsAction("RegisterProtocolHandler.ContextMenu_Settings")); | 1853 UserMetricsAction("RegisterProtocolHandler.ContextMenu_Settings")); |
| 1858 WindowOpenDisposition disposition = | 1854 WindowOpenDisposition disposition = |
| 1859 ForceNewTabDispositionFromEventFlags(event_flags); | 1855 ForceNewTabDispositionFromEventFlags(event_flags); |
| 1860 GURL url = chrome::GetSettingsUrl(chrome::kHandlerSettingsSubPage); | 1856 GURL url = chrome::GetSettingsUrl(chrome::kHandlerSettingsSubPage); |
| 1861 OpenURL(url, GURL(), disposition, ui::PAGE_TRANSITION_LINK); | 1857 OpenURL(url, GURL(), disposition, ui::PAGE_TRANSITION_LINK); |
| 1862 break; | 1858 break; |
| 1863 } | 1859 } |
| 1864 | 1860 |
| 1865 case IDC_CONTENT_CONTEXT_ADDSEARCHENGINE: { | |
| 1866 // Make sure the model is loaded. | |
| 1867 TemplateURLService* model = | |
| 1868 TemplateURLServiceFactory::GetForProfile(GetProfile()); | |
| 1869 if (!model) | |
| 1870 return; | |
| 1871 model->Load(); | |
| 1872 | |
| 1873 SearchEngineTabHelper* search_engine_tab_helper = | |
| 1874 SearchEngineTabHelper::FromWebContents(source_web_contents_); | |
| 1875 if (search_engine_tab_helper && | |
| 1876 search_engine_tab_helper->delegate()) { | |
| 1877 base::string16 keyword(TemplateURL::GenerateKeyword( | |
| 1878 params_.page_url, | |
| 1879 GetProfile()->GetPrefs()->GetString(prefs::kAcceptLanguages))); | |
| 1880 TemplateURLData data; | |
| 1881 data.SetShortName(keyword); | |
| 1882 data.SetKeyword(keyword); | |
| 1883 data.SetURL(params_.keyword_url.spec()); | |
| 1884 data.favicon_url = | |
| 1885 TemplateURL::GenerateFaviconURL(params_.page_url.GetOrigin()); | |
| 1886 // Takes ownership of the TemplateURL. | |
| 1887 search_engine_tab_helper->delegate()->ConfirmAddSearchProvider( | |
| 1888 new TemplateURL(data), GetProfile()); | |
| 1889 } | |
| 1890 break; | |
| 1891 } | |
| 1892 | |
| 1893 case IDC_CONTENT_CONTEXT_FORCESAVEPASSWORD: | 1861 case IDC_CONTENT_CONTEXT_FORCESAVEPASSWORD: |
| 1894 ChromePasswordManagerClient::FromWebContents(source_web_contents_)-> | 1862 ChromePasswordManagerClient::FromWebContents(source_web_contents_)-> |
| 1895 ForceSavePassword(); | 1863 ForceSavePassword(); |
| 1896 break; | 1864 break; |
| 1897 | 1865 |
| 1898 default: | 1866 default: |
| 1899 NOTREACHED(); | 1867 NOTREACHED(); |
| 1900 break; | 1868 break; |
| 1901 } | 1869 } |
| 1902 } | 1870 } |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2005 source_web_contents_->GetRenderViewHost()-> | 1973 source_web_contents_->GetRenderViewHost()-> |
| 2006 ExecuteMediaPlayerActionAtLocation(location, action); | 1974 ExecuteMediaPlayerActionAtLocation(location, action); |
| 2007 } | 1975 } |
| 2008 | 1976 |
| 2009 void RenderViewContextMenu::PluginActionAt( | 1977 void RenderViewContextMenu::PluginActionAt( |
| 2010 const gfx::Point& location, | 1978 const gfx::Point& location, |
| 2011 const WebPluginAction& action) { | 1979 const WebPluginAction& action) { |
| 2012 source_web_contents_->GetRenderViewHost()-> | 1980 source_web_contents_->GetRenderViewHost()-> |
| 2013 ExecutePluginActionAtLocation(location, action); | 1981 ExecutePluginActionAtLocation(location, action); |
| 2014 } | 1982 } |
| OLD | NEW |