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

Side by Side Diff: content/shell/shell_web_contents_view_delegate_win.cc

Issue 10939010: Cleanup: avoid foo ? true : false, part 1. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: rebase Created 8 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
« no previous file with comments | « content/public/test/mock_render_thread.h ('k') | gpu/demos/framework/pepper.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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/shell/shell_web_contents_view_delegate.h" 5 #include "content/shell/shell_web_contents_view_delegate.h"
6 6
7 #include "content/public/browser/devtools_http_handler.h" 7 #include "content/public/browser/devtools_http_handler.h"
8 #include "content/public/browser/render_process_host.h" 8 #include "content/public/browser/render_process_host.h"
9 #include "content/public/browser/render_view_host.h" 9 #include "content/public/browser/render_view_host.h"
10 #include "content/public/browser/render_widget_host_view.h" 10 #include "content/public/browser/render_widget_host_view.h"
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 MakeContextMenuItem(sub_menu, 110 MakeContextMenuItem(sub_menu,
111 index++, 111 index++,
112 L"Open in New Window", 112 L"Open in New Window",
113 ShellContextMenuItemOpenLinkId, 113 ShellContextMenuItemOpenLinkId,
114 true); 114 true);
115 AppendMenu(sub_menu, MF_SEPARATOR, 0, NULL); 115 AppendMenu(sub_menu, MF_SEPARATOR, 0, NULL);
116 index++; 116 index++;
117 } 117 }
118 118
119 if (params_.is_editable) { 119 if (params_.is_editable) {
120 bool cut_enabled = 120 bool cut_enabled = ((params_.edit_flags & WebContextMenuData::CanCut) != 0);
121 (params_.edit_flags & WebContextMenuData::CanCut) ? true : false;
122 MakeContextMenuItem(sub_menu, 121 MakeContextMenuItem(sub_menu,
123 index++, 122 index++,
124 L"Cut", 123 L"Cut",
125 ShellContextMenuItemCutId, 124 ShellContextMenuItemCutId,
126 cut_enabled); 125 cut_enabled);
127 126
128 bool copy_enabled = 127 bool copy_enabled =
129 (params_.edit_flags & WebContextMenuData::CanCopy) ? true : false; 128 ((params_.edit_flags & WebContextMenuData::CanCopy) != 0);
130 MakeContextMenuItem(sub_menu, 129 MakeContextMenuItem(sub_menu,
131 index++, 130 index++,
132 L"Copy", 131 L"Copy",
133 ShellContextMenuItemCopyId, 132 ShellContextMenuItemCopyId,
134 copy_enabled); 133 copy_enabled);
135 134
136 bool paste_enabled = 135 bool paste_enabled =
137 (params_.edit_flags & WebContextMenuData::CanPaste) ? true : false; 136 ((params_.edit_flags & WebContextMenuData::CanPaste) != 0);
138 MakeContextMenuItem(sub_menu, 137 MakeContextMenuItem(sub_menu,
139 index++, 138 index++,
140 L"Paste", 139 L"Paste",
141 ShellContextMenuItemPasteId, 140 ShellContextMenuItemPasteId,
142 paste_enabled); 141 paste_enabled);
143 bool delete_enabled = 142 bool delete_enabled =
144 (params_.edit_flags & WebContextMenuData::CanDelete) ? true : false; 143 ((params_.edit_flags & WebContextMenuData::CanDelete) != 0);
145 MakeContextMenuItem(sub_menu, 144 MakeContextMenuItem(sub_menu,
146 index++, 145 index++,
147 L"Delete", 146 L"Delete",
148 ShellContextMenuItemDeleteId, 147 ShellContextMenuItemDeleteId,
149 delete_enabled); 148 delete_enabled);
150 149
151 AppendMenu(sub_menu, MF_SEPARATOR, 0, NULL); 150 AppendMenu(sub_menu, MF_SEPARATOR, 0, NULL);
152 index++; 151 index++;
153 } else if (has_selection) { 152 } else if (has_selection) {
154 MakeContextMenuItem(sub_menu, 153 MakeContextMenuItem(sub_menu,
155 index++, 154 index++,
156 L"Copy", 155 L"Copy",
157 ShellContextMenuItemCopyId, 156 ShellContextMenuItemCopyId,
158 true); 157 true);
159 158
160 AppendMenu(sub_menu, MF_SEPARATOR, 0, NULL); 159 AppendMenu(sub_menu, MF_SEPARATOR, 0, NULL);
161 index++; 160 index++;
162 } 161 }
163 162
164 MakeContextMenuItem(sub_menu, 163 MakeContextMenuItem(sub_menu,
165 index++, 164 index++,
166 L"Inspect...", 165 L"Inspect...",
167 ShellContextMenuItemInspectId, 166 ShellContextMenuItemInspectId,
168 true); 167 true);
169 #if defined(USE_AURA) 168 #if defined(USE_AURA)
170 NOTIMPLEMENTED(); 169 NOTIMPLEMENTED();
171 #else 170 #else
172 gfx::Point screen_point(params.x, params.y); 171 gfx::Point screen_point(params.x, params.y);
173 POINT point = screen_point.ToPOINT();; 172 POINT point = screen_point.ToPOINT();
174 ClientToScreen(web_contents_->GetView()->GetNativeView(), &point); 173 ClientToScreen(web_contents_->GetView()->GetNativeView(), &point);
175 174
176 int selection = 175 int selection =
177 TrackPopupMenu(sub_menu, 176 TrackPopupMenu(sub_menu,
178 TPM_LEFTALIGN | TPM_RIGHTBUTTON | TPM_RETURNCMD, 177 TPM_LEFTALIGN | TPM_RIGHTBUTTON | TPM_RETURNCMD,
179 point.x, point.y, 178 point.x, point.y,
180 0, 179 0,
181 web_contents_->GetView()->GetContentNativeView(), 180 web_contents_->GetView()->GetContentNativeView(),
182 NULL); 181 NULL);
183 182
184 MenuItemSelected(selection); 183 MenuItemSelected(selection);
185 #endif 184 #endif
186 DestroyMenu(menu); 185 DestroyMenu(menu);
187 } 186 }
188 187
189 void ShellWebContentsViewDelegate::MenuItemSelected(int selection) { 188 void ShellWebContentsViewDelegate::MenuItemSelected(int selection) {
190 switch(selection) { 189 switch (selection) {
191 case ShellContextMenuItemCutId: 190 case ShellContextMenuItemCutId:
192 web_contents_->GetRenderViewHost()->Cut(); 191 web_contents_->GetRenderViewHost()->Cut();
193 break; 192 break;
194 case ShellContextMenuItemCopyId: 193 case ShellContextMenuItemCopyId:
195 web_contents_->GetRenderViewHost()->Copy(); 194 web_contents_->GetRenderViewHost()->Copy();
196 break; 195 break;
197 case ShellContextMenuItemPasteId: 196 case ShellContextMenuItemPasteId:
198 web_contents_->GetRenderViewHost()->Paste(); 197 web_contents_->GetRenderViewHost()->Paste();
199 break; 198 break;
200 case ShellContextMenuItemDeleteId: 199 case ShellContextMenuItemDeleteId:
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 260
262 void ShellWebContentsViewDelegate::TakeFocus(bool reverse) { 261 void ShellWebContentsViewDelegate::TakeFocus(bool reverse) {
263 NOTIMPLEMENTED(); 262 NOTIMPLEMENTED();
264 } 263 }
265 264
266 void ShellWebContentsViewDelegate::SizeChanged(const gfx::Size& size) { 265 void ShellWebContentsViewDelegate::SizeChanged(const gfx::Size& size) {
267 NOTIMPLEMENTED(); 266 NOTIMPLEMENTED();
268 } 267 }
269 268
270 } // namespace content 269 } // namespace content
OLDNEW
« no previous file with comments | « content/public/test/mock_render_thread.h ('k') | gpu/demos/framework/pepper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698