Add context menu support (issue #509):

- Add new CefContextMenuHandler, CefContextMenuParams and CefMenuModel classes.
- Add cef_strings.grd and related infrastructure for supporting translation of CEF strings.
- Generate include/cef_pack_resources.h and include/cef_pack_strings.h files at build time that include all IDs used by CEF pack files.

git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@596 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
Marshall Greenblatt 2012-04-19 21:18:22 +00:00
parent 7bc494880f
commit effbca00e2
4 changed files with 20 additions and 8 deletions

View File

@ -155,6 +155,10 @@ void CefMenuCreator::ExecuteCommand(CefRefPtr<CefMenuModelImpl> source,
}
void CefMenuCreator::MenuWillShow(CefRefPtr<CefMenuModelImpl> source) {
// May be called for sub-menus as well.
if (source.get() != model_.get())
return;
// Notify the host before showing the context menu.
content::RenderWidgetHostView* view =
browser_->GetWebContents()->GetRenderWidgetHostView();
@ -163,6 +167,10 @@ void CefMenuCreator::MenuWillShow(CefRefPtr<CefMenuModelImpl> source) {
}
void CefMenuCreator::MenuClosed(CefRefPtr<CefMenuModelImpl> source) {
// May be called for sub-menus as well.
if (source.get() != model_.get())
return;
// Notify the client.
CefRefPtr<CefClient> client = browser_->GetClient();
if (client.get()) {

View File

@ -19,10 +19,10 @@ class CefMenuDelegate : public MenuGtk::Delegate {
} // namespace
CefMenuCreatorRunnerWin::CefMenuCreatorRunnerWin() {
CefMenuCreatorRunnerGtk::CefMenuCreatorRunnerGtk) {
}
bool CefMenuCreatorRunnerWin::RunContextMenu(CefMenuCreator* manager) {
bool CefMenuCreatorRunnerGtk::RunContextMenu(CefMenuCreator* manager) {
if (!menu_delegate_.get())
menu_delegate_.reset(new CefMenuDelegate);

View File

@ -11,22 +11,22 @@
#import "chrome/browser/ui/cocoa/menu_controller.h"
#include "content/public/browser/web_contents_view.h"
CefMenuCreatorRunnerWin::CefMenuCreatorRunnerMac()
CefMenuCreatorRunnerMac::CefMenuCreatorRunnerMac()
: menu_controller_(nil) {
}
CefMenuCreatorRunnerWin::~CefMenuCreatorRunnerMac() {
CefMenuCreatorRunnerMac::~CefMenuCreatorRunnerMac() {
if (menu_controller_ != nil)
[menu_controller_ release];
}
bool CefMenuCreatorRunnerWin::RunContextMenu(CefMenuCreator* manager) {
bool CefMenuCreatorRunnerMac::RunContextMenu(CefMenuCreator* manager) {
// Create a menu controller based on the model.
if (menu_controller_ != nil)
[menu_controller_ release];
menu_controller_ =
[[MenuController alloc] initWithModel:manager.model()
useWithPopUpButtonCell:NO]);
[[MenuController alloc] initWithModel:manager->model()
useWithPopUpButtonCell:NO];
NSView* parent_view =
manager->browser()->GetWebContents()->GetContentNativeView();

View File

@ -98,7 +98,11 @@ def MakeFile(output, input):
guard = 'CEF_INCLUDE_'+string.upper(filename.replace('.', '_'))+'_'
result = result.replace('$GUARD$', guard)
old_contents = read_file(output)
if path_exists(output):
old_contents = read_file(output)
else:
old_contents = ''
if (result != old_contents):
write_file(output, result)
sys.stdout.write('File '+output+' updated.\n')