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" |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 error_ = keys::kIncognitoModeIsForced; | 270 error_ = keys::kIncognitoModeIsForced; |
271 *is_error = true; | 271 *is_error = true; |
272 return false; | 272 return false; |
273 } | 273 } |
274 } else if (incognito_availability == IncognitoModePrefs::FORCED) { | 274 } else if (incognito_availability == IncognitoModePrefs::FORCED) { |
275 // If incognito argument is not specified explicitly, we default to | 275 // If incognito argument is not specified explicitly, we default to |
276 // incognito when forced so by policy. | 276 // incognito when forced so by policy. |
277 incognito = true; | 277 incognito = true; |
278 } | 278 } |
279 | 279 |
280 // If we are opening an incognito window. | 280 // Remove all URLs that are not allowed in an incognito session. Note that a |
281 if (incognito) { | 281 // ChromeOS guest session is not considered incognito in this case. |
| 282 if (incognito && !Profile::IsGuestSession()) { |
282 std::string first_url_erased; | 283 std::string first_url_erased; |
283 // Guest session is an exception as it always opens in incognito mode. | |
284 for (size_t i = 0; i < urls->size();) { | 284 for (size_t i = 0; i < urls->size();) { |
285 if (browser::IsURLAllowedInIncognito((*urls)[i]) && | 285 if (browser::IsURLAllowedInIncognito((*urls)[i])) { |
286 !Profile::IsGuestSession()) { | 286 i++; |
| 287 } else { |
287 if (first_url_erased.empty()) | 288 if (first_url_erased.empty()) |
288 first_url_erased = (*urls)[i].spec(); | 289 first_url_erased = (*urls)[i].spec(); |
289 urls->erase(urls->begin() + i); | 290 urls->erase(urls->begin() + i); |
290 } else { | |
291 i++; | |
292 } | 291 } |
293 } | 292 } |
294 if (urls->empty() && !first_url_erased.empty()) { | 293 if (urls->empty() && !first_url_erased.empty()) { |
295 error_ = ExtensionErrorUtils::FormatErrorMessage( | 294 error_ = ExtensionErrorUtils::FormatErrorMessage( |
296 keys::kURLsNotAllowedInIncognitoError, first_url_erased); | 295 keys::kURLsNotAllowedInIncognitoError, first_url_erased); |
297 *is_error = true; | 296 *is_error = true; |
298 return false; | 297 return false; |
299 } | 298 } |
300 } | 299 } |
301 return incognito; | 300 return incognito; |
(...skipping 1314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1616 // called for every API call the extension made. | 1615 // called for every API call the extension made. |
1617 GotLanguage(language); | 1616 GotLanguage(language); |
1618 } | 1617 } |
1619 | 1618 |
1620 void DetectTabLanguageFunction::GotLanguage(const std::string& language) { | 1619 void DetectTabLanguageFunction::GotLanguage(const std::string& language) { |
1621 result_.reset(Value::CreateStringValue(language.c_str())); | 1620 result_.reset(Value::CreateStringValue(language.c_str())); |
1622 SendResponse(true); | 1621 SendResponse(true); |
1623 | 1622 |
1624 Release(); // Balanced in Run() | 1623 Release(); // Balanced in Run() |
1625 } | 1624 } |
OLD | NEW |