summaryrefslogtreecommitdiffstats
path: root/chrome/browser/remoting
diff options
context:
space:
mode:
authorhclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-06 23:17:43 +0000
committerhclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-06 23:17:43 +0000
commit4ee0bc31c1ad8203eb77136783132387bbc8abb0 (patch)
tree0c8471bbcb81ecc4d6f5c94bb11efcf924c45457 /chrome/browser/remoting
parent9c17999887073e5d0c58bd9e27ce56fd378a0e01 (diff)
downloadchromium_src-4ee0bc31c1ad8203eb77136783132387bbc8abb0.zip
chromium_src-4ee0bc31c1ad8203eb77136783132387bbc8abb0.tar.gz
chromium_src-4ee0bc31c1ad8203eb77136783132387bbc8abb0.tar.bz2
Add remoting to wrench menu.
This change adds remoting item to wrench menu. The change is under flag enable-remoting, so end users will not see it. The CL is cleaned up. It was compiling and working. I added the check for kEnableRemoting and resynched and it is no longer compiling. Submitted for: pranavk@chromium.org Reviewed: http://codereview.chromium.org/3075024/show BUG=50242 TEST=NONE Review URL: http://codereview.chromium.org/3080038 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@55311 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/remoting')
-rw-r--r--chrome/browser/remoting/setup.cc21
-rw-r--r--chrome/browser/remoting/setup.h19
-rw-r--r--chrome/browser/remoting/setup_flow.cc128
-rw-r--r--chrome/browser/remoting/setup_flow.h103
4 files changed, 271 insertions, 0 deletions
diff --git a/chrome/browser/remoting/setup.cc b/chrome/browser/remoting/setup.cc
new file mode 100644
index 0000000..e8e27c3
--- /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 sync_ui_util
diff --git a/chrome/browser/remoting/setup.h b/chrome/browser/remoting/setup.h
new file mode 100644
index 0000000..a365647
--- /dev/null
+++ b/chrome/browser/remoting/setup.h
@@ -0,0 +1,19 @@
+// 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_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..6bd0cad
--- /dev/null
+++ b/chrome/browser/remoting/setup_flow.cc
@@ -0,0 +1,128 @@
+// 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.
+
+#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);
+
+#if defined(OS_MACOSX)
+ // NOTE(pranavk): This is a hack to work around a problem with font height on
+ // windows. Basically font metrics are incorrectly returned in logical units
+ // instead of pixels on Windows. Logical units are very commonly 96 DPI
+ // so our localized char/line counts are too small by a factor of 96/72.
+ // So we compensate for this on non-windows platform.
+ //
+ // TODO(pranavk): Remove this hack once we fix the windows font problem (or at
+ // least work around it in some other place).
+ float scale_hack = 96.f/72.f;
+ size->set_width(size->width() * scale_hack);
+ size->set_height(size->height() * scale_hack);
+#endif
+}
+
+// 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() {
+#if defined(OS_MACOSX)
+ if (html_dialog_window_) {
+ platform_util::ActivateWindow(html_dialog_window_);
+ }
+#else
+ // TODO(pranavk): We don't currently have a way to get the reference to the
+ // dialog on windows/linux. This can be resolved by a cross platform
+ // implementation of HTML dialogs as described below.
+ NOTIMPLEMENTED();
+#endif // defined(OS_MACOSX)
+}
+
+// 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);
+#if defined(OS_MACOSX)
+ // TODO(pranavk): Figure out a cleaner way to do this than to have this
+ // gross per-OS behavior, i.e. have a cross-platform ShowHtmlDialog()
+ // function that is not tied to a browser instance.
+ flow->html_dialog_window_ =
+ html_dialog_window_controller::ShowHtmlDialog(
+ flow, service->profile());
+#else
+ Browser* b = BrowserList::GetLastActive();
+ if (b) {
+ b->BrowserShowHtmlDialog(flow, NULL);
+ } else {
+ delete flow;
+ return NULL;
+ }
+#endif // defined(OS_MACOSX)
+ 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_