| OLD | NEW |
| 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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/tab_contents/render_view_context_menu.h" | 5 #include "chrome/browser/tab_contents/render_view_context_menu.h" |
| 6 | 6 |
| 7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "base/clipboard.h" | 8 #include "base/clipboard.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 URLRequest::IsHandledURL(params_.link_url); | 300 URLRequest::IsHandledURL(params_.link_url); |
| 301 | 301 |
| 302 case IDS_CONTENT_CONTEXT_SAVEIMAGEAS: | 302 case IDS_CONTENT_CONTEXT_SAVEIMAGEAS: |
| 303 return params_.src_url.is_valid() && | 303 return params_.src_url.is_valid() && |
| 304 URLRequest::IsHandledURL(params_.src_url); | 304 URLRequest::IsHandledURL(params_.src_url); |
| 305 | 305 |
| 306 case IDS_CONTENT_CONTEXT_OPENIMAGENEWTAB: | 306 case IDS_CONTENT_CONTEXT_OPENIMAGENEWTAB: |
| 307 // The images shown in the most visited thumbnails do not currently open | 307 // The images shown in the most visited thumbnails do not currently open |
| 308 // in a new tab as they should. Disabling this context menu option for | 308 // in a new tab as they should. Disabling this context menu option for |
| 309 // now, as a quick hack, before we resolve this issue (Issue = 2608). | 309 // now, as a quick hack, before we resolve this issue (Issue = 2608). |
| 310 // TODO (sidchat): Enable this option once this issue is resolved. | 310 // TODO(sidchat): Enable this option once this issue is resolved. |
| 311 if (params_.src_url.scheme() == chrome::kChromeUIScheme) | 311 if (params_.src_url.scheme() == chrome::kChromeUIScheme) |
| 312 return false; | 312 return false; |
| 313 return true; | 313 return true; |
| 314 | 314 |
| 315 case IDS_CONTENT_CONTEXT_FULLSCREEN: | 315 case IDS_CONTENT_CONTEXT_FULLSCREEN: |
| 316 // TODO(ajwong): Enable fullscreen after we actually implement this. | 316 // TODO(ajwong): Enable fullscreen after we actually implement this. |
| 317 return false; | 317 return false; |
| 318 | 318 |
| 319 // Media control commands should all be disabled if the player is in an | 319 // Media control commands should all be disabled if the player is in an |
| 320 // error state. | 320 // error state. |
| (...skipping 24 matching lines...) Expand all Loading... |
| 345 case IDS_CONTENT_CONTEXT_SAVEVIDEOAS: | 345 case IDS_CONTENT_CONTEXT_SAVEVIDEOAS: |
| 346 return (params_.media_params.player_state & | 346 return (params_.media_params.player_state & |
| 347 ContextMenuMediaParams::CAN_SAVE) && | 347 ContextMenuMediaParams::CAN_SAVE) && |
| 348 params_.src_url.is_valid() && | 348 params_.src_url.is_valid() && |
| 349 URLRequest::IsHandledURL(params_.src_url); | 349 URLRequest::IsHandledURL(params_.src_url); |
| 350 | 350 |
| 351 case IDS_CONTENT_CONTEXT_OPENAUDIONEWTAB: | 351 case IDS_CONTENT_CONTEXT_OPENAUDIONEWTAB: |
| 352 case IDS_CONTENT_CONTEXT_OPENVIDEONEWTAB: | 352 case IDS_CONTENT_CONTEXT_OPENVIDEONEWTAB: |
| 353 return true; | 353 return true; |
| 354 | 354 |
| 355 case IDS_CONTENT_CONTEXT_SAVEPAGEAS: | 355 case IDS_CONTENT_CONTEXT_SAVEPAGEAS: { |
| 356 return SavePackage::IsSavableURL(source_tab_contents_->GetURL()); | 356 // Instead of using GetURL here, we use url() (which is the "real" url of |
| 357 // the page) from the NavigationEntry because its reflects their origin |
| 358 // rather than the display one (returned by GetURL) which may be |
| 359 // different (like having "view-source:" on the front). |
| 360 NavigationEntry* active_entry = |
| 361 source_tab_contents_->controller().GetActiveEntry(); |
| 362 GURL savable_url = (active_entry) ? active_entry->url() : |
| 363 GURL::EmptyGURL(); |
| 364 return SavePackage::IsSavableURL(savable_url); |
| 365 } |
| 357 | 366 |
| 358 case IDS_CONTENT_CONTEXT_OPENFRAMENEWTAB: | 367 case IDS_CONTENT_CONTEXT_OPENFRAMENEWTAB: |
| 359 case IDS_CONTENT_CONTEXT_OPENFRAMENEWWINDOW: | 368 case IDS_CONTENT_CONTEXT_OPENFRAMENEWWINDOW: |
| 360 return params_.frame_url.is_valid(); | 369 return params_.frame_url.is_valid(); |
| 361 | 370 |
| 362 case IDS_CONTENT_CONTEXT_UNDO: | 371 case IDS_CONTENT_CONTEXT_UNDO: |
| 363 return !!(params_.edit_flags & ContextNodeType::CAN_UNDO); | 372 return !!(params_.edit_flags & ContextNodeType::CAN_UNDO); |
| 364 | 373 |
| 365 case IDS_CONTENT_CONTEXT_REDO: | 374 case IDS_CONTENT_CONTEXT_REDO: |
| 366 return !!(params_.edit_flags & ContextNodeType::CAN_REDO); | 375 return !!(params_.edit_flags & ContextNodeType::CAN_REDO); |
| (...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 782 WriteTextToClipboard(UTF8ToUTF16(utf8_text)); | 791 WriteTextToClipboard(UTF8ToUTF16(utf8_text)); |
| 783 DidWriteURLToClipboard(utf8_text); | 792 DidWriteURLToClipboard(utf8_text); |
| 784 } | 793 } |
| 785 | 794 |
| 786 void RenderViewContextMenu::MediaPlayerActionAt( | 795 void RenderViewContextMenu::MediaPlayerActionAt( |
| 787 int x, | 796 int x, |
| 788 int y, | 797 int y, |
| 789 const MediaPlayerAction& action) { | 798 const MediaPlayerAction& action) { |
| 790 source_tab_contents_->render_view_host()->MediaPlayerActionAt(x, y, action); | 799 source_tab_contents_->render_view_host()->MediaPlayerActionAt(x, y, action); |
| 791 } | 800 } |
| OLD | NEW |