OLD | NEW |
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 "chrome/browser/render_view_context_menu_controller.h" | 5 #include "chrome/browser/render_view_context_menu_controller.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
| 9 #include "base/scoped_clipboard_writer.h" |
9 #include "base/string_util.h" | 10 #include "base/string_util.h" |
10 #include "chrome/app/chrome_dll_resource.h" | 11 #include "chrome/app/chrome_dll_resource.h" |
11 #include "chrome/common/chrome_paths.h" | 12 #include "chrome/common/chrome_paths.h" |
12 #include "chrome/common/pref_names.h" | 13 #include "chrome/common/pref_names.h" |
13 #include "chrome/common/pref_service.h" | 14 #include "chrome/common/pref_service.h" |
14 #include "chrome/browser/browser_process.h" | 15 #include "chrome/browser/browser_process.h" |
15 #include "chrome/browser/download/download_manager.h" | 16 #include "chrome/browser/download/download_manager.h" |
16 #include "chrome/browser/download/save_package.h" | 17 #include "chrome/browser/download/save_package.h" |
17 #include "chrome/browser/navigation_controller.h" | 18 #include "chrome/browser/navigation_controller.h" |
18 #include "chrome/browser/navigation_entry.h" | 19 #include "chrome/browser/navigation_entry.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 source_web_contents_->render_view_host()->InspectElementAt(x, y); | 59 source_web_contents_->render_view_host()->InspectElementAt(x, y); |
59 } | 60 } |
60 | 61 |
61 void RenderViewContextMenuController::WriteTextToClipboard( | 62 void RenderViewContextMenuController::WriteTextToClipboard( |
62 const std::wstring& text) { | 63 const std::wstring& text) { |
63 ClipboardService* clipboard = g_browser_process->clipboard_service(); | 64 ClipboardService* clipboard = g_browser_process->clipboard_service(); |
64 | 65 |
65 if (!clipboard) | 66 if (!clipboard) |
66 return; | 67 return; |
67 | 68 |
68 clipboard->Clear(); | 69 ScopedClipboardWriter scw(clipboard); |
69 clipboard->WriteText(text); | 70 scw.WriteText(text); |
70 } | 71 } |
71 | 72 |
72 void RenderViewContextMenuController::WriteURLToClipboard(const GURL& url) { | 73 void RenderViewContextMenuController::WriteURLToClipboard(const GURL& url) { |
73 if (url.SchemeIs("mailto")) | 74 if (url.SchemeIs("mailto")) |
74 WriteTextToClipboard(UTF8ToWide(url.path())); | 75 WriteTextToClipboard(UTF8ToWide(url.path())); |
75 else | 76 else |
76 WriteTextToClipboard(UTF8ToWide(url.spec())); | 77 WriteTextToClipboard(UTF8ToWide(url.spec())); |
77 } | 78 } |
78 | 79 |
79 /////////////////////////////////////////////////////////////////////////////// | 80 /////////////////////////////////////////////////////////////////////////////// |
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
444 if (id == IDS_CONTENT_CONTEXT_INSPECTELEMENT) { | 445 if (id == IDS_CONTENT_CONTEXT_INSPECTELEMENT) { |
445 PrefService* prefs = source_web_contents_->profile()->GetPrefs(); | 446 PrefService* prefs = source_web_contents_->profile()->GetPrefs(); |
446 if (!prefs->GetBoolean(prefs::kWebKitJavascriptEnabled) || | 447 if (!prefs->GetBoolean(prefs::kWebKitJavascriptEnabled) || |
447 command_line.HasSwitch(switches::kDisableJavaScript)) | 448 command_line.HasSwitch(switches::kDisableJavaScript)) |
448 return false; | 449 return false; |
449 } | 450 } |
450 | 451 |
451 return true; | 452 return true; |
452 } | 453 } |
453 | 454 |
OLD | NEW |