Merge lp://qastaging/~alexlauni/do-plugins/chrome into lp://qastaging/do-plugins

Proposed by Alex Launi
Status: Merged
Merged at revision: not available
Proposed branch: lp://qastaging/~alexlauni/do-plugins/chrome
Merge into: lp://qastaging/do-plugins
Diff against target: 101 lines
2 files modified
Chromium/Resources/Chromium.addin.xml.in (+3/-3)
Chromium/src/ChromiumBookmarkItemSource.cs (+38/-32)
To merge this branch: bzr merge lp://qastaging/~alexlauni/do-plugins/chrome
Reviewer Review Type Date Requested Status
Jason Smith (community) Approve
Jonathan Lambrechts Pending
Review via email: mp+14402@code.qastaging.launchpad.net
To post a comment you must log in.
Revision history for this message
Alex Launi (alexlauni) wrote :

Adds support for google-chrome to the chromium bookmarks plugin.

Revision history for this message
Jason Smith (jassmith) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Chromium/Resources/Chromium.addin.xml.in'
2--- Chromium/Resources/Chromium.addin.xml.in 2009-07-24 17:22:10 +0000
3+++ Chromium/Resources/Chromium.addin.xml.in 2009-11-04 05:46:11 +0000
4@@ -1,10 +1,10 @@
5 <Addin
6 id="Chromium"
7 namespace="Do"
8- version="1.0"
9+ version="1.1"
10 name="Chromium"
11- description="Search your Chromium bookmarks."
12- author="Jonathan Lambrechts"
13+ description="Search your Google Chrome, and Chromium bookmarks."
14+ author="Jonathan Lambrechts, Alex Launi"
15 category="Community"
16 defaultEnabled="false"
17 >
18
19=== modified file 'Chromium/src/ChromiumBookmarkItemSource.cs'
20--- Chromium/src/ChromiumBookmarkItemSource.cs 2009-08-10 01:44:40 +0000
21+++ Chromium/src/ChromiumBookmarkItemSource.cs 2009-11-04 05:46:11 +0000
22@@ -73,41 +73,47 @@
23
24 public override void UpdateItems ()
25 {
26+ string[] chromes = {"chromium", "google-chrome"};
27+
28 string type = "", name = "", url = "";
29 string home = Environment.GetFolderPath (Environment.SpecialFolder.Personal);
30- string bookmarksFile = "~/.config/chromium/Default/Bookmarks".Replace ("~", home);
31+ string bookmarksFileFormat = "~/.config/{0}/Default/Bookmarks".Replace ("~", home);
32
33- try {
34- Regex RE = new Regex ("(\"([^\"]*)\" *: *\"([^\"]*)\")|[{}]", RegexOptions.Multiline);
35- FileStream fs = new FileStream (bookmarksFile, FileMode.Open, FileAccess.Read);
36- StreamReader reader = new StreamReader (fs);
37-
38- items.Clear ();
39-
40- foreach (Match m in RE.Matches (reader.ReadToEnd ())) {
41- if (m.Value == "{") {
42- url = "";
43- type = "";
44- name = "";
45- }
46- else if (m.Value == "}" && type == "url" && !string.IsNullOrEmpty (name) && !string.IsNullOrEmpty (url)) {
47- items.Add (new BookmarkItem (UnescapeUTF8 (name), url));
48- }
49- else if (m.Value.StartsWith ("\"")) {
50- if (m.Groups [2].Value == "url")
51- url = m.Groups [3].Value;
52- else if (m.Groups [2].Value == "name")
53- name = m.Groups [3].Value;
54- else if (m.Groups [2].Value == "type")
55- type = m.Groups [3].Value;
56- }
57- }
58- fs.Dispose ();
59- reader.Dispose ();
60- }
61- catch (Exception e) {
62- Log.Error ("Could not read Chromium Bookmarks file {0}: {1}", bookmarksFile, e.Message);
63- Log.Debug (e.StackTrace);
64+ foreach (string app in chromes) {
65+ string bookmarksFile = string.Format (bookmarksFileFormat, app);
66+
67+ try {
68+ Regex RE = new Regex ("(\"([^\"]*)\" *: *\"([^\"]*)\")|[{}]", RegexOptions.Multiline);
69+ FileStream fs = new FileStream (bookmarksFile, FileMode.Open, FileAccess.Read);
70+ StreamReader reader = new StreamReader (fs);
71+
72+ items.Clear ();
73+
74+ foreach (Match m in RE.Matches (reader.ReadToEnd ())) {
75+ if (m.Value == "{") {
76+ url = "";
77+ type = "";
78+ name = "";
79+ }
80+ else if (m.Value == "}" && type == "url" && !string.IsNullOrEmpty (name) && !string.IsNullOrEmpty (url)) {
81+ items.Add (new BookmarkItem (UnescapeUTF8 (name), url));
82+ }
83+ else if (m.Value.StartsWith ("\"")) {
84+ if (m.Groups [2].Value == "url")
85+ url = m.Groups [3].Value;
86+ else if (m.Groups [2].Value == "name")
87+ name = m.Groups [3].Value;
88+ else if (m.Groups [2].Value == "type")
89+ type = m.Groups [3].Value;
90+ }
91+ }
92+ fs.Dispose ();
93+ reader.Dispose ();
94+ }
95+ catch (Exception e) {
96+ Log.Error ("Could not read {0} Bookmarks file {1}: {2}", app, bookmarksFile, e.Message);
97+ Log.Debug (e.StackTrace);
98+ }
99 }
100 }
101 }

Subscribers

People subscribed via source and target branches