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

Side by Side Diff: chrome/browser/ui/webui/feedback_ui.cc

Issue 10692110: screenshot disabling policy (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Addressed comments (4) Created 8 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 (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 #include "chrome/browser/ui/webui/feedback_ui.h" 5 #include "chrome/browser/ui/webui/feedback_ui.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
13 #include "base/message_loop.h" 13 #include "base/message_loop.h"
14 #include "base/string_number_conversions.h" 14 #include "base/string_number_conversions.h"
15 #include "base/string_util.h" 15 #include "base/string_util.h"
16 #include "base/time.h"
16 #include "base/utf_string_conversions.h" 17 #include "base/utf_string_conversions.h"
17 #include "base/time.h"
18 #include "base/values.h" 18 #include "base/values.h"
19 #include "chrome/browser/browser_process.h"
19 #include "chrome/browser/download/download_prefs.h" 20 #include "chrome/browser/download/download_prefs.h"
20 #include "chrome/browser/feedback/feedback_data.h" 21 #include "chrome/browser/feedback/feedback_data.h"
21 #include "chrome/browser/feedback/feedback_util.h" 22 #include "chrome/browser/feedback/feedback_util.h"
23 #include "chrome/browser/prefs/pref_service.h"
22 #include "chrome/browser/profiles/profile.h" 24 #include "chrome/browser/profiles/profile.h"
23 #include "chrome/browser/ui/browser.h" 25 #include "chrome/browser/ui/browser.h"
24 #include "chrome/browser/ui/browser_finder.h" 26 #include "chrome/browser/ui/browser_finder.h"
25 #include "chrome/browser/ui/browser_tabstrip.h" 27 #include "chrome/browser/ui/browser_tabstrip.h"
26 #include "chrome/browser/ui/browser_window.h" 28 #include "chrome/browser/ui/browser_window.h"
27 #include "chrome/browser/ui/singleton_tabs.h" 29 #include "chrome/browser/ui/singleton_tabs.h"
28 #include "chrome/browser/ui/tab_contents/tab_contents.h" 30 #include "chrome/browser/ui/tab_contents/tab_contents.h"
29 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" 31 #include "chrome/browser/ui/webui/chrome_url_data_manager.h"
30 #include "chrome/browser/ui/webui/chrome_web_ui_data_source.h" 32 #include "chrome/browser/ui/webui/chrome_web_ui_data_source.h"
31 #include "chrome/browser/ui/webui/screenshot_source.h" 33 #include "chrome/browser/ui/webui/screenshot_source.h"
32 #include "chrome/browser/ui/window_snapshot/window_snapshot.h" 34 #include "chrome/browser/ui/window_snapshot/window_snapshot.h"
33 #include "chrome/common/chrome_paths.h" 35 #include "chrome/common/chrome_paths.h"
36 #include "chrome/common/pref_names.h"
34 #include "chrome/common/url_constants.h" 37 #include "chrome/common/url_constants.h"
35 #include "content/public/browser/browser_thread.h" 38 #include "content/public/browser/browser_thread.h"
36 #include "content/public/browser/navigation_controller.h" 39 #include "content/public/browser/navigation_controller.h"
37 #include "content/public/browser/navigation_entry.h" 40 #include "content/public/browser/navigation_entry.h"
38 #include "content/public/browser/web_contents.h" 41 #include "content/public/browser/web_contents.h"
39 #include "content/public/browser/web_ui.h" 42 #include "content/public/browser/web_ui.h"
40 #include "content/public/browser/web_ui_message_handler.h" 43 #include "content/public/browser/web_ui_message_handler.h"
41 #include "grit/browser_resources.h" 44 #include "grit/browser_resources.h"
42 #include "grit/chromium_strings.h" 45 #include "grit/chromium_strings.h"
43 #include "grit/generated_resources.h" 46 #include "grit/generated_resources.h"
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 #if defined(OS_CHROMEOS) 164 #if defined(OS_CHROMEOS)
162 // For ChromeOS, don't use the browser window but the root window 165 // For ChromeOS, don't use the browser window but the root window
163 // instead to grab the screenshot. We want everything on the screen, not 166 // instead to grab the screenshot. We want everything on the screen, not
164 // just the current browser. 167 // just the current browser.
165 native_window = ash::Shell::GetPrimaryRootWindow(); 168 native_window = ash::Shell::GetPrimaryRootWindow();
166 snapshot_bounds = gfx::Rect(native_window->bounds()); 169 snapshot_bounds = gfx::Rect(native_window->bounds());
167 #else 170 #else
168 native_window = browser->window()->GetNativeWindow(); 171 native_window = browser->window()->GetNativeWindow();
169 snapshot_bounds = gfx::Rect(browser->window()->GetBounds().size()); 172 snapshot_bounds = gfx::Rect(browser->window()->GetBounds().size());
170 #endif 173 #endif
171 bool success = browser::GrabWindowSnapshot(native_window, 174 bool success = browser::GrabWindowSnapshotIfPermitted(native_window,
172 last_screenshot_png, 175 last_screenshot_png,
173 snapshot_bounds); 176 snapshot_bounds);
174 FeedbackUtil::SetScreenshotSize(success ? snapshot_bounds : gfx::Rect()); 177 FeedbackUtil::SetScreenshotSize(success ? snapshot_bounds : gfx::Rect());
175 178
176 std::string feedback_url = std::string(chrome::kChromeUIFeedbackURL) + "?" + 179 std::string feedback_url = std::string(chrome::kChromeUIFeedbackURL) + "?" +
177 kSessionIDParameter + base::IntToString(browser->session_id().id()) + 180 kSessionIDParameter + base::IntToString(browser->session_id().id()) +
178 "&" + kTabIndexParameter + base::IntToString(browser->active_index()) + 181 "&" + kTabIndexParameter + base::IntToString(browser->active_index()) +
179 "&" + kDescriptionParameter + 182 "&" + kDescriptionParameter +
180 net::EscapeUrlEncodedData(description_template, false) + "&" + 183 net::EscapeUrlEncodedData(description_template, false) + "&" +
181 kCategoryTagParameter + net::EscapeUrlEncodedData(category_tag, false); 184 kCategoryTagParameter + net::EscapeUrlEncodedData(category_tag, false);
182 185
183 #if defined(OS_CHROMEOS) 186 #if defined(OS_CHROMEOS)
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 web_ui()->RegisterMessageCallback("openSystemTab", 435 web_ui()->RegisterMessageCallback("openSystemTab",
433 base::Bind(&FeedbackHandler::HandleOpenSystemTab, 436 base::Bind(&FeedbackHandler::HandleOpenSystemTab,
434 base::Unretained(this))); 437 base::Unretained(this)));
435 } 438 }
436 439
437 void FeedbackHandler::HandleGetDialogDefaults(const ListValue*) { 440 void FeedbackHandler::HandleGetDialogDefaults(const ListValue*) {
438 // Will delete itself when feedback_data_->SendReport() is called. 441 // Will delete itself when feedback_data_->SendReport() is called.
439 feedback_data_ = new FeedbackData(); 442 feedback_data_ = new FeedbackData();
440 443
441 // send back values which the dialog js needs initially 444 // send back values which the dialog js needs initially
442 ListValue dialog_defaults; 445 ListValue dialog_defaults;
Evan Stade 2012/07/16 18:39:50 this would be a lot better as a dictionary.
qfel 2012/07/17 13:33:43 Done.
443 446
444 // 0: current url 447 // 0: current url
445 if (target_tab_url_.length()) 448 if (target_tab_url_.length())
446 dialog_defaults.Append(new StringValue(target_tab_url_)); 449 dialog_defaults.Append(new StringValue(target_tab_url_));
447 else 450 else
448 dialog_defaults.Append(new StringValue("")); 451 dialog_defaults.Append(new StringValue(""));
449 452
453 // 1: are screenshots disabled?
454 bool disable_screenshots =
455 g_browser_process->local_state()->GetBoolean(prefs::kDisableScreenshots);
456 dialog_defaults.Append(base::Value::CreateBooleanValue(disable_screenshots));
457
450 #if defined(OS_CHROMEOS) 458 #if defined(OS_CHROMEOS)
451 // 1: about:system
452 dialog_defaults.Append(new StringValue(chrome::kChromeUISystemInfoURL));
453 // Trigger the request for system information here. 459 // Trigger the request for system information here.
454 chromeos::system::SyslogsProvider* provider = 460 chromeos::system::SyslogsProvider* provider =
455 chromeos::system::SyslogsProvider::GetInstance(); 461 chromeos::system::SyslogsProvider::GetInstance();
456 if (provider) { 462 if (provider) {
457 syslogs_handle_ = provider->RequestSyslogs( 463 syslogs_handle_ = provider->RequestSyslogs(
458 true, // don't compress. 464 true, // don't compress.
459 chromeos::system::SyslogsProvider::SYSLOGS_FEEDBACK, 465 chromeos::system::SyslogsProvider::SYSLOGS_FEEDBACK,
460 &syslogs_consumer_, 466 &syslogs_consumer_,
461 base::Bind(&FeedbackData::SyslogsComplete, 467 base::Bind(&FeedbackData::SyslogsComplete,
462 base::Unretained(feedback_data_))); 468 base::Unretained(feedback_data_)));
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
645 size_t sort_size = std::min(max_saved, screenshot_filepaths.size()); 651 size_t sort_size = std::min(max_saved, screenshot_filepaths.size());
646 std::partial_sort(screenshot_filepaths.begin(), 652 std::partial_sort(screenshot_filepaths.begin(),
647 screenshot_filepaths.begin() + sort_size, 653 screenshot_filepaths.begin() + sort_size,
648 screenshot_filepaths.end(), 654 screenshot_filepaths.end(),
649 ScreenshotTimestampComp); 655 ScreenshotTimestampComp);
650 for (size_t i = 0; i < sort_size; ++i) 656 for (size_t i = 0; i < sort_size; ++i)
651 saved_screenshots->push_back(std::string(kSavedScreenshotsUrl) + 657 saved_screenshots->push_back(std::string(kSavedScreenshotsUrl) +
652 screenshot_filepaths[i]); 658 screenshot_filepaths[i]);
653 } 659 }
654 #endif 660 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698