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

Side by Side Diff: chrome/browser/extensions/api/tab_capture/tab_capture_api.cc

Issue 2619973002: Prefix search code improvement in tab_capture_api.cc (Closed)
Patch Set: Created 3 years, 11 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // Implements the Chrome Extensions Tab Capture API. 5 // Implements the Chrome Extensions Tab Capture API.
6 6
7 #include "chrome/browser/extensions/api/tab_capture/tab_capture_api.h" 7 #include "chrome/browser/extensions/api/tab_capture/tab_capture_api.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
11 #include <set> 11 #include <set>
12 #include <string> 12 #include <string>
13 #include <utility> 13 #include <utility>
14 #include <vector> 14 #include <vector>
15 15
16 #include "base/command_line.h" 16 #include "base/command_line.h"
17 #include "base/macros.h" 17 #include "base/macros.h"
18 #include "base/strings/string_util.h"
18 #include "base/strings/stringprintf.h" 19 #include "base/strings/stringprintf.h"
19 #include "base/values.h" 20 #include "base/values.h"
20 #include "chrome/browser/extensions/api/tab_capture/offscreen_tab.h" 21 #include "chrome/browser/extensions/api/tab_capture/offscreen_tab.h"
21 #include "chrome/browser/extensions/api/tab_capture/tab_capture_registry.h" 22 #include "chrome/browser/extensions/api/tab_capture/tab_capture_registry.h"
22 #include "chrome/browser/profiles/profile.h" 23 #include "chrome/browser/profiles/profile.h"
23 #include "chrome/browser/sessions/session_tab_helper.h" 24 #include "chrome/browser/sessions/session_tab_helper.h"
24 #include "chrome/browser/ui/browser.h" 25 #include "chrome/browser/ui/browser.h"
25 #include "chrome/browser/ui/browser_finder.h" 26 #include "chrome/browser/ui/browser_finder.h"
26 #include "chrome/browser/ui/tabs/tab_strip_model.h" 27 #include "chrome/browser/ui/tabs/tab_strip_model.h"
27 #include "chrome/common/chrome_switches.h" 28 #include "chrome/common/chrome_switches.h"
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 // "goog" prefix. These are never needed and may cause the renderer-side 81 // "goog" prefix. These are never needed and may cause the renderer-side
81 // getUserMedia() call to fail. http://crbug.com/579729 82 // getUserMedia() call to fail. http://crbug.com/579729
82 // 83 //
83 // TODO(miu): Remove once tabCapture API is migrated to new constraints spec. 84 // TODO(miu): Remove once tabCapture API is migrated to new constraints spec.
84 // http://crbug.com/579729 85 // http://crbug.com/579729
85 void FilterDeprecatedGoogConstraints(TabCapture::CaptureOptions* options) { 86 void FilterDeprecatedGoogConstraints(TabCapture::CaptureOptions* options) {
86 const auto FilterGoogKeysFromDictionary = [](base::DictionaryValue* dict) { 87 const auto FilterGoogKeysFromDictionary = [](base::DictionaryValue* dict) {
87 std::vector<std::string> bad_keys; 88 std::vector<std::string> bad_keys;
88 base::DictionaryValue::Iterator it(*dict); 89 base::DictionaryValue::Iterator it(*dict);
89 for (; !it.IsAtEnd(); it.Advance()) { 90 for (; !it.IsAtEnd(); it.Advance()) {
90 if (it.key().find("goog") == 0) 91 if (base::StartsWith(it.key(), "goog", base::CompareCase::SENSITIVE))
91 bad_keys.push_back(it.key()); 92 bad_keys.push_back(it.key());
92 } 93 }
93 for (const std::string& k : bad_keys) { 94 for (const std::string& k : bad_keys) {
94 std::unique_ptr<base::Value> ignored; 95 std::unique_ptr<base::Value> ignored;
95 dict->RemoveWithoutPathExpansion(k, &ignored); 96 dict->RemoveWithoutPathExpansion(k, &ignored);
96 } 97 }
97 }; 98 };
98 99
99 if (options->audio_constraints) { 100 if (options->audio_constraints) {
100 FilterGoogKeysFromDictionary( 101 FilterGoogKeysFromDictionary(
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 } 363 }
363 } 364 }
364 365
365 // No maximum size was provided, so just return the default size bounded by 366 // No maximum size was provided, so just return the default size bounded by
366 // the minimum size. 367 // the minimum size.
367 return gfx::Size(std::max(kDefaultWidth, min_size.width()), 368 return gfx::Size(std::max(kDefaultWidth, min_size.width()),
368 std::max(kDefaultHeight, min_size.height())); 369 std::max(kDefaultHeight, min_size.height()));
369 } 370 }
370 371
371 } // namespace extensions 372 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698