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 | 7 |
8 #include "chrome/browser/tab_contents/render_view_context_menu.h" | 8 #include "chrome/browser/tab_contents/render_view_context_menu.h" |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 int menu_id = IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST + (*index)++; | 355 int menu_id = IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST + (*index)++; |
356 if (menu_id >= IDC_EXTENSIONS_CONTEXT_CUSTOM_LAST) | 356 if (menu_id >= IDC_EXTENSIONS_CONTEXT_CUSTOM_LAST) |
357 return; | 357 return; |
358 extension_item_map_[menu_id] = item->id(); | 358 extension_item_map_[menu_id] = item->id(); |
359 string16 title = item->TitleWithReplacement(selection_text, | 359 string16 title = item->TitleWithReplacement(selection_text, |
360 kMaxExtensionItemTitleLength); | 360 kMaxExtensionItemTitleLength); |
361 if (item->type() == ExtensionMenuItem::NORMAL) { | 361 if (item->type() == ExtensionMenuItem::NORMAL) { |
362 ExtensionMenuItem::List children = | 362 ExtensionMenuItem::List children = |
363 GetRelevantExtensionItems(item->children(), params_, | 363 GetRelevantExtensionItems(item->children(), params_, |
364 profile_, can_cross_incognito); | 364 profile_, can_cross_incognito); |
365 if (children.size() == 0) { | 365 if (children.empty()) { |
366 menu_model->AddItem(menu_id, title); | 366 menu_model->AddItem(menu_id, title); |
367 } else { | 367 } else { |
368 ui::SimpleMenuModel* submenu = new ui::SimpleMenuModel(this); | 368 ui::SimpleMenuModel* submenu = new ui::SimpleMenuModel(this); |
369 extension_menu_models_.push_back(submenu); | 369 extension_menu_models_.push_back(submenu); |
370 menu_model->AddSubMenu(menu_id, title, submenu); | 370 menu_model->AddSubMenu(menu_id, title, submenu); |
371 RecursivelyAppendExtensionItems(children, can_cross_incognito, | 371 RecursivelyAppendExtensionItems(children, can_cross_incognito, |
372 submenu, index); | 372 submenu, index); |
373 } | 373 } |
374 } else if (item->type() == ExtensionMenuItem::CHECKBOX) { | 374 } else if (item->type() == ExtensionMenuItem::CHECKBOX) { |
375 menu_model->AddCheckItem(menu_id, title); | 375 menu_model->AddCheckItem(menu_id, title); |
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
713 IDC_SPELLCHECK_SUGGESTION_0 + i <= IDC_SPELLCHECK_SUGGESTION_LAST; | 713 IDC_SPELLCHECK_SUGGESTION_0 + i <= IDC_SPELLCHECK_SUGGESTION_LAST; |
714 ++i) { | 714 ++i) { |
715 menu_model_.AddItem(IDC_SPELLCHECK_SUGGESTION_0 + static_cast<int>(i), | 715 menu_model_.AddItem(IDC_SPELLCHECK_SUGGESTION_0 + static_cast<int>(i), |
716 params_.dictionary_suggestions[i]); | 716 params_.dictionary_suggestions[i]); |
717 } | 717 } |
718 if (params_.dictionary_suggestions.size() > 0) | 718 if (params_.dictionary_suggestions.size() > 0) |
719 menu_model_.AddSeparator(); | 719 menu_model_.AddSeparator(); |
720 | 720 |
721 // If word is misspelled, give option for "Add to dictionary" | 721 // If word is misspelled, give option for "Add to dictionary" |
722 if (!params_.misspelled_word.empty()) { | 722 if (!params_.misspelled_word.empty()) { |
723 if (params_.dictionary_suggestions.size() == 0) { | 723 if (params_.dictionary_suggestions.empty()) { |
724 menu_model_.AddItem(0, | 724 menu_model_.AddItem(0, |
725 l10n_util::GetStringUTF16( | 725 l10n_util::GetStringUTF16( |
726 IDS_CONTENT_CONTEXT_NO_SPELLING_SUGGESTIONS)); | 726 IDS_CONTENT_CONTEXT_NO_SPELLING_SUGGESTIONS)); |
727 } | 727 } |
728 menu_model_.AddItemWithStringId(IDC_SPELLCHECK_ADD_TO_DICTIONARY, | 728 menu_model_.AddItemWithStringId(IDC_SPELLCHECK_ADD_TO_DICTIONARY, |
729 IDS_CONTENT_CONTEXT_ADD_TO_DICTIONARY); | 729 IDS_CONTENT_CONTEXT_ADD_TO_DICTIONARY); |
730 menu_model_.AddSeparator(); | 730 menu_model_.AddSeparator(); |
731 } | 731 } |
732 | 732 |
733 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_UNDO, | 733 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_UNDO, |
(...skipping 798 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1532 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages), | 1532 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages), |
1533 g_browser_process->clipboard()); | 1533 g_browser_process->clipboard()); |
1534 } | 1534 } |
1535 | 1535 |
1536 void RenderViewContextMenu::MediaPlayerActionAt( | 1536 void RenderViewContextMenu::MediaPlayerActionAt( |
1537 const gfx::Point& location, | 1537 const gfx::Point& location, |
1538 const WebMediaPlayerAction& action) { | 1538 const WebMediaPlayerAction& action) { |
1539 source_tab_contents_->render_view_host()->MediaPlayerActionAt( | 1539 source_tab_contents_->render_view_host()->MediaPlayerActionAt( |
1540 location, action); | 1540 location, action); |
1541 } | 1541 } |
OLD | NEW |