| 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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 TabContentsWrapper** contents, | 63 TabContentsWrapper** contents, |
| 64 int* tab_index, std::string* error_message); | 64 int* tab_index, std::string* error_message); |
| 65 | 65 |
| 66 // Takes |url_string| and returns a GURL which is either valid and absolute | 66 // Takes |url_string| and returns a GURL which is either valid and absolute |
| 67 // or invalid. If |url_string| is not directly interpretable as a valid (it is | 67 // or invalid. If |url_string| is not directly interpretable as a valid (it is |
| 68 // likely a relative URL) an attempt is made to resolve it. |extension| is | 68 // likely a relative URL) an attempt is made to resolve it. |extension| is |
| 69 // provided so it can be resolved relative to its extension base | 69 // provided so it can be resolved relative to its extension base |
| 70 // (chrome-extension://<id>/). Using the source frame url would be more correct, | 70 // (chrome-extension://<id>/). Using the source frame url would be more correct, |
| 71 // but because the api shipped with urls resolved relative to their extension | 71 // but because the api shipped with urls resolved relative to their extension |
| 72 // base, we decided it wasn't worth breaking existing extensions to fix. | 72 // base, we decided it wasn't worth breaking existing extensions to fix. |
| 73 static GURL ResolvePossiblyRelativeURL(std::string url_string, | 73 static GURL ResolvePossiblyRelativeURL(const std::string& url_string, |
| 74 const Extension* extension); | 74 const Extension* extension); |
| 75 | 75 |
| 76 // Return the type name for a browser window type. | 76 // Return the type name for a browser window type. |
| 77 static std::string GetWindowTypeText(Browser::Type type); | 77 static std::string GetWindowTypeText(Browser::Type type); |
| 78 | 78 |
| 79 int ExtensionTabUtil::GetWindowId(const Browser* browser) { | 79 int ExtensionTabUtil::GetWindowId(const Browser* browser) { |
| 80 return browser->session_id().id(); | 80 return browser->session_id().id(); |
| 81 } | 81 } |
| 82 | 82 |
| 83 int ExtensionTabUtil::GetTabId(const TabContents* tab_contents) { | 83 int ExtensionTabUtil::GetTabId(const TabContents* tab_contents) { |
| (...skipping 1137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1221 } | 1221 } |
| 1222 | 1222 |
| 1223 void DetectTabLanguageFunction::GotLanguage(const std::string& language) { | 1223 void DetectTabLanguageFunction::GotLanguage(const std::string& language) { |
| 1224 result_.reset(Value::CreateStringValue(language.c_str())); | 1224 result_.reset(Value::CreateStringValue(language.c_str())); |
| 1225 SendResponse(true); | 1225 SendResponse(true); |
| 1226 | 1226 |
| 1227 Release(); // Balanced in Run() | 1227 Release(); // Balanced in Run() |
| 1228 } | 1228 } |
| 1229 | 1229 |
| 1230 // static helpers | 1230 // static helpers |
| 1231 // TODO(jhawkins): Move these to unnamed namespace and remove static modifier. |
| 1231 | 1232 |
| 1232 static Browser* GetBrowserInProfileWithId(Profile* profile, | 1233 static Browser* GetBrowserInProfileWithId(Profile* profile, |
| 1233 const int window_id, | 1234 const int window_id, |
| 1234 bool include_incognito, | 1235 bool include_incognito, |
| 1235 std::string* error_message) { | 1236 std::string* error_message) { |
| 1236 Profile* incognito_profile = | 1237 Profile* incognito_profile = |
| 1237 include_incognito && profile->HasOffTheRecordProfile() ? | 1238 include_incognito && profile->HasOffTheRecordProfile() ? |
| 1238 profile->GetOffTheRecordProfile() : NULL; | 1239 profile->GetOffTheRecordProfile() : NULL; |
| 1239 for (BrowserList::const_iterator browser = BrowserList::begin(); | 1240 for (BrowserList::const_iterator browser = BrowserList::begin(); |
| 1240 browser != BrowserList::end(); ++browser) { | 1241 browser != BrowserList::end(); ++browser) { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1273 if ((type & Browser::TYPE_POPUP) == Browser::TYPE_POPUP) | 1274 if ((type & Browser::TYPE_POPUP) == Browser::TYPE_POPUP) |
| 1274 return keys::kWindowTypeValuePopup; | 1275 return keys::kWindowTypeValuePopup; |
| 1275 | 1276 |
| 1276 if ((type & Browser::TYPE_APP) == Browser::TYPE_APP) | 1277 if ((type & Browser::TYPE_APP) == Browser::TYPE_APP) |
| 1277 return keys::kWindowTypeValueApp; | 1278 return keys::kWindowTypeValueApp; |
| 1278 | 1279 |
| 1279 DCHECK(type == Browser::TYPE_NORMAL); | 1280 DCHECK(type == Browser::TYPE_NORMAL); |
| 1280 return keys::kWindowTypeValueNormal; | 1281 return keys::kWindowTypeValueNormal; |
| 1281 } | 1282 } |
| 1282 | 1283 |
| 1283 static GURL ResolvePossiblyRelativeURL(std::string url_string, | 1284 static GURL ResolvePossiblyRelativeURL(const std::string& url_string, |
| 1284 const Extension* extension) { | 1285 const Extension* extension) { |
| 1285 GURL url = GURL(url_string); | 1286 GURL url = GURL(url_string); |
| 1286 if (!url.is_valid()) | 1287 if (!url.is_valid()) |
| 1287 url = extension->GetResourceURL(url_string); | 1288 url = extension->GetResourceURL(url_string); |
| 1288 | 1289 |
| 1289 return url; | 1290 return url; |
| 1290 } | 1291 } |
| OLD | NEW |