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

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

Issue 31008: Coalesce more hardcoded schemes to using predefined constants. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 9 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
« no previous file with comments | « chrome/browser/ssl/ssl_policy.cc ('k') | chrome/browser/tab_contents/site_instance.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 "build/build_config.h" 5 #include "build/build_config.h"
6 6
7 #include "chrome/browser/tab_contents/render_view_context_menu_controller.h" 7 #include "chrome/browser/tab_contents/render_view_context_menu_controller.h"
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 ClipboardService* clipboard = g_browser_process->clipboard_service(); 71 ClipboardService* clipboard = g_browser_process->clipboard_service();
72 72
73 if (!clipboard) 73 if (!clipboard)
74 return; 74 return;
75 75
76 ScopedClipboardWriter scw(clipboard); 76 ScopedClipboardWriter scw(clipboard);
77 scw.WriteText(text); 77 scw.WriteText(text);
78 } 78 }
79 79
80 void RenderViewContextMenuController::WriteURLToClipboard(const GURL& url) { 80 void RenderViewContextMenuController::WriteURLToClipboard(const GURL& url) {
81 if (url.SchemeIs("mailto")) 81 if (url.SchemeIs(chrome::kMailToScheme))
82 WriteTextToClipboard(UTF8ToWide(url.path())); 82 WriteTextToClipboard(UTF8ToWide(url.path()));
83 else 83 else
84 WriteTextToClipboard(UTF8ToWide(url.spec())); 84 WriteTextToClipboard(UTF8ToWide(url.spec()));
85 } 85 }
86 86
87 /////////////////////////////////////////////////////////////////////////////// 87 ///////////////////////////////////////////////////////////////////////////////
88 // Menu::Delegate methods 88 // Menu::Delegate methods
89 89
90 std::wstring RenderViewContextMenuController::GetLabel(int id) const { 90 std::wstring RenderViewContextMenuController::GetLabel(int id) const {
91 switch (id) { 91 switch (id) {
92 case IDS_CONTENT_CONTEXT_SEARCHWEBFOR: { 92 case IDS_CONTENT_CONTEXT_SEARCHWEBFOR: {
93 const TemplateURL* const default_provider = source_web_contents_-> 93 const TemplateURL* const default_provider = source_web_contents_->
94 profile()->GetTemplateURLModel()->GetDefaultSearchProvider(); 94 profile()->GetTemplateURLModel()->GetDefaultSearchProvider();
95 DCHECK(default_provider); // The context menu should not contain this 95 DCHECK(default_provider); // The context menu should not contain this
96 // item when there is no provider. 96 // item when there is no provider.
97 return l10n_util::GetStringF(id, default_provider->short_name(), 97 return l10n_util::GetStringF(id, default_provider->short_name(),
98 l10n_util::TruncateString(params_.selection_text, 50)); 98 l10n_util::TruncateString(params_.selection_text, 50));
99 } 99 }
100 100
101 case IDS_CONTENT_CONTEXT_COPYLINKLOCATION: 101 case IDS_CONTENT_CONTEXT_COPYLINKLOCATION:
102 if (params_.link_url.SchemeIs("mailto")) 102 if (params_.link_url.SchemeIs(chrome::kMailToScheme))
103 return l10n_util::GetString(IDS_CONTENT_CONTEXT_COPYEMAILADDRESS); 103 return l10n_util::GetString(IDS_CONTENT_CONTEXT_COPYEMAILADDRESS);
104 104
105 default: 105 default:
106 return l10n_util::GetString(id); 106 return l10n_util::GetString(id);
107 } 107 }
108 } 108 }
109 109
110 bool RenderViewContextMenuController::IsCommandEnabled(int id) const { 110 bool RenderViewContextMenuController::IsCommandEnabled(int id) const {
111 // Allow Spell Check language items on sub menu for text area context menu. 111 // Allow Spell Check language items on sub menu for text area context menu.
112 if ((id >= IDC_SPELLCHECK_LANGUAGES_FIRST) && 112 if ((id >= IDC_SPELLCHECK_LANGUAGES_FIRST) &&
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 // Don't enable the web inspector if JavaScript is disabled 537 // Don't enable the web inspector if JavaScript is disabled
538 if (id == IDS_CONTENT_CONTEXT_INSPECTELEMENT) { 538 if (id == IDS_CONTENT_CONTEXT_INSPECTELEMENT) {
539 PrefService* prefs = source_web_contents_->profile()->GetPrefs(); 539 PrefService* prefs = source_web_contents_->profile()->GetPrefs();
540 if (!prefs->GetBoolean(prefs::kWebKitJavascriptEnabled) || 540 if (!prefs->GetBoolean(prefs::kWebKitJavascriptEnabled) ||
541 command_line.HasSwitch(switches::kDisableJavaScript)) 541 command_line.HasSwitch(switches::kDisableJavaScript))
542 return false; 542 return false;
543 } 543 }
544 544
545 return true; 545 return true;
546 } 546 }
OLDNEW
« no previous file with comments | « chrome/browser/ssl/ssl_policy.cc ('k') | chrome/browser/tab_contents/site_instance.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698