Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/tab_contents/render_view_context_menu.h" | 5 #include "chrome/browser/tab_contents/render_view_context_menu.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 382 if (sorted_ids.empty()) | 382 if (sorted_ids.empty()) |
| 383 return; | 383 return; |
| 384 | 384 |
| 385 int index = 0; | 385 int index = 0; |
| 386 base::TimeTicks begin = base::TimeTicks::Now(); | 386 base::TimeTicks begin = base::TimeTicks::Now(); |
| 387 std::vector<std::pair<std::string, std::string> >::const_iterator i; | 387 std::vector<std::pair<std::string, std::string> >::const_iterator i; |
| 388 for (i = sorted_ids.begin(); | 388 for (i = sorted_ids.begin(); |
| 389 i != sorted_ids.end(); ++i) { | 389 i != sorted_ids.end(); ++i) { |
| 390 string16 printable_selection_text = PrintableSelectionText(); | 390 string16 printable_selection_text = PrintableSelectionText(); |
| 391 // Escape "&" as "&&". | 391 // Escape "&" as "&&". |
| 392 for (size_t position = printable_selection_text.find('&'); | 392 ReplaceChars(printable_selection_text, ASCIIToUTF16("&").c_str(), |
|
Yoyo Zhou
2013/02/19 18:34:01
Try L"&" and L"&&" here.
Joe Thomas
2013/02/19 19:17:50
This works only on platforms like windows where wc
Joe Thomas
2013/02/19 21:32:11
Looks like my above explanation is not fully clear
Yoyo Zhou
2013/02/19 21:57:02
Bummer. I guess C++11 initializer lists would be r
Joe Thomas
2013/02/19 22:39:05
That can be done. Patch updated.
| |
| 393 position != string16::npos; | 393 ASCIIToUTF16("&&"), &printable_selection_text); |
| 394 position = printable_selection_text.find('&', position + 2)) | |
| 395 printable_selection_text.insert(position, 1, '&'); | |
| 396 | 394 |
| 397 extension_items_.AppendExtensionItems(i->second, printable_selection_text, | 395 extension_items_.AppendExtensionItems(i->second, printable_selection_text, |
| 398 &index); | 396 &index); |
| 399 } | 397 } |
| 400 UMA_HISTOGRAM_TIMES("Extensions.ContextMenus_BuildTime", | 398 UMA_HISTOGRAM_TIMES("Extensions.ContextMenus_BuildTime", |
| 401 base::TimeTicks::Now() - begin); | 399 base::TimeTicks::Now() - begin); |
| 402 UMA_HISTOGRAM_COUNTS("Extensions.ContextMenus_ItemCount", index); | 400 UMA_HISTOGRAM_COUNTS("Extensions.ContextMenus_ItemCount", index); |
| 403 } | 401 } |
| 404 | 402 |
| 405 void RenderViewContextMenu::InitMenu() { | 403 void RenderViewContextMenu::InitMenu() { |
| (...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 823 | 821 |
| 824 AutocompleteMatch match; | 822 AutocompleteMatch match; |
| 825 AutocompleteClassifierFactory::GetForProfile(profile_)->Classify( | 823 AutocompleteClassifierFactory::GetForProfile(profile_)->Classify( |
| 826 params_.selection_text, string16(), false, false, &match, NULL); | 824 params_.selection_text, string16(), false, false, &match, NULL); |
| 827 selection_navigation_url_ = match.destination_url; | 825 selection_navigation_url_ = match.destination_url; |
| 828 if (!selection_navigation_url_.is_valid()) | 826 if (!selection_navigation_url_.is_valid()) |
| 829 return; | 827 return; |
| 830 | 828 |
| 831 string16 printable_selection_text = PrintableSelectionText(); | 829 string16 printable_selection_text = PrintableSelectionText(); |
| 832 // Escape "&" as "&&". | 830 // Escape "&" as "&&". |
| 833 for (size_t i = printable_selection_text.find('&'); i != string16::npos; | 831 ReplaceChars(printable_selection_text, ASCIIToUTF16("&").c_str(), |
| 834 i = printable_selection_text.find('&', i + 2)) | 832 ASCIIToUTF16("&&"), &printable_selection_text); |
| 835 printable_selection_text.insert(i, 1, '&'); | 833 |
| 836 | 834 |
| 837 if (AutocompleteMatch::IsSearchType(match.type)) { | 835 if (AutocompleteMatch::IsSearchType(match.type)) { |
| 838 const TemplateURL* const default_provider = | 836 const TemplateURL* const default_provider = |
| 839 TemplateURLServiceFactory::GetForProfile(profile_)-> | 837 TemplateURLServiceFactory::GetForProfile(profile_)-> |
| 840 GetDefaultSearchProvider(); | 838 GetDefaultSearchProvider(); |
| 841 if (!default_provider) | 839 if (!default_provider) |
| 842 return; | 840 return; |
| 843 menu_model_.AddItem( | 841 menu_model_.AddItem( |
| 844 IDC_CONTENT_CONTEXT_SEARCHWEBFOR, | 842 IDC_CONTENT_CONTEXT_SEARCHWEBFOR, |
| 845 l10n_util::GetStringFUTF16(IDS_CONTENT_CONTEXT_SEARCHWEBFOR, | 843 l10n_util::GetStringFUTF16(IDS_CONTENT_CONTEXT_SEARCHWEBFOR, |
| (...skipping 1026 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1872 source_web_contents_->GetRenderViewHost()-> | 1870 source_web_contents_->GetRenderViewHost()-> |
| 1873 ExecuteMediaPlayerActionAtLocation(location, action); | 1871 ExecuteMediaPlayerActionAtLocation(location, action); |
| 1874 } | 1872 } |
| 1875 | 1873 |
| 1876 void RenderViewContextMenu::PluginActionAt( | 1874 void RenderViewContextMenu::PluginActionAt( |
| 1877 const gfx::Point& location, | 1875 const gfx::Point& location, |
| 1878 const WebPluginAction& action) { | 1876 const WebPluginAction& action) { |
| 1879 source_web_contents_->GetRenderViewHost()-> | 1877 source_web_contents_->GetRenderViewHost()-> |
| 1880 ExecutePluginActionAtLocation(location, action); | 1878 ExecutePluginActionAtLocation(location, action); |
| 1881 } | 1879 } |
| OLD | NEW |