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

Unified Diff: chrome/browser/extensions/extension_tabs_module.cc

Issue 100164: extensions api: windows.removeWindow(), events: onWindowCreated, onWindowRemoved (Closed)
Patch Set: touch grd to avoid clobber build Created 11 years, 8 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/browser/extensions/extension_tabs_module.h ('k') | chrome/renderer/renderer_resources.grd » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/extension_tabs_module.cc
diff --git a/chrome/browser/extensions/extension_tabs_module.cc b/chrome/browser/extensions/extension_tabs_module.cc
index 67f4cc677a6ebc76972d762522684220d9431bca..269ffcebc23a35b6267a41ecf7a7dfc98ef9c562 100644
--- a/chrome/browser/extensions/extension_tabs_module.cc
+++ b/chrome/browser/extensions/extension_tabs_module.cc
@@ -70,10 +70,13 @@ bool GetWindowsFunction::RunImpl() {
result_.reset(new ListValue());
for (BrowserList::const_iterator browser = BrowserList::begin();
browser != BrowserList::end(); ++browser) {
- if (all_windows || (window_ids.find(ExtensionTabUtil::GetWindowId(*browser))
- != window_ids.end())) {
- static_cast<ListValue*>(result_.get())->Append(
+ // Only examine browsers in the current profile.
+ if ((*browser)->profile() == profile()) {
+ if (all_windows || (window_ids.find(ExtensionTabUtil::
+ GetWindowId(*browser)) != window_ids.end())) {
+ static_cast<ListValue*>(result_.get())->Append(
CreateWindowValue(*browser));
+ }
}
}
@@ -146,11 +149,42 @@ bool CreateWindowFunction::RunImpl() {
return true;
}
+bool RemoveWindowFunction::RunImpl() {
+ if (!args_->IsType(Value::TYPE_INTEGER))
+ return false;
+
+ int window_id;
+ if (!args_->GetAsInteger(&window_id))
+ return false;
+
+ Browser* target = NULL;
+ for (BrowserList::const_iterator browser = BrowserList::begin();
+ browser != BrowserList::end(); ++browser) {
+ // Only examine browsers in the current profile.
+ if ((*browser)->profile() == profile()) {
+ if (ExtensionTabUtil::GetWindowId(*browser) == window_id) {
+ target = *browser;
+ break;
+ }
+ }
+ }
+
+ if (target == NULL) {
+ // TODO(rafaelw): need error message.
+ return false;
+ }
+
+ target->CloseWindow();
+
+ return true;
+}
+
+
bool GetTabsForWindowFunction::RunImpl() {
if (!args_->IsType(Value::TYPE_NULL))
return false;
- Browser* browser = BrowserList::GetLastActive();
+ Browser* browser = dispatcher_->browser();
if (!browser)
return false;
« no previous file with comments | « chrome/browser/extensions/extension_tabs_module.h ('k') | chrome/renderer/renderer_resources.grd » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698