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 <limits> | 8 #include <limits> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
70 #include "ui/base/ui_base_types.h" | 70 #include "ui/base/ui_base_types.h" |
71 #include "ui/gfx/codec/jpeg_codec.h" | 71 #include "ui/gfx/codec/jpeg_codec.h" |
72 #include "ui/gfx/codec/png_codec.h" | 72 #include "ui/gfx/codec/png_codec.h" |
73 | 73 |
74 #if defined(USE_ASH) | 74 #if defined(USE_ASH) |
75 #include "ash/ash_switches.h" | 75 #include "ash/ash_switches.h" |
76 #include "base/command_line.h" | 76 #include "base/command_line.h" |
77 #include "chrome/browser/ui/views/ash/panel_view_aura.h" | 77 #include "chrome/browser/ui/views/ash/panel_view_aura.h" |
78 #endif | 78 #endif |
79 | 79 |
80 #if defined(OS_WIN) | |
81 #include "base/win/metro.h" | |
82 #endif // OS_WIN | |
83 | |
80 namespace Get = extensions::api::windows::Get; | 84 namespace Get = extensions::api::windows::Get; |
81 namespace GetAll = extensions::api::windows::GetAll; | 85 namespace GetAll = extensions::api::windows::GetAll; |
82 namespace GetCurrent = extensions::api::windows::GetCurrent; | 86 namespace GetCurrent = extensions::api::windows::GetCurrent; |
83 namespace GetLastFocused = extensions::api::windows::GetLastFocused; | 87 namespace GetLastFocused = extensions::api::windows::GetLastFocused; |
84 namespace errors = extension_manifest_errors; | 88 namespace errors = extension_manifest_errors; |
85 namespace keys = extension_tabs_module_constants; | 89 namespace keys = extension_tabs_module_constants; |
86 | 90 |
87 using content::NavigationController; | 91 using content::NavigationController; |
88 using content::NavigationEntry; | 92 using content::NavigationEntry; |
89 using content::OpenURLParams; | 93 using content::OpenURLParams; |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
208 | 212 |
209 QueryArg ParseBoolQueryArg(base::DictionaryValue* query, const char* key) { | 213 QueryArg ParseBoolQueryArg(base::DictionaryValue* query, const char* key) { |
210 if (query->HasKey(key)) { | 214 if (query->HasKey(key)) { |
211 bool value = false; | 215 bool value = false; |
212 CHECK(query->GetBoolean(key, &value)); | 216 CHECK(query->GetBoolean(key, &value)); |
213 return value ? MATCH_TRUE : MATCH_FALSE; | 217 return value ? MATCH_TRUE : MATCH_FALSE; |
214 } | 218 } |
215 return NOT_SET; | 219 return NOT_SET; |
216 } | 220 } |
217 | 221 |
222 Browser* CreateBrowserWindow(const Browser::CreateParams& params, | |
223 Profile* profile, | |
224 const std::string& extension_id) { | |
225 bool use_existing_browser_window = false; | |
226 | |
227 #if defined(OS_WIN) | |
228 // In Windows 8 metro mode we only allow new windows to be created if the | |
229 // extension id is valid in which case it is created as an application window | |
230 if (extension_id.empty() && base::win::GetMetroModule()) | |
231 use_existing_browser_window = true; | |
232 #endif // OS_WIN | |
233 | |
234 Browser* new_window = NULL; | |
235 if (use_existing_browser_window) | |
236 new_window = browser::FindTabbedBrowser(profile, false); | |
Aaron Boodman
2012/06/06 01:46:26
Document the magic boolean or make it a named cons
ananta
2012/06/06 01:52:22
Done.
| |
237 | |
238 if (!new_window) | |
239 Browser* new_window = Browser::CreateWithParams(params); | |
240 return new_window; | |
241 } | |
242 | |
218 } // namespace | 243 } // namespace |
219 | 244 |
220 // Windows --------------------------------------------------------------------- | 245 // Windows --------------------------------------------------------------------- |
221 | 246 |
222 bool GetWindowFunction::RunImpl() { | 247 bool GetWindowFunction::RunImpl() { |
223 scoped_ptr<Get::Params> params(Get::Params::Create(*args_)); | 248 scoped_ptr<Get::Params> params(Get::Params::Create(*args_)); |
224 EXTENSION_FUNCTION_VALIDATE(params.get()); | 249 EXTENSION_FUNCTION_VALIDATE(params.get()); |
225 | 250 |
226 bool populate_tabs = false; | 251 bool populate_tabs = false; |
227 if (params->get_info.get() && params->get_info->populate.get()) | 252 if (params->get_info.get() && params->get_info->populate.get()) |
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
578 create_params = Browser::CreateParams(window_type, window_profile); | 603 create_params = Browser::CreateParams(window_type, window_profile); |
579 create_params.initial_bounds = window_bounds; | 604 create_params.initial_bounds = window_bounds; |
580 } else { | 605 } else { |
581 create_params = Browser::CreateParams::CreateForApp( | 606 create_params = Browser::CreateParams::CreateForApp( |
582 window_type, | 607 window_type, |
583 web_app::GenerateApplicationNameFromExtensionId(extension_id), | 608 web_app::GenerateApplicationNameFromExtensionId(extension_id), |
584 (window_type == Browser::TYPE_PANEL ? panel_bounds : popup_bounds), | 609 (window_type == Browser::TYPE_PANEL ? panel_bounds : popup_bounds), |
585 window_profile); | 610 window_profile); |
586 } | 611 } |
587 create_params.initial_show_state = ui::SHOW_STATE_NORMAL; | 612 create_params.initial_show_state = ui::SHOW_STATE_NORMAL; |
588 Browser* new_window = Browser::CreateWithParams(create_params); | 613 |
614 Browser* new_window = CreateBrowserWindow(create_params, window_profile, | |
615 extension_id); | |
589 | 616 |
590 for (std::vector<GURL>::iterator i = urls.begin(); i != urls.end(); ++i) { | 617 for (std::vector<GURL>::iterator i = urls.begin(); i != urls.end(); ++i) { |
591 TabContentsWrapper* tab = new_window->AddSelectedTabWithURL( | 618 TabContentsWrapper* tab = new_window->AddSelectedTabWithURL( |
592 *i, content::PAGE_TRANSITION_LINK); | 619 *i, content::PAGE_TRANSITION_LINK); |
593 if (window_type == Browser::TYPE_PANEL) | 620 if (window_type == Browser::TYPE_PANEL) |
594 tab->extension_tab_helper()->SetExtensionAppIconById(extension_id); | 621 tab->extension_tab_helper()->SetExtensionAppIconById(extension_id); |
595 } | 622 } |
596 if (contents) { | 623 if (contents) { |
597 TabStripModel* target_tab_strip = new_window->tab_strip_model(); | 624 TabStripModel* target_tab_strip = new_window->tab_strip_model(); |
598 target_tab_strip->InsertTabContentsAt(urls.size(), contents, | 625 target_tab_strip->InsertTabContentsAt(urls.size(), contents, |
(...skipping 1185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1784 // called for every API call the extension made. | 1811 // called for every API call the extension made. |
1785 GotLanguage(language); | 1812 GotLanguage(language); |
1786 } | 1813 } |
1787 | 1814 |
1788 void DetectTabLanguageFunction::GotLanguage(const std::string& language) { | 1815 void DetectTabLanguageFunction::GotLanguage(const std::string& language) { |
1789 result_.reset(Value::CreateStringValue(language.c_str())); | 1816 result_.reset(Value::CreateStringValue(language.c_str())); |
1790 SendResponse(true); | 1817 SendResponse(true); |
1791 | 1818 |
1792 Release(); // Balanced in Run() | 1819 Release(); // Balanced in Run() |
1793 } | 1820 } |
OLD | NEW |