summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhashimoto@chromium.org <hashimoto@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-12 17:16:12 +0000
committerhashimoto@chromium.org <hashimoto@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-12 17:16:12 +0000
commit7f0a3efa2be4ef44c027c44dec637e6c3bbef42f (patch)
tree402e205d9ec8a834819165460dfe52c8141fb8c7
parentad74aa6434bc3a5b095a2fccb885007cbb7d1410 (diff)
downloadchromium_src-7f0a3efa2be4ef44c027c44dec637e6c3bbef42f.zip
chromium_src-7f0a3efa2be4ef44c027c44dec637e6c3bbef42f.tar.gz
chromium_src-7f0a3efa2be4ef44c027c44dec637e6c3bbef42f.tar.bz2
Stop using GetDefaultProfile() in Chrome OS implementation of platform_util::OpenExternal()
Add Profile* as an argument of OpenExternal(). Disallow calling OpenExternal() from threads other than UI thread. Changes for the implementations: Chrome OS implementation: Use the argument Profile and stop posting tasks to UI thread. Win implementation: Post tasks to FILE thread. (for the reason noted in external_protocol_handler.cc) Other implementations: Just add Profile* argument and add thread check. Changes for user code: 1. first_run_dialog.cc: Just pass Profile*. 2. browser_commands.cc: Pass Profile* acquired from Browser. 3. chrome_shell_window_delegate.cc: Pass Profile* acquired from WebContents. 4. external_protocol_handler.cc: Pass Profile* acquired with a pair of render_process_host_id and tab_contents_id. BUG=322682 TEST=git cl try Review URL: https://codereview.chromium.org/107033003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@240346 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/external_protocol/external_protocol_handler.cc39
-rw-r--r--chrome/browser/external_protocol/external_protocol_handler.h5
-rw-r--r--chrome/browser/platform_util.h6
-rw-r--r--chrome/browser/platform_util_android.cc3
-rw-r--r--chrome/browser/platform_util_chromeos.cc31
-rw-r--r--chrome/browser/platform_util_linux.cc3
-rw-r--r--chrome/browser/platform_util_mac.mm2
-rw-r--r--chrome/browser/platform_util_win.cc65
-rw-r--r--chrome/browser/ui/apps/chrome_shell_window_delegate.cc5
-rw-r--r--chrome/browser/ui/browser_commands.cc2
-rw-r--r--chrome/browser/ui/cocoa/external_protocol_dialog.h6
-rw-r--r--chrome/browser/ui/cocoa/external_protocol_dialog.mm13
-rw-r--r--chrome/browser/ui/external_protocol_dialog_delegate.cc12
-rw-r--r--chrome/browser/ui/external_protocol_dialog_delegate.h8
-rw-r--r--chrome/browser/ui/gtk/first_run_dialog.cc13
-rw-r--r--chrome/browser/ui/gtk/first_run_dialog.h6
-rw-r--r--chrome/browser/ui/gtk/protocol_dialog_gtk.cc4
-rw-r--r--chrome/browser/ui/views/external_protocol_dialog.cc24
-rw-r--r--chrome/browser/ui/views/external_protocol_dialog.h16
19 files changed, 150 insertions, 113 deletions
diff --git a/chrome/browser/external_protocol/external_protocol_handler.cc b/chrome/browser/external_protocol/external_protocol_handler.cc
index 2f9b4d9..291652d 100644
--- a/chrome/browser/external_protocol/external_protocol_handler.cc
+++ b/chrome/browser/external_protocol/external_protocol_handler.cc
@@ -17,8 +17,11 @@
#include "build/build_config.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/platform_util.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/tab_contents/tab_util.h"
#include "chrome/common/pref_names.h"
#include "content/public/browser/browser_thread.h"
+#include "content/public/browser/web_contents.h"
#include "net/base/escape.h"
#include "url/gurl.h"
@@ -70,11 +73,15 @@ void RunExternalProtocolDialogWithDelegate(
void LaunchUrlWithoutSecurityCheckWithDelegate(
const GURL& url,
+ int render_process_host_id,
+ int tab_contents_id,
ExternalProtocolHandler::Delegate* delegate) {
- if (!delegate)
- ExternalProtocolHandler::LaunchUrlWithoutSecurityCheck(url);
- else
+ if (!delegate) {
+ ExternalProtocolHandler::LaunchUrlWithoutSecurityCheck(
+ url, render_process_host_id, tab_contents_id);
+ } else {
delegate->LaunchUrlWithoutSecurityCheck(url);
+ }
}
// When we are about to launch a URL with the default OS level application,
@@ -124,7 +131,8 @@ class ExternalDefaultProtocolObserver
return;
}
- LaunchUrlWithoutSecurityCheckWithDelegate(escaped_url_, delegate_);
+ LaunchUrlWithoutSecurityCheckWithDelegate(
+ escaped_url_, render_process_host_id_, tab_contents_id_, delegate_);
}
virtual bool IsOwnedByWorker() OVERRIDE { return true; }
@@ -282,18 +290,17 @@ void ExternalProtocolHandler::LaunchUrlWithDelegate(const GURL& url,
}
// static
-void ExternalProtocolHandler::LaunchUrlWithoutSecurityCheck(const GURL& url) {
-#if defined(OS_MACOSX)
- // This must run on the UI thread on OS X.
- platform_util::OpenExternal(url);
-#else
- // Otherwise put this work on the file thread. On Windows ShellExecute may
- // block for a significant amount of time, and it shouldn't hurt on Linux.
- BrowserThread::PostTask(
- BrowserThread::FILE,
- FROM_HERE,
- base::Bind(&platform_util::OpenExternal, url));
-#endif
+void ExternalProtocolHandler::LaunchUrlWithoutSecurityCheck(
+ const GURL& url,
+ int render_process_host_id,
+ int tab_contents_id) {
+ content::WebContents* web_contents = tab_util::GetWebContentsByID(
+ render_process_host_id, tab_contents_id);
+ if (!web_contents)
+ return;
+
+ platform_util::OpenExternal(
+ Profile::FromBrowserContext(web_contents->GetBrowserContext()), url);
}
// static
diff --git a/chrome/browser/external_protocol/external_protocol_handler.h b/chrome/browser/external_protocol/external_protocol_handler.h
index 7b5fa3f..7c934c5 100644
--- a/chrome/browser/external_protocol/external_protocol_handler.h
+++ b/chrome/browser/external_protocol/external_protocol_handler.h
@@ -88,8 +88,9 @@ class ExternalProtocolHandler {
// NOTE: You should Not call this function directly unless you are sure the
// url you have has been checked against the blacklist, and has been escaped.
// All calls to this function should originate in some way from LaunchUrl.
- // This will execute on the file thread.
- static void LaunchUrlWithoutSecurityCheck(const GURL& url);
+ static void LaunchUrlWithoutSecurityCheck(const GURL& url,
+ int render_process_host_id,
+ int tab_contents_id);
// Prepopulates the dictionary with known protocols to deny or allow, if
// preferences for them do not already exist.
diff --git a/chrome/browser/platform_util.h b/chrome/browser/platform_util.h
index 0f19494..c2008a1 100644
--- a/chrome/browser/platform_util.h
+++ b/chrome/browser/platform_util.h
@@ -11,6 +11,7 @@
#include "ui/gfx/native_widget_types.h"
class GURL;
+class Profile;
namespace base {
class FilePath;
@@ -28,7 +29,8 @@ void OpenItem(const base::FilePath& full_path);
// Open the given external protocol URL in the desktop's default manner.
// (For example, mailto: URLs in the default mail user agent.)
-void OpenExternal(const GURL& url);
+// Must be called from the UI thread.
+void OpenExternal(Profile* profile, const GURL& url);
// Get the top level window for the native view. This can return NULL.
gfx::NativeWindow GetTopLevel(gfx::NativeView view);
@@ -54,6 +56,6 @@ bool IsVisible(gfx::NativeView view);
bool IsSwipeTrackingFromScrollEventsEnabled();
#endif
-} // platform_util
+} // namespace platform_util
#endif // CHROME_BROWSER_PLATFORM_UTIL_H_
diff --git a/chrome/browser/platform_util_android.cc b/chrome/browser/platform_util_android.cc
index 1476ffd..935bc3a 100644
--- a/chrome/browser/platform_util_android.cc
+++ b/chrome/browser/platform_util_android.cc
@@ -18,7 +18,7 @@ void OpenItem(const base::FilePath& full_path) {
NOTIMPLEMENTED();
}
-void OpenExternal(const GURL& url) {
+void OpenExternal(Profile* profile, const GURL& url) {
NOTIMPLEMENTED();
}
@@ -47,4 +47,3 @@ bool IsVisible(gfx::NativeView view) {
}
} // namespace platform_util
-
diff --git a/chrome/browser/platform_util_chromeos.cc b/chrome/browser/platform_util_chromeos.cc
index 7ccdd58..8824183 100644
--- a/chrome/browser/platform_util_chromeos.cc
+++ b/chrome/browser/platform_util_chromeos.cc
@@ -4,12 +4,8 @@
#include "chrome/browser/platform_util.h"
-#include "base/bind.h"
#include "chrome/browser/chromeos/file_manager/open_util.h"
-#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/ui/browser_navigator.h"
-#include "chrome/browser/ui/host_desktop.h"
-#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "content/public/browser/browser_thread.h"
#include "url/gurl.h"
@@ -20,17 +16,6 @@ namespace {
const char kGmailComposeUrl[] =
"https://mail.google.com/mail/?extsrc=mailto&url=";
-void OpenURL(const std::string& url) {
- // TODO(beng): improve this to locate context from call stack.
- chrome::NavigateParams params(
- ProfileManager::GetDefaultProfileOrOffTheRecord(),
- GURL(url),
- content::PAGE_TRANSITION_LINK);
- params.disposition = NEW_FOREGROUND_TAB;
- params.host_desktop_type = chrome::HOST_DESKTOP_TYPE_ASH;
- chrome::Navigate(&params);
-}
-
} // namespace
namespace platform_util {
@@ -45,7 +30,9 @@ void OpenItem(const base::FilePath& full_path) {
file_manager::util::OpenItem(full_path);
}
-void OpenExternal(const GURL& url) {
+void OpenExternal(Profile* profile, const GURL& url) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+
// This code should be obsolete since we have default handlers in ChromeOS
// which should handle this. However - there are two things which make it
// necessary to keep it in:
@@ -55,15 +42,17 @@ void OpenExternal(const GURL& url) {
// this function directly and which would therefore break (e.g.
// "Browser::EmailPageLocation" (to name only one).
// As such we should keep this code here.
+ chrome::NavigateParams params(profile, url, content::PAGE_TRANSITION_LINK);
+ params.disposition = NEW_FOREGROUND_TAB;
+ params.host_desktop_type = chrome::HOST_DESKTOP_TYPE_ASH;
+
if (url.SchemeIs("mailto")) {
std::string string_url = kGmailComposeUrl;
string_url.append(url.spec());
- BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
- base::Bind(OpenURL, string_url));
- } else if (url.is_valid()) {
- BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
- base::Bind(OpenURL, url.spec()));
+ params.url = GURL(url);
}
+
+ chrome::Navigate(&params);
}
} // namespace platform_util
diff --git a/chrome/browser/platform_util_linux.cc b/chrome/browser/platform_util_linux.cc
index 5e65bc2..002acf0 100644
--- a/chrome/browser/platform_util_linux.cc
+++ b/chrome/browser/platform_util_linux.cc
@@ -76,7 +76,8 @@ void OpenItem(const base::FilePath& full_path) {
base::Bind(&XDGOpen, full_path.value()));
}
-void OpenExternal(const GURL& url) {
+void OpenExternal(Profile* profile, const GURL& url) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
if (url.SchemeIs("mailto"))
XDGEmail(url.spec());
else
diff --git a/chrome/browser/platform_util_mac.mm b/chrome/browser/platform_util_mac.mm
index fad64e6..6741519 100644
--- a/chrome/browser/platform_util_mac.mm
+++ b/chrome/browser/platform_util_mac.mm
@@ -122,7 +122,7 @@ void OpenItem(const base::FilePath& full_path) {
}
}
-void OpenExternal(const GURL& url) {
+void OpenExternal(Profile* profile, const GURL& url) {
DCHECK([NSThread isMainThread]);
NSString* url_string = base::SysUTF8ToNSString(url.spec());
NSURL* ns_url = [NSURL URLWithString:url_string];
diff --git a/chrome/browser/platform_util_win.cc b/chrome/browser/platform_util_win.cc
index aa2a0a1..38ecb39 100644
--- a/chrome/browser/platform_util_win.cc
+++ b/chrome/browser/platform_util_win.cc
@@ -129,35 +129,7 @@ bool ValidateShellCommandForScheme(const std::string& scheme) {
return true;
}
-} // namespace
-
-namespace platform_util {
-
-void ShowItemInFolder(const base::FilePath& full_path) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
-
- if (chrome::GetActiveDesktop() == chrome::HOST_DESKTOP_TYPE_ASH)
- chrome::ActivateDesktopHelper(chrome::ASH_KEEP_RUNNING);
-
- BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
- base::Bind(&ShowItemInFolderOnFileThread, full_path));
-}
-
-void OpenItem(const base::FilePath& full_path) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
-
- if (chrome::GetActiveDesktop() == chrome::HOST_DESKTOP_TYPE_ASH)
- chrome::ActivateDesktopHelper(chrome::ASH_KEEP_RUNNING);
-
- BrowserThread::PostTask(
- BrowserThread::FILE, FROM_HERE,
- base::Bind(base::IgnoreResult(&ui::win::OpenItemViaShell), full_path));
-}
-
-void OpenExternal(const GURL& url) {
- if (chrome::GetActiveDesktop() == chrome::HOST_DESKTOP_TYPE_ASH)
- chrome::ActivateDesktopHelper(chrome::ASH_KEEP_RUNNING);
-
+void OpenExternalOnFileThread(const GURL& url) {
// Quote the input scheme to be sure that the command does not have
// parameters unexpected by the external program. This url should already
// have been escaped.
@@ -190,6 +162,41 @@ void OpenExternal(const GURL& url) {
}
}
+} // namespace
+
+namespace platform_util {
+
+void ShowItemInFolder(const base::FilePath& full_path) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+
+ if (chrome::GetActiveDesktop() == chrome::HOST_DESKTOP_TYPE_ASH)
+ chrome::ActivateDesktopHelper(chrome::ASH_KEEP_RUNNING);
+
+ BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
+ base::Bind(&ShowItemInFolderOnFileThread, full_path));
+}
+
+void OpenItem(const base::FilePath& full_path) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+
+ if (chrome::GetActiveDesktop() == chrome::HOST_DESKTOP_TYPE_ASH)
+ chrome::ActivateDesktopHelper(chrome::ASH_KEEP_RUNNING);
+
+ BrowserThread::PostTask(
+ BrowserThread::FILE, FROM_HERE,
+ base::Bind(base::IgnoreResult(&ui::win::OpenItemViaShell), full_path));
+}
+
+void OpenExternal(Profile* profile, const GURL& url) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+
+ if (chrome::GetActiveDesktop() == chrome::HOST_DESKTOP_TYPE_ASH)
+ chrome::ActivateDesktopHelper(chrome::ASH_KEEP_RUNNING);
+
+ BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
+ base::Bind(&OpenExternalOnFileThread, url));
+}
+
#if !defined(USE_AURA)
gfx::NativeWindow GetTopLevel(gfx::NativeView view) {
return ::GetAncestor(view, GA_ROOT);
diff --git a/chrome/browser/ui/apps/chrome_shell_window_delegate.cc b/chrome/browser/ui/apps/chrome_shell_window_delegate.cc
index 188a66a..f30e501 100644
--- a/chrome/browser/ui/apps/chrome_shell_window_delegate.cc
+++ b/chrome/browser/ui/apps/chrome_shell_window_delegate.cc
@@ -47,7 +47,10 @@ ShellWindowLinkDelegate::~ShellWindowLinkDelegate() {}
content::WebContents* ShellWindowLinkDelegate::OpenURLFromTab(
content::WebContents* source,
const content::OpenURLParams& params) {
- platform_util::OpenExternal(params.url);
+ if (source) {
+ platform_util::OpenExternal(
+ Profile::FromBrowserContext(source->GetBrowserContext()), params.url);
+ }
delete source;
return NULL;
}
diff --git a/chrome/browser/ui/browser_commands.cc b/chrome/browser/ui/browser_commands.cc
index 4c86d3e..4a3e9e1 100644
--- a/chrome/browser/ui/browser_commands.cc
+++ b/chrome/browser/ui/browser_commands.cc
@@ -814,7 +814,7 @@ void EmailPageLocation(Browser* browser) {
std::string page_url = net::EscapeQueryParamValue(wc->GetURL().spec(), false);
std::string mailto = std::string("mailto:?subject=Fwd:%20") +
title + "&body=%0A%0A" + page_url;
- platform_util::OpenExternal(GURL(mailto));
+ platform_util::OpenExternal(browser->profile(), GURL(mailto));
}
bool CanEmailPageLocation(const Browser* browser) {
diff --git a/chrome/browser/ui/cocoa/external_protocol_dialog.h b/chrome/browser/ui/cocoa/external_protocol_dialog.h
index 5e229f6..ba0a4de 100644
--- a/chrome/browser/ui/cocoa/external_protocol_dialog.h
+++ b/chrome/browser/ui/cocoa/external_protocol_dialog.h
@@ -11,9 +11,13 @@
@private
NSAlert* alert_;
GURL url_;
+ int render_process_host_id_;
+ int routing_id_;
base::Time creation_time_;
};
-- (id)initWithGURL:(const GURL*)url;
+- (id)initWithGURL:(const GURL*)url
+ renderProcessHostId:(int)renderProcessHostId
+ routingId:(int)routingId;
@end
diff --git a/chrome/browser/ui/cocoa/external_protocol_dialog.mm b/chrome/browser/ui/cocoa/external_protocol_dialog.mm
index 5525925..c57d53c 100644
--- a/chrome/browser/ui/cocoa/external_protocol_dialog.mm
+++ b/chrome/browser/ui/cocoa/external_protocol_dialog.mm
@@ -21,7 +21,9 @@
// static
void ExternalProtocolHandler::RunExternalProtocolDialog(
const GURL& url, int render_process_host_id, int routing_id) {
- [[ExternalProtocolDialogController alloc] initWithGURL:&url];
+ [[ExternalProtocolDialogController alloc] initWithGURL:&url
+ renderProcessHostId:render_process_host_id
+ routingId:routing_id];
}
///////////////////////////////////////////////////////////////////////////////
@@ -35,13 +37,17 @@ void ExternalProtocolHandler::RunExternalProtocolDialog(
@end
@implementation ExternalProtocolDialogController
-- (id)initWithGURL:(const GURL*)url {
+- (id)initWithGURL:(const GURL*)url
+ renderProcessHostId:(int)renderProcessHostId
+ routingId:(int)routingId {
DCHECK_EQ(base::MessageLoop::TYPE_UI, base::MessageLoop::current()->type());
if (!(self = [super init]))
return nil;
url_ = *url;
+ render_process_host_id_ = renderProcessHostId;
+ routing_id_ = routingId;
creation_time_ = base::Time::Now();
base::string16 appName = [self appNameForProtocol];
@@ -127,7 +133,8 @@ void ExternalProtocolHandler::RunExternalProtocolDialog(
UMA_HISTOGRAM_LONG_TIMES("clickjacking.launch_url",
base::Time::Now() - creation_time_);
- ExternalProtocolHandler::LaunchUrlWithoutSecurityCheck(url_);
+ ExternalProtocolHandler::LaunchUrlWithoutSecurityCheck(
+ url_, render_process_host_id_, routing_id_);
}
[self autorelease];
diff --git a/chrome/browser/ui/external_protocol_dialog_delegate.cc b/chrome/browser/ui/external_protocol_dialog_delegate.cc
index 2badc31..35ad163 100644
--- a/chrome/browser/ui/external_protocol_dialog_delegate.cc
+++ b/chrome/browser/ui/external_protocol_dialog_delegate.cc
@@ -15,8 +15,13 @@
#include "ui/base/l10n/l10n_util.h"
#include "ui/gfx/text_elider.h"
-ExternalProtocolDialogDelegate::ExternalProtocolDialogDelegate(const GURL& url)
- : ProtocolDialogDelegate(url) {
+ExternalProtocolDialogDelegate::ExternalProtocolDialogDelegate(
+ const GURL& url,
+ int render_process_host_id,
+ int tab_contents_id)
+ : ProtocolDialogDelegate(url),
+ render_process_host_id_(render_process_host_id),
+ tab_contents_id_(tab_contents_id) {
}
ExternalProtocolDialogDelegate::~ExternalProtocolDialogDelegate() {
@@ -65,7 +70,8 @@ void ExternalProtocolDialogDelegate::DoAccept(
url.scheme(), ExternalProtocolHandler::DONT_BLOCK);
}
- ExternalProtocolHandler::LaunchUrlWithoutSecurityCheck(url);
+ ExternalProtocolHandler::LaunchUrlWithoutSecurityCheck(
+ url, render_process_host_id_, tab_contents_id_);
}
void ExternalProtocolDialogDelegate::DoCancel(
diff --git a/chrome/browser/ui/external_protocol_dialog_delegate.h b/chrome/browser/ui/external_protocol_dialog_delegate.h
index 85de91e..836b1cd 100644
--- a/chrome/browser/ui/external_protocol_dialog_delegate.h
+++ b/chrome/browser/ui/external_protocol_dialog_delegate.h
@@ -15,7 +15,9 @@
// or not to launch the application for the given protocol.
class ExternalProtocolDialogDelegate : public ProtocolDialogDelegate {
public:
- explicit ExternalProtocolDialogDelegate(const GURL& url);
+ explicit ExternalProtocolDialogDelegate(const GURL& url,
+ int render_process_host_id,
+ int tab_contents_id);
virtual ~ExternalProtocolDialogDelegate();
virtual void DoAccept(const GURL& url, bool dont_block) const OVERRIDE;
@@ -24,6 +26,10 @@ class ExternalProtocolDialogDelegate : public ProtocolDialogDelegate {
virtual base::string16 GetMessageText() const OVERRIDE;
virtual base::string16 GetCheckboxText() const OVERRIDE;
virtual base::string16 GetTitleText() const OVERRIDE;
+
+ private:
+ int render_process_host_id_;
+ int tab_contents_id_;
};
#endif // CHROME_BROWSER_UI_EXTERNAL_PROTOCOL_DIALOG_DELEGATE_H_
diff --git a/chrome/browser/ui/gtk/first_run_dialog.cc b/chrome/browser/ui/gtk/first_run_dialog.cc
index f002127..3c5bde5 100644
--- a/chrome/browser/ui/gtk/first_run_dialog.cc
+++ b/chrome/browser/ui/gtk/first_run_dialog.cc
@@ -37,13 +37,13 @@
namespace first_run {
bool ShowFirstRunDialog(Profile* profile) {
- return FirstRunDialog::Show();
+ return FirstRunDialog::Show(profile);
}
} // namespace first_run
// static
-bool FirstRunDialog::Show() {
+bool FirstRunDialog::Show(Profile* profile) {
bool dialog_shown = false;
#if defined(GOOGLE_CHROME_BUILD)
// If the metrics reporting is managed, we won't ask.
@@ -55,7 +55,7 @@ bool FirstRunDialog::Show() {
if (show_reporting_dialog) {
// Object deletes itself.
- new FirstRunDialog();
+ new FirstRunDialog(profile);
dialog_shown = true;
// TODO(port): it should be sufficient to just run the dialog:
@@ -69,8 +69,9 @@ bool FirstRunDialog::Show() {
return dialog_shown;
}
-FirstRunDialog::FirstRunDialog()
- : dialog_(NULL),
+FirstRunDialog::FirstRunDialog(Profile* profile)
+ : profile_(profile),
+ dialog_(NULL),
report_crashes_(NULL),
make_default_(NULL) {
ShowReportingDialog();
@@ -150,7 +151,7 @@ void FirstRunDialog::OnResponseDialog(GtkWidget* widget, int response) {
}
void FirstRunDialog::OnLearnMoreLinkClicked(GtkButton* button) {
- platform_util::OpenExternal(GURL(chrome::kLearnMoreReportingURL));
+ platform_util::OpenExternal(profile_, GURL(chrome::kLearnMoreReportingURL));
}
void FirstRunDialog::FirstRunDone() {
diff --git a/chrome/browser/ui/gtk/first_run_dialog.h b/chrome/browser/ui/gtk/first_run_dialog.h
index b59c12c..ededb19 100644
--- a/chrome/browser/ui/gtk/first_run_dialog.h
+++ b/chrome/browser/ui/gtk/first_run_dialog.h
@@ -16,10 +16,10 @@ class FirstRunDialog {
public:
// Displays the first run UI for reporting opt-in, import data etc.
// Returns true if the dialog was shown.
- static bool Show();
+ static bool Show(Profile* profile);
private:
- FirstRunDialog();
+ explicit FirstRunDialog(Profile* profile);
virtual ~FirstRunDialog();
CHROMEGTK_CALLBACK_1(FirstRunDialog, void, OnResponseDialog, int);
@@ -32,6 +32,8 @@ class FirstRunDialog {
// first run tasks are done.
void FirstRunDone();
+ Profile* profile_;
+
// Dialog that holds the bug reporting and default browser checkboxes.
GtkWidget* dialog_;
diff --git a/chrome/browser/ui/gtk/protocol_dialog_gtk.cc b/chrome/browser/ui/gtk/protocol_dialog_gtk.cc
index e2e9fb1..1681444 100644
--- a/chrome/browser/ui/gtk/protocol_dialog_gtk.cc
+++ b/chrome/browser/ui/gtk/protocol_dialog_gtk.cc
@@ -32,7 +32,9 @@ const int kMessageWidth = 400;
void ExternalProtocolHandler::RunExternalProtocolDialog(
const GURL& url, int render_process_host_id, int routing_id) {
new ProtocolDialogGtk(scoped_ptr<const ProtocolDialogDelegate>(
- new ExternalProtocolDialogDelegate(url)));
+ new ExternalProtocolDialogDelegate(url,
+ render_process_host_id,
+ routing_id)));
}
///////////////////////////////////////////////////////////////////////////////
diff --git a/chrome/browser/ui/views/external_protocol_dialog.cc b/chrome/browser/ui/views/external_protocol_dialog.cc
index c518de6..8f63c3e 100644
--- a/chrome/browser/ui/views/external_protocol_dialog.cc
+++ b/chrome/browser/ui/views/external_protocol_dialog.cc
@@ -42,11 +42,8 @@ void ExternalProtocolHandler::RunExternalProtocolDialog(
// ShellExecute won't do anything. Don't bother warning the user.
return;
}
- WebContents* web_contents = tab_util::GetWebContentsByID(
- render_process_host_id, routing_id);
- DCHECK(web_contents);
// Windowing system takes ownership.
- new ExternalProtocolDialog(web_contents, url, command);
+ new ExternalProtocolDialog(url, render_process_host_id, routing_id, command);
}
///////////////////////////////////////////////////////////////////////////////
@@ -104,7 +101,8 @@ bool ExternalProtocolDialog::Accept() {
url_.scheme(), ExternalProtocolHandler::DONT_BLOCK);
}
- ExternalProtocolHandler::LaunchUrlWithoutSecurityCheck(url_);
+ ExternalProtocolHandler::LaunchUrlWithoutSecurityCheck(
+ url_, render_process_host_id_, routing_id_);
// Returning true closes the dialog.
return true;
}
@@ -124,11 +122,13 @@ const views::Widget* ExternalProtocolDialog::GetWidget() const {
///////////////////////////////////////////////////////////////////////////////
// ExternalProtocolDialog, private:
-ExternalProtocolDialog::ExternalProtocolDialog(WebContents* web_contents,
- const GURL& url,
+ExternalProtocolDialog::ExternalProtocolDialog(const GURL& url,
+ int render_process_host_id,
+ int routing_id,
const std::wstring& command)
- : web_contents_(web_contents),
- url_(url),
+ : url_(url),
+ render_process_host_id_(render_process_host_id),
+ routing_id_(routing_id),
creation_time_(base::TimeTicks::Now()) {
const int kMaxUrlWithoutSchemeSize = 256;
const int kMaxCommandSize = 256;
@@ -156,9 +156,11 @@ ExternalProtocolDialog::ExternalProtocolDialog(WebContents* web_contents,
l10n_util::GetStringUTF16(IDS_EXTERNAL_PROTOCOL_CHECKBOX_TEXT));
// Dialog is top level if we don't have a web_contents associated with us.
+ WebContents* web_contents = tab_util::GetWebContentsByID(
+ render_process_host_id_, routing_id_);
gfx::NativeWindow parent_window = NULL;
- if (web_contents_)
- parent_window = web_contents_->GetView()->GetTopLevelNativeWindow();
+ if (web_contents)
+ parent_window = web_contents->GetView()->GetTopLevelNativeWindow();
CreateBrowserModalDialogViews(this, parent_window)->Show();
}
diff --git a/chrome/browser/ui/views/external_protocol_dialog.h b/chrome/browser/ui/views/external_protocol_dialog.h
index 81e32c4..a588b63 100644
--- a/chrome/browser/ui/views/external_protocol_dialog.h
+++ b/chrome/browser/ui/views/external_protocol_dialog.h
@@ -11,10 +11,6 @@
#include "ui/views/window/dialog_delegate.h"
#include "url/gurl.h"
-namespace content {
-class WebContents;
-}
-
namespace views {
class MessageBoxView;
}
@@ -22,8 +18,9 @@ class MessageBoxView;
class ExternalProtocolDialog : public views::DialogDelegate {
public:
// RunExternalProtocolDialog calls this private constructor.
- ExternalProtocolDialog(content::WebContents* web_contents,
- const GURL& url,
+ ExternalProtocolDialog(const GURL& url,
+ int render_process_host_id,
+ int routing_id,
const std::wstring& command);
// Returns the path of the application to be launched given the protocol
@@ -48,12 +45,13 @@ class ExternalProtocolDialog : public views::DialogDelegate {
// The message box view whose commands we handle.
views::MessageBoxView* message_box_view_;
- // The associated WebContents.
- content::WebContents* web_contents_;
-
// URL of the external protocol request.
GURL url_;
+ // IDs of the associated WebContents.
+ int render_process_host_id_;
+ int routing_id_;
+
// The time at which this dialog was created.
base::TimeTicks creation_time_;