OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/memory/ref_counted_memory.h" | 11 #include "base/memory/ref_counted_memory.h" |
12 #include "base/stl_util.h" | 12 #include "base/stl_util.h" |
13 #include "base/string_number_conversions.h" | 13 #include "base/string_number_conversions.h" |
14 #include "base/string_util.h" | 14 #include "base/string_util.h" |
15 #include "base/stringprintf.h" | 15 #include "base/stringprintf.h" |
16 #include "base/utf_string_conversions.h" | 16 #include "base/utf_string_conversions.h" |
17 #include "chrome/browser/extensions/extension_function_dispatcher.h" | 17 #include "chrome/browser/extensions/extension_function_dispatcher.h" |
18 #include "chrome/browser/extensions/extension_host.h" | 18 #include "chrome/browser/extensions/extension_host.h" |
19 #include "chrome/browser/extensions/extension_service.h" | 19 #include "chrome/browser/extensions/extension_service.h" |
20 #include "chrome/browser/extensions/extension_tabs_module_constants.h" | 20 #include "chrome/browser/extensions/extension_tabs_module_constants.h" |
21 #include "chrome/browser/net/url_fixer_upper.h" | 21 #include "chrome/browser/net/url_fixer_upper.h" |
| 22 #include "chrome/browser/prefs/incognito_mode_availability_prefs.h" |
22 #include "chrome/browser/profiles/profile.h" | 23 #include "chrome/browser/profiles/profile.h" |
23 #include "chrome/browser/sessions/restore_tab_helper.h" | 24 #include "chrome/browser/sessions/restore_tab_helper.h" |
24 #include "chrome/browser/tabs/tab_strip_model.h" | 25 #include "chrome/browser/tabs/tab_strip_model.h" |
25 #include "chrome/browser/translate/translate_tab_helper.h" | 26 #include "chrome/browser/translate/translate_tab_helper.h" |
26 #include "chrome/browser/ui/browser.h" | 27 #include "chrome/browser/ui/browser.h" |
27 #include "chrome/browser/ui/browser_list.h" | 28 #include "chrome/browser/ui/browser_list.h" |
28 #include "chrome/browser/ui/browser_navigator.h" | 29 #include "chrome/browser/ui/browser_navigator.h" |
29 #include "chrome/browser/ui/browser_window.h" | 30 #include "chrome/browser/ui/browser_window.h" |
30 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 31 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
31 #include "chrome/browser/ui/window_sizer.h" | 32 #include "chrome/browser/ui/window_sizer.h" |
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
520 EXTENSION_FUNCTION_VALIDATE(args->GetInteger(keys::kHeightKey, | 521 EXTENSION_FUNCTION_VALIDATE(args->GetInteger(keys::kHeightKey, |
521 &bounds_val)); | 522 &bounds_val)); |
522 window_bounds.set_height(bounds_val); | 523 window_bounds.set_height(bounds_val); |
523 popup_bounds.set_height(bounds_val); | 524 popup_bounds.set_height(bounds_val); |
524 } | 525 } |
525 | 526 |
526 bool incognito = false; | 527 bool incognito = false; |
527 if (args->HasKey(keys::kIncognitoKey)) { | 528 if (args->HasKey(keys::kIncognitoKey)) { |
528 EXTENSION_FUNCTION_VALIDATE(args->GetBoolean(keys::kIncognitoKey, | 529 EXTENSION_FUNCTION_VALIDATE(args->GetBoolean(keys::kIncognitoKey, |
529 &incognito)); | 530 &incognito)); |
530 if (!profile_->GetPrefs()->GetBoolean(prefs::kIncognitoEnabled)) { | 531 if (profile_->GetPrefs()->GetInteger(prefs::kIncognitoModeAvailability) == |
| 532 IncognitoModeAvailabilityPrefs::DISABLED) { |
531 error_ = keys::kIncognitoModeIsDisabled; | 533 error_ = keys::kIncognitoModeIsDisabled; |
532 return false; | 534 return false; |
533 } | 535 } |
534 | 536 |
535 if (incognito) | 537 if (incognito) |
536 window_profile = window_profile->GetOffTheRecordProfile(); | 538 window_profile = window_profile->GetOffTheRecordProfile(); |
537 } | 539 } |
538 | 540 |
539 if (args->HasKey(keys::kFocusedKey)) | 541 if (args->HasKey(keys::kFocusedKey)) |
540 EXTENSION_FUNCTION_VALIDATE(args->GetBoolean(keys::kFocusedKey, | 542 EXTENSION_FUNCTION_VALIDATE(args->GetBoolean(keys::kFocusedKey, |
(...skipping 833 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1374 // called for every API call the extension made. | 1376 // called for every API call the extension made. |
1375 GotLanguage(language); | 1377 GotLanguage(language); |
1376 } | 1378 } |
1377 | 1379 |
1378 void DetectTabLanguageFunction::GotLanguage(const std::string& language) { | 1380 void DetectTabLanguageFunction::GotLanguage(const std::string& language) { |
1379 result_.reset(Value::CreateStringValue(language.c_str())); | 1381 result_.reset(Value::CreateStringValue(language.c_str())); |
1380 SendResponse(true); | 1382 SendResponse(true); |
1381 | 1383 |
1382 Release(); // Balanced in Run() | 1384 Release(); // Balanced in Run() |
1383 } | 1385 } |
OLD | NEW |