| OLD | NEW |
| (Empty) |
| 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. | |
| 4 | |
| 5 #include "chrome/renderer/extensions/tab_finder.h" | |
| 6 | |
| 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" | |
| 11 | |
| 12 using content::RenderView; | |
| 13 | |
| 14 namespace extensions { | |
| 15 | |
| 16 // static | |
| 17 content::RenderView* TabFinder::Find(int tab_id) { | |
| 18 TabFinder finder(tab_id); | |
| 19 RenderView::ForEach(&finder); | |
| 20 return finder.view_; | |
| 21 } | |
| 22 | |
| 23 TabFinder::TabFinder(int tab_id) : tab_id_(tab_id), view_(NULL) {} | |
| 24 | |
| 25 TabFinder::~TabFinder() {} | |
| 26 | |
| 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; | |
| 32 | |
| 33 ExtensionHelper* helper = ExtensionHelper::Get(render_view); | |
| 34 if (helper && helper->tab_id() == tab_id_) | |
| 35 view_ = render_view; | |
| 36 | |
| 37 return !view_; | |
| 38 } | |
| 39 | |
| 40 } // namespace extensions | |
| OLD | NEW |