Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(310)

Side by Side Diff: chrome/browser/remoting/setup_flow.cc

Issue 3080038: Add remoting to wrench menu. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: Created 10 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/remoting/setup_flow.h ('k') | chrome/browser/wrench_menu_model.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/remoting/setup_flow.h"
6
7 #include "app/gfx/font_util.h"
8 #include "base/callback.h"
9 #include "base/histogram.h"
10 #include "base/json/json_reader.h"
11 #include "base/json/json_writer.h"
12 #include "base/string_util.h"
13 #include "base/utf_string_conversions.h"
14 #include "base/values.h"
15 #include "chrome/browser/browser.h"
16 #include "chrome/browser/browser_list.h"
17 #if defined(OS_MACOSX)
18 #include "chrome/browser/cocoa/html_dialog_window_controller_cppsafe.h"
19 #endif
20 #include "chrome/browser/dom_ui/dom_ui_util.h"
21 #include "chrome/browser/google_service_auth_error.h"
22 #include "chrome/browser/platform_util.h"
23 #include "chrome/browser/pref_service.h"
24 #include "chrome/browser/profile.h"
25 #include "chrome/browser/renderer_host/render_view_host.h"
26 #include "chrome/browser/tab_contents/tab_contents.h"
27 #include "chrome/common/pref_names.h"
28 #include "gfx/font.h"
29 #include "grit/locale_settings.h"
30
31 namespace remoting_setup {
32
33 // Use static Run method to get an instance.
34 SetupFlow::SetupFlow(const std::string& args, Profile* profile)
35 : dialog_start_args_(args),
36 profile_(profile) {
37 }
38
39 SetupFlow::~SetupFlow() {
40 }
41
42 void SetupFlow::GetDialogSize(gfx::Size* size) const {
43 PrefService* prefs = profile_->GetPrefs();
44 gfx::Font approximate_web_font = gfx::Font::CreateFont(
45 UTF8ToWide(prefs->GetString(prefs::kWebKitSansSerifFontFamily)),
46 prefs->GetInteger(prefs::kWebKitDefaultFontSize));
47
48 // TODO(pranavk) Replace the following SYNC resources with REMOTING Resources.
49 *size = gfx::GetLocalizedContentsSizeForFont(
50 IDS_SYNC_SETUP_WIZARD_WIDTH_CHARS,
51 IDS_SYNC_SETUP_WIZARD_HEIGHT_LINES,
52 approximate_web_font);
53
54 #if defined(OS_MACOSX)
55 // NOTE(pranavk): This is a hack to work around a problem with font height on
56 // windows. Basically font metrics are incorrectly returned in logical units
57 // instead of pixels on Windows. Logical units are very commonly 96 DPI
58 // so our localized char/line counts are too small by a factor of 96/72.
59 // So we compensate for this on non-windows platform.
60 //
61 // TODO(pranavk): Remove this hack once we fix the windows font problem (or at
62 // least work around it in some other place).
63 float scale_hack = 96.f/72.f;
64 size->set_width(size->width() * scale_hack);
65 size->set_height(size->height() * scale_hack);
66 #endif
67 }
68
69 // A callback to notify the delegate that the dialog closed.
70 void SetupFlow::OnDialogClosed(const std::string& json_retval) {
71 delete this;
72 }
73
74 // static
75 void SetupFlow::GetArgsForGaiaLogin(DictionaryValue* args) {
76 // TODO(pranavk): implement this method.
77 }
78
79 void SetupFlow::GetDOMMessageHandlers(
80 std::vector<DOMMessageHandler*>* handlers) const {
81 // TODO(pranavk): implement this method.
82 }
83
84
85 void SetupFlow::Advance() {
86 // TODO(pranavk): implement this method.
87 }
88
89 void SetupFlow::Focus() {
90 #if defined(OS_MACOSX)
91 if (html_dialog_window_) {
92 platform_util::ActivateWindow(html_dialog_window_);
93 }
94 #else
95 // TODO(pranavk): We don't currently have a way to get the reference to the
96 // dialog on windows/linux. This can be resolved by a cross platform
97 // implementation of HTML dialogs as described below.
98 NOTIMPLEMENTED();
99 #endif // defined(OS_MACOSX)
100 }
101
102 // static
103 SetupFlow* SetupFlow::Run(Profile* service) {
104 DictionaryValue args;
105 std::string json_args;
106 base::JSONWriter::Write(&args, false, &json_args);
107
108 SetupFlow* flow = new SetupFlow(json_args, service);
109 #if defined(OS_MACOSX)
110 // TODO(pranavk): Figure out a cleaner way to do this than to have this
111 // gross per-OS behavior, i.e. have a cross-platform ShowHtmlDialog()
112 // function that is not tied to a browser instance.
113 flow->html_dialog_window_ =
114 html_dialog_window_controller::ShowHtmlDialog(
115 flow, service->profile());
116 #else
117 Browser* b = BrowserList::GetLastActive();
118 if (b) {
119 b->BrowserShowHtmlDialog(flow, NULL);
120 } else {
121 delete flow;
122 return NULL;
123 }
124 #endif // defined(OS_MACOSX)
125 return flow;
126 }
127
128 } // namespace remoting_setup
OLDNEW
« no previous file with comments | « chrome/browser/remoting/setup_flow.h ('k') | chrome/browser/wrench_menu_model.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698