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/dom_ui/bug_report_ui.h" | 5 #include "chrome/browser/dom_ui/bug_report_ui.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/callback.h" | 11 #include "base/callback.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/message_loop.h" | 13 #include "base/message_loop.h" |
14 #include "base/singleton.h" | 14 #include "base/singleton.h" |
15 #include "base/string_number_conversions.h" | 15 #include "base/string_number_conversions.h" |
16 #include "base/string_piece.h" | 16 #include "base/string_piece.h" |
17 #include "base/utf_string_conversions.h" | 17 #include "base/utf_string_conversions.h" |
18 #include "base/values.h" | 18 #include "base/values.h" |
19 #include "base/weak_ptr.h" | 19 #include "base/weak_ptr.h" |
20 #include "chrome/browser/browser_thread.h" | 20 #include "chrome/browser/browser_thread.h" |
21 #include "chrome/browser/bug_report_data.h" | 21 #include "chrome/browser/bug_report_data.h" |
22 #include "chrome/browser/bug_report_util.h" | 22 #include "chrome/browser/bug_report_util.h" |
23 #include "chrome/browser/dom_ui/web_ui_screenshot_source.h" | 23 #include "chrome/browser/dom_ui/web_ui_screenshot_source.h" |
24 #include "chrome/browser/tab_contents/tab_contents.h" | 24 #include "chrome/browser/tab_contents/tab_contents.h" |
25 #include "chrome/browser/ui/browser.h" | 25 #include "chrome/browser/ui/browser.h" |
26 #include "chrome/browser/ui/browser_list.h" | 26 #include "chrome/browser/ui/browser_list.h" |
27 #include "chrome/browser/ui/browser_window.h" | 27 #include "chrome/browser/ui/browser_window.h" |
| 28 #include "chrome/browser/ui/window_snapshot/window_snapshot.h" |
28 #include "chrome/common/chrome_paths.h" | 29 #include "chrome/common/chrome_paths.h" |
29 #include "chrome/common/jstemplate_builder.h" | 30 #include "chrome/common/jstemplate_builder.h" |
30 #include "chrome/common/url_constants.h" | 31 #include "chrome/common/url_constants.h" |
31 #include "gfx/rect.h" | 32 #include "gfx/rect.h" |
32 #include "grit/browser_resources.h" | 33 #include "grit/browser_resources.h" |
33 #include "grit/chromium_strings.h" | 34 #include "grit/chromium_strings.h" |
34 #include "grit/generated_resources.h" | 35 #include "grit/generated_resources.h" |
35 #include "grit/locale_settings.h" | 36 #include "grit/locale_settings.h" |
36 #include "ui/base/l10n/l10n_util.h" | 37 #include "ui/base/l10n/l10n_util.h" |
37 #include "ui/base/resource/resource_bundle.h" | 38 #include "ui/base/resource/resource_bundle.h" |
38 | 39 |
39 #if defined(USE_X11) | |
40 #include "ui/base/x/x11_util.h" | |
41 #elif defined(OS_MACOSX) | |
42 #include "base/mac/mac_util.h" | |
43 #elif defined(OS_WIN) | |
44 #include "app/win/win_util.h" | |
45 #endif | |
46 | |
47 #if defined(TOOLKIT_VIEWS) | |
48 #include "views/window/window.h" | |
49 #endif | |
50 | |
51 #if defined(OS_CHROMEOS) | 40 #if defined(OS_CHROMEOS) |
52 #include "base/file_util.h" | 41 #include "base/file_util.h" |
53 #include "base/path_service.h" | 42 #include "base/path_service.h" |
54 #include "base/synchronization/waitable_event.h" | 43 #include "base/synchronization/waitable_event.h" |
55 #include "chrome/browser/chromeos/cros/cros_library.h" | 44 #include "chrome/browser/chromeos/cros/cros_library.h" |
56 #include "chrome/browser/chromeos/cros/syslogs_library.h" | 45 #include "chrome/browser/chromeos/cros/syslogs_library.h" |
57 #include "chrome/browser/chromeos/login/user_manager.h" | 46 #include "chrome/browser/chromeos/login/user_manager.h" |
58 #endif | 47 #endif |
59 | 48 |
60 namespace { | 49 namespace { |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 // TODO(rkc): Eventually find a better way to do this | 130 // TODO(rkc): Eventually find a better way to do this |
142 std::vector<unsigned char>* last_screenshot_png = 0; | 131 std::vector<unsigned char>* last_screenshot_png = 0; |
143 gfx::Rect screen_size; | 132 gfx::Rect screen_size; |
144 | 133 |
145 void RefreshLastScreenshot(Browser* browser) { | 134 void RefreshLastScreenshot(Browser* browser) { |
146 if (last_screenshot_png) | 135 if (last_screenshot_png) |
147 last_screenshot_png->clear(); | 136 last_screenshot_png->clear(); |
148 else | 137 else |
149 last_screenshot_png = new std::vector<unsigned char>; | 138 last_screenshot_png = new std::vector<unsigned char>; |
150 | 139 |
151 screen_size = browser->window()->GrabWindowSnapshot(last_screenshot_png); | 140 gfx::NativeWindow native_window = browser->window()->GetNativeHandle(); |
| 141 screen_size = browser::GrabWindowSnapshot(native_window, last_screenshot_png); |
152 } | 142 } |
153 | 143 |
154 void ShowHtmlBugReportView(Browser* browser) { | 144 void ShowHtmlBugReportView(Browser* browser) { |
155 // First check if we're already open (we cannot depend on ShowSingletonTab | 145 // First check if we're already open (we cannot depend on ShowSingletonTab |
156 // for this functionality since we need to make *sure* we never get | 146 // for this functionality since we need to make *sure* we never get |
157 // instantiated again while we are open - with singleton tabs, that can | 147 // instantiated again while we are open - with singleton tabs, that can |
158 // happen) | 148 // happen) |
159 int feedback_tab_index = GetIndexOfFeedbackTab(browser); | 149 int feedback_tab_index = GetIndexOfFeedbackTab(browser); |
160 if (feedback_tab_index >=0) { | 150 if (feedback_tab_index >=0) { |
161 // Do not refresh screenshot, do not create a new tab | 151 // Do not refresh screenshot, do not create a new tab |
(...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
759 BugReportUIHTMLSource* html_source = | 749 BugReportUIHTMLSource* html_source = |
760 new BugReportUIHTMLSource(handler->Init()); | 750 new BugReportUIHTMLSource(handler->Init()); |
761 // Set up the chrome://bugreport/ source. | 751 // Set up the chrome://bugreport/ source. |
762 BrowserThread::PostTask( | 752 BrowserThread::PostTask( |
763 BrowserThread::IO, FROM_HERE, | 753 BrowserThread::IO, FROM_HERE, |
764 NewRunnableMethod( | 754 NewRunnableMethod( |
765 ChromeURLDataManager::GetInstance(), | 755 ChromeURLDataManager::GetInstance(), |
766 &ChromeURLDataManager::AddDataSource, | 756 &ChromeURLDataManager::AddDataSource, |
767 make_scoped_refptr(html_source))); | 757 make_scoped_refptr(html_source))); |
768 } | 758 } |
OLD | NEW |