Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(518)

Side by Side Diff: chrome/browser/extensions/api/desktop_capture/desktop_capture_api.cc

Issue 1239643004: extensions: tabs: set tab id to -1 for app/devtools windows (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Support no tab id and NONE tab id Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 67
68 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( 68 if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
69 switches::kAllowHttpScreenCapture) && 69 switches::kAllowHttpScreenCapture) &&
70 !content::IsOriginSecure(origin)) { 70 !content::IsOriginSecure(origin)) {
71 error_ = kTabUrlNotSecure; 71 error_ = kTabUrlNotSecure;
72 return false; 72 return false;
73 } 73 }
74 target_name = base::UTF8ToUTF16(content::IsOriginSecure(origin) ? 74 target_name = base::UTF8ToUTF16(content::IsOriginSecure(origin) ?
75 net::GetHostAndOptionalPort(origin) : origin.spec()); 75 net::GetHostAndOptionalPort(origin) : origin.spec());
76 76
77 if (!params->target_tab->id) { 77 if (!params->target_tab->id ||
78 *(params->target_tab->id) == api::tabs::TAB_ID_NONE) {
78 error_ = kNoTabIdError; 79 error_ = kNoTabIdError;
79 return false; 80 return false;
80 } 81 }
81 82
82 if (!ExtensionTabUtil::GetTabById(*(params->target_tab->id), GetProfile(), 83 if (!ExtensionTabUtil::GetTabById(*(params->target_tab->id), GetProfile(),
83 true, NULL, NULL, &web_contents, NULL)) { 84 true, NULL, NULL, &web_contents, NULL)) {
84 error_ = kInvalidTabIdError; 85 error_ = kInvalidTabIdError;
85 return false; 86 return false;
86 } 87 }
87 DCHECK(web_contents); 88 DCHECK(web_contents);
88 } else { 89 } else {
89 origin = extension()->url(); 90 origin = extension()->url();
90 target_name = base::UTF8ToUTF16(extension()->name()); 91 target_name = base::UTF8ToUTF16(extension()->name());
91 web_contents = GetSenderWebContents(); 92 web_contents = GetSenderWebContents();
92 DCHECK(web_contents); 93 DCHECK(web_contents);
93 } 94 }
94 95
95 return Execute(params->sources, web_contents, origin, target_name); 96 return Execute(params->sources, web_contents, origin, target_name);
96 } 97 }
97 98
98 DesktopCaptureCancelChooseDesktopMediaFunction:: 99 DesktopCaptureCancelChooseDesktopMediaFunction::
99 DesktopCaptureCancelChooseDesktopMediaFunction() {} 100 DesktopCaptureCancelChooseDesktopMediaFunction() {}
100 101
101 DesktopCaptureCancelChooseDesktopMediaFunction:: 102 DesktopCaptureCancelChooseDesktopMediaFunction::
102 ~DesktopCaptureCancelChooseDesktopMediaFunction() {} 103 ~DesktopCaptureCancelChooseDesktopMediaFunction() {}
103 104
104 } // namespace extensions 105 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698