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

Side by Side Diff: chrome/browser/tab_contents/render_view_context_menu.cc

Issue 8985008: Don't use browser windows for platform app shell windows (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add view type, handle window closing. Created 9 years 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 | Annotate | Revision Log
OLDNEW
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 #include <utility>
8 8
9 #include "chrome/browser/tab_contents/render_view_context_menu.h" 9 #include "chrome/browser/tab_contents/render_view_context_menu.h"
10 10
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/metrics/histogram.h" 13 #include "base/metrics/histogram.h"
14 #include "base/stl_util.h" 14 #include "base/stl_util.h"
15 #include "base/string_util.h" 15 #include "base/string_util.h"
16 #include "base/time.h" 16 #include "base/time.h"
17 #include "base/utf_string_conversions.h" 17 #include "base/utf_string_conversions.h"
18 #include "chrome/app/chrome_command_ids.h" 18 #include "chrome/app/chrome_command_ids.h"
19 #include "chrome/browser/autocomplete/autocomplete_classifier.h" 19 #include "chrome/browser/autocomplete/autocomplete_classifier.h"
20 #include "chrome/browser/autocomplete/autocomplete_edit.h" 20 #include "chrome/browser/autocomplete/autocomplete_edit.h"
21 #include "chrome/browser/autocomplete/autocomplete_match.h" 21 #include "chrome/browser/autocomplete/autocomplete_match.h"
22 #include "chrome/browser/browser_process.h" 22 #include "chrome/browser/browser_process.h"
23 #include "chrome/browser/debugger/devtools_window.h" 23 #include "chrome/browser/debugger/devtools_window.h"
24 #include "chrome/browser/download/download_service.h" 24 #include "chrome/browser/download/download_service.h"
25 #include "chrome/browser/download/download_service_factory.h" 25 #include "chrome/browser/download/download_service_factory.h"
26 #include "chrome/browser/extensions/extension_event_router.h" 26 #include "chrome/browser/extensions/extension_event_router.h"
27 #include "chrome/browser/extensions/extension_host.h"
27 #include "chrome/browser/extensions/extension_service.h" 28 #include "chrome/browser/extensions/extension_service.h"
28 #include "chrome/browser/google/google_util.h" 29 #include "chrome/browser/google/google_util.h"
29 #include "chrome/browser/net/browser_url_util.h" 30 #include "chrome/browser/net/browser_url_util.h"
30 #include "chrome/browser/prefs/incognito_mode_prefs.h" 31 #include "chrome/browser/prefs/incognito_mode_prefs.h"
31 #include "chrome/browser/prefs/pref_member.h" 32 #include "chrome/browser/prefs/pref_member.h"
32 #include "chrome/browser/prefs/pref_service.h" 33 #include "chrome/browser/prefs/pref_service.h"
33 #include "chrome/browser/printing/print_preview_context_menu_observer.h" 34 #include "chrome/browser/printing/print_preview_context_menu_observer.h"
34 #include "chrome/browser/printing/print_preview_tab_controller.h" 35 #include "chrome/browser/printing/print_preview_tab_controller.h"
35 #include "chrome/browser/printing/print_view_manager.h" 36 #include "chrome/browser/printing/print_view_manager.h"
36 #include "chrome/browser/profiles/profile.h" 37 #include "chrome/browser/profiles/profile.h"
37 #include "chrome/browser/profiles/profile_io_data.h" 38 #include "chrome/browser/profiles/profile_io_data.h"
38 #include "chrome/browser/search_engines/template_url.h" 39 #include "chrome/browser/search_engines/template_url.h"
39 #include "chrome/browser/search_engines/template_url_service.h" 40 #include "chrome/browser/search_engines/template_url_service.h"
40 #include "chrome/browser/search_engines/template_url_service_factory.h" 41 #include "chrome/browser/search_engines/template_url_service_factory.h"
41 #include "chrome/browser/spellchecker/spellcheck_host.h" 42 #include "chrome/browser/spellchecker/spellcheck_host.h"
42 #include "chrome/browser/spellchecker/spellcheck_host_metrics.h" 43 #include "chrome/browser/spellchecker/spellcheck_host_metrics.h"
43 #include "chrome/browser/tab_contents/retargeting_details.h" 44 #include "chrome/browser/tab_contents/retargeting_details.h"
44 #include "chrome/browser/tab_contents/spellchecker_submenu_observer.h" 45 #include "chrome/browser/tab_contents/spellchecker_submenu_observer.h"
45 #include "chrome/browser/tab_contents/spelling_menu_observer.h" 46 #include "chrome/browser/tab_contents/spelling_menu_observer.h"
46 #include "chrome/browser/translate/translate_manager.h" 47 #include "chrome/browser/translate/translate_manager.h"
47 #include "chrome/browser/translate/translate_prefs.h" 48 #include "chrome/browser/translate/translate_prefs.h"
48 #include "chrome/browser/translate/translate_tab_helper.h" 49 #include "chrome/browser/translate/translate_tab_helper.h"
49 #include "chrome/browser/ui/browser.h" 50 #include "chrome/browser/ui/browser.h"
50 #include "chrome/browser/ui/prefs/prefs_tab_helper.h" 51 #include "chrome/browser/ui/prefs/prefs_tab_helper.h"
51 #include "chrome/browser/ui/browser_list.h"
52 #include "chrome/browser/ui/search_engines/search_engine_tab_helper.h" 52 #include "chrome/browser/ui/search_engines/search_engine_tab_helper.h"
53 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 53 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
54 #include "chrome/browser/web_applications/web_app.h"
55 #include "chrome/common/chrome_constants.h" 54 #include "chrome/common/chrome_constants.h"
56 #include "chrome/common/chrome_notification_types.h" 55 #include "chrome/common/chrome_notification_types.h"
57 #include "chrome/common/chrome_switches.h" 56 #include "chrome/common/chrome_switches.h"
57 #include "chrome/common/extensions/extension.h"
58 #include "chrome/common/pref_names.h" 58 #include "chrome/common/pref_names.h"
59 #include "chrome/common/print_messages.h" 59 #include "chrome/common/print_messages.h"
60 #include "chrome/common/spellcheck_messages.h" 60 #include "chrome/common/spellcheck_messages.h"
61 #include "chrome/common/url_constants.h" 61 #include "chrome/common/url_constants.h"
62 #include "content/browser/child_process_security_policy.h" 62 #include "content/browser/child_process_security_policy.h"
63 #include "content/browser/download/download_manager.h" 63 #include "content/browser/download/download_manager.h"
64 #include "content/browser/download/download_stats.h" 64 #include "content/browser/download/download_stats.h"
65 #include "content/browser/download/save_package.h" 65 #include "content/browser/download/save_package.h"
66 #include "content/browser/renderer_host/render_view_host.h" 66 #include "content/browser/renderer_host/render_view_host.h"
67 #include "content/browser/renderer_host/render_widget_host_view.h" 67 #include "content/browser/renderer_host/render_widget_host_view.h"
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 } 511 }
512 UMA_HISTOGRAM_TIMES("Extensions.ContextMenus_BuildTime", 512 UMA_HISTOGRAM_TIMES("Extensions.ContextMenus_BuildTime",
513 base::TimeTicks::Now() - begin); 513 base::TimeTicks::Now() - begin);
514 UMA_HISTOGRAM_COUNTS("Extensions.ContextMenus_ItemCount", index); 514 UMA_HISTOGRAM_COUNTS("Extensions.ContextMenus_ItemCount", index);
515 } 515 }
516 516
517 void RenderViewContextMenu::InitMenu() { 517 void RenderViewContextMenu::InitMenu() {
518 bool has_link = !params_.unfiltered_link_url.is_empty(); 518 bool has_link = !params_.unfiltered_link_url.is_empty();
519 bool has_selection = !params_.selection_text.empty(); 519 bool has_selection = !params_.selection_text.empty();
520 520
521 Browser* active_browser = BrowserList::FindBrowserWithTabContents( 521 ExtensionProcessManager* process_manager =
522 source_tab_contents_); 522 profile_->GetExtensionProcessManager();
523 if (active_browser && active_browser->is_app()) { 523 ExtensionProcessManager::const_iterator iter;
524 const std::string ext_id = web_app::GetExtensionIdFromApplicationName( 524 for (iter = process_manager->begin(); iter != process_manager->end();
525 active_browser->app_name()); 525 ++iter) {
526 const Extension* app = 526 ExtensionHost* host = *iter;
527 profile_->GetExtensionService()->GetInstalledExtension(ext_id); 527 if (host->host_contents() == source_tab_contents_) {
528 if (app && app->is_platform_app()) { 528 if (host->extension() && host->extension()->is_platform_app()) {
529 int index = 0; 529 int index = 0;
530 AppendExtensionItems(app->id(), &index); 530 AppendExtensionItems(host->extension()->id(), &index);
531 return; 531 return;
miket_OOO 2011/12/20 19:12:34 This early return scares me in an Init method, par
Mihai Parparita -not on Chrome 2012/01/04 22:46:46 I've cleaned things up a bit, so that platform app
532 }
532 } 533 }
533 } 534 }
534 535
535 if (AppendCustomItems()) { 536 if (AppendCustomItems()) {
536 // If there's a selection, don't early return when there are custom items, 537 // If there's a selection, don't early return when there are custom items,
537 // but fall through to adding the normal ones after the custom ones. 538 // but fall through to adding the normal ones after the custom ones.
538 if (has_selection) { 539 if (has_selection) {
539 menu_model_.AddSeparator(); 540 menu_model_.AddSeparator();
540 } else { 541 } else {
541 // Don't add items for Pepper menu. 542 // Don't add items for Pepper menu.
(...skipping 1320 matching lines...) Expand 10 before | Expand all | Expand 10 after
1862 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages), 1863 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages),
1863 g_browser_process->clipboard()); 1864 g_browser_process->clipboard());
1864 } 1865 }
1865 1866
1866 void RenderViewContextMenu::MediaPlayerActionAt( 1867 void RenderViewContextMenu::MediaPlayerActionAt(
1867 const gfx::Point& location, 1868 const gfx::Point& location,
1868 const WebMediaPlayerAction& action) { 1869 const WebMediaPlayerAction& action) {
1869 source_tab_contents_->render_view_host()-> 1870 source_tab_contents_->render_view_host()->
1870 ExecuteMediaPlayerActionAtLocation(location, action); 1871 ExecuteMediaPlayerActionAtLocation(location, action);
1871 } 1872 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698