move popup related code to nativewindow

This commit is contained in:
Heilig Benedek 2017-05-26 03:38:27 +02:00
parent 039908a244
commit 192cd7787b
11 changed files with 95 additions and 99 deletions

View file

@ -7,6 +7,7 @@
#include <string>
#include <vector>
#include "atom/browser/api/atom_api_web_contents.h"
#include "atom/browser/native_browser_view_views.h"
#include "atom/browser/ui/views/menu_bar.h"
#include "atom/browser/window_list.h"
@ -319,6 +320,8 @@ NativeWindowViews::NativeWindowViews(
window_->CenterWindow(size);
Layout();
autofill_popup_.reset(new AutofillPopup(GetNativeView()));
#if defined(OS_WIN)
// Save initial window state.
if (fullscreen)
@ -1269,6 +1272,26 @@ void NativeWindowViews::HandleKeyboardEvent(
}
}
void NativeWindowViews::ShowAutofillPopup(
content::RenderFrameHost* frame_host,
const gfx::RectF& bounds,
const std::vector<base::string16>& values,
const std::vector<base::string16>& labels) {
auto wc = atom::api::WebContents::FromWrappedClass(
v8::Isolate::GetCurrent(), web_contents());
autofill_popup_->CreateView(
frame_host,
wc->IsOffScreenOrEmbedderOffscreen(),
widget(),
bounds);
autofill_popup_->SetItems(values, labels);
}
void NativeWindowViews::HideAutofillPopup(
content::RenderFrameHost* frame_host) {
autofill_popup_->Hide();
}
void NativeWindowViews::Layout() {
const auto size = GetContentsBounds().size();
const auto menu_bar_bounds =