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

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

Issue 115337: TBR Revert "Revert "implemented extensions api windows.update()."" (Closed)
Patch Set: Created 11 years, 7 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
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 6e61976a90dc2547974783f0da2eca5b955f9d3d..09415f46f18b0180dec8f0a8b2af45a4530932a1 100644
--- a/chrome/browser/extensions/extension_tabs_module.cc
+++ b/chrome/browser/extensions/extension_tabs_module.cc
@@ -253,6 +253,55 @@ bool CreateWindowFunction::RunImpl() {
return true;
}
+bool UpdateWindowFunction::RunImpl() {
+ EXTENSION_FUNCTION_VALIDATE(args_->IsType(Value::TYPE_LIST));
+ const ListValue* args = static_cast<const ListValue*>(args_);
+ int window_id;
+ EXTENSION_FUNCTION_VALIDATE(args->GetInteger(0, &window_id));
+ DictionaryValue* update_props;
+ EXTENSION_FUNCTION_VALIDATE(args->GetDictionary(1, &update_props));
+
+ Browser* browser = GetBrowserInProfileWithId(profile(), window_id, &error_);
+ if (!browser)
+ return false;
+
+ gfx::Rect bounds = browser->window()->GetNormalBounds();
+ // Any part of the bounds can optionally be set by the caller.
+ int bounds_val;
+ if (update_props->HasKey(kLeftKey)) {
+ EXTENSION_FUNCTION_VALIDATE(update_props->GetInteger(kLeftKey,
+ &bounds_val));
+ bounds.set_x(bounds_val);
+ }
+
+ if (update_props->HasKey(kTopKey)) {
+ EXTENSION_FUNCTION_VALIDATE(update_props->GetInteger(kTopKey,
+ &bounds_val));
+ bounds.set_y(bounds_val);
+ }
+
+ if (update_props->HasKey(kWidthKey)) {
+ EXTENSION_FUNCTION_VALIDATE(update_props->GetInteger(kWidthKey,
+ &bounds_val));
+ bounds.set_width(bounds_val);
+ }
+
+ if (update_props->HasKey(kHeightKey)) {
+ EXTENSION_FUNCTION_VALIDATE(update_props->GetInteger(kHeightKey,
+ &bounds_val));
+ bounds.set_height(bounds_val);
+ }
+
+ // TODO(rafaelw): This call to SetBounds() ends up resulting in the target
+ // window being activated (pushed to the front). On win32, this appears to be
+ // the result of HWND event handling.
+ browser->window()->SetBounds(bounds);
+ // TODO(rafaelw): Support |focused|.
+ result_.reset(CreateWindowValue(browser, false));
+
+ return true;
+}
+
bool RemoveWindowFunction::RunImpl() {
int window_id;
EXTENSION_FUNCTION_VALIDATE(args_->GetAsInteger(&window_id));
@@ -576,10 +625,10 @@ static bool GetTabById(int tab_id, Profile* profile, Browser** browser,
if (ExtensionTabUtil::GetTabById(tab_id, profile, browser, tab_strip,
contents, tab_index))
return true;
-
+
if (error_message)
*error_message = ExtensionErrorUtils::FormatErrorMessage(
kTabNotFoundError, IntToString(tab_id));
-
+
return false;
}
« no previous file with comments | « chrome/browser/extensions/extension_tabs_module.h ('k') | chrome/renderer/extensions/extension_api_client_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698