OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/views/bug_report_view.h" | 5 #include "chrome/browser/views/bug_report_view.h" |
6 | 6 |
7 #include <iostream> | 7 #include <iostream> |
8 #include <fstream> | 8 #include <fstream> |
9 | 9 |
10 #include "app/l10n_util.h" | 10 #include "app/l10n_util.h" |
(...skipping 27 matching lines...) Expand all Loading... |
38 // Report a bug data version | 38 // Report a bug data version |
39 static const int kBugReportVersion = 1; | 39 static const int kBugReportVersion = 1; |
40 | 40 |
41 // Number of lines description field can display at one time. | 41 // Number of lines description field can display at one time. |
42 static const int kDescriptionLines = 5; | 42 static const int kDescriptionLines = 5; |
43 | 43 |
44 // Google's phishing reporting URL. | 44 // Google's phishing reporting URL. |
45 static const char kReportPhishingUrl[] = | 45 static const char kReportPhishingUrl[] = |
46 "http://www.google.com/safebrowsing/report_phish/"; | 46 "http://www.google.com/safebrowsing/report_phish/"; |
47 | 47 |
48 class BugReportComboBoxModel : public views::ComboBox::Model { | 48 class BugReportComboBoxModel : public views::Combobox::Model { |
49 public: | 49 public: |
50 BugReportComboBoxModel() {} | 50 BugReportComboBoxModel() {} |
51 | 51 |
52 enum BugType { | 52 enum BugType { |
53 PAGE_WONT_LOAD = 0, | 53 PAGE_WONT_LOAD = 0, |
54 PAGE_LOOKS_ODD, | 54 PAGE_LOOKS_ODD, |
55 PHISHING_PAGE, | 55 PHISHING_PAGE, |
56 CANT_SIGN_IN, | 56 CANT_SIGN_IN, |
57 CHROME_MISBEHAVES, | 57 CHROME_MISBEHAVES, |
58 SOMETHING_MISSING, | 58 SOMETHING_MISSING, |
59 BROWSER_CRASH, | 59 BROWSER_CRASH, |
60 OTHER_PROBLEM | 60 OTHER_PROBLEM |
61 }; | 61 }; |
62 | 62 |
63 // views::ComboBox::Model interface. | 63 // views::Combobox::Model interface. |
64 virtual int GetItemCount(views::ComboBox* source) { | 64 virtual int GetItemCount(views::Combobox* source) { |
65 return OTHER_PROBLEM + 1; | 65 return OTHER_PROBLEM + 1; |
66 } | 66 } |
67 | 67 |
68 virtual std::wstring GetItemAt(views::ComboBox* source, int index) { | 68 virtual std::wstring GetItemAt(views::Combobox* source, int index) { |
69 return GetItemAtIndex(index); | 69 return GetItemAtIndex(index); |
70 } | 70 } |
71 | 71 |
72 static std::wstring GetItemAtIndex(int index) { | 72 static std::wstring GetItemAtIndex(int index) { |
73 switch (index) { | 73 switch (index) { |
74 case PAGE_WONT_LOAD: | 74 case PAGE_WONT_LOAD: |
75 return l10n_util::GetString(IDS_BUGREPORT_PAGE_WONT_LOAD); | 75 return l10n_util::GetString(IDS_BUGREPORT_PAGE_WONT_LOAD); |
76 case PAGE_LOOKS_ODD: | 76 case PAGE_LOOKS_ODD: |
77 return l10n_util::GetString(IDS_BUGREPORT_PAGE_LOOKS_ODD); | 77 return l10n_util::GetString(IDS_BUGREPORT_PAGE_LOOKS_ODD); |
78 case PHISHING_PAGE: | 78 case PHISHING_PAGE: |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 | 184 |
185 BugReportView::~BugReportView() { | 185 BugReportView::~BugReportView() { |
186 } | 186 } |
187 | 187 |
188 void BugReportView::SetupControl() { | 188 void BugReportView::SetupControl() { |
189 bug_type_model_.reset(new BugReportComboBoxModel); | 189 bug_type_model_.reset(new BugReportComboBoxModel); |
190 | 190 |
191 // Adds all controls. | 191 // Adds all controls. |
192 bug_type_label_ = new views::Label( | 192 bug_type_label_ = new views::Label( |
193 l10n_util::GetString(IDS_BUGREPORT_BUG_TYPE)); | 193 l10n_util::GetString(IDS_BUGREPORT_BUG_TYPE)); |
194 bug_type_combo_ = new views::ComboBox(bug_type_model_.get()); | 194 bug_type_combo_ = new views::Combobox(bug_type_model_.get()); |
195 bug_type_combo_->SetListener(this); | 195 bug_type_combo_->set_listener(this); |
196 | 196 |
197 page_title_label_ = new views::Label( | 197 page_title_label_ = new views::Label( |
198 l10n_util::GetString(IDS_BUGREPORT_REPORT_PAGE_TITLE)); | 198 l10n_util::GetString(IDS_BUGREPORT_REPORT_PAGE_TITLE)); |
199 page_title_text_ = new views::Label(UTF16ToWideHack(tab_->GetTitle())); | 199 page_title_text_ = new views::Label(UTF16ToWideHack(tab_->GetTitle())); |
200 page_url_label_ = new views::Label( | 200 page_url_label_ = new views::Label( |
201 l10n_util::GetString(IDS_BUGREPORT_REPORT_URL_LABEL)); | 201 l10n_util::GetString(IDS_BUGREPORT_REPORT_URL_LABEL)); |
202 // page_url_text_'s text (if any) is filled in after dialog creation | 202 // page_url_text_'s text (if any) is filled in after dialog creation |
203 page_url_text_ = new views::Textfield; | 203 page_url_text_ = new views::Textfield; |
204 page_url_text_->SetController(this); | 204 page_url_text_->SetController(this); |
205 | 205 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 layout->AddView(include_page_image_checkbox_); | 265 layout->AddView(include_page_image_checkbox_); |
266 layout->AddPaddingRow(0, kUnrelatedControlVerticalSpacing); | 266 layout->AddPaddingRow(0, kUnrelatedControlVerticalSpacing); |
267 } | 267 } |
268 | 268 |
269 gfx::Size BugReportView::GetPreferredSize() { | 269 gfx::Size BugReportView::GetPreferredSize() { |
270 return gfx::Size(views::Window::GetLocalizedContentsSize( | 270 return gfx::Size(views::Window::GetLocalizedContentsSize( |
271 IDS_BUGREPORT_DIALOG_WIDTH_CHARS, | 271 IDS_BUGREPORT_DIALOG_WIDTH_CHARS, |
272 IDS_BUGREPORT_DIALOG_HEIGHT_LINES)); | 272 IDS_BUGREPORT_DIALOG_HEIGHT_LINES)); |
273 } | 273 } |
274 | 274 |
275 void BugReportView::ItemChanged(views::ComboBox* combo_box, | 275 void BugReportView::ItemChanged(views::Combobox* combobox, |
276 int prev_index, | 276 int prev_index, |
277 int new_index) { | 277 int new_index) { |
278 if (new_index == prev_index) | 278 if (new_index == prev_index) |
279 return; | 279 return; |
280 | 280 |
281 problem_type_ = new_index; | 281 problem_type_ = new_index; |
282 bool is_phishing_report = new_index == BugReportComboBoxModel::PHISHING_PAGE; | 282 bool is_phishing_report = new_index == BugReportComboBoxModel::PHISHING_PAGE; |
283 | 283 |
284 description_text_->SetEnabled(!is_phishing_report); | 284 description_text_->SetEnabled(!is_phishing_report); |
285 description_text_->SetReadOnly(is_phishing_report); | 285 description_text_->SetReadOnly(is_phishing_report); |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
519 fetcher->Start(); | 519 fetcher->Start(); |
520 } | 520 } |
521 | 521 |
522 void BugReportView::ReportPhishing() { | 522 void BugReportView::ReportPhishing() { |
523 tab_->controller().LoadURL( | 523 tab_->controller().LoadURL( |
524 safe_browsing_util::GeneratePhishingReportUrl( | 524 safe_browsing_util::GeneratePhishingReportUrl( |
525 kReportPhishingUrl, WideToUTF8(page_url_text_->text())), | 525 kReportPhishingUrl, WideToUTF8(page_url_text_->text())), |
526 GURL(), | 526 GURL(), |
527 PageTransition::LINK); | 527 PageTransition::LINK); |
528 } | 528 } |
OLD | NEW |