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
{
17 content::RenderView
* TabFinder::Find(int tab_id
) {
18 TabFinder
finder(tab_id
);
19 RenderView::ForEach(&finder
);
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())
33 ExtensionHelper
* helper
= ExtensionHelper::Get(render_view
);
34 if (helper
&& helper
->tab_id() == tab_id_
)
40 } // namespace extensions