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

Side by Side Diff: chrome/browser/ui/views/tabs/tab_strip.cc

Issue 2421423002: Sanitize middle-click paste on New Tab button (Closed)
Patch Set: Created 4 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
« no previous file with comments | « no previous file | no next file » | 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 "chrome/browser/ui/views/tabs/tab_strip.h" 5 #include "chrome/browser/ui/views/tabs/tab_strip.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <iterator> 10 #include <iterator>
(...skipping 16 matching lines...) Expand all
27 #include "chrome/browser/ui/views/tabs/stacked_tab_strip_layout.h" 27 #include "chrome/browser/ui/views/tabs/stacked_tab_strip_layout.h"
28 #include "chrome/browser/ui/views/tabs/tab.h" 28 #include "chrome/browser/ui/views/tabs/tab.h"
29 #include "chrome/browser/ui/views/tabs/tab_drag_controller.h" 29 #include "chrome/browser/ui/views/tabs/tab_drag_controller.h"
30 #include "chrome/browser/ui/views/tabs/tab_strip_controller.h" 30 #include "chrome/browser/ui/views/tabs/tab_strip_controller.h"
31 #include "chrome/browser/ui/views/tabs/tab_strip_layout.h" 31 #include "chrome/browser/ui/views/tabs/tab_strip_layout.h"
32 #include "chrome/browser/ui/views/tabs/tab_strip_observer.h" 32 #include "chrome/browser/ui/views/tabs/tab_strip_observer.h"
33 #include "chrome/browser/ui/views/touch_uma/touch_uma.h" 33 #include "chrome/browser/ui/views/touch_uma/touch_uma.h"
34 #include "chrome/common/chrome_switches.h" 34 #include "chrome/common/chrome_switches.h"
35 #include "chrome/grit/generated_resources.h" 35 #include "chrome/grit/generated_resources.h"
36 #include "chrome/grit/theme_resources.h" 36 #include "chrome/grit/theme_resources.h"
37 #include "components/omnibox/browser/omnibox_view.h"
37 #include "content/public/browser/user_metrics.h" 38 #include "content/public/browser/user_metrics.h"
38 #include "content/public/common/content_switches.h" 39 #include "content/public/common/content_switches.h"
39 #include "third_party/skia/include/core/SkColorFilter.h" 40 #include "third_party/skia/include/core/SkColorFilter.h"
40 #include "third_party/skia/include/effects/SkBlurMaskFilter.h" 41 #include "third_party/skia/include/effects/SkBlurMaskFilter.h"
41 #include "third_party/skia/include/effects/SkLayerDrawLooper.h" 42 #include "third_party/skia/include/effects/SkLayerDrawLooper.h"
42 #include "third_party/skia/include/pathops/SkPathOps.h" 43 #include "third_party/skia/include/pathops/SkPathOps.h"
43 #include "ui/accessibility/ax_view_state.h" 44 #include "ui/accessibility/ax_view_state.h"
44 #include "ui/base/default_theme_provider.h" 45 #include "ui/base/default_theme_provider.h"
45 #include "ui/base/dragdrop/drag_drop_types.h" 46 #include "ui/base/dragdrop/drag_drop_types.h"
46 #include "ui/base/l10n/l10n_util.h" 47 #include "ui/base/l10n/l10n_util.h"
(...skipping 2614 matching lines...) Expand 10 before | Expand all | Expand 10 after
2661 TabStripModel::NEW_TAB_ENUM_COUNT); 2662 TabStripModel::NEW_TAB_ENUM_COUNT);
2662 if (event.IsMouseEvent()) { 2663 if (event.IsMouseEvent()) {
2663 const ui::MouseEvent& mouse = static_cast<const ui::MouseEvent&>(event); 2664 const ui::MouseEvent& mouse = static_cast<const ui::MouseEvent&>(event);
2664 if (mouse.IsOnlyMiddleMouseButton()) { 2665 if (mouse.IsOnlyMiddleMouseButton()) {
2665 if (ui::Clipboard::IsSupportedClipboardType( 2666 if (ui::Clipboard::IsSupportedClipboardType(
2666 ui::CLIPBOARD_TYPE_SELECTION)) { 2667 ui::CLIPBOARD_TYPE_SELECTION)) {
2667 ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread(); 2668 ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread();
2668 CHECK(clipboard); 2669 CHECK(clipboard);
2669 base::string16 clipboard_text; 2670 base::string16 clipboard_text;
2670 clipboard->ReadText(ui::CLIPBOARD_TYPE_SELECTION, &clipboard_text); 2671 clipboard->ReadText(ui::CLIPBOARD_TYPE_SELECTION, &clipboard_text);
2672
2673 // Remove any JavaScript: protocol specifiers
2674 clipboard_text = OmniboxView::SanitizeTextForPaste(clipboard_text);
2671 if (!clipboard_text.empty()) 2675 if (!clipboard_text.empty())
2672 controller_->CreateNewTabWithLocation(clipboard_text); 2676 controller_->CreateNewTabWithLocation(clipboard_text);
2673 } 2677 }
2674 return; 2678 return;
2675 } 2679 }
2676 } 2680 }
2677 2681
2678 controller_->CreateNewTab(); 2682 controller_->CreateNewTab();
2679 if (event.type() == ui::ET_GESTURE_TAP) 2683 if (event.type() == ui::ET_GESTURE_TAP)
2680 TouchUMA::RecordGestureAction(TouchUMA::GESTURE_NEWTAB_TAP); 2684 TouchUMA::RecordGestureAction(TouchUMA::GESTURE_NEWTAB_TAP);
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
2802 ConvertPointToViewAndGetEventHandler(this, newtab_button_, point); 2806 ConvertPointToViewAndGetEventHandler(this, newtab_button_, point);
2803 if (view) 2807 if (view)
2804 return view; 2808 return view;
2805 } 2809 }
2806 Tab* tab = FindTabForEvent(point); 2810 Tab* tab = FindTabForEvent(point);
2807 if (tab) 2811 if (tab)
2808 return ConvertPointToViewAndGetEventHandler(this, tab, point); 2812 return ConvertPointToViewAndGetEventHandler(this, tab, point);
2809 } 2813 }
2810 return this; 2814 return this;
2811 } 2815 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698