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.h" | 5 #include "chrome/browser/extensions/api/tabs/tabs.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 "extensions/common/constants.h" | 70 #include "extensions/common/constants.h" |
71 #include "extensions/common/error_utils.h" | 71 #include "extensions/common/error_utils.h" |
72 #include "skia/ext/image_operations.h" | 72 #include "skia/ext/image_operations.h" |
73 #include "skia/ext/platform_canvas.h" | 73 #include "skia/ext/platform_canvas.h" |
74 #include "third_party/skia/include/core/SkBitmap.h" | 74 #include "third_party/skia/include/core/SkBitmap.h" |
75 #include "ui/base/ui_base_types.h" | 75 #include "ui/base/ui_base_types.h" |
76 #include "ui/gfx/codec/jpeg_codec.h" | 76 #include "ui/gfx/codec/jpeg_codec.h" |
77 #include "ui/gfx/codec/png_codec.h" | 77 #include "ui/gfx/codec/png_codec.h" |
78 | 78 |
79 #if defined(OS_WIN) | 79 #if defined(OS_WIN) |
80 #include "base/win/metro.h" | 80 #include "win8/util/win8_util.h" |
81 #endif // OS_WIN | 81 #endif // OS_WIN |
82 | 82 |
83 namespace Get = extensions::api::windows::Get; | 83 namespace Get = extensions::api::windows::Get; |
84 namespace GetAll = extensions::api::windows::GetAll; | 84 namespace GetAll = extensions::api::windows::GetAll; |
85 namespace GetCurrent = extensions::api::windows::GetCurrent; | 85 namespace GetCurrent = extensions::api::windows::GetCurrent; |
86 namespace GetLastFocused = extensions::api::windows::GetLastFocused; | 86 namespace GetLastFocused = extensions::api::windows::GetLastFocused; |
87 namespace errors = extension_manifest_errors; | 87 namespace errors = extension_manifest_errors; |
88 namespace keys = extensions::tabs_constants; | 88 namespace keys = extensions::tabs_constants; |
89 | 89 |
90 using content::NavigationController; | 90 using content::NavigationController; |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 return NOT_SET; | 222 return NOT_SET; |
223 } | 223 } |
224 | 224 |
225 Browser* CreateBrowserWindow(const Browser::CreateParams& params, | 225 Browser* CreateBrowserWindow(const Browser::CreateParams& params, |
226 Profile* profile, | 226 Profile* profile, |
227 const std::string& extension_id) { | 227 const std::string& extension_id) { |
228 bool use_existing_browser_window = false; | 228 bool use_existing_browser_window = false; |
229 | 229 |
230 #if defined(OS_WIN) | 230 #if defined(OS_WIN) |
231 // In windows 8 metro mode we don't allow windows to be created. | 231 // In windows 8 metro mode we don't allow windows to be created. |
232 if (base::win::IsMetroProcess()) | 232 if (win8::IsSingleWindowMetroMode()) |
233 use_existing_browser_window = true; | 233 use_existing_browser_window = true; |
234 #endif // OS_WIN | 234 #endif // OS_WIN |
235 | 235 |
236 Browser* new_window = NULL; | 236 Browser* new_window = NULL; |
237 if (use_existing_browser_window) | 237 if (use_existing_browser_window) |
238 // The false parameter passed below is to ensure that we find a browser | 238 // The false parameter passed below is to ensure that we find a browser |
239 // object matching the profile passed in, instead of the original profile | 239 // object matching the profile passed in, instead of the original profile |
240 new_window = browser::FindTabbedBrowser( | 240 new_window = browser::FindTabbedBrowser( |
241 profile, false, chrome::GetActiveDesktop()); | 241 profile, false, chrome::GetActiveDesktop()); |
242 | 242 |
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
662 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &window_id)); | 662 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &window_id)); |
663 DictionaryValue* update_props; | 663 DictionaryValue* update_props; |
664 EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(1, &update_props)); | 664 EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(1, &update_props)); |
665 | 665 |
666 WindowController* controller; | 666 WindowController* controller; |
667 if (!GetWindowFromWindowID(this, window_id, &controller)) | 667 if (!GetWindowFromWindowID(this, window_id, &controller)) |
668 return false; | 668 return false; |
669 | 669 |
670 #if defined(OS_WIN) | 670 #if defined(OS_WIN) |
671 // Silently ignore changes on the window for metro mode. | 671 // Silently ignore changes on the window for metro mode. |
672 if (base::win::IsMetroProcess()) { | 672 if (win8::IsSingleWindowMetroMode()) { |
673 SetResult(controller->CreateWindowValue()); | 673 SetResult(controller->CreateWindowValue()); |
674 return true; | 674 return true; |
675 } | 675 } |
676 #endif | 676 #endif |
677 | 677 |
678 ui::WindowShowState show_state = ui::SHOW_STATE_DEFAULT; // No change. | 678 ui::WindowShowState show_state = ui::SHOW_STATE_DEFAULT; // No change. |
679 std::string state_str; | 679 std::string state_str; |
680 if (update_props->HasKey(keys::kShowStateKey)) { | 680 if (update_props->HasKey(keys::kShowStateKey)) { |
681 EXTENSION_FUNCTION_VALIDATE(update_props->GetString(keys::kShowStateKey, | 681 EXTENSION_FUNCTION_VALIDATE(update_props->GetString(keys::kShowStateKey, |
682 &state_str)); | 682 &state_str)); |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
802 } | 802 } |
803 | 803 |
804 bool RemoveWindowFunction::RunImpl() { | 804 bool RemoveWindowFunction::RunImpl() { |
805 int window_id = -1; | 805 int window_id = -1; |
806 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &window_id)); | 806 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &window_id)); |
807 | 807 |
808 WindowController* controller; | 808 WindowController* controller; |
809 if (!GetWindowFromWindowID(this, window_id, &controller)) | 809 if (!GetWindowFromWindowID(this, window_id, &controller)) |
810 return false; | 810 return false; |
811 | 811 |
812 #if defined(OS_WIN) && !defined(USE_AURA) | 812 #if defined(OS_WIN) |
813 // In Windows 8 metro mode, an existing Browser instance is reused for | 813 // In Windows 8 metro mode, an existing Browser instance is reused for |
814 // hosting the extension tab. We should not be closing it as we don't own it. | 814 // hosting the extension tab. We should not be closing it as we don't own it. |
815 if (base::win::IsMetroProcess()) | 815 if (win8::IsSingleWindowMetroMode()) |
816 return false; | 816 return false; |
817 #endif | 817 #endif |
818 | 818 |
819 WindowController::Reason reason; | 819 WindowController::Reason reason; |
820 if (!controller->CanClose(&reason)) { | 820 if (!controller->CanClose(&reason)) { |
821 if (reason == WindowController::REASON_NOT_EDITABLE) | 821 if (reason == WindowController::REASON_NOT_EDITABLE) |
822 error_ = keys::kTabStripNotEditableError; | 822 error_ = keys::kTabStripNotEditableError; |
823 return false; | 823 return false; |
824 } | 824 } |
825 controller->window()->Close(); | 825 controller->window()->Close(); |
(...skipping 1044 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1870 // called for every API call the extension made. | 1870 // called for every API call the extension made. |
1871 GotLanguage(language); | 1871 GotLanguage(language); |
1872 } | 1872 } |
1873 | 1873 |
1874 void DetectTabLanguageFunction::GotLanguage(const std::string& language) { | 1874 void DetectTabLanguageFunction::GotLanguage(const std::string& language) { |
1875 SetResult(Value::CreateStringValue(language.c_str())); | 1875 SetResult(Value::CreateStringValue(language.c_str())); |
1876 SendResponse(true); | 1876 SendResponse(true); |
1877 | 1877 |
1878 Release(); // Balanced in Run() | 1878 Release(); // Balanced in Run() |
1879 } | 1879 } |
OLD | NEW |