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

Side by Side Diff: webkit/glue/chrome_client_impl.cc

Issue 155378: Replace ShowAsPopupWithItems to CreatePopupWidgetWithInfo. Also,... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 5 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 | « webkit/glue/chrome_client_impl.h ('k') | webkit/glue/webmenuitem.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 "config.h" 5 #include "config.h"
6 6
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 8
9 MSVC_PUSH_WARNING_LEVEL(0); 9 MSVC_PUSH_WARNING_LEVEL(0);
10 #include "AccessibilityObject.h" 10 #include "AccessibilityObject.h"
(...skipping 21 matching lines...) Expand all
32 #undef LOG 32 #undef LOG
33 33
34 #include "webkit/glue/chrome_client_impl.h" 34 #include "webkit/glue/chrome_client_impl.h"
35 35
36 #include "base/gfx/rect.h" 36 #include "base/gfx/rect.h"
37 #include "base/logging.h" 37 #include "base/logging.h"
38 #include "googleurl/src/gurl.h" 38 #include "googleurl/src/gurl.h"
39 #include "webkit/api/public/WebCursorInfo.h" 39 #include "webkit/api/public/WebCursorInfo.h"
40 #include "webkit/api/public/WebInputEvent.h" 40 #include "webkit/api/public/WebInputEvent.h"
41 #include "webkit/api/public/WebKit.h" 41 #include "webkit/api/public/WebKit.h"
42 #include "webkit/api/public/WebPopupMenuInfo.h"
42 #include "webkit/api/public/WebRect.h" 43 #include "webkit/api/public/WebRect.h"
43 #include "webkit/api/public/WebURLRequest.h" 44 #include "webkit/api/public/WebURLRequest.h"
44 #include "webkit/api/src/WrappedResourceRequest.h" 45 #include "webkit/api/src/WrappedResourceRequest.h"
45 #include "webkit/glue/glue_util.h" 46 #include "webkit/glue/glue_util.h"
46 #include "webkit/glue/webframe_impl.h" 47 #include "webkit/glue/webframe_impl.h"
47 #include "webkit/glue/webkit_glue.h" 48 #include "webkit/glue/webkit_glue.h"
48 #include "webkit/glue/webview_delegate.h" 49 #include "webkit/glue/webview_delegate.h"
49 #include "webkit/glue/webview_impl.h" 50 #include "webkit/glue/webview_impl.h"
50 #include "webkit/glue/webwidget_impl.h" 51 #include "webkit/glue/webwidget_impl.h"
51 52
53 using WebCore::PopupContainer;
54 using WebCore::PopupItem;
55
52 using WebKit::WebCursorInfo; 56 using WebKit::WebCursorInfo;
53 using WebKit::WebInputEvent; 57 using WebKit::WebInputEvent;
54 using WebKit::WebMouseEvent; 58 using WebKit::WebMouseEvent;
59 using WebKit::WebPopupMenuInfo;
55 using WebKit::WebRect; 60 using WebKit::WebRect;
56 using WebKit::WebURLRequest; 61 using WebKit::WebURLRequest;
62 using WebKit::WebVector;
57 using WebKit::WrappedResourceRequest; 63 using WebKit::WrappedResourceRequest;
58 64
59 // Callback class that's given to the WebViewDelegate during a file choose 65 // Callback class that's given to the WebViewDelegate during a file choose
60 // operation. 66 // operation.
61 class WebFileChooserCallbackImpl : public WebFileChooserCallback { 67 class WebFileChooserCallbackImpl : public WebFileChooserCallback {
62 public: 68 public:
63 WebFileChooserCallbackImpl(PassRefPtr<WebCore::FileChooser> file_chooser) 69 WebFileChooserCallbackImpl(PassRefPtr<WebCore::FileChooser> file_chooser)
64 : file_chooser_(file_chooser) { 70 : file_chooser_(file_chooser) {
65 } 71 }
66 72
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 FilePath suggestion; 543 FilePath suggestion;
538 if (fileChooser->filenames().size() > 0) 544 if (fileChooser->filenames().size() > 0)
539 suggestion = FilePath( 545 suggestion = FilePath(
540 webkit_glue::StringToFilePathString(fileChooser->filenames()[0])); 546 webkit_glue::StringToFilePathString(fileChooser->filenames()[0]));
541 547
542 WebFileChooserCallbackImpl* chooser = 548 WebFileChooserCallbackImpl* chooser =
543 new WebFileChooserCallbackImpl(fileChooser); 549 new WebFileChooserCallbackImpl(fileChooser);
544 delegate->RunFileChooser(multiple_files, string16(), suggestion, chooser); 550 delegate->RunFileChooser(multiple_files, string16(), suggestion, chooser);
545 } 551 }
546 552
547 void ChromeClientImpl::popupOpened(WebCore::PopupContainer* popup_container, 553 void ChromeClientImpl::popupOpened(PopupContainer* popup_container,
548 const WebCore::IntRect& bounds, 554 const WebCore::IntRect& bounds,
549 bool activatable, 555 bool activatable,
550 bool handle_external) { 556 bool handle_externally) {
551 if (handle_external) {
552 // We're going to handle the popup with native controls by the external
553 // embedder.
554 popupOpenedInternal(popup_container, bounds, activatable);
555 return;
556 }
557
558 WebViewDelegate* delegate = webview_->delegate();
559 if (delegate) {
560 WebWidgetImpl* webwidget =
561 static_cast<WebWidgetImpl*>(delegate->CreatePopupWidget(webview_,
562 activatable));
563 webwidget->Init(popup_container, webkit_glue::IntRectToWebRect(bounds));
564 }
565 }
566
567 void ChromeClientImpl::popupOpenedInternal(
568 WebCore::PopupContainer* popup_container,
569 const WebCore::IntRect& bounds,
570 bool activatable) {
571 WebViewDelegate* delegate = webview_->delegate(); 557 WebViewDelegate* delegate = webview_->delegate();
572 if (!delegate) 558 if (!delegate)
573 return; 559 return;
574 560
575 WebWidgetImpl* webwidget = 561 WebWidget* webwidget;
576 static_cast<WebWidgetImpl*>(delegate->CreatePopupWidget(webview_, 562 if (handle_externally) {
577 activatable)); 563 WebPopupMenuInfo popup_info;
578 // Convert WebKit types for Chromium. 564 GetPopupMenuInfo(popup_container, &popup_info);
579 std::vector<WebMenuItem> popup_items; 565 webwidget = delegate->CreatePopupWidgetWithInfo(webview_, popup_info);
580 const WTF::Vector<WebCore::PopupItem*>& items = popup_container->popupData(); 566 } else {
581 for (int i = 0; i < static_cast<int>(items.size()); ++i) { 567 webwidget = delegate->CreatePopupWidget(webview_, activatable);
582 WebMenuItem menu_item;
583 menu_item.label = webkit_glue::StringToString16(items[i]->label);
584 menu_item.enabled = items[i]->enabled;
585 switch (items[i]->type) {
586 case WebCore::PopupItem::TypeOption:
587 menu_item.type = WebMenuItem::OPTION;
588 break;
589 case WebCore::PopupItem::TypeGroup:
590 menu_item.type = WebMenuItem::GROUP;
591 break;
592 case WebCore::PopupItem::TypeSeparator:
593 menu_item.type = WebMenuItem::SEPARATOR;
594 break;
595 default:
596 NOTIMPLEMENTED();
597 }
598 popup_items.push_back(menu_item);
599 } 568 }
600 569
601 webwidget->InitWithItems(popup_container, 570 static_cast<WebWidgetImpl*>(webwidget)->Init(
602 webkit_glue::IntRectToWebRect(bounds), 571 popup_container, webkit_glue::IntRectToWebRect(bounds));
603 popup_container->menuItemHeight(),
604 popup_container->selectedIndex(),
605 popup_items);
606 } 572 }
607 573
608 void ChromeClientImpl::SetCursor(const WebCursorInfo& cursor) { 574 void ChromeClientImpl::SetCursor(const WebCursorInfo& cursor) {
609 if (ignore_next_set_cursor_) { 575 if (ignore_next_set_cursor_) {
610 ignore_next_set_cursor_ = false; 576 ignore_next_set_cursor_ = false;
611 return; 577 return;
612 } 578 }
613 579
614 WebViewDelegate* delegate = webview_->delegate(); 580 WebViewDelegate* delegate = webview_->delegate();
615 if (delegate) 581 if (delegate)
616 delegate->SetCursor(webview_, cursor); 582 delegate->SetCursor(webview_, cursor);
617 } 583 }
618 584
619 void ChromeClientImpl::SetCursorForPlugin(const WebCursorInfo& cursor) { 585 void ChromeClientImpl::SetCursorForPlugin(const WebCursorInfo& cursor) {
620 SetCursor(cursor); 586 SetCursor(cursor);
621 // Currently, Widget::setCursor is always called after this function in 587 // Currently, Widget::setCursor is always called after this function in
622 // EventHandler.cpp and since we don't want that we set a flag indicating 588 // EventHandler.cpp and since we don't want that we set a flag indicating
623 // that the next SetCursor call is to be ignored. 589 // that the next SetCursor call is to be ignored.
624 ignore_next_set_cursor_ = true; 590 ignore_next_set_cursor_ = true;
625 } 591 }
626 592
627 void ChromeClientImpl::formStateDidChange(const WebCore::Node*) { 593 void ChromeClientImpl::formStateDidChange(const WebCore::Node*) {
628 WebViewDelegate* delegate = webview_->delegate(); 594 WebViewDelegate* delegate = webview_->delegate();
629 if (delegate) 595 if (delegate)
630 delegate->OnNavStateChanged(webview_); 596 delegate->OnNavStateChanged(webview_);
631 } 597 }
598
599 void ChromeClientImpl::GetPopupMenuInfo(PopupContainer* popup_container,
600 WebPopupMenuInfo* info) {
601 const Vector<PopupItem*>& input_items = popup_container->popupData();
602
603 WebVector<WebPopupMenuInfo::Item> output_items(input_items.size());
604
605 for (size_t i = 0; i < input_items.size(); ++i) {
606 const PopupItem& input_item = *input_items[i];
607 WebPopupMenuInfo::Item& output_item = output_items[i];
608
609 output_item.label = webkit_glue::StringToWebString(input_item.label);
610 output_item.enabled = input_item.enabled;
611
612 switch (input_item.type) {
613 case PopupItem::TypeOption:
614 output_item.type = WebPopupMenuInfo::Item::Option;
615 break;
616 case PopupItem::TypeGroup:
617 output_item.type = WebPopupMenuInfo::Item::Group;
618 break;
619 case PopupItem::TypeSeparator:
620 output_item.type = WebPopupMenuInfo::Item::Separator;
621 break;
622 default:
623 NOTREACHED();
624 }
625 }
626
627 info->itemHeight = popup_container->menuItemHeight();
628 info->selectedIndex = popup_container->selectedIndex();
629 info->items.swap(output_items);
630 }
OLDNEW
« no previous file with comments | « webkit/glue/chrome_client_impl.h ('k') | webkit/glue/webmenuitem.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698