OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/extensions/extension_tabs_module.h" | 5 #include "chrome/browser/extensions/extension_tabs_module.h" |
6 | 6 |
7 #include "base/base64.h" | 7 #include "base/base64.h" |
8 #include "base/string_number_conversions.h" | 8 #include "base/string_number_conversions.h" |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 window_type = Browser::TYPE_POPUP; | 366 window_type = Browser::TYPE_POPUP; |
367 } else { | 367 } else { |
368 EXTENSION_FUNCTION_VALIDATE(false); | 368 EXTENSION_FUNCTION_VALIDATE(false); |
369 } | 369 } |
370 } | 370 } |
371 } | 371 } |
372 | 372 |
373 Browser* new_window = new Browser(window_type, window_profile); | 373 Browser* new_window = new Browser(window_type, window_profile); |
374 new_window->CreateBrowserWindow(); | 374 new_window->CreateBrowserWindow(); |
375 new_window->AddTabWithURL(url, GURL(), PageTransition::LINK, -1, | 375 new_window->AddTabWithURL(url, GURL(), PageTransition::LINK, -1, |
376 TabStripModel::ADD_SELECTED, NULL, std::string()); | 376 TabStripModel::ADD_SELECTED, NULL, std::string(), |
| 377 &new_window); |
377 | 378 |
378 new_window->window()->SetBounds(bounds); | 379 new_window->window()->SetBounds(bounds); |
379 new_window->window()->Show(); | 380 new_window->window()->Show(); |
380 | 381 |
381 if (new_window->profile()->IsOffTheRecord() && !include_incognito()) { | 382 if (new_window->profile()->IsOffTheRecord() && !include_incognito()) { |
382 // Don't expose incognito windows if the extension isn't allowed. | 383 // Don't expose incognito windows if the extension isn't allowed. |
383 result_.reset(Value::CreateNullValue()); | 384 result_.reset(Value::CreateNullValue()); |
384 } else { | 385 } else { |
385 result_.reset(ExtensionTabUtil::CreateWindowValue(new_window, false)); | 386 result_.reset(ExtensionTabUtil::CreateWindowValue(new_window, false)); |
386 } | 387 } |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
574 index = -1; | 575 index = -1; |
575 } | 576 } |
576 if (index > tab_strip->count()) { | 577 if (index > tab_strip->count()) { |
577 index = tab_strip->count(); | 578 index = tab_strip->count(); |
578 } | 579 } |
579 | 580 |
580 int add_types = selected ? TabStripModel::ADD_SELECTED : | 581 int add_types = selected ? TabStripModel::ADD_SELECTED : |
581 TabStripModel::ADD_NONE; | 582 TabStripModel::ADD_NONE; |
582 add_types |= TabStripModel::ADD_FORCE_INDEX; | 583 add_types |= TabStripModel::ADD_FORCE_INDEX; |
583 TabContents* contents = browser->AddTabWithURL(url, GURL(), | 584 TabContents* contents = browser->AddTabWithURL(url, GURL(), |
584 PageTransition::LINK, index, add_types, NULL, std::string()); | 585 PageTransition::LINK, index, add_types, NULL, std::string(), &browser); |
585 index = tab_strip->GetIndexOfTabContents(contents); | 586 index = browser->tabstrip_model()->GetIndexOfTabContents(contents); |
586 | 587 |
587 if (selected) | 588 if (selected) |
588 contents->Focus(); | 589 contents->Focus(); |
589 | 590 |
590 // Return data about the newly created tab. | 591 // Return data about the newly created tab. |
591 if (has_callback()) | 592 if (has_callback()) |
592 result_.reset(ExtensionTabUtil::CreateTabValue(contents, tab_strip, index)); | 593 result_.reset(ExtensionTabUtil::CreateTabValue(contents, |
| 594 browser->tabstrip_model(), |
| 595 index)); |
593 | 596 |
594 return true; | 597 return true; |
595 } | 598 } |
596 | 599 |
597 bool GetTabFunction::RunImpl() { | 600 bool GetTabFunction::RunImpl() { |
598 int tab_id; | 601 int tab_id; |
599 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &tab_id)); | 602 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &tab_id)); |
600 | 603 |
601 TabStripModel* tab_strip = NULL; | 604 TabStripModel* tab_strip = NULL; |
602 TabContents* contents = NULL; | 605 TabContents* contents = NULL; |
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1097 } | 1100 } |
1098 | 1101 |
1099 static GURL ResolvePossiblyRelativeURL(std::string url_string, | 1102 static GURL ResolvePossiblyRelativeURL(std::string url_string, |
1100 Extension* extension) { | 1103 Extension* extension) { |
1101 GURL url = GURL(url_string); | 1104 GURL url = GURL(url_string); |
1102 if (!url.is_valid()) | 1105 if (!url.is_valid()) |
1103 url = extension->GetResourceURL(url_string); | 1106 url = extension->GetResourceURL(url_string); |
1104 | 1107 |
1105 return url; | 1108 return url; |
1106 } | 1109 } |
OLD | NEW |