Permalink
Browse files

Move window selection logic into WebPage

  • Loading branch information...
1 parent aaba4d1 commit 33bc195fe19101c1e8682f9526805737e447fc8e @mhoran mhoran committed Mar 28, 2012
Showing with 9 additions and 4 deletions.
  1. +7 −0 src/WebPage.cpp
  2. +1 −0 src/WebPage.h
  3. +1 −4 src/WindowFocus.cpp
View
@@ -267,3 +267,10 @@ QString WebPage::getWindowName() {
else
return "";
}
+
+bool WebPage::matchesWindowSelector(QString selector) {
+ return (selector == getWindowName() ||
+ selector == mainFrame()->title() ||
+ selector == mainFrame()->url().toString() ||
+ selector == uuid());
+}
View
@@ -25,6 +25,7 @@ class WebPage : public QWebPage {
QWebPage *createWindow(WebWindowType type);
QString uuid();
QString getWindowName();
+ bool matchesWindowSelector(QString);
public slots:
bool shouldInterruptJavaScript();
View
@@ -26,10 +26,7 @@ void WindowFocus::focusWindow(QString selector) {
while (pageIterator.hasNext()) {
WebPage *page = pageIterator.next();
- if (selector == page->getWindowName() ||
- selector == page->mainFrame()->title() ||
- selector == page->mainFrame()->url().toString() ||
- selector == page->uuid()) {
+ if (page->matchesWindowSelector(selector)) {
success(page);
return;
}

0 comments on commit 33bc195

Please sign in to comment.