1
Index: chrome/chrome_browser.gypi
2
===================================================================
3
--- chrome/chrome_browser.gypi (revision 136242)
4
+++ chrome/chrome_browser.gypi (working copy)
6
'browser/ui/webui/options2/cookies_view_handler2.h',
7
'browser/ui/webui/options2/core_options_handler2.cc',
8
'browser/ui/webui/options2/core_options_handler2.h',
9
+ 'browser/ui/webui/options2/desktop_integration_settings_handler2.cc',
10
+ 'browser/ui/webui/options2/desktop_integration_settings_handler2.h',
11
'browser/ui/webui/options2/font_settings_handler2.cc',
12
'browser/ui/webui/options2/font_settings_handler2.h',
13
'browser/ui/webui/options2/font_settings_utils2.h',
14
Index: chrome/app/generated_resources.grd
15
===================================================================
16
--- chrome/app/generated_resources.grd (revision 136242)
17
+++ chrome/app/generated_resources.grd (working copy)
18
@@ -10393,6 +10393,9 @@
19
<message name="IDS_OPTIONS_ADVANCED_SECTION_TITLE_CONTENT">
22
+ <message name="IDS_OPTIONS_ADVANCED_SECTION_TITLE_INTEGRATION">
25
<message name="IDS_OPTIONS_ADVANCED_SECTION_TITLE_SECURITY">
28
@@ -16037,6 +16040,35 @@
32
+ <!-- Desktop integration -->
33
+ <message name="IDS_PROMPT_INTEGRATION_ENABLE_BUTTON_LABEL" desc="The text to be displayed on the checkbox that enables desktop integration.">
34
+ Prompt integration options for any website
36
+ <message name="IDS_DESKTOP_INTEGRATION_SETTINGS_EXCEPTIONS_BUTTON_LABEL" desc="The text to be displayed on the button that drives integration exceptions.">
39
+ <message name="IDS_DESKTOP_INTEGRATION_SETTINGS_OVERLAY_TITLE" desc="Title for the desktop integration overlay.">
40
+ Integration prompt exceptions
42
+ <message name="IDS_DESKTOP_INTEGRATION_SETTINGS_OVERLAY_DESCRIPTION" desc="Description for the desktop integration overlay.">
43
+ These websites won't prompt any integration options
45
+ <message name="IDS_DESKTOP_INTEGRATION_SETTINGS_OVERLAY_COLUMN_DESCRIPTION" desc="Description of the desktop integration overlay's integrated websites list column.">
48
+ <message name="IDS_OPTIONS_SETTINGS_INTEGRATION_WEBSITE_ADD_BUTTON"
49
+ desc="The label for the add button for adding a integration websites">
52
+ <message name="IDS_OPTIONS_SETTINGS_INTEGRATION_WEBSITE_ADD_TEXT"
53
+ desc="The description text for the add overlay for adding a integration websites">
54
+ Website domain name (e.g. www.html5rocks.com)
56
+ <message name="IDS_OPTIONS_SETTINGS_INTEGRATION_WEBSITE_ADD_TITLE"
57
+ desc="Title for add overlay for adding a integration websites">
58
+ Add Integrated Website
61
<!-- Manage Profile Dialog -->
62
<message name="IDS_PROFILES_MANAGE_TITLE" desc="Title of the manage profile dialog">
64
Index: chrome/browser/resources/options2/options.html
65
===================================================================
66
--- chrome/browser/resources/options2/options.html (revision 136242)
67
+++ chrome/browser/resources/options2/options.html (working copy)
69
<link rel="stylesheet" href="clear_browser_data_overlay.css">
70
<link rel="stylesheet" href="content_settings.css">
71
<link rel="stylesheet" href="cookies_view.css">
72
+<link rel="stylesheet" href="desktop_integration_overlay.css">
73
<link rel="stylesheet" href="font_settings.css">
74
<link rel="stylesheet" href="handler_options.css">
75
<link rel="stylesheet" href="home_page_overlay.css">
77
<include src="font_settings.html">
78
<include src="home_page_overlay.html">
79
<include src="import_data_overlay.html">
80
+ <include src="desktop_integration_overlay.html">
81
<include src="instant_confirm_overlay.html">
82
<include src="language_options.html">
83
<include src="manage_profile_overlay.html">
85
<include src="autofill_edit_creditcard_overlay.html">
86
<include src="content_settings_exceptions_area.html">
87
<include src="cookies_view.html">
88
+ <include src="desktop_integration_add_website_overlay.html">
89
<include src="handler_options.html">
90
<include src="language_add_language_overlay.html">
91
<if expr="pp_ifdef('chromeos')">
92
Index: chrome/browser/resources/options2/options.js
93
===================================================================
94
--- chrome/browser/resources/options2/options.js (revision 136242)
95
+++ chrome/browser/resources/options2/options.js (working copy)
97
var ContentSettingsExceptionsArea =
98
options.contentSettings.ContentSettingsExceptionsArea;
99
var CookiesView = options.CookiesView;
100
+var DesktopIntegrationOverlay = options.DesktopIntegrationOverlay;
101
+var AddDesktopIntegrationWebsiteOverlay = options.AddDesktopIntegrationWebsiteOverlay;
102
var FontSettings = options.FontSettings;
103
var HandlerOptions = options.HandlerOptions;
104
var HomePageOverlay = options.HomePageOverlay;
106
OptionsPage.registerOverlay(FontSettings.getInstance(),
107
BrowserOptions.getInstance(),
108
[$('fontSettingsCustomizeFontsButton')]);
109
+ if (cr.isLinux && !cr.isChromeos) {
110
+ OptionsPage.registerOverlay(AddDesktopIntegrationWebsiteOverlay.getInstance(),
111
+ DesktopIntegrationOverlay.getInstance());
112
+ OptionsPage.registerOverlay(DesktopIntegrationOverlay.getInstance(),
113
+ BrowserOptions.getInstance(),
114
+ [$('desktop-integration-button')]);
116
if (HandlerOptions && $('manage-handlers-button')) {
117
OptionsPage.registerOverlay(HandlerOptions.getInstance(),
118
ContentSettings.getInstance(),
119
Index: chrome/browser/resources/options2/desktop_integration_add_website_overlay.html
120
===================================================================
121
--- chrome/browser/resources/options2/desktop_integration_add_website_overlay.html (revision 0)
122
+++ chrome/browser/resources/options2/desktop_integration_add_website_overlay.html (revision 0)
124
+<div id="add-desktop-integration-website-overlay-page" class="page" hidden>
125
+ <div class="close-button"></div>
126
+ <h1 i18n-content="add_desktop_website_title"></h1>
128
+ <div class="content-area">
129
+ <span i18n-content="add_desktop_website_input_label"></span>
130
+ <input id="website-url-field" type="url" data-type="url"
131
+ class="weakrtl favicon-cell hbox stretch">
134
+ <div class="action-area button-strip">
135
+ <button id="add-integration-website-overlay-cancel-button" i18n-content="cancel">
137
+ <button id="add-integration-website-overlay-ok-button" i18n-content="ok"></button>
140
Index: chrome/browser/resources/options2/desktop_integration_add_website_overlay.js
141
===================================================================
142
--- chrome/browser/resources/options2/desktop_integration_add_website_overlay.js (revision 0)
143
+++ chrome/browser/resources/options2/desktop_integration_add_website_overlay.js (revision 0)
145
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
146
+// Use of this source code is governed by a BSD-style license that can be
147
+// found in the LICENSE file.
149
+///////////////////////////////////////////////////////////////////////////////
150
+// AddDesktopIntegrationWebsiteOverlay class:
152
+cr.define('options', function() {
153
+ /** @const */ var OptionsPage = options.OptionsPage;
158
+ function AddDesktopIntegrationWebsiteOverlay() {
159
+ OptionsPage.call(this, 'addDesktopIntegrationWebsite',
160
+ localStrings.getString('add_button'),
161
+ 'add-desktop-integration-website-overlay-page');
164
+ cr.addSingletonGetter(AddDesktopIntegrationWebsiteOverlay);
166
+ AddDesktopIntegrationWebsiteOverlay.prototype = {
167
+ // Inherit AddDesktopIntegrationWebsiteOverlay from OptionsPage.
168
+ __proto__: OptionsPage.prototype,
171
+ * Initializes AddDesktopIntegrationWebsiteOverlay page.
172
+ * Calls base class implementation to starts preference initialization.
174
+ initializePage: function() {
175
+ // Call base class implementation to starts preference initialization.
176
+ OptionsPage.prototype.initializePage.call(this);
178
+ // Set up the cancel button.
179
+ $('add-integration-website-overlay-cancel-button').onclick = function(e) {
180
+ OptionsPage.closeOverlay();
186
+ AddDesktopIntegrationWebsiteOverlay: AddDesktopIntegrationWebsiteOverlay
189
Index: chrome/browser/resources/options2/options_bundle.js
190
===================================================================
191
--- chrome/browser/resources/options2/options_bundle.js (revision 136242)
192
+++ chrome/browser/resources/options2/options_bundle.js (working copy)
194
<include src="content_settings_ui.js"></include>
195
<include src="cookies_list.js"></include>
196
<include src="cookies_view.js"></include>
197
+<include src="desktop_integration_add_website_overlay.js"></include>
198
+<include src="desktop_integration_overlay.js"></include>
199
<include src="font_settings.js"></include>
200
<include src="handler_options.js"></include>
201
<include src="handler_options_list.js"></include>
202
Index: chrome/browser/resources/options2/browser_options.html
203
===================================================================
204
--- chrome/browser/resources/options2/browser_options.html (revision 136242)
205
+++ chrome/browser/resources/options2/browser_options.html (working copy)
207
<if expr="not pp_ifdef('toolkit_views') and is_posix and not is_macosx">
208
<button id="themes-gallery" i18n-content="themesGallery"></button>
209
<button id="themes-GTK-button"
210
- i18n-content="themesGTKButton"></button>
211
+ i18n-content="themesGTKButton"></button>
212
<button id="themes-reset"
213
i18n-content="themesSetClassic"></button>
220
+<if expr="is_linux and not pp_ifdef('chromeos')">
221
+ <section id="desktop-integration-section">
222
+ <h3 i18n-content="advancedSectionTitleIntegration"></h3>
223
+ <div class="checkbox">
225
+ <input id="promptIntegrationForAnyWebsite" pref="desktop_integration_prompt.enabled"
226
+ metric="Options_PromptIntegration" type="checkbox">
227
+ <span i18n-content="promptIntegrationEnableIntegration"></span>
230
+ <button id="desktop-integration-button"
231
+ i18n-content="desktopIntegrationExceptionsSettingsButton"></button>
235
<if expr="not pp_ifdef('chromeos')">
237
<h3 i18n-content="advancedSectionTitleNetwork"></h3>
238
Index: chrome/browser/resources/options2/desktop_integration_overlay.html
239
===================================================================
240
--- chrome/browser/resources/options2/desktop_integration_overlay.html (revision 0)
241
+++ chrome/browser/resources/options2/desktop_integration_overlay.html (revision 0)
243
+<div id="desktop-integration-area" class="page" hidden>
245
+ <div class="close-button"></div>
246
+ <h1 i18n-content="desktopIntegrationPage"></h1>
248
+ <span i18n-content="desktopIntegrationInfoText"></span>
250
+ <div id="desktop-integration-column-headers">
251
+ <div id="desktop-integration-description-column" i18n-content="desktopIntegrationColumnDescription">
255
+ <div class="content-area">
256
+ <list id="domains-list"></list>
258
+ <div class="desktop-integration-lower-left">
259
+ <button id="desktop-integration-add-button"
260
+ i18n-content="add_button"></button>
264
+ <div class="action-area">
265
+ <div class="button-strip">
266
+ <button id="desktop-integrations-overlay-confirm"
274
Index: chrome/browser/resources/options2/desktop_integration_overlay.js
275
===================================================================
276
--- chrome/browser/resources/options2/desktop_integration_overlay.js (revision 0)
277
+++ chrome/browser/resources/options2/desktop_integration_overlay.js (revision 0)
279
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
280
+// Use of this source code is governed by a BSD-style license that can be
281
+// found in the LICENSE file.
283
+cr.define('options', function() {
284
+ /** @const */ var ArrayDataModel = cr.ui.ArrayDataModel;
285
+ /** @const */ var DeletableItemList = options.DeletableItemList;
286
+ /** @const */ var DeletableItem = options.DeletableItem;
289
+ * Creates a new exceptions list item.
291
+ * @extends {options.DeletableItem}
293
+ function IntegratedWebsitesListItem(domain) {
294
+ var el = cr.doc.createElement('div');
295
+ el.__proto__ = IntegratedWebsitesListItem.prototype;
296
+ el.domain = domain;
301
+ IntegratedWebsitesListItem.prototype = {
302
+ __proto__: DeletableItem.prototype,
305
+ * Called when an element is decorated as a list item.
307
+ decorate: function() {
308
+ DeletableItem.prototype.decorate.call(this);
310
+ // The stored label.
311
+ var label = this.ownerDocument.createElement('div');
312
+ label.className = 'domain-name';
313
+ label.textContent = this.domain;
314
+ this.contentElement.appendChild(label);
316
+ this.deletable = true;
321
+ * Creates a integrated websites list.
323
+ * @extends {cr.ui.List}
325
+ var IntegratedWebsitesList = cr.ui.define('list');
327
+ IntegratedWebsitesList.prototype = {
328
+ __proto__: DeletableItemList.prototype,
331
+ * Called when an element is decorated as a list.
333
+ decorate: function() {
334
+ DeletableItemList.prototype.decorate.call(this);
339
+ createItem: function(domain) {
340
+ return new IntegratedWebsitesListItem(domain);
344
+ * Adds a website domain name to the list of allowed integrated websites.
345
+ * @param {string} domain domain name of the website to add.
347
+ addWebsite: function(domain) {
348
+ if (!domain || this.dataModel.indexOf(domain) >= 0) {
351
+ this.dataModel.push(url);
353
+ chrome.send('addIntegrationSite', [domain]);
357
+ * Forces a revailidation of the list content. Content added while the list
358
+ * is hidden is not properly rendered when the list becomes visible. In
359
+ * addition, deleting a single item from the list results in a stale cache
360
+ * requiring an invalidation.
362
+ refresh: function() {
363
+ // TODO(kevers): Investigate if the root source of the problems can be
364
+ // fixed in cr.ui.list.
370
+ * Sets the integrated websites in the js model.
371
+ * @param {Object} entries A list of dictionaries of values, each dictionary
372
+ * represents an exception.
374
+ setIntegratedWebsites: function(entries) {
375
+ var integratedWebsites = null;
377
+ integratedWebsites = JSON.parse(entries);
379
+ console.log("Error while parsing integrated websites json: " + entries);
382
+ // TODO hightlight domains differently based on permission
384
+ domains = domains.concat(integratedWebsites['allowed']);
385
+ domains = domains.concat(integratedWebsites['dontask']);
386
+ this.dataModel = new ArrayDataModel(domains);
391
+ * Removes all integration scripts from the js model.
393
+ reset: function() {
394
+ this.dataModel = new ArrayDataModel([]);
398
+ deleteItemAtIndex: function(index) {
400
+ var args = [this.dataModel.item(index)];
401
+ chrome.send('removeIntegrationSite', args);
402
+ this.dataModel.splice(index, 1);
407
+ * The length of the list.
410
+ return null != this.dataModel ? this.dataModel.length : 0;
414
+ var OptionsPage = options.OptionsPage;
417
+ * DesktopIntegrationOverlay class
418
+ * Encapsulated handling of the 'Desktop integration' page.
421
+ function DesktopIntegrationOverlay() {
422
+ OptionsPage.call(this, 'desktopIntegrationOverlay',
423
+ templateData.desktopIntegrationPage,
424
+ 'desktop-integration-area');
427
+ cr.addSingletonGetter(DesktopIntegrationOverlay);
429
+ DesktopIntegrationOverlay.prototype = {
430
+ __proto__: OptionsPage.prototype,
433
+ * Initialize the page.
435
+ initializePage: function() {
436
+ OptionsPage.prototype.initializePage.call(this);
438
+ var integrationList = $('domains-list');
439
+ IntegratedWebsitesList.decorate(integrationList);
440
+ $('desktop-integrations-overlay-confirm').onclick =
441
+ OptionsPage.closeOverlay.bind(OptionsPage);
443
+ // Set up add button.
444
+ $('desktop-integration-add-button').onclick = function(e) {
445
+ OptionsPage.navigateToPage('addDesktopIntegrationWebsite');
448
+ // Listen to add website dialog ok button.
449
+ var addWebsiteOkButton = $('add-integration-website-overlay-ok-button');
450
+ addWebsiteOkButton.addEventListener('click',
451
+ this.handleAddWebsiteOkButtonClick_.bind(this));
454
+ handleAddWebsiteOkButtonClick_: function () {
455
+ var website = $('website-url-field').value;
456
+ $('domains-list').addWebsite(String(website));
457
+ OptionsPage.closeOverlay();
461
+ * Called by the options page when this page has been shown.
463
+ didShowPage: function() {
464
+ chrome.send('updateIntegratedWebsitesList');
468
+ DesktopIntegrationOverlay.setIntegratedWebsites = function(entries) {
469
+ $('domains-list').setIntegratedWebsites(entries);
474
+ IntegratedWebsitesListItem: IntegratedWebsitesListItem,
475
+ IntegratedWebsitesList: IntegratedWebsitesList,
476
+ DesktopIntegrationOverlay: DesktopIntegrationOverlay
480
Index: chrome/browser/resources/options2/desktop_integration_overlay.css
481
===================================================================
482
--- chrome/browser/resources/options2/desktop_integration_overlay.css (revision 0)
483
+++ chrome/browser/resources/options2/desktop_integration_overlay.css (revision 0)
485
+/* Copyright (c) 2012 The Chromium Authors. All rights reserved.
486
+ * Use of this source code is governed by a BSD-style license that can be
487
+ * found in the LICENSE file. */
489
+#desktop-integration-options {
493
+#desktop-integration-options list {
497
+.desktop-integration-list-item {
498
+ -webkit-box-flex: 1;
499
+ -webkit-padding-start: 8px;
501
+ text-overflow: ellipsis;
504
+.desktop-integration-lower-left button {
508
+.desktop-integration-lower-left {
509
+ -webkit-box-flex: 0;
510
+ -webkit-padding-start: 12px;
511
+ padding-bottom: 10px;
514
+#desktop-integration-column-headers {
515
+ -webkit-margin-start: 17px;
516
+ display: -webkit-box;
520
+#desktop-integration-column-headers > div {
524
+#desktop-integration-pattern-column {
525
+ -webkit-box-flex: 1;
528
+#desktop-integration-behavior-column {
532
+#desktop-integration-area list {
533
+ margin-bottom: 10px;
538
+ -webkit-box-flex: 1;
544
+#domains-list .domain-name {
545
+ -webkit-box-flex: 1;
547
+ text-overflow: ellipsis;
548
+ white-space: nowrap;
552
+ -webkit-padding-start: 12px;
553
+ padding-bottom: 2px;
556
Index: chrome/browser/resources/options2/browser_options.js
557
===================================================================
558
--- chrome/browser/resources/options2/browser_options.js (revision 136242)
559
+++ chrome/browser/resources/options2/browser_options.js (working copy)
561
[String(event.target.options[event.target.selectedIndex].value)]);
564
+ // Desktop integration section
565
+ if (cr.isLinux && !cr.isChromeOS) {
566
+ var updateButtonState = function () {
567
+ $('desktop-integration-button').disabled =
568
+ ! $('promptIntegrationForAnyWebsite').checked;
570
+ $('promptIntegrationForAnyWebsite').onchange = function () {
571
+ updateButtonState();
572
+ chrome.send('setDesktopIntegrationAllowed',
573
+ [$('promptIntegrationForAnyWebsite').checked]);
575
+ updateButtonState();
576
+ $('desktop-integration-button').onclick = function(event) {
577
+ OptionsPage.navigateToPage('desktopIntegrationOverlay');
581
// Languages section.
582
$('language-button').onclick = function(event) {
583
OptionsPage.navigateToPage('languages');
584
@@ -1022,6 +1039,24 @@
588
+ * Disable the desktop integration settings if needed.
591
+ disableDesktopIntegration_: function() {
592
+ $('desktop-integration-section').style.display = 'none';
596
+ * Disable the desktop integration settings if needed.
599
+ setDesktopIntegrationIsAllowed_: function(enabled) {
600
+ $('promptIntegrationForAnyWebsite').checked = enabled;
601
+ $('desktop-integration-button').disabled =
602
+ ! $('promptIntegrationForAnyWebsite').checked;
606
* Set the checked state of the metrics reporting checkbox.
609
@@ -1325,6 +1360,7 @@
610
//Forward public APIs to private implementations.
612
'addBluetoothDevice',
613
+ 'disableDesktopIntegration',
614
'getStartStopSyncButton',
615
'hideBluetoothSettings',
616
'removeCloudPrintConnectorSection',
617
@@ -1338,6 +1374,7 @@
618
'setGtkThemeButtonEnabled',
619
'setHighContrastCheckboxState',
620
'setInstantFieldTrialStatus',
621
+ 'setDesktopIntegrationIsAllowed',
622
'setMetricsReportingCheckboxState',
623
'setMetricsReportingSettingVisibility',
625
Index: chrome/browser/ui/webui/options2/options_ui2.cc
626
===================================================================
627
--- chrome/browser/ui/webui/options2/options_ui2.cc (revision 136242)
628
+++ chrome/browser/ui/webui/options2/options_ui2.cc (working copy)
630
#include "chrome/browser/ui/webui/options2/certificate_manager_handler2.h"
633
+#if defined(OS_LINUX)
634
+#include "chrome/browser/ui/webui/options2/desktop_integration_settings_handler2.h"
637
using content::RenderViewHost;
641
AddOptionsPageUIHandler(localized_strings, new ClearBrowserDataHandler());
642
AddOptionsPageUIHandler(localized_strings, new ContentSettingsHandler());
643
AddOptionsPageUIHandler(localized_strings, new CookiesViewHandler());
644
+#if defined(OS_LINUX)
645
+ AddOptionsPageUIHandler(localized_strings,
646
+ new DesktopIntegrationSettingsHandler());
648
AddOptionsPageUIHandler(localized_strings, new FontSettingsHandler());
649
AddOptionsPageUIHandler(localized_strings, new HomePageOverlayHandler());
650
AddOptionsPageUIHandler(localized_strings, new WebIntentsSettingsHandler());
651
Index: chrome/browser/ui/webui/options2/desktop_integration_settings_handler2.h
652
===================================================================
653
--- chrome/browser/ui/webui/options2/desktop_integration_settings_handler2.h (revision 0)
654
+++ chrome/browser/ui/webui/options2/desktop_integration_settings_handler2.h (revision 0)
656
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
657
+// Use of this source code is governed by a BSD-style license that can be
658
+// found in the LICENSE file.
660
+#ifndef CHROME_BROWSER_UI_WEBUI_OPTIONS2_DESKTOP_INTEGRATION_SETTINGS_HANDLER2_H_
661
+#define CHROME_BROWSER_UI_WEBUI_OPTIONS2_DESKTOP_INTEGRATION_SETTINGS_HANDLER2_H_
665
+#include "base/compiler_specific.h"
666
+#include "chrome/browser/ui/webui/options2/options_ui2.h"
669
+class DictionaryValue;
673
+namespace options2 {
675
+class DesktopIntegrationSettingsHandler : public OptionsPageUIHandler {
677
+ DesktopIntegrationSettingsHandler();
678
+ virtual ~DesktopIntegrationSettingsHandler();
680
+ // OptionsPageUIHandler implementation.
681
+ virtual void GetLocalizedValues(
682
+ base::DictionaryValue* localized_strings) OVERRIDE;
683
+ virtual void InitializeHandler() OVERRIDE;
684
+ virtual void InitializePage() OVERRIDE;
685
+ virtual void RegisterMessages() OVERRIDE;
689
+ // Loads the data associated with the currently integrated websites.
690
+ void LoadIntegratedWebsitesData();
692
+ // Initializes the list of website domain names that are currently
693
+ // either allowed or 'dontask' and send it to the overlay.
694
+ void LoadUnityWebappsEntryPoint();
696
+ // Removes an website from the list of integrated websites that won't prompt
697
+ // from integration.
698
+ // |args| - A string, the domain name of the website to remove.
699
+ void RemoveIntegrationSite(const ListValue* args);
701
+ // Adds an website from the list of integrated websites that won't prompt
702
+ // from integration. The website is being added to the list of 'allowed' sites.
703
+ // |args| - A string, the domain name of the website to add.
704
+ void AddIntegrationSite(const ListValue* args);
706
+ // Updates the integration allowed flag.
707
+ // |args| - A boolean flag indicating if integration should be allowed
708
+ void SetDesktopIntegrationAllowed(const ListValue* args);
710
+ // Updates the list of integrated websites.
711
+ void UpdateIntegratedWebsitesList(const ListValue* args);
713
+ // Predicate informing if we have been able to initialize the connection
714
+ // with the unity-webapps library (entry point for website integration
716
+ bool IsUnityWebappsInitialized() const;
719
+ void * lib_unity_webapps_handle_;
720
+ void * get_all_func_handle_;
721
+ void * remove_from_permissions_func_handle_;
722
+ void * add_allowed_domain_func_handle_;
723
+ void * is_integration_allowed_func_handle_;
724
+ void * set_integration_allowed_func_handle_;
726
+ DISALLOW_COPY_AND_ASSIGN(DesktopIntegrationSettingsHandler);
729
+} // namespace options2
731
+#endif // CHROME_BROWSER_UI_WEBUI_OPTIONS2_DESKTOP_INTEGRATION_SETTINGS_HANDLER2_H_
732
Index: chrome/browser/ui/webui/options2/desktop_integration_settings_handler2.cc
733
===================================================================
734
--- chrome/browser/ui/webui/options2/desktop_integration_settings_handler2.cc (revision 0)
735
+++ chrome/browser/ui/webui/options2/desktop_integration_settings_handler2.cc (revision 0)
737
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
738
+// Use of this source code is governed by a BSD-style license that can be
739
+// found in the LICENSE file.
741
+#include "chrome/browser/ui/webui/options2/desktop_integration_settings_handler2.h"
747
+#include "base/bind.h"
748
+#include "base/bind_helpers.h"
749
+#include "base/logging.h"
750
+#include "base/string16.h"
751
+#include "base/string_number_conversions.h"
752
+#include "base/utf_string_conversions.h"
753
+#include "base/values.h"
754
+#include "chrome/browser/ui/webui/web_ui_util.h"
755
+#include "chrome/common/guid.h"
756
+#include "chrome/common/url_constants.h"
757
+#include "content/public/browser/web_ui.h"
758
+#include "grit/generated_resources.h"
759
+#include "grit/webkit_resources.h"
760
+#include "ui/base/l10n/l10n_util.h"
762
+namespace options2 {
764
+// TODO: -> extract to function
765
+DesktopIntegrationSettingsHandler::DesktopIntegrationSettingsHandler()
766
+ : lib_unity_webapps_handle_(NULL),
767
+ get_all_func_handle_(NULL),
768
+ remove_from_permissions_func_handle_(NULL),
769
+ add_allowed_domain_func_handle_(NULL),
770
+ is_integration_allowed_func_handle_(NULL) {
773
+DesktopIntegrationSettingsHandler::~DesktopIntegrationSettingsHandler() {
774
+ if (lib_unity_webapps_handle_) {
775
+ dlclose (lib_unity_webapps_handle_);
776
+ lib_unity_webapps_handle_ = NULL;
778
+ remove_from_permissions_func_handle_ = NULL;
779
+ get_all_func_handle_ = NULL;
780
+ add_allowed_domain_func_handle_ = NULL;
781
+ is_integration_allowed_func_handle_ = NULL;
785
+/////////////////////////////////////////////////////////////////////////////
786
+// OptionsPageUIHandler implementation:
787
+void DesktopIntegrationSettingsHandler::GetLocalizedValues(
788
+ DictionaryValue* localized_strings) {
789
+ DCHECK(localized_strings);
791
+ static OptionsStringResource resources[] = {
792
+ { "desktopIntegrationInfoText",
793
+ IDS_DESKTOP_INTEGRATION_SETTINGS_OVERLAY_DESCRIPTION },
794
+ { "desktopIntegrationColumnDescription",
795
+ IDS_DESKTOP_INTEGRATION_SETTINGS_OVERLAY_COLUMN_DESCRIPTION },
798
+ localized_strings->SetString("add_button",
799
+ l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_INTEGRATION_WEBSITE_ADD_BUTTON));
800
+ localized_strings->SetString("add_desktop_website_input_label",
801
+ l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_INTEGRATION_WEBSITE_ADD_TEXT));
802
+ localized_strings->SetString("add_desktop_website_title",
803
+ l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_INTEGRATION_WEBSITE_ADD_TITLE));
805
+ RegisterStrings(localized_strings, resources, arraysize(resources));
806
+ RegisterTitle(localized_strings, "desktopIntegrationPage",
807
+ IDS_DESKTOP_INTEGRATION_SETTINGS_OVERLAY_TITLE);
810
+void DesktopIntegrationSettingsHandler::InitializeHandler() {
811
+ if (!IsUnityWebappsInitialized()) {
812
+ LoadUnityWebappsEntryPoint();
816
+void DesktopIntegrationSettingsHandler::InitializePage() {
817
+ DCHECK(IsUnityWebappsInitialized());
818
+ LoadIntegratedWebsitesData();
821
+void DesktopIntegrationSettingsHandler::RegisterMessages() {
822
+ web_ui()->RegisterMessageCallback(
823
+ "addIntegrationSite",
824
+ base::Bind(&DesktopIntegrationSettingsHandler::AddIntegrationSite,
825
+ base::Unretained(this)));
826
+ web_ui()->RegisterMessageCallback(
827
+ "setDesktopIntegrationAllowed",
828
+ base::Bind(&DesktopIntegrationSettingsHandler::SetDesktopIntegrationAllowed,
829
+ base::Unretained(this)));
830
+ web_ui()->RegisterMessageCallback(
831
+ "removeIntegrationSite",
832
+ base::Bind(&DesktopIntegrationSettingsHandler::RemoveIntegrationSite,
833
+ base::Unretained(this)));
834
+ web_ui()->RegisterMessageCallback(
835
+ "updateIntegratedWebsitesList",
836
+ base::Bind(&DesktopIntegrationSettingsHandler::UpdateIntegratedWebsitesList,
837
+ base::Unretained(this)));
840
+void DesktopIntegrationSettingsHandler::LoadUnityWebappsEntryPoint() {
841
+ DCHECK(!IsUnityWebappsInitialized());
843
+ // TODO run on FILE thread
844
+ static const char* const search_paths[] = {
845
+ "/usr/local/lib/libunity_webapps.so.0"
846
+ , "/usr/lib/libunity_webapps.so.0"
849
+ void * handle = NULL;
850
+ for (size_t i = 0; i < sizeof(search_paths)/sizeof(search_paths[0]); ++i) {
851
+ DCHECK(handle == NULL);
852
+ // TODO validate path?
853
+ handle = dlopen (search_paths[i], RTLD_LAZY|RTLD_GLOBAL);
855
+ LOG(ERROR) << "Found libunitywebapps entry point:" << search_paths[i];
860
+ LOG(INFO) << "Could not load Unity Webapps entry point library";
864
+ void * get_all_handle =
865
+ dlsym (handle, "unity_webapps_permissions_get_all_domains");
866
+ void * remove_from_permissions_handle =
867
+ dlsym (handle, "unity_webapps_permissions_remove_domain_from_permissions");
868
+ void * add_allowed_domain_handle =
869
+ dlsym (handle, "unity_webapps_permissions_allow_domain");
870
+ void * is_integration_allowed_handle =
871
+ dlsym (handle, "unity_webapps_permissions_is_integration_allowed");
872
+ void * set_integration_allowed_handle =
873
+ dlsym (handle, "unity_webapps_permissions_set_integration_allowed");
875
+ if (!get_all_handle ||
876
+ !remove_from_permissions_handle ||
877
+ !add_allowed_domain_handle ||
878
+ !is_integration_allowed_handle ||
879
+ !set_integration_allowed_handle) {
880
+ LOG(WARNING) << "Could not load Unity Webapps entry point functions";
885
+ lib_unity_webapps_handle_ = handle;
886
+ get_all_func_handle_ = get_all_handle;
887
+ remove_from_permissions_func_handle_ = remove_from_permissions_handle;
888
+ add_allowed_domain_func_handle_ = add_allowed_domain_handle;
889
+ is_integration_allowed_func_handle_ = is_integration_allowed_handle;
890
+ set_integration_allowed_func_handle_ = set_integration_allowed_handle;
893
+bool DesktopIntegrationSettingsHandler::IsUnityWebappsInitialized() const {
894
+ return NULL != lib_unity_webapps_handle_
895
+ && NULL != get_all_func_handle_
896
+ && NULL != remove_from_permissions_func_handle_
897
+ && NULL != add_allowed_domain_func_handle_
898
+ && NULL != is_integration_allowed_func_handle_
899
+ && NULL != set_integration_allowed_func_handle_;
902
+void DesktopIntegrationSettingsHandler::LoadIntegratedWebsitesData() {
903
+ if (!IsUnityWebappsInitialized()) {
904
+ web_ui()->CallJavascriptFunction(
905
+ "BrowserOptions.disableDesktopIntegration");
909
+ typedef gboolean (* IsIntegrationAllowedFunc) (void);
910
+ gboolean isallowed =
911
+ ((IsIntegrationAllowedFunc) is_integration_allowed_func_handle_) ();
912
+ web_ui()->CallJavascriptFunction(
913
+ "BrowserOptions.setDesktopIntegrationIsAllowed",
914
+ base::FundamentalValue(isallowed));
917
+void DesktopIntegrationSettingsHandler::UpdateIntegratedWebsitesList(
918
+ const ListValue* args) {
919
+ DCHECK(IsUnityWebappsInitialized());
921
+ // TODO move elsewhere
922
+ typedef gchar* (* GetAllDomainsFunc) (void);
924
+ gchar* all_domains = ((GetAllDomainsFunc) get_all_func_handle_) ();
926
+ web_ui()->CallJavascriptFunction(
927
+ "DesktopIntegrationOverlay.setIntegratedWebsites",
928
+ StringValue(all_domains));
932
+void DesktopIntegrationSettingsHandler::SetDesktopIntegrationAllowed(
933
+ const ListValue* args) {
934
+ DCHECK(IsUnityWebappsInitialized());
936
+ // TODO move elsewhere
937
+ typedef void (* SetDesktopIntegrationAllowedFunc) (gboolean);
940
+ if (!args->GetBoolean(0, &is_allowed)) {
945
+ LOG(INFO) << "Setting desktop integration:" << is_allowed;
947
+ ((SetDesktopIntegrationAllowedFunc) set_integration_allowed_func_handle_) (
948
+ is_allowed ? TRUE : FALSE);
951
+void DesktopIntegrationSettingsHandler::AddIntegrationSite(
952
+ const ListValue* args) {
953
+ DCHECK(IsUnityWebappsInitialized());
955
+ // TODO move elsewhere
956
+ typedef void (* AddDomainFromPermissionsFunc) (gchar *);
958
+ std::string domain;
959
+ if (!args->GetString(0, &domain)) {
964
+ LOG(INFO) << "Adding domain:" << domain << " to the list of websites allowed";
966
+ ((AddDomainFromPermissionsFunc) add_allowed_domain_func_handle_) (
967
+ const_cast<gchar *>(domain.c_str()));
969
+ LoadIntegratedWebsitesData ();
972
+void DesktopIntegrationSettingsHandler::RemoveIntegrationSite(
973
+ const ListValue* args) {
974
+ DCHECK(IsUnityWebappsInitialized());
976
+ // TODO move elsewhere
977
+ typedef void (* RemoveDomainFromPermissionsFunc) (gchar *);
979
+ std::string domain;
980
+ if (!args->GetString(0, &domain)) {
985
+ LOG(INFO) << "Removing domain:" << domain << " from the list of websites not prompting integration";
987
+ ((RemoveDomainFromPermissionsFunc) remove_from_permissions_func_handle_) (
988
+ const_cast<gchar *>(domain.c_str()));
990
+ LoadIntegratedWebsitesData ();
993
+} // namespace options2
994
Index: chrome/browser/ui/webui/options2/browser_options_handler2.cc
995
===================================================================
996
--- chrome/browser/ui/webui/options2/browser_options_handler2.cc (revision 136242)
997
+++ chrome/browser/ui/webui/options2/browser_options_handler2.cc (working copy)
999
{ "advancedSectionTitleCloudPrint", IDS_GOOGLE_CLOUD_PRINT },
1000
{ "advancedSectionTitleContent",
1001
IDS_OPTIONS_ADVANCED_SECTION_TITLE_CONTENT },
1002
+ { "advancedSectionTitleIntegration",
1003
+ IDS_OPTIONS_ADVANCED_SECTION_TITLE_INTEGRATION },
1004
{ "advancedSectionTitleLanguages",
1005
IDS_OPTIONS_ADVANCED_SECTION_TITLE_LANGUAGES },
1006
{ "advancedSectionTitleNetwork",
1008
{ "defaultFontSizeLabel", IDS_OPTIONS_DEFAULT_FONT_SIZE_LABEL },
1009
{ "defaultSearchManageEngines", IDS_OPTIONS_DEFAULTSEARCH_MANAGE_ENGINES },
1010
{ "defaultZoomFactorLabel", IDS_OPTIONS_DEFAULT_ZOOM_LEVEL_LABEL },
1011
+ { "desktopIntegrationExceptionsSettingsButton",
1012
+ IDS_DESKTOP_INTEGRATION_SETTINGS_EXCEPTIONS_BUTTON_LABEL },
1013
#if defined(OS_CHROMEOS)
1014
{ "disableGData", IDS_OPTIONS_DISABLE_GDATA },
1017
{ "profilesDeleteSingle", IDS_PROFILES_DELETE_SINGLE_BUTTON_LABEL },
1018
{ "profilesListItemCurrent", IDS_PROFILES_LIST_ITEM_CURRENT },
1019
{ "profilesManage", IDS_PROFILES_MANAGE_BUTTON_LABEL },
1020
+ { "promptIntegrationEnableIntegration",
1021
+ IDS_PROMPT_INTEGRATION_ENABLE_BUTTON_LABEL },
1022
{ "proxiesLabel", IDS_OPTIONS_PROXIES_LABEL },
1023
{ "safeBrowsingEnableProtection",
1024
IDS_OPTIONS_SAFEBROWSING_ENABLEPROTECTION },