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/api/tabs/tabs_api.h" | 5 #include "chrome/browser/extensions/api/tabs/tabs_api.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <algorithm> | 8 #include <algorithm> |
9 #include <limits> | 9 #include <limits> |
10 #include <memory> | 10 #include <memory> |
(...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
591 // Create a new BrowserWindow. | 591 // Create a new BrowserWindow. |
592 Browser::CreateParams create_params(window_type, window_profile); | 592 Browser::CreateParams create_params(window_type, window_profile); |
593 if (extension_id.empty()) { | 593 if (extension_id.empty()) { |
594 create_params.initial_bounds = window_bounds; | 594 create_params.initial_bounds = window_bounds; |
595 } else { | 595 } else { |
596 create_params = Browser::CreateParams::CreateForApp( | 596 create_params = Browser::CreateParams::CreateForApp( |
597 web_app::GenerateApplicationNameFromExtensionId(extension_id), | 597 web_app::GenerateApplicationNameFromExtensionId(extension_id), |
598 false /* trusted_source */, window_bounds, window_profile); | 598 false /* trusted_source */, window_bounds, window_profile); |
599 } | 599 } |
600 create_params.initial_show_state = ui::SHOW_STATE_NORMAL; | 600 create_params.initial_show_state = ui::SHOW_STATE_NORMAL; |
| 601 create_params.user_gesture = user_gesture(); |
601 if (create_data && create_data->state) { | 602 if (create_data && create_data->state) { |
602 create_params.initial_show_state = | 603 create_params.initial_show_state = |
603 ConvertToWindowShowState(create_data->state); | 604 ConvertToWindowShowState(create_data->state); |
604 } | 605 } |
605 | 606 |
606 Browser* new_window = new Browser(create_params); | 607 Browser* new_window = new Browser(create_params); |
607 | 608 |
608 for (const GURL& url : urls) { | 609 for (const GURL& url : urls) { |
609 chrome::NavigateParams navigate_params(new_window, url, | 610 chrome::NavigateParams navigate_params(new_window, url, |
610 ui::PAGE_TRANSITION_LINK); | 611 ui::PAGE_TRANSITION_LINK); |
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
997 options.opener_tab_id); | 998 options.opener_tab_id); |
998 AssignOptionalValue(params->create_properties.selected, options.active); | 999 AssignOptionalValue(params->create_properties.selected, options.active); |
999 // The 'active' property has replaced the 'selected' property. | 1000 // The 'active' property has replaced the 'selected' property. |
1000 AssignOptionalValue(params->create_properties.active, options.active); | 1001 AssignOptionalValue(params->create_properties.active, options.active); |
1001 AssignOptionalValue(params->create_properties.pinned, options.pinned); | 1002 AssignOptionalValue(params->create_properties.pinned, options.pinned); |
1002 AssignOptionalValue(params->create_properties.index, options.index); | 1003 AssignOptionalValue(params->create_properties.index, options.index); |
1003 AssignOptionalValue(params->create_properties.url, options.url); | 1004 AssignOptionalValue(params->create_properties.url, options.url); |
1004 | 1005 |
1005 std::string error; | 1006 std::string error; |
1006 std::unique_ptr<base::DictionaryValue> result( | 1007 std::unique_ptr<base::DictionaryValue> result( |
1007 ExtensionTabUtil::OpenTab(this, options, &error)); | 1008 ExtensionTabUtil::OpenTab(this, options, user_gesture(), &error)); |
1008 if (!result) | 1009 if (!result) |
1009 return RespondNow(Error(error)); | 1010 return RespondNow(Error(error)); |
1010 | 1011 |
1011 // Return data about the newly created tab. | 1012 // Return data about the newly created tab. |
1012 return RespondNow(has_callback() ? OneArgument(std::move(result)) | 1013 return RespondNow(has_callback() ? OneArgument(std::move(result)) |
1013 : NoArguments()); | 1014 : NoArguments()); |
1014 } | 1015 } |
1015 | 1016 |
1016 ExtensionFunction::ResponseAction TabsDuplicateFunction::Run() { | 1017 ExtensionFunction::ResponseAction TabsDuplicateFunction::Run() { |
1017 std::unique_ptr<tabs::Duplicate::Params> params( | 1018 std::unique_ptr<tabs::Duplicate::Params> params( |
(...skipping 1097 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2115 params->tab_id | 2116 params->tab_id |
2116 ? ErrorUtils::FormatErrorMessage(keys::kCannotDiscardTab, | 2117 ? ErrorUtils::FormatErrorMessage(keys::kCannotDiscardTab, |
2117 base::IntToString(*params->tab_id)) | 2118 base::IntToString(*params->tab_id)) |
2118 : keys::kCannotFindTabToDiscard)); | 2119 : keys::kCannotFindTabToDiscard)); |
2119 } | 2120 } |
2120 | 2121 |
2121 TabsDiscardFunction::TabsDiscardFunction() {} | 2122 TabsDiscardFunction::TabsDiscardFunction() {} |
2122 TabsDiscardFunction::~TabsDiscardFunction() {} | 2123 TabsDiscardFunction::~TabsDiscardFunction() {} |
2123 | 2124 |
2124 } // namespace extensions | 2125 } // namespace extensions |
OLD | NEW |