| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/desktop_capture/desktop_capture_api.h" | 5 #include "chrome/browser/extensions/api/desktop_capture/desktop_capture_api.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "chrome/browser/extensions/extension_tab_util.h" | 9 #include "chrome/browser/extensions/extension_tab_util.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| 11 #include "chrome/common/chrome_switches.h" | 11 #include "chrome/common/chrome_switches.h" |
| 12 #include "content/public/browser/render_process_host.h" | 12 #include "content/public/browser/render_process_host.h" |
| 13 #include "content/public/browser/render_view_host.h" | 13 #include "content/public/browser/render_view_host.h" |
| 14 #include "content/public/browser/web_contents.h" | 14 #include "content/public/browser/web_contents.h" |
| 15 #include "content/public/common/origin_util.h" |
| 15 #include "net/base/net_util.h" | 16 #include "net/base/net_util.h" |
| 16 | 17 |
| 17 namespace extensions { | 18 namespace extensions { |
| 18 | 19 |
| 19 namespace { | 20 namespace { |
| 20 | 21 |
| 21 const char kNoTabIdError[] = "targetTab doesn't have id field set."; | 22 const char kNoTabIdError[] = "targetTab doesn't have id field set."; |
| 22 const char kNoUrlError[] = "targetTab doesn't have URL field set."; | 23 const char kNoUrlError[] = "targetTab doesn't have URL field set."; |
| 23 const char kInvalidOriginError[] = "targetTab.url is not a valid URL."; | 24 const char kInvalidOriginError[] = "targetTab.url is not a valid URL."; |
| 24 const char kInvalidTabIdError[] = "Invalid tab specified."; | 25 const char kInvalidTabIdError[] = "Invalid tab specified."; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 } | 60 } |
| 60 origin = GURL(*(params->target_tab->url)).GetOrigin(); | 61 origin = GURL(*(params->target_tab->url)).GetOrigin(); |
| 61 | 62 |
| 62 if (!origin.is_valid()) { | 63 if (!origin.is_valid()) { |
| 63 error_ = kInvalidOriginError; | 64 error_ = kInvalidOriginError; |
| 64 return false; | 65 return false; |
| 65 } | 66 } |
| 66 | 67 |
| 67 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( | 68 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 68 switches::kAllowHttpScreenCapture) && | 69 switches::kAllowHttpScreenCapture) && |
| 69 !origin.SchemeIsSecure()) { | 70 !content::IsOriginSecure(origin)) { |
| 70 error_ = kTabUrlNotSecure; | 71 error_ = kTabUrlNotSecure; |
| 71 return false; | 72 return false; |
| 72 } | 73 } |
| 73 target_name = base::UTF8ToUTF16(origin.SchemeIsSecure() ? | 74 target_name = base::UTF8ToUTF16(content::IsOriginSecure(origin) ? |
| 74 net::GetHostAndOptionalPort(origin) : origin.spec()); | 75 net::GetHostAndOptionalPort(origin) : origin.spec()); |
| 75 | 76 |
| 76 if (!params->target_tab->id) { | 77 if (!params->target_tab->id) { |
| 77 error_ = kNoTabIdError; | 78 error_ = kNoTabIdError; |
| 78 return false; | 79 return false; |
| 79 } | 80 } |
| 80 | 81 |
| 81 if (!ExtensionTabUtil::GetTabById(*(params->target_tab->id), GetProfile(), | 82 if (!ExtensionTabUtil::GetTabById(*(params->target_tab->id), GetProfile(), |
| 82 true, NULL, NULL, &web_contents, NULL)) { | 83 true, NULL, NULL, &web_contents, NULL)) { |
| 83 error_ = kInvalidTabIdError; | 84 error_ = kInvalidTabIdError; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 94 return Execute(params->sources, web_contents, origin, target_name); | 95 return Execute(params->sources, web_contents, origin, target_name); |
| 95 } | 96 } |
| 96 | 97 |
| 97 DesktopCaptureCancelChooseDesktopMediaFunction:: | 98 DesktopCaptureCancelChooseDesktopMediaFunction:: |
| 98 DesktopCaptureCancelChooseDesktopMediaFunction() {} | 99 DesktopCaptureCancelChooseDesktopMediaFunction() {} |
| 99 | 100 |
| 100 DesktopCaptureCancelChooseDesktopMediaFunction:: | 101 DesktopCaptureCancelChooseDesktopMediaFunction:: |
| 101 ~DesktopCaptureCancelChooseDesktopMediaFunction() {} | 102 ~DesktopCaptureCancelChooseDesktopMediaFunction() {} |
| 102 | 103 |
| 103 } // namespace extensions | 104 } // namespace extensions |
| OLD | NEW |