Reland the ULONG -> SIZE_T change from 317177
[chromium-blink-merge.git] / extensions / renderer / tab_finder.cc
blobca8b602dcf95d929ca4de16c92631e69cdbbba6b
1 // Copyright (c) 2012 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.
5 #include "extensions/renderer/tab_finder.h"
7 #include "content/public/renderer/render_view.h"
8 #include "extensions/renderer/extension_helper.h"
9 #include "third_party/WebKit/public/web/WebFrame.h"
10 #include "third_party/WebKit/public/web/WebView.h"
12 using content::RenderView;
14 namespace extensions {
16 // static
17 content::RenderView* TabFinder::Find(int tab_id) {
18 TabFinder finder(tab_id);
19 RenderView::ForEach(&finder);
20 return finder.view_;
23 TabFinder::TabFinder(int tab_id) : tab_id_(tab_id), view_(NULL) {}
25 TabFinder::~TabFinder() {}
27 // Note: Visit returns false to terminate the iteration.
28 bool TabFinder::Visit(RenderView* render_view) {
29 // Only interested in the top frame.
30 if (render_view->GetWebView()->mainFrame()->parent())
31 return true;
33 ExtensionHelper* helper = ExtensionHelper::Get(render_view);
34 if (helper && helper->tab_id() == tab_id_)
35 view_ = render_view;
37 return !view_;
40 } // namespace extensions