diff options
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/views/browser_dialogs.h | 25 | ||||
-rw-r--r-- | chrome/browser/views/bug_report_view.cc | 42 | ||||
-rw-r--r-- | chrome/browser/views/bug_report_view.h | 3 | ||||
-rw-r--r-- | chrome/browser/views/frame/browser_view.cc | 36 |
4 files changed, 65 insertions, 41 deletions
diff --git a/chrome/browser/views/browser_dialogs.h b/chrome/browser/views/browser_dialogs.h new file mode 100644 index 0000000..47221fe --- /dev/null +++ b/chrome/browser/views/browser_dialogs.h @@ -0,0 +1,25 @@ +// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_VIEWS_BROWSER_DIALOGS_H_ +#define CHROME_BROWSER_VIEWS_BROWSER_DIALOGS_H_ + +// This file contains functions for running a variety of browser dialogs and +// popups. The dialogs here are the ones that the caller does not need to +// access the class of the popup. It allows us to break dependencies by +// allowing the callers to not depend on the classes implementing the dialogs. + +class Profile; +class TabContents; + +namespace views { +class Widget; +} // namespace views + +// Shows the "Report a problem with this page" dialog box. See BugReportView. +void ShowBugReportView(views::Widget* parent, + Profile* profile, + TabContents* tab); + +#endif // CHROME_BROWSER_VIEWS_BROWSER_DIALOGS_H_ diff --git a/chrome/browser/views/bug_report_view.cc b/chrome/browser/views/bug_report_view.cc index e4bdd7d..1c91753 100644 --- a/chrome/browser/views/bug_report_view.cc +++ b/chrome/browser/views/bug_report_view.cc @@ -8,6 +8,8 @@ #include <fstream> #include "app/l10n_util.h" +#include "app/win_util.h" +#include "base/file_version_info.h" #include "base/string_util.h" #include "chrome/browser/net/url_fetcher.h" #include "chrome/browser/profile.h" @@ -26,6 +28,7 @@ #include "views/controls/label.h" #include "views/grid_layout.h" #include "views/standard_layout.h" +#include "views/widget/widget.h" #include "views/window/client_view.h" #include "views/window/window.h" @@ -110,6 +113,25 @@ class BugReportView::PostCleanup : public URLFetcher::Delegate { DISALLOW_COPY_AND_ASSIGN(PostCleanup); }; +// Global "display this dialog" function declared in browser_dialogs.h. +void ShowBugReportView(views::Widget* parent, + Profile* profile, + TabContents* tab) { + BugReportView* view = new BugReportView(profile, tab); + + // Grab an exact snapshot of the window that the user is seeing (i.e. as + // rendered--do not re-render, and include windowed plugins) + std::vector<unsigned char> *screenshot_png = new std::vector<unsigned char>; + win_util::GrabWindowSnapshot(parent->GetNativeView(), screenshot_png); + // the BugReportView takes ownership of the png data, and will dispose of + // it in its destructor. + view->set_png_data(screenshot_png); + + // Create and show the dialog. + views::Window::CreateChromeWindow(parent->GetNativeView(), gfx::Rect(), + view)->Show(); +} + BugReportView::PostCleanup::PostCleanup() { } @@ -138,6 +160,22 @@ BugReportView::BugReportView(Profile* profile, TabContents* tab) problem_type_(0) { DCHECK(profile); SetupControl(); + + // We want to use the URL of the current committed entry (the current URL may + // actually be the pending one). + if (tab->controller().GetActiveEntry()) { + page_url_text_->SetText(UTF8ToWide( + tab->controller().GetActiveEntry()->url().spec())); + } + + // Retrieve the application version info. + scoped_ptr<FileVersionInfo> version_info( + FileVersionInfo::CreateFileVersionInfoForCurrentModule()); + if (version_info.get()) { + version_ = version_info->product_name() + L" - " + + version_info->file_version() + + L" (" + version_info->last_change() + L")"; + } } BugReportView::~BugReportView() { @@ -319,10 +357,6 @@ views::View* BugReportView::GetContentsView() { return this; } -void BugReportView::SetUrl(const GURL& url) { - page_url_text_->SetText(UTF8ToWide(url.spec())); -} - // SetOSVersion copies the maj.minor.build + servicePack_string // into a string (for Windows only). This should probably be // in a util somewhere. We currently have diff --git a/chrome/browser/views/bug_report_view.h b/chrome/browser/views/bug_report_view.h index 9edf1f0..9fec67f 100644 --- a/chrome/browser/views/bug_report_view.h +++ b/chrome/browser/views/bug_report_view.h @@ -40,7 +40,6 @@ class BugReportView : public views::View, explicit BugReportView(Profile* profile, TabContents* tab); virtual ~BugReportView(); - void set_version(const std::wstring& version) { version_ = version; } // NOTE: set_png_data takes ownership of the vector void set_png_data(std::vector<unsigned char> *png_data) { png_data_.reset(png_data); @@ -72,8 +71,6 @@ class BugReportView : public views::View, virtual bool Accept(); virtual views::View* GetContentsView(); - void SetUrl(const GURL& url); - private: class PostCleanup; diff --git a/chrome/browser/views/frame/browser_view.cc b/chrome/browser/views/frame/browser_view.cc index 000371c..ce0197d 100644 --- a/chrome/browser/views/frame/browser_view.cc +++ b/chrome/browser/views/frame/browser_view.cc @@ -9,9 +9,7 @@ #include "app/l10n_util.h" #include "app/os_exchange_data.h" #include "app/resource_bundle.h" -#include "app/win_util.h" #include "base/command_line.h" -#include "base/file_version_info.h" #include "base/time.h" #include "chrome/app/chrome_dll_resource.h" #include "chrome/browser/app_modal_dialog_queue.h" @@ -28,6 +26,7 @@ #include "chrome/browser/views/bookmark_bubble_view.h" #include "chrome/browser/views/bookmark_manager_view.h" #include "chrome/browser/views/browser_bubble.h" +#include "chrome/browser/views/browser_dialogs.h" #include "chrome/browser/views/bug_report_view.h" #include "chrome/browser/views/chrome_views_delegate.h" #include "chrome/browser/views/clear_browsing_data.h" @@ -810,38 +809,7 @@ void BrowserView::ShowReportBugDialog() { TabContents* current_tab = browser_->GetSelectedTabContents(); if (!current_tab) return; - - BugReportView* bug_report_view = new BugReportView(browser_->profile(), - current_tab); - - if (current_tab->controller().GetLastCommittedEntry()) { - // URL for the current page - bug_report_view->SetUrl( - current_tab->controller().GetActiveEntry()->url()); - } - - // retrieve the application version info - std::wstring version; - scoped_ptr<FileVersionInfo> version_info( - FileVersionInfo::CreateFileVersionInfoForCurrentModule()); - if (version_info.get()) { - version = version_info->product_name() + L" - " + - version_info->file_version() + - L" (" + version_info->last_change() + L")"; - } - bug_report_view->set_version(version); - - // Grab an exact snapshot of the window that the user is seeing (i.e. as - // rendered--do not re-render, and include windowed plugins) - std::vector<unsigned char> *screenshot_png = new std::vector<unsigned char>; - win_util::GrabWindowSnapshot(GetWidget()->GetNativeView(), screenshot_png); - // the BugReportView takes ownership of the png data, and will dispose of - // it in its destructor. - bug_report_view->set_png_data(screenshot_png); - - // Create and show the dialog - views::Window::CreateChromeWindow(GetWidget()->GetNativeView(), gfx::Rect(), - bug_report_view)->Show(); + ShowBugReportView(GetWidget(), browser_->profile(), current_tab); } void BrowserView::ShowClearBrowsingDataDialog() { |