Skip to content

Commit

Permalink
ChromeFrame host browser commands need to account for the command gro…
Browse files Browse the repository at this point in the history
…up guid and the command id in all cases. We were

detecting MSHTML command ids based on the command id only while ignoring the group which was wrong.

Part of the fix for http://code.google.com/p/chromium/issues/detail?id=24034

Bug=24034

Review URL: http://codereview.chromium.org/2873070

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@53699 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
ananta@chromium.org committed Jul 26, 2010
1 parent 44693a7 commit 6fd1a7a
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 22 deletions.
54 changes: 35 additions & 19 deletions chrome_frame/chrome_active_document.cc
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,21 @@ HRESULT ChromeActiveDocument::FinalConstruct() {

find_dialog_.Init(automation_client_.get());

enabled_commands_map_[OLECMDID_PRINT] = true;
enabled_commands_map_[OLECMDID_FIND] = true;
enabled_commands_map_[OLECMDID_CUT] = true;
enabled_commands_map_[OLECMDID_COPY] = true;
enabled_commands_map_[OLECMDID_PASTE] = true;
enabled_commands_map_[OLECMDID_SELECTALL] = true;
enabled_commands_map_[OLECMDID_SAVEAS] = true;
OLECMDF flags = static_cast<OLECMDF>(OLECMDF_ENABLED | OLECMDF_SUPPORTED);

null_group_commands_map_[OLECMDID_PRINT] = flags;
null_group_commands_map_[OLECMDID_FIND] = flags;
null_group_commands_map_[OLECMDID_CUT] = flags;
null_group_commands_map_[OLECMDID_COPY] = flags;
null_group_commands_map_[OLECMDID_PASTE] = flags;
null_group_commands_map_[OLECMDID_SELECTALL] = flags;
null_group_commands_map_[OLECMDID_SAVEAS] = flags;

mshtml_group_commands_map_[IDM_BASELINEFONT1] = flags;
mshtml_group_commands_map_[IDM_BASELINEFONT2] = flags;
mshtml_group_commands_map_[IDM_BASELINEFONT3] = flags;
mshtml_group_commands_map_[IDM_BASELINEFONT4] = flags;
mshtml_group_commands_map_[IDM_BASELINEFONT5] = flags;

HMODULE this_module = reinterpret_cast<HMODULE>(&__ImageBase);
accelerator_table_ =
Expand Down Expand Up @@ -314,17 +322,24 @@ STDMETHODIMP ChromeActiveDocument::QueryStatus(const GUID* cmd_group_guid,
OLECMD commands[],
OLECMDTEXT* command_text) {
DLOG(INFO) << __FUNCTION__;
const GUID* supported_groups[] = {
&GUID_NULL,
&CGID_MSHTML,
&CGID_Explorer,
};

bool supported = (cmd_group_guid == NULL);
for (int i = 0; !supported && i < arraysize(supported_groups); ++i)
supported = (IsEqualGUID(*cmd_group_guid, *supported_groups[i]) != FALSE);
CommandStatusMap* command_map = NULL;

if (cmd_group_guid) {
if (IsEqualGUID(*cmd_group_guid, GUID_NULL)) {
command_map = &null_group_commands_map_;
} else if (IsEqualGUID(*cmd_group_guid, CGID_MSHTML)) {
command_map = &mshtml_group_commands_map_;
} else if (IsEqualGUID(*cmd_group_guid, CGID_Explorer)) {
command_map = &explorer_group_commands_map_;
} else if (IsEqualGUID(*cmd_group_guid, CGID_ShellDocView)) {
command_map = &shdoc_view_group_commands_map_;
}
} else {
command_map = &null_group_commands_map_;
}

if (!supported) {
if (!command_map) {
DLOG(INFO) << "unsupported command group: "
<< GuidToString(*cmd_group_guid);
return OLECMDERR_E_NOTSUPPORTED;
Expand All @@ -333,9 +348,10 @@ STDMETHODIMP ChromeActiveDocument::QueryStatus(const GUID* cmd_group_guid,
for (ULONG command_index = 0; command_index < number_of_commands;
command_index++) {
DLOG(INFO) << "Command id = " << commands[command_index].cmdID;
if (enabled_commands_map_.find(commands[command_index].cmdID) !=
enabled_commands_map_.end())
commands[command_index].cmdf = OLECMDF_ENABLED;
CommandStatusMap::iterator index =
command_map->find(commands[command_index].cmdID);
if (index != command_map->end())
commands[command_index].cmdf = index->second;
}
return S_OK;
}
Expand Down
9 changes: 6 additions & 3 deletions chrome_frame/chrome_active_document.h
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ END_EXEC_COMMAND_MAP()
static bool ShouldFireDocumentComplete();

protected:
typedef std::map<int, bool> EnabledCommandsMap;
typedef std::map<int, OLECMDF> CommandStatusMap;

IPC::NavigationInfo navigation_info_;
bool is_doc_object_;
Expand All @@ -446,8 +446,11 @@ END_EXEC_COMMAND_MAP()
// Our find dialog
CFFindDialog find_dialog_;

// Contains the list of enabled commands ids.
EnabledCommandsMap enabled_commands_map_;
// These members contain the status of the commands we support.
CommandStatusMap null_group_commands_map_;
CommandStatusMap mshtml_group_commands_map_;
CommandStatusMap explorer_group_commands_map_;
CommandStatusMap shdoc_view_group_commands_map_;

// Set to true if the automation_client_ member is initialized from
// an existing ChromeActiveDocument instance which is going away and
Expand Down

0 comments on commit 6fd1a7a

Please sign in to comment.