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

Side by Side Diff: chrome/browser/dom_ui/bug_report_ui.cc

Issue 5514001: Crash fix + OS specific ss's enabled. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Moved TODO to the h file from the cc file. Created 10 years 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/dom_ui/bug_report_ui.h ('k') | chrome/browser/gtk/browser_window_gtk.cc » ('j') | 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 done.Wait(); 109 done.Wait();
110 } 110 }
111 111
112 std::string GetUserEmail() { 112 std::string GetUserEmail() {
113 chromeos::UserManager* manager = chromeos::UserManager::Get(); 113 chromeos::UserManager* manager = chromeos::UserManager::Get();
114 if (!manager) 114 if (!manager)
115 return std::string(); 115 return std::string();
116 else 116 else
117 return manager->logged_in_user().email(); 117 return manager->logged_in_user().email();
118 } 118 }
119 #endif
119 120
120 #endif 121 // Returns the index of the feedback tab if already open, -1 otherwise
122 int GetIndexOfFeedbackTab(Browser* browser) {
123 GURL bug_report_url(chrome::kChromeUIBugReportURL);
124 for (int i = 0; i < browser->tab_count(); ++i) {
125 TabContents* tab = browser->GetTabContentsAt(i);
126 if (tab && tab->GetURL().GetWithEmptyPath() == bug_report_url)
127 return i;
128 }
129
130 return -1;
131 }
132
121 } // namespace 133 } // namespace
122 134
123 135
124 namespace browser { 136 namespace browser {
125 137
126 // TODO(rkc): Eventually find a better way to do this 138 // TODO(rkc): Eventually find a better way to do this
127 std::vector<unsigned char>* last_screenshot_png = 0; 139 std::vector<unsigned char>* last_screenshot_png = 0;
128 gfx::Rect screen_size; 140 gfx::Rect screen_size;
129 141
142 // Get bounds in different ways for different OS's;
143 #if defined(TOOLKIT_VIEWS)
144 // Windows/ChromeOS support Views - so we get dimensions from the
145 // views::Window object
130 void RefreshLastScreenshot(views::Window* parent) { 146 void RefreshLastScreenshot(views::Window* parent) {
147 gfx::NativeWindow window = parent->GetNativeWindow();
148 int width = parent->GetBounds().width();
149 int height = parent->GetBounds().height();
150 #elif defined(OS_LINUX)
151 // Linux provides its bounds and a native window handle to the screen
152 void RefreshLastScreenshot(gfx::NativeWindow window,
153 const gfx::Rect& bounds) {
154 int width = bounds.width();
155 int height = bounds.height();
156 #elif defined(OS_MACOSX)
157 // Mac gets its bounds from the GrabWindowSnapshot function
158 void RefreshLastScreenshot(NSWindow* window) {
159 int width = 0;
160 int height = 0;
161 #endif
162
131 // Grab an exact snapshot of the window that the user is seeing (i.e. as 163 // Grab an exact snapshot of the window that the user is seeing (i.e. as
132 // rendered--do not re-render, and include windowed plugins). 164 // rendered--do not re-render, and include windowed plugins).
133 if (last_screenshot_png) 165 if (last_screenshot_png)
134 last_screenshot_png->clear(); 166 last_screenshot_png->clear();
135 else 167 else
136 last_screenshot_png = new std::vector<unsigned char>; 168 last_screenshot_png = new std::vector<unsigned char>;
137 169
138 #if defined(USE_X11) 170 #if defined(USE_X11)
139 screen_size = parent->GetBounds(); 171 x11_util::GrabWindowSnapshot(window, last_screenshot_png);
140 x11_util::GrabWindowSnapshot(parent->GetNativeWindow(), last_screenshot_png);
141 #elif defined(OS_MACOSX) 172 #elif defined(OS_MACOSX)
142 int width = 0, height = 0; 173 mac_util::GrabWindowSnapshot(window, last_screenshot_png, &width, &height);
143 mac_util::GrabWindowSnapshot(parent->GetNativeWindow(), last_screenshot_png,
144 &width, &height);
145 #elif defined(OS_WIN) 174 #elif defined(OS_WIN)
146 screen_size = parent->GetBounds(); 175 win_util::GrabWindowSnapshot(window, last_screenshot_png);
147 win_util::GrabWindowSnapshot(parent->GetNativeWindow(), last_screenshot_png);
148 #endif 176 #endif
177
178 screen_size.set_width(width);
179 screen_size.set_height(height);
149 } 180 }
150 181
151 // Global "display this dialog" function declared in browser_dialogs.h. 182 #if defined(TOOLKIT_VIEWS)
152 void ShowHtmlBugReportView(views::Window* parent, Browser* browser) { 183 void ShowHtmlBugReportView(views::Window* parent, Browser* browser) {
184 #elif defined(OS_LINUX)
185 void ShowHtmlBugReportView(gfx::NativeWindow window, const gfx::Rect& bounds,
186 Browser* browser) {
187 #elif defined(OS_MACOSX)
188 void ShowHtmlBugReportView(NSWindow* window, Browser* browser) {
189 #endif
190
191 // First check if we're already open (we cannot depend on ShowSingletonTab
192 // for this functionality since we need to make *sure* we never get
193 // instantiated again while we are open - with singleton tabs, that can
194 // happen)
195 int feedback_tab_index = GetIndexOfFeedbackTab(browser);
196 if (feedback_tab_index >=0) {
197 // Do not refresh screenshot, do not create a new tab
198 browser->SelectTabContentsAt(feedback_tab_index, true);
199 }
200
201 // now for refreshing the last screenshot
202 #if defined(TOOLKIT_VIEWS)
203 RefreshLastScreenshot(parent);
204 #elif defined(OS_LINUX)
205 RefreshLastScreenshot(window, bounds);
206 #elif defined(OS_MACOSX)
207 RefreshLastScreenshot(window);
208 #endif
209
153 std::string bug_report_url = std::string(chrome::kChromeUIBugReportURL) + 210 std::string bug_report_url = std::string(chrome::kChromeUIBugReportURL) +
154 "#" + base::IntToString(browser->selected_index()); 211 "#" + base::IntToString(browser->selected_index());
155
156 RefreshLastScreenshot(parent);
157 browser->ShowSingletonTab(GURL(bug_report_url), false); 212 browser->ShowSingletonTab(GURL(bug_report_url), false);
158 } 213 }
159 214
160 } // namespace browser 215 } // namespace browser
161 216
162 217
163 class BugReportUIHTMLSource : public ChromeURLDataManager::DataSource { 218 class BugReportUIHTMLSource : public ChromeURLDataManager::DataSource {
164 public: 219 public:
165 explicit BugReportUIHTMLSource(base::StringPiece html); 220 explicit BugReportUIHTMLSource(base::StringPiece html);
166 221
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after
655 } 710 }
656 711
657 // #5 - System info checkbox. 712 // #5 - System info checkbox.
658 std::string sys_info_checkbox; 713 std::string sys_info_checkbox;
659 (*i)->GetAsString(&sys_info_checkbox); 714 (*i)->GetAsString(&sys_info_checkbox);
660 bool send_sys_info = (sys_info_checkbox == "true"); 715 bool send_sys_info = (sys_info_checkbox == "true");
661 716
662 // If we aren't sending the sys_info, cancel the gathering of the syslogs. 717 // If we aren't sending the sys_info, cancel the gathering of the syslogs.
663 if (!send_sys_info) 718 if (!send_sys_info)
664 CancelFeedbackCollection(); 719 CancelFeedbackCollection();
720 #endif
665 721
666 // Update the data in bug_report_ so it can be sent 722 // Update the data in bug_report_ so it can be sent
667 bug_report_->UpdateData(dom_ui_->GetProfile() 723 bug_report_->UpdateData(dom_ui_->GetProfile()
668 , target_tab_url_ 724 , target_tab_url_
669 , target_tab_title_ 725 , target_tab_title_
670 , problem_type 726 , problem_type
671 , page_url 727 , page_url
672 , description 728 , description
673 , image 729 , image
674 #if defined(OS_CHROMEOS) 730 #if defined(OS_CHROMEOS)
675 , user_email 731 , user_email
676 , send_sys_info 732 , send_sys_info
677 , false // sent_report 733 , false // sent_report
678 #endif 734 #endif
679 ); 735 );
680 736
737 #if defined(OS_CHROMEOS)
681 // If we don't require sys_info, or we have it, or we never requested it 738 // If we don't require sys_info, or we have it, or we never requested it
682 // (because libcros failed to load), then send the report now. 739 // (because libcros failed to load), then send the report now.
683 // Otherwise, the report will get sent when we receive sys_info. 740 // Otherwise, the report will get sent when we receive sys_info.
684 if (!send_sys_info || bug_report_->sys_info() != NULL || 741 if (!send_sys_info || bug_report_->sys_info() != NULL ||
685 syslogs_handle_ == 0) { 742 syslogs_handle_ == 0) {
686 bug_report_->SendReport(); 743 bug_report_->SendReport();
687 } 744 }
688 #else 745 #else
689 bug_report_->SendReport(); 746 bug_report_->SendReport();
690 #endif 747 #endif
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
743 BugReportUIHTMLSource* html_source = 800 BugReportUIHTMLSource* html_source =
744 new BugReportUIHTMLSource(handler->Init()); 801 new BugReportUIHTMLSource(handler->Init());
745 // Set up the chrome://bugreport/ source. 802 // Set up the chrome://bugreport/ source.
746 BrowserThread::PostTask( 803 BrowserThread::PostTask(
747 BrowserThread::IO, FROM_HERE, 804 BrowserThread::IO, FROM_HERE,
748 NewRunnableMethod( 805 NewRunnableMethod(
749 Singleton<ChromeURLDataManager>::get(), 806 Singleton<ChromeURLDataManager>::get(),
750 &ChromeURLDataManager::AddDataSource, 807 &ChromeURLDataManager::AddDataSource,
751 make_scoped_refptr(html_source))); 808 make_scoped_refptr(html_source)));
752 } 809 }
OLDNEW
« no previous file with comments | « chrome/browser/dom_ui/bug_report_ui.h ('k') | chrome/browser/gtk/browser_window_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698