| 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> |
| 11 #include <utility> | 11 #include <utility> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "base/bind.h" | 14 #include "base/bind.h" |
| 15 #include "base/command_line.h" | 15 #include "base/command_line.h" |
| 16 #include "base/location.h" | 16 #include "base/location.h" |
| 17 #include "base/logging.h" | 17 #include "base/logging.h" |
| 18 #include "base/memory/ptr_util.h" | 18 #include "base/memory/ptr_util.h" |
| 19 #include "base/memory/ref_counted_memory.h" | 19 #include "base/memory/ref_counted_memory.h" |
| 20 #include "base/metrics/histogram_macros.h" |
| 20 #include "base/single_thread_task_runner.h" | 21 #include "base/single_thread_task_runner.h" |
| 21 #include "base/stl_util.h" | 22 #include "base/stl_util.h" |
| 22 #include "base/strings/pattern.h" | 23 #include "base/strings/pattern.h" |
| 23 #include "base/strings/string16.h" | 24 #include "base/strings/string16.h" |
| 24 #include "base/strings/string_number_conversions.h" | 25 #include "base/strings/string_number_conversions.h" |
| 25 #include "base/strings/string_util.h" | 26 #include "base/strings/string_util.h" |
| 26 #include "base/strings/utf_string_conversions.h" | 27 #include "base/strings/utf_string_conversions.h" |
| 27 #include "base/threading/thread_task_runner_handle.h" | 28 #include "base/threading/thread_task_runner_handle.h" |
| 28 #include "chrome/browser/browser_process.h" | 29 #include "chrome/browser/browser_process.h" |
| 29 #include "chrome/browser/chrome_notification_types.h" | 30 #include "chrome/browser/chrome_notification_types.h" |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 } | 193 } |
| 193 | 194 |
| 194 template <typename T> | 195 template <typename T> |
| 195 void AssignOptionalValue(const std::unique_ptr<T>& source, | 196 void AssignOptionalValue(const std::unique_ptr<T>& source, |
| 196 std::unique_ptr<T>& destination) { | 197 std::unique_ptr<T>& destination) { |
| 197 if (source.get()) { | 198 if (source.get()) { |
| 198 destination.reset(new T(*source)); | 199 destination.reset(new T(*source)); |
| 199 } | 200 } |
| 200 } | 201 } |
| 201 | 202 |
| 203 void ReportRequestedWindowState(windows::WindowState state) { |
| 204 UMA_HISTOGRAM_ENUMERATION("TabsApi.RequestedWindowState", state, |
| 205 windows::WINDOW_STATE_LAST + 1); |
| 206 } |
| 207 |
| 202 ui::WindowShowState ConvertToWindowShowState(windows::WindowState state) { | 208 ui::WindowShowState ConvertToWindowShowState(windows::WindowState state) { |
| 203 switch (state) { | 209 switch (state) { |
| 204 case windows::WINDOW_STATE_NORMAL: | 210 case windows::WINDOW_STATE_NORMAL: |
| 205 case windows::WINDOW_STATE_DOCKED: | 211 case windows::WINDOW_STATE_DOCKED: |
| 206 return ui::SHOW_STATE_NORMAL; | 212 return ui::SHOW_STATE_NORMAL; |
| 207 case windows::WINDOW_STATE_MINIMIZED: | 213 case windows::WINDOW_STATE_MINIMIZED: |
| 208 return ui::SHOW_STATE_MINIMIZED; | 214 return ui::SHOW_STATE_MINIMIZED; |
| 209 case windows::WINDOW_STATE_MAXIMIZED: | 215 case windows::WINDOW_STATE_MAXIMIZED: |
| 210 return ui::SHOW_STATE_MAXIMIZED; | 216 return ui::SHOW_STATE_MAXIMIZED; |
| 211 case windows::WINDOW_STATE_FULLSCREEN: | 217 case windows::WINDOW_STATE_FULLSCREEN: |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 482 #if defined(USE_ASH) | 488 #if defined(USE_ASH) |
| 483 bool create_ash_panel = false; | 489 bool create_ash_panel = false; |
| 484 bool saw_focus_key = false; | 490 bool saw_focus_key = false; |
| 485 #endif // defined(USE_ASH) | 491 #endif // defined(USE_ASH) |
| 486 | 492 |
| 487 gfx::Rect window_bounds; | 493 gfx::Rect window_bounds; |
| 488 bool focused = true; | 494 bool focused = true; |
| 489 std::string extension_id; | 495 std::string extension_id; |
| 490 | 496 |
| 491 if (create_data) { | 497 if (create_data) { |
| 498 // Report UMA stats to decide when to remove the deprecated "docked" windows |
| 499 // state (crbug.com/703733). |
| 500 ReportRequestedWindowState(create_data->state); |
| 501 |
| 492 // Figure out window type before figuring out bounds so that default | 502 // Figure out window type before figuring out bounds so that default |
| 493 // bounds can be set according to the window type. | 503 // bounds can be set according to the window type. |
| 494 switch (create_data->type) { | 504 switch (create_data->type) { |
| 495 case windows::CREATE_TYPE_POPUP: | 505 case windows::CREATE_TYPE_POPUP: |
| 496 window_type = Browser::TYPE_POPUP; | 506 window_type = Browser::TYPE_POPUP; |
| 497 extension_id = extension()->id(); | 507 extension_id = extension()->id(); |
| 498 break; | 508 break; |
| 499 | 509 |
| 500 case windows::CREATE_TYPE_PANEL: { | 510 case windows::CREATE_TYPE_PANEL: { |
| 501 extension_id = extension()->id(); | 511 extension_id = extension()->id(); |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 662 EXTENSION_FUNCTION_VALIDATE(params); | 672 EXTENSION_FUNCTION_VALIDATE(params); |
| 663 | 673 |
| 664 WindowController* controller; | 674 WindowController* controller; |
| 665 std::string error; | 675 std::string error; |
| 666 if (!windows_util::GetWindowFromWindowID( | 676 if (!windows_util::GetWindowFromWindowID( |
| 667 this, params->window_id, WindowController::GetAllWindowFilter(), | 677 this, params->window_id, WindowController::GetAllWindowFilter(), |
| 668 &controller, &error)) { | 678 &controller, &error)) { |
| 669 return RespondNow(Error(error)); | 679 return RespondNow(Error(error)); |
| 670 } | 680 } |
| 671 | 681 |
| 682 // Report UMA stats to decide when to remove the deprecated "docked" windows |
| 683 // state (crbug.com/703733). |
| 684 ReportRequestedWindowState(params->update_info.state); |
| 685 |
| 672 ui::WindowShowState show_state = | 686 ui::WindowShowState show_state = |
| 673 ConvertToWindowShowState(params->update_info.state); | 687 ConvertToWindowShowState(params->update_info.state); |
| 674 | 688 |
| 675 if (show_state != ui::SHOW_STATE_FULLSCREEN && | 689 if (show_state != ui::SHOW_STATE_FULLSCREEN && |
| 676 show_state != ui::SHOW_STATE_DEFAULT) | 690 show_state != ui::SHOW_STATE_DEFAULT) |
| 677 controller->SetFullscreenMode(false, extension()->url()); | 691 controller->SetFullscreenMode(false, extension()->url()); |
| 678 | 692 |
| 679 switch (show_state) { | 693 switch (show_state) { |
| 680 case ui::SHOW_STATE_MINIMIZED: | 694 case ui::SHOW_STATE_MINIMIZED: |
| 681 controller->window()->Minimize(); | 695 controller->window()->Minimize(); |
| (...skipping 1440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2122 params->tab_id | 2136 params->tab_id |
| 2123 ? ErrorUtils::FormatErrorMessage(keys::kCannotDiscardTab, | 2137 ? ErrorUtils::FormatErrorMessage(keys::kCannotDiscardTab, |
| 2124 base::IntToString(*params->tab_id)) | 2138 base::IntToString(*params->tab_id)) |
| 2125 : keys::kCannotFindTabToDiscard)); | 2139 : keys::kCannotFindTabToDiscard)); |
| 2126 } | 2140 } |
| 2127 | 2141 |
| 2128 TabsDiscardFunction::TabsDiscardFunction() {} | 2142 TabsDiscardFunction::TabsDiscardFunction() {} |
| 2129 TabsDiscardFunction::~TabsDiscardFunction() {} | 2143 TabsDiscardFunction::~TabsDiscardFunction() {} |
| 2130 | 2144 |
| 2131 } // namespace extensions | 2145 } // namespace extensions |
| OLD | NEW |