Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(327)

Side by Side Diff: chrome/renderer/extensions/tab_finder.cc

Issue 10443105: Take 2 at implementing activeTab. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: empty -> is_empty Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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 "chrome/renderer/extensions/extension_helper.h"
8 #include "content/public/renderer/render_view.h"
9 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
10 #include "third_party/WebKit/Source/WebKit/chromium/public/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
OLDNEW
« no previous file with comments | « chrome/renderer/extensions/tab_finder.h ('k') | chrome/renderer/extensions/user_script_scheduler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698