summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorhclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-12 00:18:32 +0000
committerhclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-12 00:18:32 +0000
commitda96e54c008fabe2bd36ce9ec2a5e4923844b48b (patch)
tree7113ddb9aaf0aeb1cf1a3b63b51ac54117c686c5 /chrome
parent1b1eecda2907942e1db3492ac2e599a0da8b2437 (diff)
downloadchromium_src-da96e54c008fabe2bd36ce9ec2a5e4923844b48b.zip
chromium_src-da96e54c008fabe2bd36ce9ec2a5e4923844b48b.tar.gz
chromium_src-da96e54c008fabe2bd36ce9ec2a5e4923844b48b.tar.bz2
Adding remoting setup to wrench menu
pranvak@ is OOO so I'm submitting for him. This patch will add a menu in wrench menu to start the chromoting setup flow. Submit for: pranvak@chromium.org Reviewed: http://codereview.chromium.org/3075024/show Review URL: http://codereview.chromium.org/3134003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@55815 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/app/chrome_dll_resource.h3
-rw-r--r--chrome/app/generated_resources.grd16
-rw-r--r--chrome/browser/browser.cc19
-rw-r--r--chrome/browser/browser.h3
-rw-r--r--chrome/browser/remoting/setup.cc21
-rw-r--r--chrome/browser/remoting/setup.h19
-rw-r--r--chrome/browser/remoting/setup_flow.cc97
-rw-r--r--chrome/browser/remoting/setup_flow.h103
-rw-r--r--chrome/browser/wrench_menu_model.cc8
-rw-r--r--chrome/chrome_browser.gypi4
10 files changed, 293 insertions, 0 deletions
diff --git a/chrome/app/chrome_dll_resource.h b/chrome/app/chrome_dll_resource.h
index 6a9b539..9022381 100644
--- a/chrome/app/chrome_dll_resource.h
+++ b/chrome/app/chrome_dll_resource.h
@@ -234,6 +234,9 @@
#define IDC_WRITING_DIRECTION_LTR 41122 // OSX only
#define IDC_WRITING_DIRECTION_RTL 41123 // OSX only
+// Remoting
+#define IDC_REMOTING_SETUP 41140
+
// Translate
#define IDC_TRANSLATE_OPTIONS_ALWAYS 42000
#define IDC_TRANSLATE_OPTIONS_NEVER_TRANSLATE_LANG 42001
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd
index 6f346ba..3e9842c 100644
--- a/chrome/app/generated_resources.grd
+++ b/chrome/app/generated_resources.grd
@@ -6926,6 +6926,22 @@ Keep your key file in a safe place. You will need it to create new versions of y
<message name="IDS_OMNIBOX_SEARCH_HINT_OMNIBOX_TEXT" desc="The text displayed selected in the omnibox once the user clicked the 'Show Me' button on the omnibox search hint infobar.">
Type your search query here
</message>
+
+ <!-- Remoting strings -->
+ <if expr="not pp_ifdef('use_titlecase')">
+ <message name="IDS_REMOTING_SETUP_LABEL" desc="The label that appears on the remoting setup menu.">
+ Set up remoting...
+ </message>
+ </if>
+ <if expr="pp_ifdef('use_titlecase')">
+ <message name="IDS_REMOTING_SETUP_LABEL" desc="In Title Case. The label that appears on the remoting setup menu.">
+ Set Up Remoting...
+ </message>
+ </if>
+ <message name="IDS_REMOTING_SETUP_DIALOG_TITLE" desc="Title of the remoting setup dialog.">
+ Set up remoting
+ </message>
+
<!-- Sync strings -->
diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc
index ed40e3e..8fdd799 100644
--- a/chrome/browser/browser.cc
+++ b/chrome/browser/browser.cc
@@ -61,6 +61,9 @@
#include "chrome/browser/platform_util.h"
#include "chrome/browser/pref_service.h"
#include "chrome/browser/profile.h"
+#if defined(ENABLE_REMOTING)
+#include "chrome/browser/remoting/setup.h"
+#endif
#include "chrome/browser/renderer_host/render_view_host.h"
#include "chrome/browser/renderer_host/site_instance.h"
#include "chrome/browser/sessions/session_service.h"
@@ -1074,6 +1077,13 @@ void Browser::UpdateCommandsForFullscreenMode(bool is_fullscreen) {
command_updater_.UpdateCommandEnabled(IDC_IMPORT_SETTINGS, show_main_ui);
command_updater_.UpdateCommandEnabled(IDC_SYNC_BOOKMARKS,
show_main_ui && profile_->IsSyncAccessible());
+
+#if defined(ENABLE_REMOTING)
+ if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableRemoting)) {
+ command_updater_.UpdateCommandEnabled(IDC_REMOTING_SETUP, show_main_ui);
+ }
+#endif
+
command_updater_.UpdateCommandEnabled(IDC_OPTIONS, show_main_ui);
command_updater_.UpdateCommandEnabled(IDC_EDIT_SEARCH_ENGINES, show_main_ui);
command_updater_.UpdateCommandEnabled(IDC_VIEW_PASSWORDS, show_main_ui);
@@ -1824,6 +1834,12 @@ void Browser::OpenSyncMyBookmarksDialog() {
profile_, ProfileSyncService::START_FROM_WRENCH);
}
+#if defined(ENABLE_REMOTING)
+void Browser::OpenRemotingSetupDialog() {
+ remoting_setup::OpenRemotingSetupDialog(profile_);
+}
+#endif
+
void Browser::OpenAboutChromeDialog() {
UserMetrics::RecordAction(UserMetricsAction("AboutChrome"), profile_);
window_->ShowAboutChromeDialog();
@@ -2116,6 +2132,9 @@ void Browser::ExecuteCommandWithDisposition(
case IDC_SHOW_DOWNLOADS: ShowDownloadsTab(); break;
case IDC_MANAGE_EXTENSIONS: ShowExtensionsTab(); break;
case IDC_SYNC_BOOKMARKS: OpenSyncMyBookmarksDialog(); break;
+#if defined(ENABLE_REMOTING)
+ case IDC_REMOTING_SETUP: OpenRemotingSetupDialog(); break;
+#endif
case IDC_OPTIONS: OpenOptionsDialog(); break;
case IDC_EDIT_SEARCH_ENGINES: OpenKeywordEditor(); break;
case IDC_VIEW_PASSWORDS: OpenPasswordManager(); break;
diff --git a/chrome/browser/browser.h b/chrome/browser/browser.h
index f01c8be..ff3bb03 100644
--- a/chrome/browser/browser.h
+++ b/chrome/browser/browser.h
@@ -523,6 +523,9 @@ class Browser : public TabStripModelDelegate,
void OpenKeywordEditor();
void OpenPasswordManager();
void OpenSyncMyBookmarksDialog();
+#if defined(ENABLE_REMOTING)
+ void OpenRemotingSetupDialog();
+#endif
void OpenImportSettingsDialog();
void OpenAboutChromeDialog();
void OpenUpdateChromeDialog();
diff --git a/chrome/browser/remoting/setup.cc b/chrome/browser/remoting/setup.cc
new file mode 100644
index 0000000..0054efb
--- /dev/null
+++ b/chrome/browser/remoting/setup.cc
@@ -0,0 +1,21 @@
+// Copyright (c) 2010 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.
+
+#include "chrome/browser/remoting/setup.h"
+#include "chrome/browser/remoting/setup_flow.h"
+
+//#include "app/l10n_util.h"
+//#include "base/utf_string_conversions.h"
+#include "chrome/browser/google_service_auth_error.h"
+#include "chrome/browser/profile.h"
+
+typedef GoogleServiceAuthError AuthError;
+
+namespace remoting_setup {
+
+void OpenRemotingSetupDialog(Profile* profile) {
+ remoting_setup::SetupFlow::Run(profile->GetOriginalProfile());
+}
+
+} // namespace remoting_setup
diff --git a/chrome/browser/remoting/setup.h b/chrome/browser/remoting/setup.h
new file mode 100644
index 0000000..1b7a8bf
--- /dev/null
+++ b/chrome/browser/remoting/setup.h
@@ -0,0 +1,19 @@
+// Copyright (c) 2010 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_REMOTING_SETUP_H_
+#define CHROME_BROWSER_REMOTING_SETUP_H_
+
+#include "base/string16.h"
+
+class Profile;
+
+namespace remoting_setup {
+
+// Open the appropriate setup dialog for the given profile (which can be
+// incognito).
+void OpenRemotingSetupDialog(Profile* profile);
+} // namespace remoting_setup
+
+#endif // CHROME_BROWSER_REMOTING_SETUP_H_
diff --git a/chrome/browser/remoting/setup_flow.cc b/chrome/browser/remoting/setup_flow.cc
new file mode 100644
index 0000000..5b945e9
--- /dev/null
+++ b/chrome/browser/remoting/setup_flow.cc
@@ -0,0 +1,97 @@
+// Copyright (c) 2010 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.
+
+#include "chrome/browser/remoting/setup_flow.h"
+
+#include "app/gfx/font_util.h"
+#include "base/callback.h"
+#include "base/histogram.h"
+#include "base/json/json_reader.h"
+#include "base/json/json_writer.h"
+#include "base/string_util.h"
+#include "base/utf_string_conversions.h"
+#include "base/values.h"
+#include "chrome/browser/browser.h"
+#include "chrome/browser/browser_list.h"
+#if defined(OS_MACOSX)
+#include "chrome/browser/cocoa/html_dialog_window_controller_cppsafe.h"
+#endif
+#include "chrome/browser/dom_ui/dom_ui_util.h"
+#include "chrome/browser/google_service_auth_error.h"
+#include "chrome/browser/platform_util.h"
+#include "chrome/browser/pref_service.h"
+#include "chrome/browser/profile.h"
+#include "chrome/browser/renderer_host/render_view_host.h"
+#include "chrome/browser/tab_contents/tab_contents.h"
+#include "chrome/common/pref_names.h"
+#include "gfx/font.h"
+#include "grit/locale_settings.h"
+
+namespace remoting_setup {
+
+// Use static Run method to get an instance.
+SetupFlow::SetupFlow(const std::string& args, Profile* profile)
+ : dialog_start_args_(args),
+ profile_(profile) {
+}
+
+SetupFlow::~SetupFlow() {
+}
+
+void SetupFlow::GetDialogSize(gfx::Size* size) const {
+ PrefService* prefs = profile_->GetPrefs();
+ gfx::Font approximate_web_font = gfx::Font::CreateFont(
+ UTF8ToWide(prefs->GetString(prefs::kWebKitSansSerifFontFamily)),
+ prefs->GetInteger(prefs::kWebKitDefaultFontSize));
+
+ // TODO(pranavk) Replace the following SYNC resources with REMOTING Resources.
+ *size = gfx::GetLocalizedContentsSizeForFont(
+ IDS_SYNC_SETUP_WIZARD_WIDTH_CHARS,
+ IDS_SYNC_SETUP_WIZARD_HEIGHT_LINES,
+ approximate_web_font);
+}
+
+// A callback to notify the delegate that the dialog closed.
+void SetupFlow::OnDialogClosed(const std::string& json_retval) {
+ delete this;
+}
+
+// static
+void SetupFlow::GetArgsForGaiaLogin(DictionaryValue* args) {
+ // TODO(pranavk): implement this method.
+}
+
+void SetupFlow::GetDOMMessageHandlers(
+ std::vector<DOMMessageHandler*>* handlers) const {
+ // TODO(pranavk): implement this method.
+}
+
+
+void SetupFlow::Advance() {
+ // TODO(pranavk): implement this method.
+}
+
+void SetupFlow::Focus() {
+ // TODO(pranavk): implement this method.
+ NOTIMPLEMENTED();
+}
+
+// static
+SetupFlow* SetupFlow::Run(Profile* service) {
+ DictionaryValue args;
+ std::string json_args;
+ base::JSONWriter::Write(&args, false, &json_args);
+
+ SetupFlow* flow = new SetupFlow(json_args, service);
+ Browser* b = BrowserList::GetLastActive();
+ if (b) {
+ b->BrowserShowHtmlDialog(flow, NULL);
+ } else {
+ delete flow;
+ return NULL;
+ }
+ return flow;
+}
+
+} // namespace remoting_setup
diff --git a/chrome/browser/remoting/setup_flow.h b/chrome/browser/remoting/setup_flow.h
new file mode 100644
index 0000000..dd33c55
--- /dev/null
+++ b/chrome/browser/remoting/setup_flow.h
@@ -0,0 +1,103 @@
+// Copyright (c) 2010 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_REMOTING_SETUP_FLOW_H_
+#define CHROME_BROWSER_REMOTING_SETUP_FLOW_H_
+
+#include <string>
+#include <vector>
+
+#include "app/l10n_util.h"
+#include "base/time.h"
+#include "chrome/browser/dom_ui/html_dialog_ui.h"
+#include "gfx/native_widget_types.h"
+#include "grit/generated_resources.h"
+
+namespace remoting_setup {
+
+// The state machine used by Remoting for setup wizard.
+class SetupFlow : public HtmlDialogUIDelegate {
+ public:
+ virtual ~SetupFlow();
+
+ // Runs a flow from |start| to |end|, and does the work of actually showing
+ // the HTML dialog. |container| is kept up-to-date with the lifetime of the
+ // flow (e.g it is emptied on dialog close).
+ static SetupFlow* Run(Profile* service);
+
+ // Fills |args| with "user" and "error" arguments by querying |service|.
+ static void GetArgsForGaiaLogin(DictionaryValue* args);
+
+ // Triggers a state machine transition to advance_state.
+ void Advance();
+
+ // Focuses the dialog. This is useful in cases where the dialog has been
+ // obscured by a browser window.
+ void Focus();
+
+ // HtmlDialogUIDelegate implementation.
+ // Get the HTML file path for the content to load in the dialog.
+ virtual GURL GetDialogContentURL() const {
+ return GURL("chrome://remotingresources/setup");
+ }
+
+ // HtmlDialogUIDelegate implementation.
+ virtual void GetDOMMessageHandlers(
+ std::vector<DOMMessageHandler*>* handlers) const;
+
+ // HtmlDialogUIDelegate implementation.
+ // Get the size of the dialog.
+ virtual void GetDialogSize(gfx::Size* size) const;
+
+ // HtmlDialogUIDelegate implementation.
+ // Gets the JSON string input to use when opening the dialog.
+ virtual std::string GetDialogArgs() const {
+ return dialog_start_args_;
+ }
+
+ // HtmlDialogUIDelegate implementation.
+ // A callback to notify the delegate that the dialog closed.
+ virtual void OnDialogClosed(const std::string& json_retval);
+
+ // HtmlDialogUIDelegate implementation.
+ virtual void OnCloseContents(TabContents* source, bool* out_close_dialog) { }
+
+ // HtmlDialogUIDelegate implementation.
+ virtual std::wstring GetDialogTitle() const {
+ return l10n_util::GetString(IDS_REMOTING_SETUP_DIALOG_TITLE);
+ }
+
+ // HtmlDialogUIDelegate implementation.
+ virtual bool IsDialogModal() const {
+ return false;
+ }
+
+ void OnUserClickedCustomize() {
+ // TODO(pranavk): Implement this method.
+ }
+
+ bool ClickCustomizeOk() {
+ // TODO(pranavk): Implement this method.
+ return true;
+ }
+
+ void ClickCustomizeCancel() {
+ // TODO(pranavk): Implement this method.
+ }
+
+ private:
+
+ // Use static Run method to get an instance.
+ SetupFlow(const std::string& args, Profile* profile);
+
+ DISALLOW_COPY_AND_ASSIGN(SetupFlow);
+
+ std::string dialog_start_args_; // The args to pass to the initial page.
+
+ Profile* profile_;
+};
+
+} // namespace remoting_setup
+
+#endif // CHROME_BROWSER_REMOTING_SETUP_FLOW_H_
diff --git a/chrome/browser/wrench_menu_model.cc b/chrome/browser/wrench_menu_model.cc
index 367b700..d4b576f 100644
--- a/chrome/browser/wrench_menu_model.cc
+++ b/chrome/browser/wrench_menu_model.cc
@@ -10,6 +10,7 @@
#include "app/l10n_util.h"
#include "app/menus/button_menu_item_model.h"
#include "app/resource_bundle.h"
+#include "base/command_line.h"
#include "base/string_number_conversions.h"
#include "chrome/app/chrome_dll_resource.h"
#include "chrome/browser/browser.h"
@@ -22,6 +23,7 @@
#include "chrome/browser/sync/sync_ui_util.h"
#include "chrome/browser/tab_contents/tab_contents.h"
#include "chrome/browser/upgrade_detector.h"
+#include "chrome/common/chrome_switches.h"
#include "chrome/common/notification_service.h"
#include "chrome/common/notification_source.h"
#include "chrome/common/notification_type.h"
@@ -298,6 +300,12 @@ void WrenchMenuModel::Build() {
tools_menu_model_.get());
AddSeparator();
+#if defined(ENABLE_REMOTING)
+ if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableRemoting)) {
+ AddItem(IDC_REMOTING_SETUP,
+ l10n_util::GetStringUTF16(IDS_REMOTING_SETUP_LABEL));
+ }
+#endif
AddItemWithStringId(IDC_SHOW_BOOKMARK_MANAGER, IDS_BOOKMARK_MANAGER);
AddItemWithStringId(IDC_SHOW_HISTORY, IDS_SHOW_HISTORY);
AddItemWithStringId(IDC_SHOW_DOWNLOADS, IDS_SHOW_DOWNLOADS);
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index 4186a2d..5ab036e 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -2167,6 +2167,10 @@
'browser/profile_import_process_host.h',
'browser/profile_manager.cc',
'browser/profile_manager.h',
+ 'browser/remoting/setup.cc',
+ 'browser/remoting/setup.h',
+ 'browser/remoting/setup_flow.cc',
+ 'browser/remoting/setup_flow.h',
'browser/remove_rows_table_model.h',
'browser/renderer_host/async_resource_handler.cc',
'browser/renderer_host/async_resource_handler.h',