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

Side by Side Diff: chrome_frame/chrome_active_document.cc

Issue 218019: Initial import of the Chrome Frame codebase. Integration in chrome.gyp coming... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 11 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « chrome_frame/chrome_active_document.bmp ('k') | chrome_frame/chrome_active_document.rgs » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // Implementation of ChromeActiveDocument
6 #include "chrome_frame/chrome_active_document.h"
7
8 #include <hlink.h>
9 #include <htiface.h>
10 #include <mshtmcid.h>
11 #include <shdeprecated.h>
12 #include <shlguid.h>
13 #include <shobjidl.h>
14 #include <tlogstg.h>
15 #include <urlmon.h>
16 #include <wininet.h>
17
18 #include "base/command_line.h"
19 #include "base/file_util.h"
20 #include "base/logging.h"
21 #include "base/path_service.h"
22 #include "base/process_util.h"
23 #include "base/registry.h"
24 #include "base/scoped_variant_win.h"
25 #include "base/string_tokenizer.h"
26 #include "base/string_util.h"
27 #include "base/thread.h"
28 #include "base/thread_local.h"
29
30 #include "grit/generated_resources.h"
31 #include "chrome/browser/tab_contents/tab_contents.h"
32 #include "chrome/common/chrome_constants.h"
33 #include "chrome/common/navigation_types.h"
34 #include "chrome/test/automation/browser_proxy.h"
35 #include "chrome/test/automation/tab_proxy.h"
36 #include "chrome_frame/utils.h"
37
38 const wchar_t kChromeAttachExternalTabPrefix[] = L"attach_external_tab";
39
40 static const wchar_t kUseChromeNetworking[] = L"UseChromeNetworking";
41 static const wchar_t kHandleTopLevelRequests[] =
42 L"HandleTopLevelRequests";
43
44 base::ThreadLocalPointer<ChromeActiveDocument> g_active_doc_cache;
45
46 bool g_first_launch_by_process_ = true;
47
48 ChromeActiveDocument::ChromeActiveDocument()
49 : first_navigation_(true),
50 is_automation_client_reused_(false) {
51 }
52
53 HRESULT ChromeActiveDocument::FinalConstruct() {
54 // If we have a cached ChromeActiveDocument instance in TLS, then grab
55 // ownership of the cached document's automation client. This is an
56 // optimization to get Chrome active documents to load faster.
57 ChromeActiveDocument* cached_document = g_active_doc_cache.Get();
58 if (cached_document) {
59 DCHECK(automation_client_.get() == NULL);
60 automation_client_.reset(cached_document->automation_client_.release());
61 DLOG(INFO) << "Reusing automation client instance from "
62 << cached_document;
63 DCHECK(automation_client_.get() != NULL);
64 automation_client_->Reinitialize(this);
65 is_automation_client_reused_ = true;
66 } else {
67 // The FinalConstruct implementation in the ChromeFrameActivexBase class
68 // i.e. Base creates an instance of the ChromeFrameAutomationClient class
69 // and initializes it, which would spawn a new Chrome process, etc.
70 // We don't want to be doing this if we have a cached document, whose
71 // automation client instance can be reused.
72 HRESULT hr = Base::FinalConstruct();
73 if (FAILED(hr))
74 return hr;
75 }
76
77 bool chrome_network = GetConfigBool(false, kUseChromeNetworking);
78 bool top_level_requests = GetConfigBool(true, kHandleTopLevelRequests);
79 automation_client_->set_use_chrome_network(chrome_network);
80 automation_client_->set_handle_top_level_requests(top_level_requests);
81
82 find_dialog_.Init(automation_client_.get());
83
84 enabled_commands_map_[OLECMDID_PRINT] = true;
85 enabled_commands_map_[OLECMDID_FIND] = true;
86 enabled_commands_map_[OLECMDID_CUT] = true;
87 enabled_commands_map_[OLECMDID_COPY] = true;
88 enabled_commands_map_[OLECMDID_PASTE] = true;
89 enabled_commands_map_[OLECMDID_SELECTALL] = true;
90 return S_OK;
91 }
92
93 ChromeActiveDocument::~ChromeActiveDocument() {
94 DLOG(INFO) << __FUNCTION__;
95 if (find_dialog_.IsWindow()) {
96 find_dialog_.DestroyWindow();
97 }
98 }
99
100 // Override DoVerb
101 STDMETHODIMP ChromeActiveDocument::DoVerb(LONG verb,
102 LPMSG msg,
103 IOleClientSite* active_site,
104 LONG index,
105 HWND parent_window,
106 LPCRECT pos) {
107 // IE will try and in-place activate us in some cases. This happens when
108 // the user opens a new IE window with a URL that has us as the DocObject.
109 // Here we refuse to be activated in-place and we will force IE to UIActivate
110 // us.
111 if (OLEIVERB_INPLACEACTIVATE == verb) {
112 return E_NOTIMPL;
113 }
114 // Check if we should activate as a docobject or not
115 // (client supports IOleDocumentSite)
116 if (doc_site_) {
117 switch (verb) {
118 case OLEIVERB_SHOW:
119 case OLEIVERB_OPEN:
120 case OLEIVERB_UIACTIVATE:
121 if (!m_bUIActive) {
122 return doc_site_->ActivateMe(NULL);
123 }
124 break;
125 }
126 }
127 return IOleObjectImpl<ChromeActiveDocument>::DoVerb(verb,
128 msg,
129 active_site,
130 index,
131 parent_window,
132 pos);
133 }
134
135 STDMETHODIMP ChromeActiveDocument::InPlaceDeactivate(void) {
136 // Release the pointers we have no need for now.
137 doc_site_.Release();
138 in_place_frame_.Release();
139 return IOleInPlaceObjectWindowlessImpl<ChromeActiveDocument>::
140 InPlaceDeactivate();
141 }
142
143 // Override IOleInPlaceActiveObjectImpl::OnDocWindowActivate
144 STDMETHODIMP ChromeActiveDocument::OnDocWindowActivate(BOOL activate) {
145 DLOG(INFO) << __FUNCTION__;
146 return S_OK;
147 }
148
149 STDMETHODIMP ChromeActiveDocument::TranslateAccelerator(MSG* msg) {
150 DLOG(INFO) << __FUNCTION__;
151 if (msg == NULL)
152 return E_POINTER;
153
154 if (msg->message == WM_KEYDOWN && msg->wParam == VK_TAB) {
155 HWND focus = ::GetFocus();
156 if (focus != m_hWnd && !::IsChild(m_hWnd, focus)) {
157 // The call to SetFocus triggers a WM_SETFOCUS that makes the base class
158 // set focus to the correct element in Chrome.
159 ::SetFocus(m_hWnd);
160 return S_OK;
161 }
162 }
163
164 return S_FALSE;
165 }
166 // Override IPersistStorageImpl::IsDirty
167 STDMETHODIMP ChromeActiveDocument::IsDirty() {
168 DLOG(INFO) << __FUNCTION__;
169 return S_FALSE;
170 }
171
172 bool ChromeActiveDocument::is_frame_busting_enabled() {
173 return false;
174 }
175
176 STDMETHODIMP ChromeActiveDocument::Load(BOOL fully_avalable,
177 IMoniker* moniker_name,
178 LPBC bind_context,
179 DWORD mode) {
180 if (NULL == moniker_name) {
181 return E_INVALIDARG;
182 }
183 CComHeapPtr<WCHAR> display_name;
184 moniker_name->GetDisplayName(bind_context, NULL, &display_name);
185 std::wstring url = display_name;
186
187 bool is_chrome_protocol = StartsWith(url, kChromeProtocolPrefix, false);
188 bool is_new_navigation = true;
189
190 if (is_chrome_protocol) {
191 url.erase(0, lstrlen(kChromeProtocolPrefix));
192 is_new_navigation =
193 !StartsWith(url, kChromeAttachExternalTabPrefix, false);
194 }
195
196 if (!IsValidUrlScheme(url)) {
197 DLOG(WARNING) << __FUNCTION__ << " Disallowing navigation to url: "
198 << url;
199 return E_INVALIDARG;
200 }
201
202 if (!is_new_navigation) {
203 WStringTokenizer tokenizer(url, L"&");
204 // Skip over kChromeAttachExternalTabPrefix
205 tokenizer.GetNext();
206
207 intptr_t external_tab_cookie = 0;
208
209 if (tokenizer.GetNext())
210 StringToInt(tokenizer.token(),
211 reinterpret_cast<int*>(&external_tab_cookie));
212
213 if (external_tab_cookie == 0) {
214 NOTREACHED() << "invalid url for attach tab: " << url;
215 return E_FAIL;
216 }
217
218 automation_client_->AttachExternalTab(external_tab_cookie);
219 }
220
221 // Initiate navigation before launching chrome so that the url will be
222 // cached and sent with launch settings.
223 if (is_new_navigation) {
224 url_.Reset(::SysAllocString(url.c_str()));
225 if (url_.Length()) {
226 std::string utf8_url;
227 WideToUTF8(url_, url_.Length(), &utf8_url);
228 if (!automation_client_->InitiateNavigation(utf8_url)) {
229 DLOG(ERROR) << "Invalid URL: " << url;
230 Error(L"Invalid URL");
231 url_.Reset();
232 return E_INVALIDARG;
233 }
234
235 DLOG(INFO) << "Url is " << url_;
236 }
237 }
238
239 if (!is_automation_client_reused_ &&
240 !InitializeAutomation(GetHostProcessName(false), L"", IsIEInPrivate())) {
241 return E_FAIL;
242 }
243
244 if (!is_chrome_protocol) {
245 CComObject<UrlmonUrlRequest>* new_request = NULL;
246 CComObject<UrlmonUrlRequest>::CreateInstance(&new_request);
247 new_request->AddRef();
248
249 if (SUCCEEDED(new_request->ConnectToExistingMoniker(moniker_name,
250 bind_context,
251 url))) {
252 base_url_request_.swap(&new_request);
253 DCHECK(new_request == NULL);
254 } else {
255 new_request->Release();
256 }
257 }
258
259 UMA_HISTOGRAM_CUSTOM_COUNTS("ChromeFrame.FullTabLaunchType",
260 is_chrome_protocol, 0, 1, 2);
261 return S_OK;
262 }
263
264 STDMETHODIMP ChromeActiveDocument::Save(IMoniker* moniker_name,
265 LPBC bind_context,
266 BOOL remember) {
267 return E_NOTIMPL;
268 }
269
270 STDMETHODIMP ChromeActiveDocument::SaveCompleted(IMoniker* moniker_name,
271 LPBC bind_context) {
272 return E_NOTIMPL;
273 }
274
275 STDMETHODIMP ChromeActiveDocument::GetCurMoniker(IMoniker** moniker_name) {
276 return E_NOTIMPL;
277 }
278
279 STDMETHODIMP ChromeActiveDocument::GetClassID(CLSID* class_id) {
280 if (NULL == class_id) {
281 return E_POINTER;
282 }
283 *class_id = GetObjectCLSID();
284 return S_OK;
285 }
286
287 STDMETHODIMP ChromeActiveDocument::QueryStatus(const GUID* cmd_group_guid,
288 ULONG number_of_commands,
289 OLECMD commands[],
290 OLECMDTEXT* command_text) {
291 DLOG(INFO) << __FUNCTION__;
292 for (ULONG command_index = 0; command_index < number_of_commands;
293 command_index++) {
294 DLOG(INFO) << "Command id = " << commands[command_index].cmdID;
295 if (enabled_commands_map_.find(commands[command_index].cmdID) !=
296 enabled_commands_map_.end()) {
297 commands[command_index].cmdf = OLECMDF_ENABLED;
298 }
299 }
300 return S_OK;
301 }
302
303 STDMETHODIMP ChromeActiveDocument::Exec(const GUID* cmd_group_guid,
304 DWORD command_id,
305 DWORD cmd_exec_opt,
306 VARIANT* in_args,
307 VARIANT* out_args) {
308 DLOG(INFO) << __FUNCTION__ << " Cmd id =" << command_id;
309 // Bail out if we have been uninitialized.
310 if (automation_client_.get() && automation_client_->tab()) {
311 return ProcessExecCommand(cmd_group_guid, command_id, cmd_exec_opt,
312 in_args, out_args);
313 }
314 return S_FALSE;
315 }
316
317 STDMETHODIMP ChromeActiveDocument::GetUrlForEvents(BSTR* url) {
318 if (NULL == url) {
319 return E_POINTER;
320 }
321 *url = ::SysAllocString(url_);
322 return S_OK;
323 }
324
325 HRESULT ChromeActiveDocument::IOleObject_SetClientSite(
326 IOleClientSite* client_site) {
327 if (client_site == NULL) {
328 ChromeActiveDocument* cached_document = g_active_doc_cache.Get();
329 if (cached_document) {
330 DCHECK(this == cached_document);
331 g_active_doc_cache.Set(NULL);
332 cached_document->Release();
333 }
334 }
335 return Base::IOleObject_SetClientSite(client_site);
336 }
337
338
339 HRESULT ChromeActiveDocument::ActiveXDocActivate(LONG verb) {
340 HRESULT hr = S_OK;
341 m_bNegotiatedWnd = TRUE;
342 if (!m_bInPlaceActive) {
343 hr = m_spInPlaceSite->CanInPlaceActivate();
344 if (FAILED(hr)) {
345 return hr;
346 }
347 m_spInPlaceSite->OnInPlaceActivate();
348 }
349 m_bInPlaceActive = TRUE;
350 // get location in the parent window,
351 // as well as some information about the parent
352 ScopedComPtr<IOleInPlaceUIWindow> in_place_ui_window;
353 frame_info_.cb = sizeof(OLEINPLACEFRAMEINFO);
354 HWND parent_window = NULL;
355 if (m_spInPlaceSite->GetWindow(&parent_window) == S_OK) {
356 in_place_frame_.Release();
357 RECT position_rect = {0};
358 RECT clip_rect = {0};
359 m_spInPlaceSite->GetWindowContext(in_place_frame_.Receive(),
360 in_place_ui_window.Receive(),
361 &position_rect,
362 &clip_rect,
363 &frame_info_);
364 if (!m_bWndLess) {
365 if (IsWindow()) {
366 ::ShowWindow(m_hWnd, SW_SHOW);
367 SetFocus();
368 } else {
369 m_hWnd = Create(parent_window, position_rect);
370 }
371 }
372 SetObjectRects(&position_rect, &clip_rect);
373 }
374
375 ScopedComPtr<IOleInPlaceActiveObject> in_place_active_object(this);
376
377 // Gone active by now, take care of UIACTIVATE
378 if (DoesVerbUIActivate(verb)) {
379 if (!m_bUIActive) {
380 m_bUIActive = TRUE;
381 hr = m_spInPlaceSite->OnUIActivate();
382 if (FAILED(hr)) {
383 return hr;
384 }
385 // set ourselves up in the host
386 if (in_place_active_object) {
387 if (in_place_frame_) {
388 in_place_frame_->SetActiveObject(in_place_active_object, NULL);
389 }
390 if (in_place_ui_window) {
391 in_place_ui_window->SetActiveObject(in_place_active_object, NULL);
392 }
393 }
394 }
395 }
396 m_spClientSite->ShowObject();
397 return S_OK;
398 }
399
400 void ChromeActiveDocument::OnNavigationStateChanged(int tab_handle, int flags,
401 const IPC::NavigationInfo& nav_info) {
402 // TODO(joshia): handle INVALIDATE_TAB,INVALIDATE_LOAD etc.
403 DLOG(INFO) << __FUNCTION__ << std::endl << " Flags: " << flags
404 << "Url: " << nav_info.url <<
405 ", Title: " << nav_info.title <<
406 ", Type: " << nav_info.navigation_type << ", Relative Offset: " <<
407 nav_info.relative_offset << ", Index: " << nav_info.navigation_index;;
408
409 UpdateNavigationState(nav_info);
410 }
411
412 void ChromeActiveDocument::OnUpdateTargetUrl(int tab_handle,
413 const std::wstring& new_target_url) {
414 if (in_place_frame_) {
415 in_place_frame_->SetStatusText(new_target_url.c_str());
416 }
417 }
418
419 bool IsFindAccelerator(const MSG& msg) {
420 // TODO(robertshield): This may not stand up to localization. Fix if this
421 // is the case.
422 return msg.message == WM_KEYDOWN && msg.wParam == 'F' &&
423 win_util::IsCtrlPressed() &&
424 !(win_util::IsAltPressed() || win_util::IsShiftPressed());
425 }
426
427 void ChromeActiveDocument::OnAcceleratorPressed(int tab_handle,
428 const MSG& accel_message) {
429 bool handled_accel = false;
430 if (in_place_frame_ != NULL) {
431 handled_accel = (S_OK == in_place_frame_->TranslateAcceleratorW(
432 const_cast<MSG*>(&accel_message), 0));
433 }
434
435 if (!handled_accel) {
436 if (IsFindAccelerator(accel_message)) {
437 // Handle the showing of the find dialog explicitly.
438 OnFindInPage();
439 } else if (AllowFrameToTranslateAccelerator(accel_message) != S_OK) {
440 DLOG(INFO) << "IE DID NOT handle accel key " << accel_message.wParam;
441 TabProxy* tab = GetTabProxy();
442 if (tab) {
443 tab->ProcessUnhandledAccelerator(accel_message);
444 }
445 }
446 } else {
447 DLOG(INFO) << "IE handled accel key " << accel_message.wParam;
448 }
449 }
450
451 void ChromeActiveDocument::OnTabbedOut(int tab_handle, bool reverse) {
452 DLOG(INFO) << __FUNCTION__;
453 if (in_place_frame_) {
454 MSG msg = { NULL, WM_KEYDOWN, VK_TAB };
455 in_place_frame_->TranslateAcceleratorW(&msg, 0);
456 }
457 }
458
459 void ChromeActiveDocument::OnDidNavigate(int tab_handle,
460 const IPC::NavigationInfo& nav_info) {
461 DLOG(INFO) << __FUNCTION__ << std::endl << "Url: " << nav_info.url <<
462 ", Title: " << nav_info.title <<
463 ", Type: " << nav_info.navigation_type << ", Relative Offset: " <<
464 nav_info.relative_offset << ", Index: " << nav_info.navigation_index;
465
466 // This could be NULL if the active document instance is being destroyed.
467 if (!m_spInPlaceSite) {
468 DLOG(INFO) << __FUNCTION__ << "m_spInPlaceSite is NULL. Returning";
469 return;
470 }
471
472 UpdateNavigationState(nav_info);
473 }
474
475 void ChromeActiveDocument::UpdateNavigationState(
476 const IPC::NavigationInfo& new_navigation_info) {
477 bool is_title_changed = (navigation_info_.title != new_navigation_info.title);
478 bool is_url_changed = (navigation_info_.url.is_valid() &&
479 (navigation_info_.url != new_navigation_info.url));
480 bool is_ssl_state_changed =
481 (navigation_info_.security_style != new_navigation_info.security_style) ||
482 (navigation_info_.has_mixed_content !=
483 new_navigation_info.has_mixed_content);
484
485 navigation_info_ = new_navigation_info;
486
487 if (is_title_changed) {
488 ScopedVariant title(navigation_info_.title.c_str());
489 IEExec(NULL, OLECMDID_SETTITLE, OLECMDEXECOPT_DONTPROMPTUSER,
490 title.AsInput(), NULL);
491 }
492
493 if (is_ssl_state_changed) {
494 int lock_status = SECURELOCK_SET_UNSECURE;
495 switch (navigation_info_.security_style) {
496 case SECURITY_STYLE_AUTHENTICATION_BROKEN:
497 lock_status = SECURELOCK_SET_SECUREUNKNOWNBIT;
498 break;
499 case SECURITY_STYLE_AUTHENTICATED:
500 lock_status = navigation_info_.has_mixed_content ?
501 SECURELOCK_SET_MIXED : SECURELOCK_SET_SECUREUNKNOWNBIT;
502 break;
503 default:
504 break;
505 }
506
507 ScopedVariant secure_lock_status(lock_status);
508 IEExec(&CGID_ShellDocView, INTERNAL_CMDID_SET_SSL_LOCK,
509 OLECMDEXECOPT_DODEFAULT, secure_lock_status.AsInput(), NULL);
510 }
511
512 if (navigation_info_.url.is_valid() &&
513 (is_url_changed || url_.Length() == 0)) {
514 url_.Allocate(UTF8ToWide(navigation_info_.url.spec()).c_str());
515 // Now call the FireNavigateCompleteEvent which makes IE update the text
516 // in the address-bar. We call the FireBeforeNavigateComplete2Event and
517 // FireDocumentComplete event just for completeness sake. If some BHO
518 // chooses to cancel the navigation in the OnBeforeNavigate2 handler
519 // we will ignore the cancellation request.
520
521 // Todo(joshia): investigate if there's a better way to set URL in the
522 // address bar
523 ScopedComPtr<IWebBrowserEventsService> web_browser_events_svc;
524 DoQueryService(__uuidof(web_browser_events_svc), m_spClientSite,
525 web_browser_events_svc.Receive());
526 if (web_browser_events_svc) {
527 // TODO(joshia): maybe we should call FireBeforeNavigate2Event in
528 // ChromeActiveDocument::Load and abort if cancelled.
529 VARIANT_BOOL should_cancel = VARIANT_FALSE;
530 web_browser_events_svc->FireBeforeNavigate2Event(&should_cancel);
531 web_browser_events_svc->FireNavigateComplete2Event();
532 if (VARIANT_TRUE != should_cancel) {
533 web_browser_events_svc->FireDocumentCompleteEvent();
534 }
535 }
536 }
537 }
538
539 void ChromeActiveDocument::OnFindInPage() {
540 TabProxy* tab = GetTabProxy();
541 if (tab) {
542 if (!find_dialog_.IsWindow()) {
543 find_dialog_.Create(m_hWnd);
544 }
545
546 find_dialog_.ShowWindow(SW_SHOW);
547 }
548 }
549
550 void ChromeActiveDocument::OnViewSource() {
551 DCHECK(navigation_info_.url.is_valid());
552 std::string url_to_open = "view-source:";
553 url_to_open += navigation_info_.url.spec();
554 OnOpenURL(0, GURL(url_to_open), NEW_WINDOW);
555 }
556
557 void ChromeActiveDocument::OnOpenURL(int tab_handle, const GURL& url_to_open,
558 int open_disposition) {
559 // If the disposition indicates that we should be opening the URL in the
560 // current tab, then we can reuse the ChromeFrameAutomationClient instance
561 // maintained by the current ChromeActiveDocument instance. We cache this
562 // instance so that it can be used by the new ChromeActiveDocument instance
563 // which may be instantiated for handling the new URL.
564 if (open_disposition == CURRENT_TAB) {
565 // Grab a reference to ensure that the document remains valid.
566 AddRef();
567 g_active_doc_cache.Set(this);
568 }
569
570 Base::OnOpenURL(tab_handle, url_to_open, open_disposition);
571 }
572
573 void ChromeActiveDocument::OnLoad(int tab_handle, const GURL& url) {
574 if (ready_state_ < READYSTATE_COMPLETE) {
575 ready_state_ = READYSTATE_COMPLETE;
576 FireOnChanged(DISPID_READYSTATE);
577 }
578 }
579
580 bool ChromeActiveDocument::PreProcessContextMenu(HMENU menu) {
581 ScopedComPtr<IBrowserService> browser_service;
582 ScopedComPtr<ITravelLog> travel_log;
583
584 DoQueryService(SID_SShellBrowser, m_spClientSite, browser_service.Receive());
585 if (!browser_service)
586 return true;
587
588 browser_service->GetTravelLog(travel_log.Receive());
589 if (!travel_log)
590 return true;
591
592 if (SUCCEEDED(travel_log->GetTravelEntry(browser_service, TLOG_BACK, NULL))) {
593 EnableMenuItem(menu, IDS_CONTENT_CONTEXT_BACK, MF_BYCOMMAND | MF_ENABLED);
594 } else {
595 EnableMenuItem(menu, IDS_CONTENT_CONTEXT_BACK, MF_BYCOMMAND | MFS_DISABLED);
596 }
597
598
599 if (SUCCEEDED(travel_log->GetTravelEntry(browser_service, TLOG_FORE, NULL))) {
600 EnableMenuItem(menu, IDS_CONTENT_CONTEXT_FORWARD,
601 MF_BYCOMMAND | MF_ENABLED);
602 } else {
603 EnableMenuItem(menu, IDS_CONTENT_CONTEXT_FORWARD,
604 MF_BYCOMMAND | MFS_DISABLED);
605 }
606
607 // Call base class (adds 'About' item)
608 return Base::PreProcessContextMenu(menu);
609 }
610
611 bool ChromeActiveDocument::HandleContextMenuCommand(UINT cmd) {
612 ScopedComPtr<IWebBrowser2> web_browser2;
613 DoQueryService(SID_SWebBrowserApp, m_spClientSite, web_browser2.Receive());
614
615 switch (cmd) {
616 case IDS_CONTENT_CONTEXT_BACK:
617 web_browser2->GoBack();
618 break;
619
620 case IDS_CONTENT_CONTEXT_FORWARD:
621 web_browser2->GoForward();
622 break;
623
624 case IDS_CONTENT_CONTEXT_RELOAD:
625 web_browser2->Refresh();
626 break;
627
628 default:
629 return Base::HandleContextMenuCommand(cmd);
630 }
631
632 return true;
633 }
634
635 HRESULT ChromeActiveDocument::IEExec(const GUID* cmd_group_guid,
636 DWORD command_id, DWORD cmd_exec_opt,
637 VARIANT* in_args, VARIANT* out_args) {
638 HRESULT hr = E_FAIL;
639 ScopedComPtr<IOleCommandTarget> frame_cmd_target;
640 if (m_spInPlaceSite)
641 hr = frame_cmd_target.QueryFrom(m_spInPlaceSite);
642
643 if (frame_cmd_target)
644 hr = frame_cmd_target->Exec(cmd_group_guid, command_id, cmd_exec_opt,
645 in_args, out_args);
646
647 return hr;
648 }
OLDNEW
« no previous file with comments | « chrome_frame/chrome_active_document.bmp ('k') | chrome_frame/chrome_active_document.rgs » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698