1
Index: src/chrome/app/generated_resources.grd
2
===================================================================
3
--- src/chrome/app/generated_resources.grd (revision 205727)
4
+++ src/chrome/app/generated_resources.grd (working copy)
5
@@ -12234,6 +12234,9 @@
6
<message name="IDS_OPTIONS_ADVANCED_SECTION_TITLE_CONTENT">
9
+ <message name="IDS_OPTIONS_ADVANCED_SECTION_TITLE_INTEGRATION">
12
<message name="IDS_OPTIONS_ADVANCED_SECTION_TITLE_SECURITY">
15
@@ -14928,6 +14931,35 @@
19
+ <!-- Desktop integration -->
20
+ <message name="IDS_PROMPT_INTEGRATION_ENABLE_BUTTON_LABEL" desc="The text to be displayed on the checkbox that enables desktop integration.">
21
+ Notify me when the website I am visiting can run as an application
23
+ <message name="IDS_DESKTOP_INTEGRATION_NOTE_DESCRIPTION" desc="The text to be displayed below the Exceptions button in the Integrated Websites section.">
24
+ Websites which have been installed can be removed, like any other application, using Ubuntu Software Center.
26
+ <message name="IDS_DESKTOP_INTEGRATION_SETTINGS_EXCEPTIONS_BUTTON_LABEL" desc="The text to be displayed on the button that drives integration exceptions.">
29
+ <message name="IDS_DESKTOP_INTEGRATION_SETTINGS_OVERLAY_TITLE" desc="Title for the desktop integration overlay.">
30
+ Integration prompt exceptions
32
+ <message name="IDS_DESKTOP_INTEGRATION_SETTINGS_OVERLAY_DESCRIPTION" desc="Description for the desktop integration overlay.">
33
+ These websites won't prompt to be installed:
35
+ <message name="IDS_OPTIONS_SETTINGS_INTEGRATION_WEBSITE_ADD_BUTTON"
36
+ desc="The label for the add button for adding a integration websites">
39
+ <message name="IDS_OPTIONS_SETTINGS_INTEGRATION_WEBSITE_ADD_TEXT"
40
+ desc="The description text for the add overlay for adding a integration websites">
41
+ Website domain name (e.g. www.html5rocks.com)
43
+ <message name="IDS_OPTIONS_SETTINGS_INTEGRATION_WEBSITE_ADD_TITLE"
44
+ desc="Title for add overlay for adding a integration websites">
45
+ Add Integrated Website
48
<!-- Manage Profile Dialog -->
49
<message name="IDS_PROFILES_MANAGE_TITLE" desc="Title of the manage profile dialog">
51
Index: src/chrome/browser/resources/options/browser_options.html
52
===================================================================
53
--- src/chrome/browser/resources/options/browser_options.html (revision 205727)
54
+++ src/chrome/browser/resources/options/browser_options.html (working copy)
58
</if> <!-- pp_ifdef('chromeos') -->
60
+<if expr="is_linux and not pp_ifdef('chromeos')">
61
+ <section id="desktop-integration-section">
62
+ <h3 i18n-content="advancedSectionTitleIntegration"></h3>
63
+ <div class="checkbox">
65
+ <input id="promptIntegrationForAnyWebsite"
66
+ metric="Options_PromptIntegration" type="checkbox">
67
+ <span i18n-content="promptIntegrationEnableIntegration"></span>
70
+ <button id="desktop-integration-button"
71
+ i18n-content="desktopIntegrationExceptionsSettingsButton"></button>
75
<section id="passwords-and-autofill-section">
76
<h3 i18n-content="passwordsAndAutofillGroupName"></h3>
77
<div class="checkbox">
78
Index: src/chrome/browser/resources/options/browser_options.js
79
===================================================================
80
--- src/chrome/browser/resources/options/browser_options.js (revision 205727)
81
+++ src/chrome/browser/resources/options/browser_options.js (working copy)
83
[String(event.target.options[event.target.selectedIndex].value)]);
86
+ // Desktop integration section.
87
+ if (cr.isLinux && !cr.isChromeOS) {
88
+ var updateButtonState = function () {
89
+ $('desktop-integration-button').disabled =
90
+ ! $('promptIntegrationForAnyWebsite').checked;
92
+ $('promptIntegrationForAnyWebsite').onchange = function () {
93
+ updateButtonState();
94
+ chrome.send('setDesktopIntegrationAllowed',
95
+ [$('promptIntegrationForAnyWebsite').checked]);
97
+ updateButtonState();
98
+ $('desktop-integration-button').onclick = function(event) {
99
+ OptionsPage.navigateToPage('desktopIntegrationOverlay');
103
// Languages section.
104
$('language-button').onclick = function(event) {
105
OptionsPage.navigateToPage('languages');
106
@@ -1110,6 +1127,24 @@
110
+ * Disable the desktop integration settings if needed.
113
+ disableDesktopIntegration_: function() {
114
+ $('desktop-integration-section').style.display = 'none';
118
+ * Disable the desktop integration settings if needed.
121
+ setDesktopIntegrationIsAllowed_: function(enabled) {
122
+ $('promptIntegrationForAnyWebsite').checked = enabled;
123
+ $('desktop-integration-button').disabled =
124
+ ! $('promptIntegrationForAnyWebsite').checked;
128
* Set the checked state of the metrics reporting checkbox.
131
@@ -1401,6 +1436,7 @@
132
//Forward public APIs to private implementations.
134
'addBluetoothDevice',
135
+ 'disableDesktopIntegration',
136
'enableFactoryResetSection',
138
'getStartStopSyncButton',
139
@@ -1414,6 +1450,7 @@
141
'setGtkThemeButtonEnabled',
142
'setHighContrastCheckboxState',
143
+ 'setDesktopIntegrationIsAllowed',
144
'setMetricsReportingCheckboxState',
145
'setMetricsReportingSettingVisibility',
146
'setPasswordGenerationSettingVisibility',
147
Index: src/chrome/browser/resources/options/options.html
148
===================================================================
149
--- src/chrome/browser/resources/options/options.html (revision 205727)
150
+++ src/chrome/browser/resources/options/options.html (working copy)
152
<link rel="stylesheet" href="clear_browser_data_overlay.css">
153
<link rel="stylesheet" href="content_settings.css">
154
<link rel="stylesheet" href="cookies_view.css">
155
+<link rel="stylesheet" href="desktop_integration_overlay.css">
156
<link rel="stylesheet" href="do_not_track_confirm_overlay.css">
157
<link rel="stylesheet" href="managed_user_set_passphrase.css">
158
<link rel="stylesheet" href="managed_user_settings.css">
160
<include src="font_settings.html">
161
<include src="home_page_overlay.html">
162
<include src="import_data_overlay.html">
163
+ <include src="desktop_integration_overlay.html">
164
<include src="language_options.html">
165
<include src="manage_profile_overlay.html">
166
<include src="password_manager.html">
168
<include src="autofill_edit_creditcard_overlay.html">
169
<include src="content_settings_exceptions_area.html">
170
<include src="cookies_view.html">
171
+ <include src="desktop_integration_add_website_overlay.html">
172
<include src="handler_options.html">
173
<include src="language_add_language_overlay.html">
174
<include src="managed_user_set_passphrase.html">
175
Index: src/chrome/browser/resources/options/options.js
176
===================================================================
177
--- src/chrome/browser/resources/options/options.js (revision 205727)
178
+++ src/chrome/browser/resources/options/options.js (working copy)
180
options.contentSettings.ContentSettingsExceptionsArea;
181
var ContentSettings = options.ContentSettings;
182
var CookiesView = options.CookiesView;
183
+var DesktopIntegrationOverlay = options.DesktopIntegrationOverlay;
184
+var AddDesktopIntegrationWebsiteOverlay = options.AddDesktopIntegrationWebsiteOverlay;
185
var CreateProfileOverlay = options.CreateProfileOverlay;
186
var EditDictionaryOverlay = cr.IsMac ? null : options.EditDictionaryOverlay;
187
var FactoryResetOverlay = options.FactoryResetOverlay;
189
OptionsPage.registerOverlay(FontSettings.getInstance(),
190
BrowserOptions.getInstance(),
191
[$('fontSettingsCustomizeFontsButton')]);
192
+ if (cr.isLinux && !cr.isChromeos) {
193
+ OptionsPage.registerOverlay(AddDesktopIntegrationWebsiteOverlay.getInstance(),
194
+ DesktopIntegrationOverlay.getInstance());
195
+ OptionsPage.registerOverlay(DesktopIntegrationOverlay.getInstance(),
196
+ BrowserOptions.getInstance(),
197
+ [$('desktop-integration-button')]);
199
if (HandlerOptions && $('manage-handlers-button')) {
200
OptionsPage.registerOverlay(HandlerOptions.getInstance(),
201
ContentSettings.getInstance(),
202
Index: src/chrome/browser/resources/options/options_bundle.js
203
===================================================================
204
--- src/chrome/browser/resources/options/options_bundle.js (revision 205727)
205
+++ src/chrome/browser/resources/options/options_bundle.js (working copy)
207
<include src="content_settings_ui.js"></include>
208
<include src="cookies_list.js"></include>
209
<include src="cookies_view.js"></include>
210
+<include src="desktop_integration_add_website_overlay.js"></include>
211
+<include src="desktop_integration_overlay.js"></include>
212
<include src="factory_reset_overlay.js"></include>
213
<include src="managed_user_exceptions_area.js"></include>
214
<include src="managed_user_settings.js"></include>
215
Index: src/chrome/browser/ui/webui/options/browser_options_handler.cc
216
===================================================================
217
--- src/chrome/browser/ui/webui/options/browser_options_handler.cc (revision 205727)
218
+++ src/chrome/browser/ui/webui/options/browser_options_handler.cc (working copy)
220
{ "currentUserOnly", IDS_OPTIONS_CURRENT_USER_ONLY },
221
{ "advancedSectionTitleContent",
222
IDS_OPTIONS_ADVANCED_SECTION_TITLE_CONTENT },
223
+ { "advancedSectionTitleIntegration",
224
+ IDS_OPTIONS_ADVANCED_SECTION_TITLE_INTEGRATION },
225
{ "advancedSectionTitleLanguages",
226
IDS_OPTIONS_ADVANCED_SECTION_TITLE_LANGUAGES },
227
{ "advancedSectionTitleNetwork",
229
{ "defaultFontSizeLabel", IDS_OPTIONS_DEFAULT_FONT_SIZE_LABEL },
230
{ "defaultSearchManageEngines", IDS_OPTIONS_DEFAULTSEARCH_MANAGE_ENGINES },
231
{ "defaultZoomFactorLabel", IDS_OPTIONS_DEFAULT_ZOOM_LEVEL_LABEL },
232
+ { "desktopIntegrationExceptionsSettingsButton",
233
+ IDS_DESKTOP_INTEGRATION_SETTINGS_EXCEPTIONS_BUTTON_LABEL },
234
+ { "desktopIntegrationNoteSettingsContent",
235
+ IDS_DESKTOP_INTEGRATION_NOTE_DESCRIPTION },
236
#if defined(OS_CHROMEOS)
237
{ "disableGData", IDS_OPTIONS_DISABLE_GDATA },
240
{ "profilesDeleteSingle", IDS_PROFILES_DELETE_SINGLE_BUTTON_LABEL },
241
{ "profilesListItemCurrent", IDS_PROFILES_LIST_ITEM_CURRENT },
242
{ "profilesManage", IDS_PROFILES_MANAGE_BUTTON_LABEL },
243
+ { "promptIntegrationEnableIntegration",
244
+ IDS_PROMPT_INTEGRATION_ENABLE_BUTTON_LABEL },
245
#if defined(ENABLE_SETTINGS_APP)
246
{ "profilesAppListSwitch", IDS_SETTINGS_APP_PROFILES_SWITCH_BUTTON_LABEL },
248
Index: src/chrome/browser/ui/webui/options/options_ui.cc
249
===================================================================
250
--- src/chrome/browser/ui/webui/options/options_ui.cc (revision 205727)
251
+++ src/chrome/browser/ui/webui/options/options_ui.cc (working copy)
253
#include "chrome/browser/ui/webui/options/certificate_manager_handler.h"
256
+#if defined(OS_LINUX)
257
+#include "chrome/browser/ui/webui/options/desktop_integration_settings_handler.h"
260
using content::RenderViewHost;
264
AddOptionsPageUIHandler(localized_strings, new ClearBrowserDataHandler());
265
AddOptionsPageUIHandler(localized_strings, new ContentSettingsHandler());
266
AddOptionsPageUIHandler(localized_strings, new CookiesViewHandler());
267
+#if defined(OS_LINUX)
268
+ AddOptionsPageUIHandler(localized_strings,
269
+ new DesktopIntegrationSettingsHandler());
271
AddOptionsPageUIHandler(localized_strings, new FontSettingsHandler());
272
AddOptionsPageUIHandler(localized_strings, new HomePageOverlayHandler());
273
AddOptionsPageUIHandler(localized_strings,
274
Index: src/chrome/chrome_browser_ui.gypi
275
===================================================================
276
--- src/chrome/chrome_browser_ui.gypi (revision 205727)
277
+++ src/chrome/chrome_browser_ui.gypi (working copy)
278
@@ -2142,6 +2142,8 @@
279
'browser/ui/webui/options/cookies_view_handler.h',
280
'browser/ui/webui/options/core_options_handler.cc',
281
'browser/ui/webui/options/core_options_handler.h',
282
+ 'browser/ui/webui/options/desktop_integration_settings_handler.cc',
283
+ 'browser/ui/webui/options/desktop_integration_settings_handler.h',
284
'browser/ui/webui/options/font_settings_handler.cc',
285
'browser/ui/webui/options/font_settings_handler.h',
286
'browser/ui/webui/options/font_settings_utils.h',
287
Index: src/chrome/browser/ui/webui/options/desktop_integration_settings_handler.cc
288
===================================================================
289
--- src/chrome/browser/ui/webui/options/desktop_integration_settings_handler.cc (revision 0)
290
+++ src/chrome/browser/ui/webui/options/desktop_integration_settings_handler.cc (working copy)
292
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
293
+// Use of this source code is governed by a BSD-style license that can be
294
+// found in the LICENSE file.
296
+#include "chrome/browser/ui/webui/options/desktop_integration_settings_handler.h"
302
+#include "base/bind.h"
303
+#include "base/bind_helpers.h"
304
+#include "base/logging.h"
305
+#include "base/string16.h"
306
+#include "base/string_number_conversions.h"
307
+#include "base/utf_string_conversions.h"
308
+#include "base/values.h"
309
+#include "chrome/common/url_constants.h"
310
+#include "content/public/browser/web_ui.h"
311
+#include "grit/generated_resources.h"
312
+#include "grit/webkit_resources.h"
313
+#include "ui/base/l10n/l10n_util.h"
315
+// Not a constant but preprocessor definition for easy concatenation.
316
+#define kLibunityWebappsEntryPointLibName "libunity-webapps.so.0"
320
+// TODO: -> extract to function
321
+DesktopIntegrationSettingsHandler::DesktopIntegrationSettingsHandler()
322
+ : lib_unity_webapps_handle_(NULL),
323
+ get_all_func_handle_(NULL),
324
+ remove_from_permissions_func_handle_(NULL),
325
+ add_allowed_domain_func_handle_(NULL),
326
+ is_integration_allowed_func_handle_(NULL),
327
+ set_integration_allowed_func_handle_(NULL) {
330
+DesktopIntegrationSettingsHandler::~DesktopIntegrationSettingsHandler() {
331
+ if (lib_unity_webapps_handle_) {
332
+ dlclose (lib_unity_webapps_handle_);
333
+ lib_unity_webapps_handle_ = NULL;
335
+ remove_from_permissions_func_handle_ = NULL;
336
+ get_all_func_handle_ = NULL;
337
+ add_allowed_domain_func_handle_ = NULL;
338
+ is_integration_allowed_func_handle_ = NULL;
339
+ set_integration_allowed_func_handle_ = NULL;
343
+/////////////////////////////////////////////////////////////////////////////
344
+// OptionsPageUIHandler implementation:
345
+void DesktopIntegrationSettingsHandler::GetLocalizedValues(
346
+ DictionaryValue* localized_strings) {
347
+ DCHECK(localized_strings);
349
+ static OptionsStringResource resources[] = {
350
+ { "desktopIntegrationInfoText",
351
+ IDS_DESKTOP_INTEGRATION_SETTINGS_OVERLAY_DESCRIPTION }
354
+ localized_strings->SetString("add_button",
355
+ l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_INTEGRATION_WEBSITE_ADD_BUTTON));
356
+ localized_strings->SetString("add_desktop_website_input_label",
357
+ l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_INTEGRATION_WEBSITE_ADD_TEXT));
358
+ localized_strings->SetString("add_desktop_website_title",
359
+ l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_INTEGRATION_WEBSITE_ADD_TITLE));
361
+ RegisterStrings(localized_strings, resources, arraysize(resources));
362
+ RegisterTitle(localized_strings, "desktopIntegrationPage",
363
+ IDS_DESKTOP_INTEGRATION_SETTINGS_OVERLAY_TITLE);
366
+void DesktopIntegrationSettingsHandler::InitializeHandler() {
367
+ if (!IsUnityWebappsInitialized()) {
368
+ LoadUnityWebappsEntryPoint();
372
+void DesktopIntegrationSettingsHandler::InitializePage() {
373
+ DCHECK(IsUnityWebappsInitialized());
374
+ LoadIntegratedWebsitesData();
377
+void DesktopIntegrationSettingsHandler::RegisterMessages() {
378
+ web_ui()->RegisterMessageCallback(
379
+ std::string("addIntegrationSite"),
380
+ base::Bind(&DesktopIntegrationSettingsHandler::AddIntegrationSite,
381
+ base::Unretained(this)));
382
+ web_ui()->RegisterMessageCallback(
383
+ std::string("setDesktopIntegrationAllowed"),
384
+ base::Bind(&DesktopIntegrationSettingsHandler::SetDesktopIntegrationAllowed,
385
+ base::Unretained(this)));
386
+ web_ui()->RegisterMessageCallback(
387
+ std::string("removeIntegrationSite"),
388
+ base::Bind(&DesktopIntegrationSettingsHandler::RemoveIntegrationSite,
389
+ base::Unretained(this)));
390
+ web_ui()->RegisterMessageCallback(
391
+ std::string("updateIntegratedWebsitesList"),
392
+ base::Bind(&DesktopIntegrationSettingsHandler::UpdateIntegratedWebsitesList,
393
+ base::Unretained(this)));
396
+void DesktopIntegrationSettingsHandler::LoadUnityWebappsEntryPoint() {
397
+ DCHECK(!IsUnityWebappsInitialized());
399
+ // TODO run on FILE thread
400
+ static const char* const search_paths[] = {
401
+ kLibunityWebappsEntryPointLibName,
402
+ "/usr/local/lib/" kLibunityWebappsEntryPointLibName
403
+ , "/usr/lib/" kLibunityWebappsEntryPointLibName
406
+ void * handle = NULL;
407
+ for (size_t i = 0; i < sizeof(search_paths)/sizeof(search_paths[0]); ++i) {
408
+ DCHECK(handle == NULL);
409
+ // TODO validate path?
410
+ handle = dlopen (search_paths[i], RTLD_LAZY|RTLD_GLOBAL);
412
+ LOG(INFO) << "Found libunitywebapps entry point:" << search_paths[i];
417
+ LOG(INFO) << "Could not load Unity Webapps entry point library";
421
+ void * get_all_handle =
422
+ dlsym (handle, "unity_webapps_permissions_get_all_domains");
423
+ void * remove_from_permissions_handle =
424
+ dlsym (handle, "unity_webapps_permissions_remove_domain_from_permissions");
425
+ void * add_allowed_domain_handle =
426
+ dlsym (handle, "unity_webapps_permissions_allow_domain");
427
+ void * is_integration_allowed_handle =
428
+ dlsym (handle, "unity_webapps_permissions_is_integration_allowed");
429
+ void * set_integration_allowed_handle =
430
+ dlsym (handle, "unity_webapps_permissions_set_integration_allowed");
432
+ if (!get_all_handle ||
433
+ !remove_from_permissions_handle ||
434
+ !add_allowed_domain_handle ||
435
+ !is_integration_allowed_handle ||
436
+ !set_integration_allowed_handle) {
437
+ LOG(WARNING) << "Could not load Unity Webapps entry point functions";
442
+ // TODO(FIXME): cleanup that mess
443
+ lib_unity_webapps_handle_ = handle;
444
+ get_all_func_handle_ = get_all_handle;
445
+ remove_from_permissions_func_handle_ = remove_from_permissions_handle;
446
+ add_allowed_domain_func_handle_ = add_allowed_domain_handle;
447
+ is_integration_allowed_func_handle_ = is_integration_allowed_handle;
448
+ set_integration_allowed_func_handle_ = set_integration_allowed_handle;
451
+bool DesktopIntegrationSettingsHandler::IsUnityWebappsInitialized() const {
452
+ return NULL != lib_unity_webapps_handle_
453
+ && NULL != get_all_func_handle_
454
+ && NULL != remove_from_permissions_func_handle_
455
+ && NULL != add_allowed_domain_func_handle_
456
+ && NULL != is_integration_allowed_func_handle_
457
+ && NULL != set_integration_allowed_func_handle_;
460
+void DesktopIntegrationSettingsHandler::LoadIntegratedWebsitesData() {
461
+ if (!IsUnityWebappsInitialized()) {
462
+ web_ui()->CallJavascriptFunction(
463
+ "BrowserOptions.disableDesktopIntegration");
464
+ LOG(INFO) << "Disabling Desktop Integration options";
468
+ typedef gboolean (* IsIntegrationAllowedFunc) (void);
469
+ gboolean isallowed =
470
+ ((IsIntegrationAllowedFunc) is_integration_allowed_func_handle_) ();
471
+ web_ui()->CallJavascriptFunction(
472
+ "BrowserOptions.setDesktopIntegrationIsAllowed",
473
+ base::FundamentalValue(isallowed));
476
+void DesktopIntegrationSettingsHandler::UpdateIntegratedWebsitesList(
477
+ const base::ListValue* args) {
478
+ DCHECK(IsUnityWebappsInitialized());
480
+ // TODO move elsewhere
481
+ typedef gchar* (* GetAllDomainsFunc) (void);
483
+ gchar* all_domains = ((GetAllDomainsFunc) get_all_func_handle_) ();
485
+ web_ui()->CallJavascriptFunction(
486
+ "DesktopIntegrationOverlay.setIntegratedWebsites",
487
+ StringValue(all_domains));
491
+void DesktopIntegrationSettingsHandler::SetDesktopIntegrationAllowed(
492
+ const base::ListValue* args) {
493
+ DCHECK(IsUnityWebappsInitialized());
495
+ // TODO move elsewhere
496
+ typedef void (* SetDesktopIntegrationAllowedFunc) (gboolean);
499
+ if (!args->GetBoolean(0, &is_allowed)) {
504
+ LOG(INFO) << "Setting desktop integration:" << is_allowed;
506
+ ((SetDesktopIntegrationAllowedFunc) set_integration_allowed_func_handle_) (
507
+ is_allowed ? TRUE : FALSE);
510
+void DesktopIntegrationSettingsHandler::AddIntegrationSite(
511
+ const base::ListValue* args) {
512
+ DCHECK(IsUnityWebappsInitialized());
514
+ // TODO move elsewhere
515
+ typedef void (* AddDomainFromPermissionsFunc) (gchar *);
517
+ std::string domain;
518
+ if (!args->GetString(0, &domain)) {
523
+ LOG(INFO) << "Adding domain:" << domain << " to the list of websites allowed";
525
+ ((AddDomainFromPermissionsFunc) add_allowed_domain_func_handle_) (
526
+ const_cast<gchar *>(domain.c_str()));
528
+ LoadIntegratedWebsitesData ();
531
+void DesktopIntegrationSettingsHandler::RemoveIntegrationSite(
532
+ const base::ListValue* args) {
533
+ DCHECK(IsUnityWebappsInitialized());
535
+ // TODO move elsewhere
536
+ typedef void (* RemoveDomainFromPermissionsFunc) (gchar *);
538
+ std::string domain;
539
+ if (!args->GetString(0, &domain)) {
544
+ LOG(INFO) << "Removing domain:" << domain << " from the list of websites not prompting integration";
546
+ ((RemoveDomainFromPermissionsFunc) remove_from_permissions_func_handle_) (
547
+ const_cast<gchar *>(domain.c_str()));
549
+ LoadIntegratedWebsitesData ();
552
+} // namespace options
553
Index: src/chrome/browser/ui/webui/options/desktop_integration_settings_handler.h
554
===================================================================
555
--- src/chrome/browser/ui/webui/options/desktop_integration_settings_handler.h (revision 0)
556
+++ src/chrome/browser/ui/webui/options/desktop_integration_settings_handler.h (working copy)
558
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
559
+// Use of this source code is governed by a BSD-style license that can be
560
+// found in the LICENSE file.
562
+#ifndef CHROME_BROWSER_UI_WEBUI_OPTIONS_DESKTOP_INTEGRATION_SETTINGS_HANDLER2_H_
563
+#define CHROME_BROWSER_UI_WEBUI_OPTIONS_DESKTOP_INTEGRATION_SETTINGS_HANDLER2_H_
567
+#include "base/compiler_specific.h"
568
+#include "chrome/browser/ui/webui/options/options_ui.h"
571
+class DictionaryValue;
577
+class DesktopIntegrationSettingsHandler : public OptionsPageUIHandler {
579
+ DesktopIntegrationSettingsHandler();
580
+ virtual ~DesktopIntegrationSettingsHandler();
582
+ // OptionsPageUIHandler implementation.
583
+ virtual void GetLocalizedValues(
584
+ base::DictionaryValue* localized_strings) OVERRIDE;
585
+ virtual void InitializeHandler() OVERRIDE;
586
+ virtual void InitializePage() OVERRIDE;
587
+ virtual void RegisterMessages() OVERRIDE;
591
+ // Loads the data associated with the currently integrated websites.
592
+ void LoadIntegratedWebsitesData();
594
+ // Initializes the list of website domain names that are currently
595
+ // either allowed or 'dontask' and send it to the overlay.
596
+ void LoadUnityWebappsEntryPoint();
598
+ // Removes an website from the list of integrated websites that won't prompt
599
+ // from integration.
600
+ // |args| - A string, the domain name of the website to remove.
601
+ void RemoveIntegrationSite(const base::ListValue* args);
603
+ // Adds an website from the list of integrated websites that won't prompt
604
+ // from integration. The website is being added to the list of 'allowed' sites.
605
+ // |args| - A string, the domain name of the website to add.
606
+ void AddIntegrationSite(const base::ListValue* args);
608
+ // Updates the integration allowed flag.
609
+ // |args| - A boolean flag indicating if integration should be allowed
610
+ void SetDesktopIntegrationAllowed(const base::ListValue* args);
612
+ // Updates the list of integrated websites.
613
+ void UpdateIntegratedWebsitesList(const base::ListValue* args);
615
+ // Predicate informing if we have been able to initialize the connection
616
+ // with the unity-webapps library (entry point for website integration
618
+ bool IsUnityWebappsInitialized() const;
621
+ void * lib_unity_webapps_handle_;
622
+ void * get_all_func_handle_;
623
+ void * remove_from_permissions_func_handle_;
624
+ void * add_allowed_domain_func_handle_;
625
+ void * is_integration_allowed_func_handle_;
626
+ void * set_integration_allowed_func_handle_;
628
+ DISALLOW_COPY_AND_ASSIGN(DesktopIntegrationSettingsHandler);
631
+} // namespace options
633
+#endif // CHROME_BROWSER_UI_WEBUI_OPTIONS_DESKTOP_INTEGRATION_SETTINGS_HANDLER2_H_
634
Index: src/chrome/browser/resources/options/desktop_integration_overlay.css
635
===================================================================
636
--- src/chrome/browser/resources/options/desktop_integration_overlay.css (revision 0)
637
+++ src/chrome/browser/resources/options/desktop_integration_overlay.css (working copy)
639
+/* Copyright (c) 2012 The Chromium Authors. All rights reserved.
640
+ * Use of this source code is governed by a BSD-style license that can be
641
+ * found in the LICENSE file. */
643
+#desktop-integration-options {
647
+#desktop-integration-options list {
651
+.desktop-integration-list-item {
652
+ -webkit-box-flex: 1;
653
+ -webkit-padding-start: 8px;
655
+ text-overflow: ellipsis;
658
+.desktop-integration-lower-left button {
662
+.desktop-integration-lower-left {
663
+ -webkit-box-flex: 0;
664
+ -webkit-padding-start: 12px;
665
+ padding-bottom: 10px;
668
+#desktop-integration-column-headers {
669
+ -webkit-margin-start: 17px;
670
+ display: -webkit-box;
674
+#desktop-integration-column-headers > div {
678
+#desktop-integration-pattern-column {
679
+ -webkit-box-flex: 1;
682
+#desktop-integration-behavior-column {
686
+#desktop-integration-area list {
687
+ margin-bottom: 10px;
692
+ -webkit-box-flex: 1;
698
+#domains-list .domain-name {
699
+ -webkit-box-flex: 1;
701
+ text-overflow: ellipsis;
702
+ white-space: nowrap;
706
+ -webkit-padding-start: 12px;
707
+ padding-bottom: 2px;
710
Index: src/chrome/browser/resources/options/desktop_integration_add_website_overlay.html
711
===================================================================
712
--- src/chrome/browser/resources/options/desktop_integration_add_website_overlay.html (revision 0)
713
+++ src/chrome/browser/resources/options/desktop_integration_add_website_overlay.html (working copy)
715
+<div id="add-desktop-integration-website-overlay-page" class="page" hidden>
716
+ <div class="close-button"></div>
717
+ <h1 i18n-content="add_desktop_website_title"></h1>
719
+ <div class="content-area">
720
+ <span i18n-content="add_desktop_website_input_label"></span>
721
+ <input id="integration-domain-url-field" type="url" data-type="url"
722
+ class="weakrtl favicon-cell hbox stretch">
725
+ <div class="action-area button-strip">
726
+ <button id="add-integration-website-overlay-cancel-button" i18n-content="cancel">
728
+ <button id="add-integration-website-overlay-ok-button" i18n-content="ok"></button>
731
Index: src/chrome/browser/resources/options/desktop_integration_overlay.html
732
===================================================================
733
--- src/chrome/browser/resources/options/desktop_integration_overlay.html (revision 0)
734
+++ src/chrome/browser/resources/options/desktop_integration_overlay.html (working copy)
736
+<div id="desktop-integration-area" class="page" hidden>
738
+ <div class="close-button"></div>
739
+ <h1 i18n-content="desktopIntegrationPage"></h1>
741
+ <span i18n-content="desktopIntegrationInfoText"></span>
743
+ <div class="content-area">
744
+ <list id="domains-list"></list>
746
+ <div class="desktop-integration-lower-left">
747
+ <button id="desktop-integration-add-button"
748
+ i18n-content="add_button"></button>
752
+ <div class="action-area">
753
+ <div class="button-strip">
754
+ <button id="desktop-integrations-overlay-confirm"
762
Index: src/chrome/browser/resources/options/desktop_integration_overlay.js
763
===================================================================
764
--- src/chrome/browser/resources/options/desktop_integration_overlay.js (revision 0)
765
+++ src/chrome/browser/resources/options/desktop_integration_overlay.js (working copy)
767
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
768
+// Use of this source code is governed by a BSD-style license that can be
769
+// found in the LICENSE file.
771
+cr.define('options', function() {
772
+ /** @const */ var ArrayDataModel = cr.ui.ArrayDataModel;
773
+ /** @const */ var DeletableItemList = options.DeletableItemList;
774
+ /** @const */ var DeletableItem = options.DeletableItem;
777
+ * Creates a new exceptions list item.
779
+ * @extends {options.DeletableItem}
781
+ function IntegratedWebsitesListItem(domain) {
782
+ var el = cr.doc.createElement('div');
783
+ el.__proto__ = IntegratedWebsitesListItem.prototype;
784
+ el.domain = domain;
789
+ IntegratedWebsitesListItem.prototype = {
790
+ __proto__: DeletableItem.prototype,
793
+ * Called when an element is decorated as a list item.
795
+ decorate: function() {
796
+ DeletableItem.prototype.decorate.call(this);
798
+ // The stored label.
799
+ var label = this.ownerDocument.createElement('div');
800
+ label.className = 'domain-name';
801
+ label.textContent = this.domain;
802
+ this.contentElement.appendChild(label);
804
+ this.deletable = true;
809
+ * Creates a integrated websites list.
811
+ * @extends {cr.ui.List}
813
+ var IntegratedWebsitesList = cr.ui.define('list');
815
+ IntegratedWebsitesList.prototype = {
816
+ __proto__: DeletableItemList.prototype,
819
+ * Called when an element is decorated as a list.
821
+ decorate: function() {
822
+ DeletableItemList.prototype.decorate.call(this);
827
+ createItem: function(domain) {
828
+ return new IntegratedWebsitesListItem(domain);
832
+ * Adds a website domain name to the list of allowed integrated websites.
833
+ * @param {string} domain domain name of the website to add.
835
+ addWebsite: function(domain) {
836
+ if (!domain || this.dataModel.indexOf(domain) >= 0) {
839
+ this.dataModel.push(domain);
841
+ chrome.send('addIntegrationSite', [domain]);
845
+ * Forces a revailidation of the list content. Content added while the list
846
+ * is hidden is not properly rendered when the list becomes visible. In
847
+ * addition, deleting a single item from the list results in a stale cache
848
+ * requiring an invalidation.
850
+ refresh: function() {
851
+ // TODO(kevers): Investigate if the root source of the problems can be
852
+ // fixed in cr.ui.list.
858
+ * Sets the integrated websites in the js model.
859
+ * @param {Object} entries A list of dictionaries of values, each dictionary
860
+ * represents an exception.
862
+ setIntegratedWebsites: function(entries) {
863
+ var integratedWebsites = null;
865
+ integratedWebsites = JSON.parse(entries);
867
+ console.log("Error while parsing integrated websites json: " + entries);
870
+ // TODO hightlight domains differently based on permission
872
+ domains = domains.concat(integratedWebsites['allowed']);
873
+ domains = domains.concat(integratedWebsites['dontask']);
874
+ this.dataModel = new ArrayDataModel(domains);
879
+ * Removes all integration scripts from the js model.
881
+ reset: function() {
882
+ this.dataModel = new ArrayDataModel([]);
886
+ deleteItemAtIndex: function(index) {
888
+ var args = [this.dataModel.item(index)];
889
+ chrome.send('removeIntegrationSite', args);
890
+ this.dataModel.splice(index, 1);
895
+ * The length of the list.
898
+ return null != this.dataModel ? this.dataModel.length : 0;
902
+ var OptionsPage = options.OptionsPage;
905
+ * DesktopIntegrationOverlay class
906
+ * Encapsulated handling of the 'Desktop integration' page.
909
+ function DesktopIntegrationOverlay() {
910
+ OptionsPage.call(this, 'desktopIntegrationOverlay',
911
+ loadTimeData.getString('desktopIntegrationPage'),
912
+ 'desktop-integration-area');
915
+ cr.addSingletonGetter(DesktopIntegrationOverlay);
917
+ DesktopIntegrationOverlay.prototype = {
918
+ __proto__: OptionsPage.prototype,
921
+ * Initialize the page.
923
+ initializePage: function() {
924
+ OptionsPage.prototype.initializePage.call(this);
926
+ var integrationList = $('domains-list');
927
+ IntegratedWebsitesList.decorate(integrationList);
928
+ $('desktop-integrations-overlay-confirm').onclick =
929
+ OptionsPage.closeOverlay.bind(OptionsPage);
931
+ // Set up add button.
932
+ $('desktop-integration-add-button').onclick = function(e) {
933
+ OptionsPage.navigateToPage('addDesktopIntegrationWebsite');
936
+ // Listen to add website dialog ok button.
937
+ var addWebsiteOkButton = $('add-integration-website-overlay-ok-button');
938
+ addWebsiteOkButton.addEventListener('click',
939
+ this.handleAddWebsiteOkButtonClick_.bind(this));
942
+ handleAddWebsiteOkButtonClick_: function () {
943
+ var website = $('integration-domain-url-field').value;
944
+ var integratedDomain = website.replace(/\s*/g, '')
945
+ console.log (integratedDomain);
946
+ $('domains-list').addWebsite(integratedDomain);
947
+ OptionsPage.closeOverlay();
951
+ * Called by the options page when this page has been shown.
953
+ didShowPage: function() {
954
+ chrome.send('updateIntegratedWebsitesList');
958
+ DesktopIntegrationOverlay.setIntegratedWebsites = function(entries) {
959
+ $('domains-list').setIntegratedWebsites(entries);
964
+ IntegratedWebsitesListItem: IntegratedWebsitesListItem,
965
+ IntegratedWebsitesList: IntegratedWebsitesList,
966
+ DesktopIntegrationOverlay: DesktopIntegrationOverlay
970
Index: src/chrome/browser/resources/options/desktop_integration_add_website_overlay.js
971
===================================================================
972
--- src/chrome/browser/resources/options/desktop_integration_add_website_overlay.js (revision 0)
973
+++ src/chrome/browser/resources/options/desktop_integration_add_website_overlay.js (working copy)
975
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
976
+// Use of this source code is governed by a BSD-style license that can be
977
+// found in the LICENSE file.
979
+///////////////////////////////////////////////////////////////////////////////
980
+// AddDesktopIntegrationWebsiteOverlay class:
982
+cr.define('options', function() {
983
+ /** @const */ var OptionsPage = options.OptionsPage;
988
+ function AddDesktopIntegrationWebsiteOverlay() {
989
+ OptionsPage.call(this, 'addDesktopIntegrationWebsite',
990
+ loadTimeData.getString('add_button'),
991
+ 'add-desktop-integration-website-overlay-page');
994
+ cr.addSingletonGetter(AddDesktopIntegrationWebsiteOverlay);
996
+ AddDesktopIntegrationWebsiteOverlay.prototype = {
997
+ // Inherit AddDesktopIntegrationWebsiteOverlay from OptionsPage.
998
+ __proto__: OptionsPage.prototype,
1001
+ * Initializes AddDesktopIntegrationWebsiteOverlay page.
1002
+ * Calls base class implementation to starts preference initialization.
1004
+ initializePage: function() {
1005
+ // Call base class implementation to starts preference initialization.
1006
+ OptionsPage.prototype.initializePage.call(this);
1008
+ // Cleanup any previously entered text.
1009
+ $('integration-domain-url-field').value = '';
1011
+ // Set up the cancel button.
1012
+ $('add-integration-website-overlay-cancel-button').onclick = function(e) {
1013
+ OptionsPage.closeOverlay();
1019
+ AddDesktopIntegrationWebsiteOverlay: AddDesktopIntegrationWebsiteOverlay