| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <algorithm> | 5 #include <algorithm> |
| 6 #include <set> | 6 #include <set> |
| 7 #include <utility> |
| 7 | 8 |
| 8 #include "chrome/browser/tab_contents/render_view_context_menu.h" | 9 #include "chrome/browser/tab_contents/render_view_context_menu.h" |
| 9 | 10 |
| 10 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 11 #include "base/logging.h" | 12 #include "base/logging.h" |
| 12 #include "base/metrics/histogram.h" | 13 #include "base/metrics/histogram.h" |
| 13 #include "base/stl_util.h" | 14 #include "base/stl_util.h" |
| 14 #include "base/string_util.h" | 15 #include "base/string_util.h" |
| 15 #include "base/time.h" | 16 #include "base/time.h" |
| 16 #include "base/utf_string_conversions.h" | 17 #include "base/utf_string_conversions.h" |
| (...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 391 RecursivelyAppendExtensionItems(submenu_items, can_cross_incognito, submenu, | 392 RecursivelyAppendExtensionItems(submenu_items, can_cross_incognito, submenu, |
| 392 index); | 393 index); |
| 393 } | 394 } |
| 394 SetExtensionIcon(extension_id); | 395 SetExtensionIcon(extension_id); |
| 395 } | 396 } |
| 396 | 397 |
| 397 void RenderViewContextMenu::RecursivelyAppendExtensionItems( | 398 void RenderViewContextMenu::RecursivelyAppendExtensionItems( |
| 398 const ExtensionMenuItem::List& items, | 399 const ExtensionMenuItem::List& items, |
| 399 bool can_cross_incognito, | 400 bool can_cross_incognito, |
| 400 ui::SimpleMenuModel* menu_model, | 401 ui::SimpleMenuModel* menu_model, |
| 401 int *index) { | 402 int* index) { |
| 402 string16 selection_text = PrintableSelectionText(); | 403 string16 selection_text = PrintableSelectionText(); |
| 403 ExtensionMenuItem::Type last_type = ExtensionMenuItem::NORMAL; | 404 ExtensionMenuItem::Type last_type = ExtensionMenuItem::NORMAL; |
| 404 int radio_group_id = 1; | 405 int radio_group_id = 1; |
| 405 | 406 |
| 406 for (ExtensionMenuItem::List::const_iterator i = items.begin(); | 407 for (ExtensionMenuItem::List::const_iterator i = items.begin(); |
| 407 i != items.end(); ++i) { | 408 i != items.end(); ++i) { |
| 408 ExtensionMenuItem* item = *i; | 409 ExtensionMenuItem* item = *i; |
| 409 | 410 |
| 410 // If last item was of type radio but the current one isn't, auto-insert | 411 // If last item was of type radio but the current one isn't, auto-insert |
| 411 // a separator. The converse case is handled below. | 412 // a separator. The converse case is handled below. |
| (...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 792 IDS_CONTENT_CONTEXT_COPY); | 793 IDS_CONTENT_CONTEXT_COPY); |
| 793 } | 794 } |
| 794 | 795 |
| 795 void RenderViewContextMenu::AppendSearchProvider() { | 796 void RenderViewContextMenu::AppendSearchProvider() { |
| 796 DCHECK(profile_); | 797 DCHECK(profile_); |
| 797 | 798 |
| 798 TrimWhitespace(params_.selection_text, TRIM_ALL, ¶ms_.selection_text); | 799 TrimWhitespace(params_.selection_text, TRIM_ALL, ¶ms_.selection_text); |
| 799 if (params_.selection_text.empty()) | 800 if (params_.selection_text.empty()) |
| 800 return; | 801 return; |
| 801 | 802 |
| 803 ReplaceChars(params_.selection_text, AutocompleteMatch::kInvalidChars, |
| 804 ASCIIToUTF16(" "), ¶ms_.selection_text); |
| 805 |
| 802 AutocompleteMatch match; | 806 AutocompleteMatch match; |
| 803 profile_->GetAutocompleteClassifier()->Classify( | 807 profile_->GetAutocompleteClassifier()->Classify( |
| 804 params_.selection_text, string16(), false, false, &match, NULL); | 808 params_.selection_text, string16(), false, false, &match, NULL); |
| 805 selection_navigation_url_ = match.destination_url; | 809 selection_navigation_url_ = match.destination_url; |
| 806 if (!selection_navigation_url_.is_valid()) | 810 if (!selection_navigation_url_.is_valid()) |
| 807 return; | 811 return; |
| 808 | 812 |
| 809 string16 printable_selection_text = PrintableSelectionText(); | 813 string16 printable_selection_text = PrintableSelectionText(); |
| 810 // Escape "&" as "&&". | 814 // Escape "&" as "&&". |
| 811 for (size_t i = printable_selection_text.find('&'); i != string16::npos; | 815 for (size_t i = printable_selection_text.find('&'); i != string16::npos; |
| (...skipping 1049 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1861 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages), | 1865 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages), |
| 1862 g_browser_process->clipboard()); | 1866 g_browser_process->clipboard()); |
| 1863 } | 1867 } |
| 1864 | 1868 |
| 1865 void RenderViewContextMenu::MediaPlayerActionAt( | 1869 void RenderViewContextMenu::MediaPlayerActionAt( |
| 1866 const gfx::Point& location, | 1870 const gfx::Point& location, |
| 1867 const WebMediaPlayerAction& action) { | 1871 const WebMediaPlayerAction& action) { |
| 1868 source_tab_contents_->render_view_host()-> | 1872 source_tab_contents_->render_view_host()-> |
| 1869 ExecuteMediaPlayerActionAtLocation(location, action); | 1873 ExecuteMediaPlayerActionAtLocation(location, action); |
| 1870 } | 1874 } |
| OLD | NEW |