OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/base64.h" | 10 #include "base/base64.h" |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/memory/ref_counted_memory.h" | 13 #include "base/memory/ref_counted_memory.h" |
14 #include "base/message_loop.h" | 14 #include "base/message_loop.h" |
15 #include "base/stl_util.h" | 15 #include "base/stl_util.h" |
16 #include "base/string16.h" | 16 #include "base/string16.h" |
17 #include "base/string_number_conversions.h" | 17 #include "base/string_number_conversions.h" |
18 #include "base/string_util.h" | 18 #include "base/string_util.h" |
19 #include "base/stringprintf.h" | 19 #include "base/stringprintf.h" |
20 #include "base/utf_string_conversions.h" | 20 #include "base/utf_string_conversions.h" |
21 #include "chrome/browser/extensions/extension_function_dispatcher.h" | 21 #include "chrome/browser/extensions/extension_function_dispatcher.h" |
22 #include "chrome/browser/extensions/extension_host.h" | 22 #include "chrome/browser/extensions/extension_host.h" |
23 #include "chrome/browser/extensions/extension_service.h" | 23 #include "chrome/browser/extensions/extension_service.h" |
24 #include "chrome/browser/extensions/extension_tab_helper.h" | |
24 #include "chrome/browser/extensions/extension_tab_util.h" | 25 #include "chrome/browser/extensions/extension_tab_util.h" |
25 #include "chrome/browser/extensions/extension_tabs_module_constants.h" | 26 #include "chrome/browser/extensions/extension_tabs_module_constants.h" |
26 #include "chrome/browser/extensions/extension_window_controller.h" | 27 #include "chrome/browser/extensions/extension_window_controller.h" |
27 #include "chrome/browser/extensions/extension_window_list.h" | 28 #include "chrome/browser/extensions/extension_window_list.h" |
28 #include "chrome/browser/net/url_fixer_upper.h" | 29 #include "chrome/browser/net/url_fixer_upper.h" |
29 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 30 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
30 #include "chrome/browser/profiles/profile.h" | 31 #include "chrome/browser/profiles/profile.h" |
31 #include "chrome/browser/sessions/restore_tab_helper.h" | 32 #include "chrome/browser/sessions/restore_tab_helper.h" |
32 #include "chrome/browser/tabs/tab_strip_model.h" | 33 #include "chrome/browser/tabs/tab_strip_model.h" |
33 #include "chrome/browser/translate/translate_tab_helper.h" | 34 #include "chrome/browser/translate/translate_tab_helper.h" |
(...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
608 if (extension_id.empty()) { | 609 if (extension_id.empty()) { |
609 new_window = Browser::CreateForType(window_type, window_profile); | 610 new_window = Browser::CreateForType(window_type, window_profile); |
610 new_window->window()->SetBounds(window_bounds); | 611 new_window->window()->SetBounds(window_bounds); |
611 } else { | 612 } else { |
612 new_window = Browser::CreateForApp( | 613 new_window = Browser::CreateForApp( |
613 window_type, | 614 window_type, |
614 web_app::GenerateApplicationNameFromExtensionId(extension_id), | 615 web_app::GenerateApplicationNameFromExtensionId(extension_id), |
615 (window_type == Browser::TYPE_PANEL ? panel_bounds : popup_bounds), | 616 (window_type == Browser::TYPE_PANEL ? panel_bounds : popup_bounds), |
616 window_profile); | 617 window_profile); |
617 } | 618 } |
618 for (std::vector<GURL>::iterator i = urls.begin(); i != urls.end(); ++i) | 619 for (std::vector<GURL>::iterator i = urls.begin(); i != urls.end(); ++i) { |
619 new_window->AddSelectedTabWithURL(*i, content::PAGE_TRANSITION_LINK); | 620 TabContentsWrapper* tab = new_window->AddSelectedTabWithURL( |
621 *i, content::PAGE_TRANSITION_LINK); | |
622 if (window_type == Browser::TYPE_PANEL) | |
623 tab->extension_tab_helper()->SetExtensionAppIconById(extension_id); | |
Mihai Parparita -not on Chrome
2012/03/05 23:28:29
Drive-by: Why can't SetExtensionAppById be used? T
stevenjb
2012/03/05 23:50:55
I tried that first, but it triggered a DCHECK on e
| |
624 } | |
620 if (contents) { | 625 if (contents) { |
621 TabStripModel* target_tab_strip = new_window->tabstrip_model(); | 626 TabStripModel* target_tab_strip = new_window->tabstrip_model(); |
622 target_tab_strip->InsertTabContentsAt(urls.size(), contents, | 627 target_tab_strip->InsertTabContentsAt(urls.size(), contents, |
623 TabStripModel::ADD_NONE); | 628 TabStripModel::ADD_NONE); |
624 } else if (urls.empty()) { | 629 } else if (urls.empty()) { |
625 new_window->NewTab(); | 630 new_window->NewTab(); |
626 } | 631 } |
627 new_window->SelectNumberedTab(0); | 632 new_window->SelectNumberedTab(0); |
628 | 633 |
629 // Unlike other window types, Panels do not take focus by default. | 634 // Unlike other window types, Panels do not take focus by default. |
(...skipping 1173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1803 // called for every API call the extension made. | 1808 // called for every API call the extension made. |
1804 GotLanguage(language); | 1809 GotLanguage(language); |
1805 } | 1810 } |
1806 | 1811 |
1807 void DetectTabLanguageFunction::GotLanguage(const std::string& language) { | 1812 void DetectTabLanguageFunction::GotLanguage(const std::string& language) { |
1808 result_.reset(Value::CreateStringValue(language.c_str())); | 1813 result_.reset(Value::CreateStringValue(language.c_str())); |
1809 SendResponse(true); | 1814 SendResponse(true); |
1810 | 1815 |
1811 Release(); // Balanced in Run() | 1816 Release(); // Balanced in Run() |
1812 } | 1817 } |
OLD | NEW |