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

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

Issue 7981040: Make chrome.tabs.update's tabId parameter optional. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Created 9 years, 3 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 219e36674dbe60ebe021bfd37ba6dfdbe67fd801..07145b5a0ddadf0b099b78bc06d48479abef53c7 100644
--- a/chrome/browser/extensions/extension_tabs_module.cc
+++ b/chrome/browser/extensions/extension_tabs_module.cc
@@ -892,18 +892,38 @@ UpdateTabFunction::UpdateTabFunction() {
}
bool UpdateTabFunction::RunImpl() {
- int tab_id;
- EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &tab_id));
DictionaryValue* update_props;
EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(1, &update_props));
- TabStripModel* tab_strip = NULL;
+ Value* tab_value = NULL;
Mihai Parparita -not on Chrome 2011/09/21 23:24:05 ExecuteCodeInTabFunction::RunImpl, ReloadTabFuncti
miket_OOO 2011/09/22 00:06:44 Yes, I agree. If I promise not to avoid doing it,
+ if (HasOptionalArgument(0)) {
+ EXTENSION_FUNCTION_VALIDATE(args_->Get(0, &tab_value));
+ }
+
+ int tab_id = -1;
TabContentsWrapper* contents = NULL;
+ if (tab_value == NULL || tab_value->IsType(Value::TYPE_NULL)) {
+ Browser* browser = GetCurrentBrowser();
+ if (!browser) {
+ error_ = keys::kNoCurrentWindowError;
+ return false;
+ }
+ contents = browser->tabstrip_model()->GetActiveTabContents();
+ if (!contents) {
+ error_ = keys::kNoSelectedTabError;
+ return false;
+ }
+ tab_id = ExtensionTabUtil::GetTabId(contents->tab_contents());
+ } else {
+ EXTENSION_FUNCTION_VALIDATE(tab_value->GetAsInteger(&tab_id));
+ }
+
int tab_index = -1;
+ TabStripModel* tab_strip = NULL;
if (!GetTabById(tab_id, profile(), include_incognito(),
- NULL, &tab_strip, &contents, &tab_index, &error_))
+ NULL, &tab_strip, &contents, &tab_index, &error_)) {
return false;
-
+ }
NavigationController& controller = contents->controller();
// TODO(rafaelw): handle setting remaining tab properties:

Powered by Google App Engine
This is Rietveld 408576698