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

Side by Side Diff: chrome/browser/extensions/extension_host.cc

Issue 9235002: Enable devtools via context menu in platform apps and popup extensions. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Menu for popup extensions Created 8 years, 10 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
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/extensions/extension_host.h" 5 #include "chrome/browser/extensions/extension_host.h"
6 6
7 #include <list> 7 #include <list>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/memory/singleton.h" 10 #include "base/memory/singleton.h"
(...skipping 27 matching lines...) Expand all
38 #include "content/public/browser/render_process_host.h" 38 #include "content/public/browser/render_process_host.h"
39 #include "content/public/browser/site_instance.h" 39 #include "content/public/browser/site_instance.h"
40 #include "content/public/browser/web_contents.h" 40 #include "content/public/browser/web_contents.h"
41 #include "content/public/browser/web_contents_view.h" 41 #include "content/public/browser/web_contents_view.h"
42 #include "grit/browser_resources.h" 42 #include "grit/browser_resources.h"
43 #include "grit/chromium_strings.h" 43 #include "grit/chromium_strings.h"
44 #include "grit/generated_resources.h" 44 #include "grit/generated_resources.h"
45 #include "ui/base/keycodes/keyboard_codes.h" 45 #include "ui/base/keycodes/keyboard_codes.h"
46 #include "ui/base/l10n/l10n_util.h" 46 #include "ui/base/l10n/l10n_util.h"
47 #include "ui/base/resource/resource_bundle.h" 47 #include "ui/base/resource/resource_bundle.h"
48 #include "webkit/glue/context_menu.h"
49 48
50 #if defined(TOOLKIT_VIEWS) 49 #if defined(TOOLKIT_VIEWS)
51 #include "ui/views/widget/widget.h" 50 #include "ui/views/widget/widget.h"
52 #endif 51 #endif
53 52
54 using WebKit::WebDragOperation; 53 using WebKit::WebDragOperation;
55 using WebKit::WebDragOperationsMask; 54 using WebKit::WebDragOperationsMask;
56 using content::OpenURLParams; 55 using content::OpenURLParams;
57 using content::SiteInstance; 56 using content::SiteInstance;
58 using content::WebContents; 57 using content::WebContents;
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 // Only allow these from hosts that are bound to a browser (e.g. popups). 419 // Only allow these from hosts that are bound to a browser (e.g. popups).
421 // Otherwise they are not driven by a user gesture. 420 // Otherwise they are not driven by a user gesture.
422 Browser* browser = GetBrowser(); 421 Browser* browser = GetBrowser();
423 return browser ? browser->OpenURL(params) : NULL; 422 return browser ? browser->OpenURL(params) : NULL;
424 } 423 }
425 default: 424 default:
426 return NULL; 425 return NULL;
427 } 426 }
428 } 427 }
429 428
430 bool ExtensionHost::HandleContextMenu(const ContextMenuParams& params) {
431 // Only allow context menus on non-linked editable items and selections.
432 // Context entries for the page and "Save * as..." are currently unsupported.
433 bool has_link = !params.unfiltered_link_url.is_empty();
434 bool has_selection = !params.selection_text.empty();
435 bool editable = params.is_editable;
436 bool media = params.media_type != WebKit::WebContextMenuData::MediaTypeNone;
437 // Returning true suppresses the context menu, having been "handled" here.
438 return has_link || media || !(editable || has_selection);
439 }
440
441 bool ExtensionHost::PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event, 429 bool ExtensionHost::PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event,
442 bool* is_keyboard_shortcut) { 430 bool* is_keyboard_shortcut) {
443 if (extension_host_type_ == chrome::VIEW_TYPE_EXTENSION_POPUP && 431 if (extension_host_type_ == chrome::VIEW_TYPE_EXTENSION_POPUP &&
444 event.type == NativeWebKeyboardEvent::RawKeyDown && 432 event.type == NativeWebKeyboardEvent::RawKeyDown &&
445 event.windowsKeyCode == ui::VKEY_ESCAPE) { 433 event.windowsKeyCode == ui::VKEY_ESCAPE) {
446 DCHECK(is_keyboard_shortcut != NULL); 434 DCHECK(is_keyboard_shortcut != NULL);
447 *is_keyboard_shortcut = true; 435 *is_keyboard_shortcut = true;
448 } 436 }
449 return false; 437 return false;
450 } 438 }
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
565 browser::Navigate(&params); 553 browser::Navigate(&params);
566 } 554 }
567 555
568 556
569 void ExtensionHost::RenderViewReady() { 557 void ExtensionHost::RenderViewReady() {
570 content::NotificationService::current()->Notify( 558 content::NotificationService::current()->Notify(
571 chrome::NOTIFICATION_EXTENSION_HOST_CREATED, 559 chrome::NOTIFICATION_EXTENSION_HOST_CREATED,
572 content::Source<Profile>(profile_), 560 content::Source<Profile>(profile_),
573 content::Details<ExtensionHost>(this)); 561 content::Details<ExtensionHost>(this));
574 } 562 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698