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

Unified 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/extensions/tab_finder.cc
diff --git a/chrome/renderer/extensions/tab_finder.cc b/chrome/renderer/extensions/tab_finder.cc
new file mode 100644
index 0000000000000000000000000000000000000000..b8217935777726ee9df12e3567b15bf48375f110
--- /dev/null
+++ b/chrome/renderer/extensions/tab_finder.cc
@@ -0,0 +1,40 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/renderer/extensions/tab_finder.h"
+
+#include "chrome/renderer/extensions/extension_helper.h"
+#include "content/public/renderer/render_view.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
+
+using content::RenderView;
+
+namespace extensions {
+
+// static
+content::RenderView* TabFinder::Find(int tab_id) {
+ TabFinder finder(tab_id);
+ RenderView::ForEach(&finder);
+ return finder.view_;
+}
+
+TabFinder::TabFinder(int tab_id) : tab_id_(tab_id), view_(NULL) {}
+
+TabFinder::~TabFinder() {}
+
+// Note: Visit returns false to terminate the iteration.
+bool TabFinder::Visit(RenderView* render_view) {
+ // Only interested in the top frame.
+ if (render_view->GetWebView()->mainFrame()->parent())
+ return true;
+
+ ExtensionHelper* helper = ExtensionHelper::Get(render_view);
+ if (helper && helper->tab_id() == tab_id_)
+ view_ = render_view;
+
+ return !view_;
+}
+
+} // namespace extensions
« 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